I just found out LLVM and don't know much more about it. I tried using llvm in the browser . I see that any C code that I write is converted to LLVM bytecode, which is then converted to native code. The page shows a textual representation of the byte code. For example, for the following C code:
int array[] = { 1, 2, 3}; int foo(int X) { return array[X]; }
It displays the following bytecode:
target datalayout = "ep:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-linux-gnu" @array = global [3 x i32] [i32 1, i32 2, i32 3] ; <[3 x i32]*> [#uses=1] define i32 @foo(i32 %X) nounwind readonly { entry: %0 = sext i32 %X to i64 ; <i64> [#uses=1] %1 = getelementptr inbounds [3 x i32]* @array, i64 0, i64 %0 ; <i32*> [#uses=1] %2 = load i32* %1, align 4 ; <i32> [#uses=1] ret i32 %2 }
My question is: can I write byte code and pass it to the llvm assembler to convert to native code, skipping the first step of writing C code in general? If so, how do I do this? Does anyone have pointers to me?
bytecode llvm
341008
source share