Syntax tweak in llvmc: (something [a,b,c]) -> (something a, b, c).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117196 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov committed 2010-10-23 07:32:46 +00:00
1 parent c761f7dca2
commit 17ef94fe1b
4 files changed
+154 -190

No files matched your search

+35 -33
View File
@@ -456,22 +456,22 @@ use TableGen inheritance instead.
* Possible tests are:
- ``switch_on`` - Returns true if a given command-line switch is provided by
the user. Can be given a list as argument, in that case ``(switch_on ["foo",
"bar", "baz"])`` is equivalent to ``(and (switch_on "foo"), (switch_on
the user. Can be given multiple arguments, in that case ``(switch_on "foo",
"bar", "baz")`` is equivalent to ``(and (switch_on "foo"), (switch_on
"bar"), (switch_on "baz"))``.
Example: ``(switch_on "opt")``.
- ``any_switch_on`` - Given a list of switch options, returns true if any of
- ``any_switch_on`` - Given a number of switch options, returns true if any of
the switches is turned on.
Example: ``(any_switch_on ["foo", "bar", "baz"])`` is equivalent to ``(or
Example: ``(any_switch_on "foo", "bar", "baz")`` is equivalent to ``(or
(switch_on "foo"), (switch_on "bar"), (switch_on "baz"))``.
- ``parameter_equals`` - Returns true if a command-line parameter equals
a given value.
- ``parameter_equals`` - Returns true if a command-line parameter (first
argument) equals a given value (second argument).
Example: ``(parameter_equals "W", "all")``.
- ``element_in_list`` - Returns true if a command-line parameter
list contains a given value.
- ``element_in_list`` - Returns true if a command-line parameter list (first
argument) contains a given value (second argument).
Example: ``(element_in_list "l", "pthread")``.
- ``input_languages_contain`` - Returns true if a given language
@@ -479,27 +479,27 @@ use TableGen inheritance instead.
Example: ``(input_languages_contain "c++")``.
- ``in_language`` - Evaluates to true if the input file language is equal to
the argument. At the moment works only with ``cmd_line`` and ``actions`` (on
the argument. At the moment works only with ``command`` and ``actions`` (on
non-join nodes).
Example: ``(in_language "c++")``.
- ``not_empty`` - Returns true if a given option (which should be either a
parameter or a parameter list) is set by the user. Like ``switch_on``, can
be also given a list as argument.
Example: ``(not_empty "o")``.
be also given multiple arguments.
Examples: ``(not_empty "o")``, ``(not_empty "o", "l")``.
- ``any_not_empty`` - Returns true if ``not_empty`` returns true for any of
the options in the list.
Example: ``(any_not_empty ["foo", "bar", "baz"])`` is equivalent to ``(or
the provided options.
Example: ``(any_not_empty "foo", "bar", "baz")`` is equivalent to ``(or
(not_empty "foo"), (not_empty "bar"), (not_empty "baz"))``.
- ``empty`` - The opposite of ``not_empty``. Equivalent to ``(not (not_empty
X))``. Provided for convenience. Can be given a list as argument.
X))``. Can be given multiple arguments.
- ``any_not_empty`` - Returns true if ``not_empty`` returns true for any of
the options in the list.
Example: ``(any_empty ["foo", "bar", "baz"])`` is equivalent to ``(not (and
(not_empty "foo"), (not_empty "bar"), (not_empty "baz")))``.
the provided options.
Example: ``(any_empty "foo", "bar", "baz")`` is equivalent to ``(or
(not_empty "foo"), (not_empty "bar"), (not_empty "baz"))``.
- ``single_input_file`` - Returns true if there was only one input file
provided on the command-line. Used without arguments:
@@ -511,16 +511,18 @@ use TableGen inheritance instead.
- ``default`` - Always evaluates to true. Should always be the last
test in the ``case`` expression.
- ``and`` - A standard binary logical combinator that returns true iff all of
- ``and`` - A standard logical combinator that returns true iff all of
its arguments return true. Used like this: ``(and (test1), (test2),
... (testN))``. Nesting of ``and`` and ``or`` is allowed, but not
encouraged.
- ``or`` - A binary logical combinator that returns true iff any of its
arguments returns true. Example: ``(or (test1), (test2), ... (testN))``.
- ``or`` - A logical combinator that returns true iff any of its arguments
return true.
Example: ``(or (test1), (test2), ... (testN))``.
- ``not`` - Standard unary logical combinator that negates its
argument. Example: ``(not (or (test1), (test2), ... (testN)))``.
argument.
Example: ``(not (or (test1), (test2), ... (testN)))``.
@@ -549,10 +551,10 @@ The complete list of all currently implemented tool properties follows.
* Possible tool properties:
- ``in_language`` - input language name. Can be either a string or a
list, in case the tool supports multiple input languages.
- ``in_language`` - input language name. Can be given multiple arguments, in
case the tool supports multiple input languages.
- ``out_language`` - output language name. Multiple output languages are not
- ``out_language`` - output language name. Multiple output languages are
allowed.
- ``output_suffix`` - output file suffix. Can also be changed
@@ -687,12 +689,12 @@ occasions. Example (adapted from the built-in Base plugin)::
def Preprocess : OptionPreprocessor<
(case (not (any_switch_on ["O0", "O1", "O2", "O3"])),
(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 "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"))
>;
@@ -709,10 +711,10 @@ 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.
For convenience, ``set_option`` and ``unset_option`` also work with multiple
arguments. That is, instead of ``[(unset_option "A"), (unset_option "B")]`` you
can use ``(unset_option "A", "B")``. Obviously, ``(set_option "A", "B")`` is
only valid if both ``A`` and ``B`` are switches.
More advanced topics
+16 -15
View File
@@ -152,23 +152,22 @@ def LinkerOptList : OptionList<[
// Option preprocessor.
def Preprocess : OptionPreprocessor<
(case (not (any_switch_on ["O0", "O1", "O2", "O3"])),
(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"]),
(switch_on ["O1", "O0"]),
(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"),
(switch_on "O1", "O0"),
(unset_option "O0"))
>;
// Tools
class llvm_gcc_based <string cmd, string in_lang,
string E_ext, list<string> out_lang,
class llvm_gcc_based <string cmd, string in_lang, string E_ext, dag out_lang,
string out_ext> : Tool<
[(in_language in_lang),
(out_language out_lang),
out_lang,
(output_suffix out_ext),
(command cmd),
(actions
@@ -184,7 +183,7 @@ class llvm_gcc_based <string cmd, string in_lang,
(and (switch_on "emit-llvm"), (not (switch_on "opt"))),
(stop_compilation),
// ('-S' && '-emit-llvm') && !('opt') -> output .ll
(and (switch_on ["emit-llvm", "S"]), (not (switch_on "opt"))),
(and (switch_on "emit-llvm", "S"), (not (switch_on "opt"))),
[(forward "S"), (output_suffix "ll")],
// Ususally just output .bc
(not (switch_on "fsyntax-only")),
@@ -222,10 +221,12 @@ class llvm_gcc_based <string cmd, string in_lang,
]>;
class llvm_gcc_comp_based <string cmd, string in_lang, string E_ext>
: llvm_gcc_based<cmd, in_lang, E_ext, ["llvm-bitcode", "object-code"], "bc">;
: llvm_gcc_based<cmd, in_lang, E_ext,
(out_language "llvm-bitcode", "object-code"), "bc">;
class llvm_gcc_pch_based <string cmd, string in_lang, string E_ext>
: llvm_gcc_based<cmd, in_lang, E_ext, ["precompiled-header"], "gch">;
: llvm_gcc_based<cmd, in_lang, E_ext,
(out_language "precompiled-header"), "gch">;
def llvm_gcc_c : llvm_gcc_comp_based
<"@LLVMGCCCOMMAND@ -x c", "c", "i">;
@@ -250,7 +251,7 @@ def opt : Tool<
(out_language "llvm-bitcode"),
(output_suffix "opt.bc"),
(actions (case (switch_on "emit-llvm"), (stop_compilation),
(switch_on ["emit-llvm", "S"]),
(switch_on "emit-llvm", "S"),
[(append_cmd "-S"), (output_suffix "ll")],
(not_empty "Wo,"), (forward_value "Wo,"),
(switch_on "O1"), (forward "O1"),
@@ -282,7 +283,7 @@ def llvm_gcc_assembler : Tool<
]>;
def llc : Tool<
[(in_language ["llvm-bitcode", "llvm-assembler"]),
[(in_language "llvm-bitcode", "llvm-assembler"),
(out_language "assembler"),
(output_suffix "s"),
(command "llc"),
@@ -304,7 +305,7 @@ def llc : Tool<
// Base class for linkers
class llvm_gcc_based_linker <string cmd, dag on_empty> : Tool<
[(in_language ["object-code", "static-library", "dynamic-library"]),
[(in_language "object-code", "static-library", "dynamic-library"),
(out_language "executable"),
(output_suffix "out"),
(command cmd),
+3 -3
View File
@@ -25,12 +25,12 @@ class clang_based<string language, string cmd, string ext_E> : Tool<
[(forward "E"), (stop_compilation), (output_suffix ext_E)],
(and (switch_on "E"), (empty "o")), (no_out_file),
(switch_on "fsyntax-only"), (stop_compilation),
(switch_on ["S", "emit-llvm"]),
(switch_on "S", "emit-llvm"),
[(append_cmd "-emit-llvm"),
(stop_compilation), (output_suffix "ll")],
(not (switch_on ["S", "emit-llvm"])),
(not (switch_on "S", "emit-llvm")),
(append_cmd "-emit-llvm-bc"),
(switch_on ["c", "emit-llvm"]),
(switch_on "c", "emit-llvm"),
(stop_compilation),
(not_empty "include"), (forward "include"),
(not_empty "I"), (forward "I"))),