5 LLVMC is a generic compiler driver, which plays the same role for LLVM
6 as the ``gcc`` program does for GCC - the difference being that LLVMC
7 is designed to be more adaptable and easier to customize. This
8 tutorial describes the basic usage and configuration of LLVMC.
17 In general, LLVMC tries to be command-line compatible with ``gcc`` as
18 much as possible, so most of the familiar options work::
20 $ llvmc2 -O3 -Wall hello.cpp
24 For further help on command-line LLVMC usage, refer to the ``llvmc
27 Using LLVMC to generate toolchain drivers
28 =========================================
30 At the time of writing LLVMC does not support on-the-fly reloading of
31 configuration, so it will be necessary to recompile its source
32 code. LLVMC uses TableGen [1]_ as its configuration language, so
33 you'll need to familiar with it.
35 Start by compiling ``examples/Simple.td``, which is a simple wrapper
38 $ cd $LLVM_DIR/tools/llvmc2
39 $ make TOOLNAME=mygcc GRAPH=examples/Simple.td
45 Contents of the file ``Simple.td`` look like this::
47 // Include common definitions
53 (out_language "executable"),
54 (output_suffix "out"),
55 (cmd_line "gcc $INFILE -o $OUTFILE"),
60 def LanguageMap : LanguageMap<[LangToSuffixes<"c", ["c"]>]>;
63 def CompilationGraph : CompilationGraph<[Edge<root, gcc>]>;
65 As you can see, this file consists of three parts: tool descriptions,
66 language map, and the compilation graph definition.
68 At the heart of LLVMC is the idea of a transformation graph: vertices
69 in this graph are tools, and edges signify that there is a
70 transformation path between two tools (for example, assembly source
71 produced by the compiler can be transformed into executable code by an
72 assembler). A special node named ``root`` is used to mark the graph
75 Tool descriptions are basically lists of properties: most properties
76 in the example above should be self-explanatory; the ``sink`` property
77 means that all options lacking an explicit description should be
78 forwarded to this tool.
80 ``LanguageMap`` associates a language name with a list of suffixes and
81 is used for deciding which toolchain corresponds to a given input
84 To learn more about LLVMC customization, refer to the reference
85 manual and sample configuration files in the ``examples`` directory.
90 .. [1] TableGen Fundamentals
91 http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html