Using LLVM
LLVM documentation is very good.
Of particular relevance for Proteus are ll files and
LLVM tools. One point to note is that the man
pages
for the tools proved to be an invaluable source of information about options and usage.
The Getting Started guide provides a simple example of usage.
Simple commands to produce ll files all assume that llvm and llvm-gcc frontend are in your path and are given as instructions to be entered at the command prompt
- Produce an ll file from single C source
-
llvm-gcc -S --emit-llvm program.c -o program.ll
- Produce an ll file from single C++ source
-
llvm-g++ -S --emit-llvm program.cc -o program.ll
- Produce an ll file from multiple C++ source
-
llvm-g++ -c --emit-llvm part1.cc -o part1.bc llvm-g++ -c --emit-llvm part2.cc -o part2.bc llvm-g++ -c --emit-llvm part3.cc -o part3.bcNow to link them togetherllvm-ld -disable-opt -o combined part1.bc part2.bc part3.bcRun the optimisations on the combined file and output an ll fileopt -S -disable-inlining -O3 -std-compile-opts -std-link-opts combined.bc -o combined-optimized.ll