-
Notifications
You must be signed in to change notification settings - Fork 2
llvm
MeadowView edited this page Feb 21, 2021
·
1 revision
- Webpage: http://llvm.org
- AOSA book chapter: http://www.aosabook.org/en/llvm.html
- LLVM Documentation: http://llvm.org/docs/
- LLVM Tutorial (Kaleidoscope): http://llvm.org/docs/tutorial/index.html
- LLVM Passes: http://llvm.org/docs/Passes.html
-
LLVM IR:
.llfile
define i32 @add1(i32 %a, i32 %b) {
entry:
%tmp1 = add i32 %a, %b
ret i32 %tmp1
}
define i32 @add2(i32 %a, i32 %b) {
entry:
%tmp1 = icmp eq i32 %a, 0
br i1 %tmp1, label %done, label %recurse
recurse:
%tmp2 = sub i32 %a, 1
%tmp3 = add i32 %b, 1
%tmp4 = call i32 @add2(i32 %tmp2, i32 %tmp3)
ret i32 %tmp4
done:
ret i32 %b
}- LLVM IR (.ll) => [llvm-as] => BITCODE goop (.bc)
- LLVM BITCODE (.bc) => [llvm-dis] => LLVM IR (.ll)
-
clang -S -emit-llvm foo.c: Produces foo.ll which is an LLVM IR file.- The
-emit-llvmoption can also be passed to the compiler front-end directly, and not the driver by means of -cc1:
- The
-
clang -cc1 foo.c -emit-llvm- Produces foo.ll with the IR. -cc1 adds some cool options like -ast-print. Check out -cc1 --help for more details.
-
llc foo.ll- compiles LLVM IR further to assembly