Anonymous user
Modulinos: Difference between revisions
Fixed LLVM
(Simplified compilation process) |
(Fixed LLVM) |
||
Line 320:
=={{header|LLVM}}==
LLVM
<lang sh>$ make
<lang llvm>@msg_directory = internal constant [15 x i8] c"Directory: %s\0A\00"▼
llvm-as scriptedmain.ll
@msg_program = internal constant [13 x i8] c"Program: %s\0A\00"▼
llc scriptedmain.bc
gcc -o scriptedmain scriptedmain.s
./scriptedmain
Main: The meaning of life is 42
llvm-as test.ll
llc test.bc
gcc -o test test.s scriptedmain.s
./test
Test: The meaning of life is 42</lang>
Makefile
declare i32 @printf(i8* noalias nocapture, ...)▼
<lang make>EXECUTABLE_SM=scriptedmain
define i32 @main(i32 %argc, i8** %argv) {▼
EXECUTABLE_TEST=test
all: test.ll scriptedmain.s
%cwd_ptr = getelementptr inbounds [1024 x i8]* %cwd, i32 0, i32 0▼
llvm-as test.ll
llc test.bc
gcc -o $(EXECUTABLE_TEST) test.s scriptedmain.s
./$(EXECUTABLE_TEST)
scriptedmain.s: scriptedmain.ll
llvm-as scriptedmain.ll
llc scriptedmain.bc
gcc -o $(EXECUTABLE_SM) scriptedmain.s
./$(EXECUTABLE_SM)
clean:
call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @msg_directory, i32 0, i32 0), i8* %cwd_ptr)▼
rm $(EXECUTABLE_TEST)
rm $(EXECUTABLE_SM)
rm test.s
rm test.bc
rm scriptedmain.s
rm scriptedmain.bc</lang>
scriptedmain.ll
▲<lang llvm>@
▲declare i32 @printf(i8* noalias nocapture, ...)
define i32 @meaning_of_life() {
ret i32 42
}
define weak i32 @main(i32 %argc, i8** %argv) {
%meaning = call i32 @meaning_of_life()
▲
}</lang>
test.ll
▲<lang llvm>@
declare i32 @printf(i8* noalias nocapture, ...)
declare i32 @meaning_of_life()
▲define i32 @main(i32 %argc, i8** %argv) {
%meaning = call i32 @meaning_of_life()
▲ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([
ret i32 0
|