R32V2020 C Compiler
Jump to navigation
Jump to search
Not Yet Implemented
- clang is used to create LLVM IR
- Install clang
sudo apt-get install clang
- Create LLVM IR
clang -S -emit-llvm foo.c
- Example Source File
int square(int a) { return(a*a); }
- .ll Output for example
; ModuleID = 'foo.c' target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" target triple = "armv6--linux-gnueabihf" ; Function Attrs: nounwind define i32 @square(i32 %a) #0 { %1 = alloca i32, align 4 store i32 %a, i32* %1, align 4 %2 = load i32, i32* %1, align 4 %3 = load i32, i32* %1, align 4 %4 = mul nsw i32 %2, %3 ret i32 %4 }
- Writing an LLVM Backend
- Tutorial for Writing Backend for a RISC style CPU (very similar (ISA)
- Writing a backend for the Tricore CPU (pdf)
- Godbolt Compiler Explorer - set option to
-S -emit-llvm -O0
- LLVM Installers includes clang
- Windows install option
- Command line
"c:\Program Files\LLVM\bin\clang" -S -emit-llvm -O0 foo.c