Build Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVM
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
#include <br />
int main(int argc, char *argv[])<br />
{<br />
printf("Hello world!\n");<br />
return 0;<br />
}<br />
函 式 printf() 後 方 僅 有 一 個<br />
字 串 參 數 , 前 端 預 設 將 其<br />
轉 換 為 puts() puts()<br />
• 反 組 譯 BitCode<br />
$ llvmdis < hello.bc<br />
; ModuleID = ''<br />
target datalayout = "ep:32:32:32...<br />
target triple = "i386pclinuxgnu"<br />
@str = internal constant [13 x i8] c"Hello world!\00"<br />
define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {<br />
entry:<br />
%puts = tail call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @str, i32 0, i32 0))<br />
ret i32 0<br />
}<br />
Declare i32 @puts(i8* nocapture) nounwind<br />
• 輸 出 x86 後 端 組 合 語 言<br />
$ llc hello.bc o hello.s