summaryrefslogtreecommitdiff
path: root/tools/llvmc/doc
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-12-17 07:49:16 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-12-17 07:49:16 +0000
commit994dbe007394da2ecdc815a8784bbfa6067dceb2 (patch)
treed07bf684fba79a16e896b46cfe84f0d01fcbc623 /tools/llvmc/doc
parent24723288a2d3377add3a05caa01cdec3a40794b7 (diff)
downloadllvm-994dbe007394da2ecdc815a8784bbfa6067dceb2.tar.gz
llvm-994dbe007394da2ecdc815a8784bbfa6067dceb2.tar.bz2
llvm-994dbe007394da2ecdc815a8784bbfa6067dceb2.tar.xz
Add a 'set_option' action for use in OptionPreprocessor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc/doc')
-rw-r--r--tools/llvmc/doc/LLVMC-Reference.rst43
1 files changed, 25 insertions, 18 deletions
diff --git a/tools/llvmc/doc/LLVMC-Reference.rst b/tools/llvmc/doc/LLVMC-Reference.rst
index 4d80a2a6e1..7336195dfe 100644
--- a/tools/llvmc/doc/LLVMC-Reference.rst
+++ b/tools/llvmc/doc/LLVMC-Reference.rst
@@ -656,10 +656,10 @@ For example, without those definitions the following command wouldn't work::
$ 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
===================
@@ -672,24 +672,31 @@ 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 (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])),
- [(unset_option ["O0", "O1", "O2"]),
- (warning "Multiple -O options specified, defaulted to -O3.")],
- (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 optimization options
-(so that they are not forwarded to the compiler).
+ 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 a special action
-``unset_option``, which, as the name suggests, unsets a given option. For
-convenience, ``unset_option`` also works on lists.
+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 a parameter option with ``set_option``, use
+the two-argument form: ``(set_option "parameter", "value")``. 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"])``).
More advanced topics