LLVM/Clang
Mouna Abidi & Manel Grichi
1
LLVM/Clang Mouna Abidi & Manel Grichi 1 Plan What is LLVM? - - PowerPoint PPT Presentation
LLVM/Clang Mouna Abidi & Manel Grichi 1 Plan What is LLVM? How will you be using it? LLVM Architecture Compiler Simple case study Conclusion 2 What is LLVM? Low Level Virtual Machine Modern Compiler
Mouna Abidi & Manel Grichi
1
2
3
LLVM Suite Clang Test Suite
4
5
http://appleinsider.com/articles/08/06/20/apples_other_open_secret_the_llvm_complier
6
7
Front End (Clang): takes your source code and turns it into an intermediate representation (IR). The passes: transform IR to IR that is more faster that the input IR. Back End (LLVM): generates actual machine code
8
9
10
Clang GCC Languages (C/C++ and objectiveC) Java, Ada, FORTRAN, Go, (C/C++ and objectiveC) Design modular design, suite of libraries monolithic Reusability Easy to reuse, extensible design Difficult to reuse AST Easy understandable Very old codebase Compile time Faster compile time Longer compile time Error Better error messages
11
12
13
14
clang -S -emit-llvm boolean_optimization.c -o boolean_optimization.ll
15
16
(x and z) xor (y and z) == z and (x xor y)
17
18
– very powerful and easy to use – human readable IR allows for following optimization steps – modular design allows adding own functionality
– to replace GCC – to generate code for embedded processors – to learn about compilers and optimizations
19