【发布时间】:2013-12-15 07:41:34
【问题描述】:
LLVM 原生代码是什么样的让我很困惑?比如main.s有两种,哪一种是native code? 这个:
.file "main.bc"
.text
.globl main
.align 16, 0x90
.type main,@function
main: # @main
# BB#0:
subl $12, %esp
movl $.L.str, (%esp)
calll puts
calll foo
xorl %eax, %eax
addl $12, %esp
ret
.Ltmp0:
.size main, .Ltmp0-main
.type .L.str,@object # @.str
.section .rodata.str1.1,"aMS",@progbits,1
.L.str:
.asciz "This is a shared library test..."
.size .L.str, 33
.section ".note.GNU-stack","",@progbits
或:
@.str = private unnamed_addr constant [33 x i8] c"This is a shared library test...\00", align 1
define i32 @main() nounwind {
%1 = alloca i32, align 4
store i32 0, i32* %1
%2 = call i32 @puts(i8* getelementptr inbounds ([33 x i8]* @.str, i32 0, i32 0))
call void @foo()
ret i32 0
}
declare i32 @puts(i8*)
declare void @foo()
第一个由llvm-llc生成,第二个由-emit-llvm -S生成。
如果我想使用 LLVM 将静态库或共享库转换为本机代码,我该如何使用 LLVM?
【问题讨论】:
标签: llvm