Running clang notes

From Dmz-portal

Jump to: navigation, search

- ARM
1. emit .ll files from .c files:
clang foo.c -o foo.ll -emit-llvm -O3 -S -ccc-host-triple arm-unknown-linux -ccc-clang-archs arm

2. emit .s files from .ll files:
llc foo.bc -o foo.s -march=arm

3. emit .o files from .ll files:
llc foo.bc -o foo.o -march=arm -filetype=obj

- Mips
1. emit .ll files from .c files:
clang foo.c -o foo.ll -emit-llvm -O3 -S -ccc-host-triple mipsel-unknown-linux -ccc-clang-archs mipsel

2. emit .s files from .ll files:
llc foo.bc -o foo.s -mcpu=4ke -march=mipsel

If you want to see all the passes run, add -debug-pass=Structure to the command line of llc:
llc foo.bc -o foo.s -mcpu=4ke -march=mipsel -debug-pass=Structure

Assembly or object code output takes place in "Assembly Printer" pass.
For example, in ARMAsmPrinter.cpp the following code lowers MachineInstr MI to MCInst TmpInst:

01885 MCInst TmpInst;
01886 LowerARMMachineInstrToMCInst(MI, TmpInst, *this);
01887
01888 OutStreamer.EmitInstruction(TmpInst);

You can run set break point at line 1888 and do "MI->dump()" or "TmpInst.dump()" to see what MI or TmpInst looks like.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox