69 ^ self positionAtEnd: anLLVMBasicBlock |
69 ^ self positionAtEnd: anLLVMBasicBlock |
70 |
70 |
71 "Created: / 10-08-2015 / 09:03:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
71 "Created: / 10-08-2015 / 09:03:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
72 ! ! |
72 ! ! |
73 |
73 |
74 !LLVMBuilder methodsFor:'assertions'! |
|
75 |
|
76 assertIsBasicBlockValue:value |
|
77 <resource: #skipInDebuggersWalkback> |
|
78 |
|
79 self assert:value isLLVMValue. |
|
80 self assert:value isBasicBlockValue |
|
81 |
|
82 "Created: / 08-08-2015 / 02:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
83 ! |
|
84 |
|
85 assertIsIntegerOrIntegerVectorValue:value |
|
86 <resource: #skipInDebuggersWalkback> |
|
87 |
|
88 self assert:(value class == LLVMValue) message:'value is not an LLVMValue'. |
|
89 self assert:(value isIntegerOrIntegerVectorValue) |
|
90 |
|
91 "Modified (format): / 08-08-2015 / 02:41:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
92 ! |
|
93 |
|
94 assertIsString:aString |
|
95 <resource: #skipInDebuggersWalkback> |
|
96 |
|
97 self assert:aString isSingleByteString description:'string is not a valid LLVM name (twine)' |
|
98 |
|
99 "Created: / 07-08-2015 / 18:38:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
100 "Modified (format): / 08-08-2015 / 02:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
101 ! |
|
102 |
|
103 assertIsType: type |
|
104 <resource: #skipInDebuggersWalkback> |
|
105 |
|
106 self assert: type isLLVMType message: 'value is not an LLVMType'. |
|
107 |
|
108 "Created: / 10-08-2015 / 06:26:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
109 ! |
|
110 |
|
111 assertIsValue: value |
|
112 <resource: #skipInDebuggersWalkback> |
|
113 |
|
114 self assert: value isLLVMValue message: 'value is not an LLVMValue'. |
|
115 |
|
116 "Created: / 08-08-2015 / 03:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
117 ! |
|
118 |
|
119 assertIsValue: value ofType: type |
|
120 <resource: #skipInDebuggersWalkback> |
|
121 |
|
122 self assert: value isLLVMValue message: 'value is not an LLVMValue'. |
|
123 self assert: value type = type message: 'value has incorrect type' |
|
124 |
|
125 "Created: / 08-08-2015 / 02:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
126 ! |
|
127 |
|
128 assertIsValueOfSameType:value1 as:value2 |
|
129 <resource: #skipInDebuggersWalkback> |
|
130 |
|
131 self assert: value1 type = value2 type message:'types of values differ!!' |
|
132 |
|
133 "Created: / 07-08-2015 / 18:37:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
134 "Modified: / 08-08-2015 / 02:57:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 ! ! |
|
136 |
|
137 !LLVMBuilder methodsFor:'initialization & release'! |
74 !LLVMBuilder methodsFor:'initialization & release'! |
138 |
75 |
139 dispose |
76 dispose |
140 ^ LLVM DisposeBuilder: self. |
77 ^ LLVM DisposeBuilder: self. |
141 |
78 |
142 "Modified (comment): / 08-07-2015 / 22:39:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
79 "Modified (comment): / 08-07-2015 / 22:39:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
80 ! ! |
|
81 |
|
82 !LLVMBuilder methodsFor:'instructions - aggregates'! |
|
83 |
|
84 extractvalue: value at: index |
|
85 ^ self extractvalue: value at: index as: '' |
|
86 |
|
87 "Created: / 10-08-2015 / 17:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
88 ! |
|
89 |
|
90 extractvalue: value at: index as: name |
|
91 |
|
92 |
|
93 self assertIsValue: value. |
|
94 self assert: ((value type kind == LLVMStructTypeKind) or:[ value type kind == LLVMArrayTypeKind ]) message: 'value is not a struct or an array'. |
|
95 self assert: index isInteger message: 'index is not an integer'. |
|
96 |
|
97 ^ LLVM BuildExtractValue: self _: value _: index _: name. |
|
98 |
|
99 |
|
100 "Created: / 10-08-2015 / 17:39:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
143 ! ! |
101 ! ! |
144 |
102 |
145 !LLVMBuilder methodsFor:'instructions - binary'! |
103 !LLVMBuilder methodsFor:'instructions - binary'! |
146 |
104 |
147 add:value1 _:value2 |
105 add:value1 _:value2 |
352 ! |
310 ! |
353 |
311 |
354 gep: pointer at: integerOrArrayOfIntegers as: name |
312 gep: pointer at: integerOrArrayOfIntegers as: name |
355 | indices | |
313 | indices | |
356 |
314 |
357 self assert: (pointer isKindOf: LLVMValue). |
315 self assertIsValue: pointer ofKind: LLVMPointerTypeKind. |
358 self assert: (integerOrArrayOfIntegers isInteger |
316 self assert: (integerOrArrayOfIntegers isInteger |
359 or:[ integerOrArrayOfIntegers isSequenceable and:[ integerOrArrayOfIntegers allSatisfy:[:e|e isInteger] ] ]). |
317 or:[ integerOrArrayOfIntegers isSequenceable and:[ integerOrArrayOfIntegers allSatisfy:[:e|e isInteger] ] ]). |
360 self assert: (name isSingleByteString). |
318 self assertIsString: name. |
361 integerOrArrayOfIntegers isInteger ifTrue:[ |
319 integerOrArrayOfIntegers isInteger ifTrue:[ |
362 indices := LLVMObjectArray with: (LLVMConstant uint32: integerOrArrayOfIntegers) |
320 indices := LLVMObjectArray with: (LLVMConstant uint32: integerOrArrayOfIntegers) |
363 ] ifFalse:[ |
321 ] ifFalse:[ |
364 indices := LLVMObjectArray new: integerOrArrayOfIntegers size. |
322 indices := LLVMObjectArray new: integerOrArrayOfIntegers size. |
365 1 to: indices size do:[:i | |
323 1 to: indices size do:[:i | |
395 "Created: / 10-08-2015 / 06:45:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
354 "Created: / 10-08-2015 / 06:45:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
396 ! ! |
355 ! ! |
397 |
356 |
398 !LLVMBuilder methodsFor:'instructions - other'! |
357 !LLVMBuilder methodsFor:'instructions - other'! |
399 |
358 |
400 call: function with: arg1 |
359 call: function _: args |
401 ^ self call: function withArguments: (Array with: arg1) as: ''. |
360 ^ self call: function _: args as: ''. |
402 |
361 |
403 "Created: / 17-07-2015 / 12:48:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
362 "Created: / 10-08-2015 / 18:53:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
404 ! |
363 ! |
405 |
364 |
406 call: function with: arg1 with: arg2 |
365 call: function _: arguments as: name |
407 ^ self call: function withArguments: (Array with: arg1 with: arg2) as: ''. |
|
408 |
|
409 "Created: / 17-07-2015 / 12:48:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
410 ! |
|
411 |
|
412 call: function with: arg1 with: arg2 with: arg3 |
|
413 ^ self call: function withArguments: (Array with: arg1 with: arg2 with: arg3) as: ''. |
|
414 |
|
415 "Created: / 17-07-2015 / 12:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
416 ! |
|
417 |
|
418 call: function withArguments: arguments |
|
419 ^ self call: function withArguments: arguments as: ''. |
|
420 |
|
421 "Created: / 17-07-2015 / 12:47:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
422 ! |
|
423 |
|
424 call: function withArguments: arguments as: name |
|
425 | argumentsArray argumentsSize | |
366 | argumentsArray argumentsSize | |
426 |
367 |
427 self assert: (function isKindOf: LLVMFunction). |
368 self assertIsFunctionValue: function. |
428 self assert: (arguments isCollection). |
369 self assertIsValueArray: arguments. |
429 arguments do:[:argument | |
370 self assertIsString: name. |
430 self assert: (argument isKindOf:LLVMValue). |
|
431 ]. |
|
432 self assert: name isSingleByteString. |
|
433 |
371 |
434 argumentsSize := arguments size. |
372 argumentsSize := arguments size. |
435 argumentsArray := arguments asLLVMObjectArray. |
373 argumentsArray := arguments asLLVMObjectArray. |
436 ^ LLVM BuildCall: self _: function _: argumentsArray _: argumentsSize _: name |
374 ^ LLVM BuildCall: self _: function _: argumentsArray _: argumentsSize _: name |
437 |
375 |
438 "Created: / 17-07-2015 / 11:09:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
376 "Created: / 10-08-2015 / 18:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
439 ! ! |
377 ! ! |
440 |
378 |
441 !LLVMBuilder methodsFor:'instructions - terminators'! |
379 !LLVMBuilder methodsFor:'instructions - terminators'! |
442 |
380 |
443 br: target |
381 br: target |