diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 06:26:08 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 06:26:08 +0000 |
commit | e43228958ce2d9c0c69c7ccaef8bb0517d085951 (patch) | |
tree | 096fc172c497ac64dcb47e71f8b32b11c15296f1 /tools/llvmc2 | |
parent | 270cae3bf818987d3079ba26ef3319960a034d25 (diff) | |
download | external_llvm-e43228958ce2d9c0c69c7ccaef8bb0517d085951.zip external_llvm-e43228958ce2d9c0c69c7ccaef8bb0517d085951.tar.gz external_llvm-e43228958ce2d9c0c69c7ccaef8bb0517d085951.tar.bz2 |
New feature: OptionList.
It can be handy to have all information about options gathered in a single place
to provide an overview of all supported options. This patch allows the following:
def Options : OptionList<[
(switch_option "E", (help "Help string")),
(alias_option "quiet", "q")
...
]>;
Tool-specific option properties (like 'append_cmd') have (obviously) no meaning in
this context, so the only properties that are allowed are 'help' and 'required'.
See usage example in examples/Clang.td.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc2')
-rw-r--r-- | tools/llvmc2/Common.td | 5 | ||||
-rw-r--r-- | tools/llvmc2/examples/Clang.td | 63 |
2 files changed, 55 insertions, 13 deletions
diff --git a/tools/llvmc2/Common.td b/tools/llvmc2/Common.td index 78bca37..046e19e 100644 --- a/tools/llvmc2/Common.td +++ b/tools/llvmc2/Common.td @@ -69,6 +69,11 @@ def or; def inc_weight; def dec_weight; +// Option list - used to specify aliases and sometimes help strings. +class OptionList<list<dag> l> { + list<dag> options = l; +} + // Map from suffixes to language names class LangToSuffixes<string str, list<string> lst> { diff --git a/tools/llvmc2/examples/Clang.td b/tools/llvmc2/examples/Clang.td index f57c726..07d59e8 100644 --- a/tools/llvmc2/examples/Clang.td +++ b/tools/llvmc2/examples/Clang.td @@ -4,22 +4,55 @@ include "Common.td" -def clang : Tool< -[(in_language ["c", "c++", "objective-c"]), + +// TOFIX: Add an explicit option list for aliases and things like this. +def Options : OptionList<[ +(switch_option "E", + (help "Stop after the preprocessing stage, do not run the compiler")) +]>; + +class clang_base<string language, dag cmdline> : Tool< +[(in_language language), (out_language "llvm-bitcode"), (output_suffix "bc"), - (cmd_line (case (switch_on "E"), "clang -E $INFILE", - (in_language "c"), - "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE", - (in_language "c++"), - "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE", - (in_language "objective-c"), - "clang -emit-llvm-bc -x objective-c$INFILE -o $OUTFILE")), - (switch_option "E", (stop_compilation), (output_suffix "i"), - (help "Stop after the preprocessing stage, do not run the compiler")), + (cmd_line cmdline), + (switch_option "E", (stop_compilation), (output_suffix "i")), (sink) ]>; +def clang_c : clang_base<"c", +(case +(switch_on "E"), + (case + (not_empty "o"), + "clang -E -x c $INFILE -o $OUTFILE", + (default), + "clang -E -x c $INFILE"), +(default), + "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE")>; + +def clang_cpp : clang_base<"c++", +(case +(switch_on "E"), + (case + (not_empty "o"), + "clang -E -x c++ $INFILE -o $OUTFILE", + (default), + "clang -E -x c++ $INFILE"), +(default), + "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE")>; + +def clang_objective_c : clang_base<"objective-c", +(case +(switch_on "E"), + (case + (not_empty "o"), + "clang -E -x objective-c $INFILE -o $OUTFILE", + (default), + "clang -E -x objective-c $INFILE"), +(default), + "clang -emit-llvm-bc -x objective-c $INFILE -o $OUTFILE")>; + // Default linker def llvm_ld : Tool< [(in_language "llvm-bitcode"), @@ -43,7 +76,11 @@ def LanguageMap : LanguageMap< // Compilation graph def CompilationGraph : CompilationGraph<[ - Edge<root, clang>, - Edge<clang, llvm_ld> + Edge<root, clang_c>, + Edge<root, clang_cpp>, + Edge<root, clang_objective_c>, + Edge<clang_c, llvm_ld>, + Edge<clang_cpp, llvm_ld>, + Edge<clang_objective_c, llvm_ld> ]>; |