author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 01 Aug 2015 06:21:29 +0100 | |
changeset 13 | fa967c0e1827 |
parent 12 | f98e97fd02ef |
child 14 | c7dea3fcc5a7 |
permissions | -rw-r--r-- |
12
f98e97fd02ef
Package renamed from jv:libllvms to jv:llvm_s
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
1 |
"{ Package: 'jv:llvm_s' }" |
0 | 2 |
|
3 |
"{ NameSpace: Smalltalk }" |
|
4 |
||
1
e3dcb6272f0b
Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
5 |
LLVMObject subclass:#LLVMType |
0 | 6 |
instanceVariableNames:'' |
4 | 7 |
classVariableNames:'Int1 Int16 Int32 Int64 IntPtr' |
8 |
poolDictionaries:'LLVMTypeKind' |
|
13
fa967c0e1827
Renamed class categories to begin with LLVM-S
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12
diff
changeset
|
9 |
category:'LLVM-S-Core' |
0 | 10 |
! |
11 |
||
12 |
!LLVMType class methodsFor:'instance creation'! |
|
13 |
||
14 |
function: argumentTypes returning: returnType |
|
1
e3dcb6272f0b
Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
15 |
^ LLVM FunctionType: returnType _: argumentTypes asLLVMObjectArray _: argumentTypes size _: 0 |
0 | 16 |
|
17 |
"Created: / 07-07-2015 / 21:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1
e3dcb6272f0b
Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
0
diff
changeset
|
18 |
"Modified: / 08-07-2015 / 22:58:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 19 |
! |
20 |
||
21 |
int1 |
|
4 | 22 |
Int64 isNil ifTrue:[ |
23 |
Int64 := LLVM Int64Type |
|
24 |
]. |
|
25 |
^ Int64 |
|
0 | 26 |
|
27 |
"Created: / 07-07-2015 / 21:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4 | 28 |
"Modified: / 11-07-2015 / 07:01:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 29 |
! |
30 |
||
31 |
int16 |
|
32 |
^ LLVM Int16Type |
|
33 |
||
34 |
"Created: / 07-07-2015 / 21:21:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
35 |
! |
|
36 |
||
37 |
int32 |
|
38 |
^ LLVM Int32Type |
|
39 |
||
40 |
"Created: / 07-07-2015 / 21:21:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
41 |
! |
|
42 |
||
43 |
int64 |
|
44 |
^ LLVM Int64Type |
|
45 |
||
46 |
"Created: / 07-07-2015 / 21:21:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
47 |
! |
|
48 |
||
49 |
int8 |
|
50 |
^ LLVM Int8Type |
|
51 |
||
52 |
"Created: / 07-07-2015 / 21:21:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4 | 53 |
! |
54 |
||
55 |
intptr |
|
56 |
IntPtr isNil ifTrue:[ |
|
57 |
IntPtr := LLVM IntPtrType: LLVMTargetData new. |
|
58 |
]. |
|
59 |
^ IntPtr |
|
60 |
||
61 |
"Created: / 11-07-2015 / 07:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
0 | 62 |
! ! |
63 |
||
64 |
!LLVMType methodsFor:'accessing'! |
|
65 |
||
66 |
kind |
|
67 |
^ LLVM GetTypeKind: self |
|
68 |
||
69 |
"Created: / 07-07-2015 / 21:59:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
70 |
! ! |
|
71 |
||
2
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
72 |
!LLVMType methodsFor:'debugging-dumping'! |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
73 |
|
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
74 |
dumpOn: aStream |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
75 |
aStream nextPutAll: self dumpString |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
76 |
|
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
77 |
"Created: / 10-07-2015 / 14:32:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
78 |
! |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
79 |
|
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
80 |
dumpString |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
81 |
| cstr str| |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
82 |
|
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
83 |
cstr := LLVM PrintTypeToString: self. |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
84 |
str := cstr copyCStringFromHeap. |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
85 |
LLVM DisposeMessage: cstr. |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
86 |
^ str |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
87 |
|
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
88 |
"Created: / 10-07-2015 / 14:31:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4 | 89 |
! |
90 |
||
91 |
printOn: aStream |
|
92 |
| kind | |
|
93 |
||
94 |
super printOn: aStream. |
|
95 |
aStream nextPutAll: self dumpString. |
|
96 |
aStream nextPutAll: ' ['. |
|
97 |
kind := self kind. |
|
98 |
kind == LLVMVoidTypeKind ifTrue:[ |
|
99 |
aStream nextPutAll:'void' |
|
100 |
] ifFalse:[ kind == LLVMHalfTypeKind ifTrue:[ |
|
101 |
aStream nextPutAll:'half' |
|
102 |
] ifFalse:[ kind == LLVMFloatTypeKind ifTrue:[ |
|
103 |
aStream nextPutAll:'float' |
|
104 |
] ifFalse:[ kind == LLVMDoubleTypeKind ifTrue:[ |
|
105 |
aStream nextPutAll:'double' |
|
106 |
] ifFalse:[ kind == LLVMX86_FP80TypeKind ifTrue:[ |
|
107 |
aStream nextPutAll:'x86-fp80' |
|
108 |
] ifFalse:[ kind == LLVMFP128TypeKind ifTrue:[ |
|
109 |
aStream nextPutAll:'fp128' |
|
110 |
] ifFalse:[ kind == LLVMLabelTypeKind ifTrue:[ |
|
111 |
aStream nextPutAll:'label' |
|
112 |
] ifFalse:[ kind == LLVMIntegerTypeKind ifTrue:[ |
|
113 |
aStream nextPutAll:'int' |
|
114 |
] ifFalse:[ kind == LLVMFunctionTypeKind ifTrue:[ |
|
115 |
aStream nextPutAll:'funct' |
|
116 |
] ifFalse:[ kind == LLVMStructTypeKind ifTrue:[ |
|
117 |
aStream nextPutAll:'struct' |
|
118 |
] ifFalse:[ kind == LLVMArrayTypeKind ifTrue:[ |
|
119 |
aStream nextPutAll:'array' |
|
120 |
] ifFalse:[ kind == LLVMPointerTypeKind ifTrue:[ |
|
121 |
aStream nextPutAll:'ptr' |
|
122 |
] ifFalse:[ kind == LLVMVectorTypeKind ifTrue:[ |
|
123 |
aStream nextPutAll:'vector' |
|
124 |
] ifFalse:[ kind == LLVMMetadataTypeKind ifTrue:[ |
|
125 |
aStream nextPutAll:'md' |
|
126 |
] ifFalse:[ kind == LLVMX86_MMXTypeKind ifTrue:[ |
|
127 |
aStream nextPutAll:'x86-mmx' |
|
128 |
]]]]]]]]]]]]]]]. |
|
129 |
aStream nextPutAll: ']'. |
|
130 |
||
131 |
"Created: / 11-07-2015 / 07:08:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
132 |
! ! |
53abac7217de
Added support for creating execution engines and fetching function addresses.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
133 |
|
5 | 134 |
!LLVMType methodsFor:'testing'! |
135 |
||
136 |
isIntegerType |
|
137 |
^ self kind == LLVMIntegerTypeKind |
|
138 |
||
139 |
"Created: / 11-07-2015 / 14:56:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
! |
|
141 |
||
142 |
isVectorType |
|
143 |
^ self kind == LLVMVectorTypeKind |
|
144 |
||
145 |
"Created: / 11-07-2015 / 14:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146 |
! ! |
|
147 |