LLVM

LLVM IR ê 考查

結構 struct

C:

#include <stdio.h>

/* 定義 struct */
struct a_struct{
int a; // i32
double b;
};

int main(void){
struct a_struct a;
return 0;
}

LLVM IR:


; ModuleID = 'a.c'
%struct.a_struct = type { i32, double } ; 生 struct

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
%1 = alloca i32, align 4
%a = alloca %struct.a_struct, align 8
store i32 0, i32* %1, align 4
ret i32 0
}

安裝 Racket-llvm

(上新更新佇:2019-09-26)

  • Clone git repo
    git clone git@github.com:bubba/racket-llvm.git
  • 包做 .zip:
    raco pkg create --binary racket-llvm
  • 安裝:
    raco pkg install racket-llvm.zip
  • raco pkg show
    看安裝 ê 結果,親像:
    Installation-wide:
    Package Checksum Source
    ....
    User-specific for installation "6.3":
    Package Checksum Source
    racket-llvm 52ebbb73... file /tmp/a/racket-llvm.zip