Last active
July 15, 2019 23:16
-
-
Save Risto-Stevcev/926a2858d00d1ed162fb4995086dde9d to your computer and use it in GitHub Desktop.
LLVM hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; To emit LLVM from C code (for discovery): | |
; clang -emit-llvm -S hello.c -o hello.ll | |
; Declare the printf function | |
declare i32 @printf(i8*, ...) | |
@.str = private unnamed_addr constant [14 x i8] c"hello world!\0A\00" | |
define i32 @main() noinline optnone { | |
call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0)) | |
ret i32 0 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llc hello.ll && gcc -o hello hello.s && ./hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment