Thu, 12 Jul 2007

4:05 PM - LLVM backend code

http://llvm.org/demo/index.cgi

LLVM is a backend for a compiler suite.  Apple has been working on this project for some time along with many others.  The goal is to get rid of gcc eventually.  This could be another issue for the MBSD project.

I decided to test this. 

#include <stdio.h>

int main(void)
{
    printf("hello world ");
    return 0;
}

result:
; ModuleID = '/tmp/webcompile/_16373_0.bc'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
target triple = "i686-pc-linux-gnu"
@.str = internal constant [12 x i8] c"hello world0" ; <[12 x i8]*> [#uses=1]

define i32 @main() {
entry:
%tmp2 = tail call i32 @puts( i8* getelementptr ([12 x i8]* @.str, i32 0, i32 0) ) ; <i32> [#uses=0]
ret i32 0
}

Note that it turned it into a puts call!

declare i32 @puts(i8*)

0 comments