From d6d2efc4ce08062cdf8952f74efc918e8c6a7ee1 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Wed, 6 May 2009 01:41:47 +0000 Subject: Regenerate documentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71055 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CompilerDriver.html | 111 ++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 55 deletions(-) (limited to 'docs/CompilerDriver.html') diff --git a/docs/CompilerDriver.html b/docs/CompilerDriver.html index f5767b8338..08dc20b6e1 100644 --- a/docs/CompilerDriver.html +++ b/docs/CompilerDriver.html @@ -3,46 +3,47 @@ - + Customizing LLVMC: Reference Manual

Customizing LLVMC: Reference Manual

+ -
-

Contents

+

Written by Mikhail Glushenkov

-
+

Introduction

LLVMC is a generic compiler driver, designed to be customizable and extensible. It plays the same role for LLVM as the gcc program does for GCC - LLVMC's job is essentially to transform a set of input @@ -55,11 +56,11 @@ abstract graph. The structure of this graph is completely determined by plugins, which can be either statically or dynamically linked. This makes it possible to easily adapt LLVMC for other purposes - for example, as a build tool for game resources.

-

Because LLVMC employs TableGen as its configuration language, you +

Because LLVMC employs TableGen as its configuration language, you need to be familiar with it to customize LLVMC.

-
-

Compiling with LLVMC

+
+

Compiling with LLVMC

LLVMC tries hard to be as compatible with gcc as possible, although there are some small differences. Most of the time, however, you shouldn't be able to notice them:

@@ -96,8 +97,8 @@ hello also possible to choose the work-in-progress clang compiler with the -clang option.

-
-

Predefined options

+
+

Predefined options

LLVMC has some built-in options that can't be overridden in the configuration libraries:

    @@ -125,8 +126,8 @@ and do not delete them on exit. Hidden option, useful for debugging. their standard meaning.
-
-

Compiling LLVMC plugins

+
+

Compiling LLVMC plugins

It's easiest to start working on your own LLVMC plugin by copying the skeleton project which lives under $LLVMC_DIR/plugins/Simple:

@@ -141,7 +142,7 @@ counting the build script). Simpl
 description of the compilation graph; its format is documented in the
 following sections. PluginMain.cpp is just a helper file used to
 compile the auto-generated C++ code produced from TableGen source. It
-can also contain hook definitions (see below).

+can also contain hook definitions (see below).

The first thing that you should do is to change the LLVMC_PLUGIN variable in the Makefile to avoid conflicts (since this variable is used to name the resulting library):

@@ -178,8 +179,8 @@ $ cd $LLVMC_DIR $ make BUILTIN_PLUGINS=""
-
-

Customizing LLVMC: the compilation graph

+
+

Customizing LLVMC: the compilation graph

Each TableGen configuration file should include the common definitions:

@@ -246,8 +247,8 @@ plugin priority feature described above.

debugging), run llvmc --view-graph. You will need dot and gsview installed for this to work properly.

-
-

Describing options

+
+

Describing options

Command-line options that the plugin supports are defined by using an OptionList:

@@ -315,8 +316,8 @@ the one_or_more and <
 
 
 
-
-

External options

+
+

External options

Sometimes, when linking several plugins together, one plugin needs to access options defined in some other plugin. Because of the way options are implemented, such options must be marked as @@ -327,11 +328,11 @@ for. Example:

(switch_option "E", (extern)) ...
-

See also the section on plugin priorities.

+

See also the section on plugin priorities.

-
-

Conditional evaluation

+
+

Conditional evaluation

The 'case' construct is the main means by which programmability is achieved in LLVMC. It can be used to calculate edge weights, program actions and modify the shell commands to be executed. The 'case' @@ -410,8 +411,8 @@ one of its arguments returns true. Example:

-
-

Writing a tool description

+
+

Writing a tool description

As was said earlier, nodes in the compilation graph represent tools, which are described separately. A tool definition looks like this (taken from the include/llvm/CompilerDriver/Tools.td file):

@@ -452,8 +453,8 @@ below). -
-

Actions

+
+

Actions

A tool often needs to react to command-line options, and this is precisely what the actions property is for. The next example illustrates this feature:

@@ -496,7 +497,7 @@ Example: (case (forward "Wall").
  • forward_as - Change the name of an option, but forward the argument unchanged. -Example: (forward_as "O0" "--disable-optimization").
  • +Example: (forward_as "O0", "--disable-optimization").
  • output_suffix - modify the output suffix of this tool. Example: (output_suffix "i").
  • @@ -513,8 +514,8 @@ Example: (unpack_values
    -
    -

    Language map

    +
    +

    Language map

    If you are adding support for a new language to LLVMC, you'll need to modify the language map, which defines mappings from file extensions to language names. It is used to choose the proper toolchain(s) for a @@ -536,10 +537,10 @@ linked with the root node. Since tools are not allowed to have multiple output languages, for nodes "inside" the graph the input and output languages should match. This is enforced at compile-time.

    -
    -

    More advanced topics

    -
    -

    Hooks and environment variables

    +
    +

    More advanced topics

    +
    +

    Hooks and environment variables

    Normally, LLVMC executes programs from the system PATH. Sometimes, this is not sufficient: for example, we may want to specify tool paths or names in the configuration file. This can be easily achieved via @@ -561,7 +562,7 @@ and have the signature std::strin (cmd_line "$ENV(VAR1)/path/to/file -o $ENV(VAR2)")

    To change the command line string based on user-provided options use -the case expression (documented above):

    +the case expression (documented above):

     (cmd_line
       (case
    @@ -571,8 +572,8 @@ the case expression (
            "llvm-g++ -c -x c $INFILE -o $OUTFILE -emit-llvm"))
     
    -
    -

    How plugins are loaded

    +
    +

    How plugins are loaded

    It is possible for LLVMC plugins to depend on each other. For example, one can create edges between nodes defined in some other plugin. To make this work, however, that plugin should be loaded first. To @@ -587,12 +588,12 @@ def Priority : PluginPriority<$PRIORITY_VALUE>; with 0. Therefore, the plugin with the highest priority value will be loaded last.

    -
    -

    Debugging

    +
    +

    Debugging

    When writing LLVMC plugins, it can be useful to get a visual view of the resulting compilation graph. This can be achieved via the command -line option --view-graph. This command assumes that Graphviz and -Ghostview are installed. There is also a --write-graph option that +line option --view-graph. This command assumes that Graphviz and +Ghostview are installed. There is also a --write-graph option that creates a Graphviz source file (compilation-graph.dot) in the current directory.

    Another useful llvmc option is --check-graph. It checks the -- cgit v1.2.3