5 This file was automatically generated by rst2html.
6 Please do not edit directly!
7 The ReST source lives in the directory 'tools/llvmc/doc'.
13 <div class="doc_author">
14 <p>Written by <a href="mailto:foldr@codedgers.com">Mikhail Glushenkov</a></p>
20 LLVMC is a generic compiler driver, which plays the same role for LLVM
21 as the ``gcc`` program does for GCC - the difference being that LLVMC
22 is designed to be more adaptable and easier to customize. Most of
23 LLVMC functionality is implemented via plugins, which can be loaded
24 dynamically or compiled in. This tutorial describes the basic usage
25 and configuration of LLVMC.
31 In general, LLVMC tries to be command-line compatible with ``gcc`` as
32 much as possible, so most of the familiar options work::
34 $ llvmc -O3 -Wall hello.cpp
38 This will invoke ``llvm-g++`` under the hood (you can see which
39 commands are executed by using the ``-v`` option). For further help on
40 command-line LLVMC usage, refer to the ``llvmc --help`` output.
43 Using LLVMC to generate toolchain drivers
44 =========================================
46 LLVMC plugins are written mostly using TableGen_, so you need to
47 be familiar with it to get anything done.
49 .. _TableGen: http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html
51 Start by compiling ``example/Simple``, which is a primitive wrapper for
54 $ cd $LLVM_DIR/tools/llvmc
56 # NB: A less verbose way to compile standalone LLVMC-based drivers is
57 # described in the reference manual.
59 $ make LLVMC_BASED_DRIVER_NAME=mygcc LLVMC_BUILTIN_PLUGINS=Simple
66 Here we link our plugin with the LLVMC core statically to form an executable
67 file called ``mygcc``. It is also possible to build our plugin as a dynamic
68 library to be loaded by the ``llvmc`` executable (or any other LLVMC-based
69 standalone driver); this is described in the reference manual.
71 Contents of the file ``Simple.td`` look like this::
73 // Include common definitions
74 include "llvm/CompilerDriver/Common.td"
79 (out_language "executable"),
80 (output_suffix "out"),
81 (cmd_line "gcc $INFILE -o $OUTFILE"),
86 def LanguageMap : LanguageMap<[LangToSuffixes<"c", ["c"]>]>;
89 def CompilationGraph : CompilationGraph<[Edge<"root", "gcc">]>;
91 As you can see, this file consists of three parts: tool descriptions,
92 language map, and the compilation graph definition.
94 At the heart of LLVMC is the idea of a compilation graph: vertices in
95 this graph are tools, and edges represent a transformation path
96 between two tools (for example, assembly source produced by the
97 compiler can be transformed into executable code by an assembler). The
98 compilation graph is basically a list of edges; a special node named
99 ``root`` is used to mark graph entry points.
101 Tool descriptions are represented as property lists: most properties
102 in the example above should be self-explanatory; the ``sink`` property
103 means that all options lacking an explicit description should be
104 forwarded to this tool.
106 The ``LanguageMap`` associates a language name with a list of suffixes
107 and is used for deciding which toolchain corresponds to a given input
110 To learn more about LLVMC customization, refer to the reference
111 manual and plugin source code in the ``plugins`` directory.
117 <a href="http://jigsaw.w3.org/css-validator/check/referer">
118 <img src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
119 alt="Valid CSS" /></a>
120 <a href="http://validator.w3.org/check?uri=referer">
121 <img src="http://www.w3.org/Icons/valid-xhtml10-blue"
122 alt="Valid XHTML 1.0 Transitional"/></a>
124 <a href="mailto:foldr@codedgers.com">Mikhail Glushenkov</a><br />
125 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br />
127 Last modified: $Date: 2008-12-11 11:34:48 -0600 (Thu, 11 Dec 2008) $