--- a/LLVMExamples.st Mon Aug 03 21:25:56 2015 +0100
+++ b/LLVMExamples.st Wed Aug 05 22:39:52 2015 +0100
@@ -177,7 +177,7 @@
module := LLVMModule newWithName: testSelector.
- printfFunctionType := LLVMType function: #() returning: LLVMType int32.
+ printfFunctionType := LLVMType function: { LLVMType char pointer } varargs: true returning: LLVMType int32.
printfFunction := module addFunctionNamed: 'printf' type: printfFunctionType.
helloWorldString := module addGlobalNamed: '.str' value: (LLVMConstant string: 'Hello World!!' , Character lf).
@@ -188,9 +188,11 @@
mainFunctionEntry := mainFunction addBasicBlockNamed: 'entry'.
asm := LLVMBuilder new.
asm positionAtEnd: mainFunctionEntry.
- asm call: printfFunction with: helloWorldString.
+ asm call: printfFunction with: (asm gep: helloWorldString at: #(0 0)).
asm ret: (LLVMConstant sint32: 0).
-
+ "
+ module writeBitcodeToFile: '/tmp/main.bc'
+ "
jit := LLVMExecutionEngine newForModule: module.
externalFunction := jit externalOfFunction: mainFunction.
@@ -202,6 +204,7 @@
"
"Created: / 03-08-2015 / 10:28:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 03-08-2015 / 18:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 05-08-2015 / 20:59:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 05-08-2015 / 22:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !