Skip to content

Instantly share code, notes, and snippets.

@obiknows
Created May 11, 2017 02:34
Show Gist options
  • Save obiknows/96e7caf97039d034c50d6300498cbfa7 to your computer and use it in GitHub Desktop.
Save obiknows/96e7caf97039d034c50d6300498cbfa7 to your computer and use it in GitHub Desktop.
tfun test
Test:
make clean && make
./warhol.native -c < tests/tfun.wl > tfun.ll
lli tfun.ll
Source:
fun int prt3() {
print(3);
return 0;
}
fun int main() {
prt3();
return 0;
}
Output:
plt@ubuntu-plt:~/work/warhol$ lli tfun.ll
3
LLVM IR:
; ModuleID = 'Warhol'
@fmt = private unnamed_addr constant [4 x i8] c"%d\0A\00"
@fmt1 = private unnamed_addr constant [4 x i8] c"%d\0A\00"
declare i32 @printf(i8*, ...)
declare i32 @openfile(i8*, ...)
define i32 @main() {
entry:
%prt3_result = call i32 @prt3()
ret i32 0
}
define i32 @prt3() {
entry:
%printf = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @fmt1, i32 0, i32 0), i32 3)
ret i32 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment