X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FCompilerDriver.html;h=3c82e2b076903256c4946d96a928a87112627dfe;hb=a75ce9f5d2236d93c117e861e60e6f3f748c9555;hp=9bc08aca163798b1b50480aecd7326eb5a9c27f9;hpb=3128015782709f0e16b1935b9834771047950704;p=oota-llvm.git diff --git a/docs/CompilerDriver.html b/docs/CompilerDriver.html index 9bc08aca163..3c82e2b0769 100644 --- a/docs/CompilerDriver.html +++ b/docs/CompilerDriver.html @@ -17,27 +17,28 @@ The ReST source lives in the directory 'tools/llvmc/doc'. -->

Contents

-

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 @@ -578,15 +605,50 @@ def LanguageMap : LanguageMap< $ llvmc hello.cpp llvmc: Unknown suffix: cpp -

The language map entries should be added only for tools that are -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.

+

The language map entries are needed only for the tools that are linked from the +root node. Since a tool can't have multiple output languages, for inner nodes of +the graph the input and output languages should match. This is enforced at +compile-time.

+
+
+

Option preprocessor

+

It is sometimes useful to run error-checking code before processing the +compilation graph. For example, if optimization options "-O1" and "-O2" are +implemented as switches, we might want to output a warning if the user invokes +the driver with both of these options enabled.

+

The OptionPreprocessor feature is reserved specially for these +occasions. Example (adapted from the built-in Base plugin):

+
+def Preprocess : OptionPreprocessor<
+(case (not (any_switch_on ["O0", "O1", "O2", "O3"])),
+           (set_option "O2"),
+      (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])),
+           (unset_option ["O0", "O1", "O2"]),
+      (and (switch_on "O2"), (any_switch_on ["O0", "O1"])),
+           (unset_option ["O0", "O1"]),
+      (and (switch_on "O1"), (switch_on "O0")),
+           (unset_option "O0"))
+>;
+
+

Here, OptionPreprocessor is used to unset all spurious -O options so +that they are not forwarded to the compiler. If no optimization options are +specified, -O2 is enabled.

+

OptionPreprocessor is basically a single big case expression, which is +evaluated only once right after the plugin is loaded. The only allowed actions +in OptionPreprocessor are error, warning, and two special actions: +unset_option and set_option. As their names suggest, they can be used to +set or unset a given option. To set an option with set_option, use the +two-argument form: (set_option "parameter", VALUE). Here, VALUE can be +either a string, a string list, or a boolean constant.

+

For convenience, set_option and unset_option also work on lists. That +is, instead of [(unset_option "A"), (unset_option "B")] you can use +(unset_option ["A", "B"]). Obviously, (set_option ["A", "B"]) is valid +only if both A and B are switches.

-

More advanced topics

+

More advanced topics

-

Hooks and environment variables

+

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 @@ -619,7 +681,7 @@ the case expression (

-

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 @@ -635,7 +697,7 @@ 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 @@ -651,7 +713,7 @@ perform any compilation tasks and returns the number of encountered errors as its status code.

-

Conditioning on the executable name

+

Conditioning on the executable name

For now, the executable name (the value passed to the driver in argv[0]) is accessible only in the C++ code (i.e. hooks). Use the following code:

@@ -659,12 +721,16 @@ namespace llvmc {
 extern const char* ProgramName;
 }
 
+namespace hooks {
+
 std::string MyHook() {
 //...
 if (strcmp(ProgramName, "mydriver") == 0) {
    //...
 
 }
+
+} // end namespace hooks
 

In general, you're encouraged not to make the behaviour dependent on the executable file name, and use command-line switches instead. See for example how @@ -682,7 +748,7 @@ the Base plugin behav Mikhail Glushenkov
LLVM Compiler Infrastructure
-Last modified: $Date: 2008-12-11 11:34:48 -0600 (Thu, 11 Dec 2008) $ +Last modified: $Date$