[llvm-commits] [llvm] r111862 - in /llvm/trunk: include/llvm/CompilerDriver/ test/LLVMC/ tools/llvmc/examples/Simple/ tools/llvmc/examples/mcc16/ tools/llvmc/src/ utils/TableGen/
Mikhail Glushenkov
foldr at codedgers.com
Mon Aug 23 16:21:23 PDT 2010
Author: foldr
Date: Mon Aug 23 18:21:23 2010
New Revision: 111862
URL: http://llvm.org/viewvc/llvm-project?rev=111862&view=rev
Log:
llvmc: Make syntax more consistent.
CompilationGraph and LanguageMap definitions do not use special syntax anymore.
Added:
llvm/trunk/test/LLVMC/LanguageMap.td
Modified:
llvm/trunk/include/llvm/CompilerDriver/Common.td
llvm/trunk/test/LLVMC/Alias.td
llvm/trunk/test/LLVMC/AppendCmdHook.td
llvm/trunk/test/LLVMC/EnvParentheses.td
llvm/trunk/test/LLVMC/ForwardAs.td
llvm/trunk/test/LLVMC/ForwardTransformedValue.td
llvm/trunk/test/LLVMC/ForwardValue.td
llvm/trunk/test/LLVMC/HookWithArguments.td
llvm/trunk/test/LLVMC/HookWithInFile.td
llvm/trunk/test/LLVMC/Init.td
llvm/trunk/test/LLVMC/MultiValuedOption.td
llvm/trunk/test/LLVMC/NoActions.td
llvm/trunk/test/LLVMC/OneOrMore.td
llvm/trunk/test/LLVMC/OptionPreprocessor.td
llvm/trunk/test/LLVMC/OutputSuffixHook.td
llvm/trunk/tools/llvmc/examples/Simple/Simple.td
llvm/trunk/tools/llvmc/examples/mcc16/PIC16.td
llvm/trunk/tools/llvmc/src/Base.td.in
llvm/trunk/tools/llvmc/src/Clang.td
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/Common.td (original)
+++ llvm/trunk/include/llvm/CompilerDriver/Common.td Mon Aug 23 18:21:23 2010
@@ -96,9 +96,6 @@
// Increase the edge weight.
def inc_weight;
-// Empty DAG marker.
-def empty_dag_marker;
-
// Option list - a single place to specify options.
class OptionList<list<dag> l> {
list<dag> options = l;
@@ -111,31 +108,17 @@
// Map from suffixes to language names
-class LangToSuffixes<string str, list<string> lst> {
- string lang = str;
- list<string> suffixes = lst;
-}
+def lang_to_suffixes;
-class LanguageMap<list<LangToSuffixes> lst> {
- list<LangToSuffixes> map = lst;
+class LanguageMap<list<dag> l> {
+ list<dag> map = l;
}
// Compilation graph
-class EdgeBase<string t1, string t2, dag d> {
- string a = t1;
- string b = t2;
- dag weight = d;
-}
-
-class Edge<string t1, string t2> : EdgeBase<t1, t2, (empty_dag_marker)>;
-
-// Edge and SimpleEdge are synonyms.
-class SimpleEdge<string t1, string t2> : EdgeBase<t1, t2, (empty_dag_marker)>;
-
-// Optionally enabled edge.
-class OptionalEdge<string t1, string t2, dag props> : EdgeBase<t1, t2, props>;
+def edge;
+def optional_edge;
-class CompilationGraph<list<EdgeBase> lst> {
- list<EdgeBase> edges = lst;
+class CompilationGraph<list<dag> l> {
+ list<dag> edges = l;
}
Modified: llvm/trunk/test/LLVMC/Alias.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/Alias.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/Alias.td (original)
+++ llvm/trunk/test/LLVMC/Alias.td Mon Aug 23 18:21:23 2010
@@ -21,4 +21,4 @@
(switch_on "dummy1"), (forward "dummy1")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/AppendCmdHook.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/AppendCmdHook.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/AppendCmdHook.td (original)
+++ llvm/trunk/test/LLVMC/AppendCmdHook.td Mon Aug 23 18:21:23 2010
@@ -26,4 +26,4 @@
(switch_on "dummy2"), (append_cmd "-arg3 $CALL(MyHook)")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/EnvParentheses.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/EnvParentheses.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/EnvParentheses.td (original)
+++ llvm/trunk/test/LLVMC/EnvParentheses.td Mon Aug 23 18:21:23 2010
@@ -13,6 +13,6 @@
(out_language "dummy")
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
def Graph : CompilationGraph<[]>;
Modified: llvm/trunk/test/LLVMC/ForwardAs.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardAs.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/ForwardAs.td (original)
+++ llvm/trunk/test/LLVMC/ForwardAs.td Mon Aug 23 18:21:23 2010
@@ -18,4 +18,4 @@
(not_empty "dummy"), (forward_as "dummy", "unique_name")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/ForwardTransformedValue.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardTransformedValue.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/ForwardTransformedValue.td (original)
+++ llvm/trunk/test/LLVMC/ForwardTransformedValue.td Mon Aug 23 18:21:23 2010
@@ -24,4 +24,4 @@
(not_empty "b"), (forward_transformed_value "b", "HookB")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/ForwardValue.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardValue.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/ForwardValue.td (original)
+++ llvm/trunk/test/LLVMC/ForwardValue.td Mon Aug 23 18:21:23 2010
@@ -21,4 +21,4 @@
(not_empty "b"), (forward_value "b")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/HookWithArguments.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/HookWithArguments.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/HookWithArguments.td (original)
+++ llvm/trunk/test/LLVMC/HookWithArguments.td Mon Aug 23 18:21:23 2010
@@ -17,4 +17,4 @@
(out_language "dummy")
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/HookWithInFile.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/HookWithInFile.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/HookWithInFile.td (original)
+++ llvm/trunk/test/LLVMC/HookWithInFile.td Mon Aug 23 18:21:23 2010
@@ -13,4 +13,4 @@
(out_language "dummy")
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/Init.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/Init.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/Init.td (original)
+++ llvm/trunk/test/LLVMC/Init.td Mon Aug 23 18:21:23 2010
@@ -22,4 +22,4 @@
(not_empty "dummy2"), (forward "dummy2")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Added: llvm/trunk/test/LLVMC/LanguageMap.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/LanguageMap.td?rev=111862&view=auto
==============================================================================
--- llvm/trunk/test/LLVMC/LanguageMap.td (added)
+++ llvm/trunk/test/LLVMC/LanguageMap.td Mon Aug 23 18:21:23 2010
@@ -0,0 +1,29 @@
+// Check that LanguageMap is processed properly.
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
+// RUN: FileCheck -input-file %t %s
+// RUN: %compile_cxx -x c++ %t
+// XFAIL: vg_leak
+
+include "llvm/CompilerDriver/Common.td"
+
+def OptList : OptionList<[
+(switch_option "dummy1", (help "none"))
+]>;
+
+def dummy_tool : Tool<[
+(command "dummy_cmd"),
+(in_language "dummy_lang"),
+(out_language "dummy_lang"),
+(actions (case
+ (switch_on "dummy1"), (forward "dummy1")))
+]>;
+
+def lang_map : LanguageMap<[
+ // CHECK: langMap["dummy"] = "dummy_lang"
+ // CHECK: langMap["DUM"] = "dummy_lang"
+ (lang_to_suffixes "dummy_lang", ["dummy", "DUM"]),
+ // CHECK: langMap["DUM2"] = "dummy_lang_2"
+ (lang_to_suffixes "dummy_lang_2", "DUM2")
+]>;
+
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/MultiValuedOption.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiValuedOption.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/MultiValuedOption.td (original)
+++ llvm/trunk/test/LLVMC/MultiValuedOption.td Mon Aug 23 18:21:23 2010
@@ -21,4 +21,4 @@
(not_empty "baz"), (forward "baz")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/NoActions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/NoActions.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/NoActions.td (original)
+++ llvm/trunk/test/LLVMC/NoActions.td Mon Aug 23 18:21:23 2010
@@ -13,4 +13,4 @@
(out_language "dummy")
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/OneOrMore.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OneOrMore.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/OneOrMore.td (original)
+++ llvm/trunk/test/LLVMC/OneOrMore.td Mon Aug 23 18:21:23 2010
@@ -22,4 +22,4 @@
(not_empty "baz"), (forward "baz")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/test/LLVMC/OptionPreprocessor.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OptionPreprocessor.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/OptionPreprocessor.td (original)
+++ llvm/trunk/test/LLVMC/OptionPreprocessor.td Mon Aug 23 18:21:23 2010
@@ -63,5 +63,5 @@
(not_empty "foo_l"), (error)))
]>;
-def Graph : CompilationGraph<[Edge<"root", "dummy">]>;
+def Graph : CompilationGraph<[(edge "root", "dummy")]>;
Modified: llvm/trunk/test/LLVMC/OutputSuffixHook.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OutputSuffixHook.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/OutputSuffixHook.td (original)
+++ llvm/trunk/test/LLVMC/OutputSuffixHook.td Mon Aug 23 18:21:23 2010
@@ -21,4 +21,4 @@
(switch_on "dummy1"), (output_suffix "$CALL(MyHook)")))
]>;
-def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+def DummyGraph : CompilationGraph<[(edge "root", "dummy_tool")]>;
Modified: llvm/trunk/tools/llvmc/examples/Simple/Simple.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/Simple/Simple.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/examples/Simple/Simple.td (original)
+++ llvm/trunk/tools/llvmc/examples/Simple/Simple.td Mon Aug 23 18:21:23 2010
@@ -36,6 +36,6 @@
(out_file_option "-o")
]>;
-def LanguageMap : LanguageMap<[LangToSuffixes<"c", ["c"]>]>;
+def LanguageMap : LanguageMap<[(lang_to_suffixes "c", "c")]>;
-def CompilationGraph : CompilationGraph<[Edge<"root", "gcc">]>;
+def CompilationGraph : CompilationGraph<[(edge "root", "gcc")]>;
Modified: llvm/trunk/tools/llvmc/examples/mcc16/PIC16.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/mcc16/PIC16.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/examples/mcc16/PIC16.td (original)
+++ llvm/trunk/tools/llvmc/examples/mcc16/PIC16.td Mon Aug 23 18:21:23 2010
@@ -202,33 +202,33 @@
// Language map
def LanguageMap : LanguageMap<[
- LangToSuffixes<"c", ["c"]>,
- LangToSuffixes<"c-cpp-output", ["i"]>,
- LangToSuffixes<"assembler", ["s"]>,
- LangToSuffixes<"assembler-with-cpp", ["S"]>,
- LangToSuffixes<"llvm-assembler", ["ll"]>,
- LangToSuffixes<"llvm-bitcode", ["bc"]>,
- LangToSuffixes<"object-code", ["o"]>,
- LangToSuffixes<"executable", ["cof"]>
+ (lang_to_suffixes "c", "c"),
+ (lang_to_suffixes "c-cpp-output", "i"),
+ (lang_to_suffixes "assembler", "s"),
+ (lang_to_suffixes "assembler-with-cpp", "S"),
+ (lang_to_suffixes "llvm-assembler", "ll"),
+ (lang_to_suffixes "llvm-bitcode", "bc"),
+ (lang_to_suffixes "object-code", "o"),
+ (lang_to_suffixes "executable", "cof")
]>;
// Compilation graph
def CompilationGraph : CompilationGraph<[
- Edge<"root", "clang_cc">,
- Edge<"root", "llvm_ld">,
- OptionalEdge<"root", "llvm_ld_optimizer", (case
- (switch_on "S"), (inc_weight),
- (switch_on "c"), (inc_weight))>,
- Edge<"root", "gpasm">,
- Edge<"root", "mplink">,
- Edge<"clang_cc", "llvm_ld">,
- OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case
- (switch_on "S"), (inc_weight),
- (switch_on "c"), (inc_weight))>,
- Edge<"llvm_ld", "pic16passes">,
- Edge<"llvm_ld_optimizer", "pic16passes">,
- Edge<"pic16passes", "llc">,
- Edge<"llc", "gpasm">,
- Edge<"gpasm", "mplink">
+ (edge "root", "clang_cc"),
+ (edge "root", "llvm_ld"),
+ (optional_edge "root", "llvm_ld_optimizer",
+ (case (switch_on "S"), (inc_weight),
+ (switch_on "c"), (inc_weight))),
+ (edge "root", "gpasm"),
+ (edge "root", "mplink"),
+ (edge "clang_cc", "llvm_ld"),
+ (optional_edge "clang_cc", "llvm_ld_optimizer",
+ (case (switch_on "S"), (inc_weight),
+ (switch_on "c"), (inc_weight))),
+ (edge "llvm_ld", "pic16passes"),
+ (edge "llvm_ld_optimizer", "pic16passes"),
+ (edge "pic16passes", "llc"),
+ (edge "llc", "gpasm"),
+ (edge "gpasm", "mplink")
]>;
Modified: llvm/trunk/tools/llvmc/src/Base.td.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Base.td.in?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/src/Base.td.in (original)
+++ llvm/trunk/tools/llvmc/src/Base.td.in Mon Aug 23 18:21:23 2010
@@ -304,73 +304,78 @@
// Language map
-def LanguageMap : LanguageMap<
- [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
- LangToSuffixes<"c++-header", ["hpp"]>,
- LangToSuffixes<"c", ["c"]>,
- LangToSuffixes<"c-header", ["h"]>,
- LangToSuffixes<"c-cpp-output", ["i"]>,
- LangToSuffixes<"objective-c-cpp-output", ["mi"]>,
- LangToSuffixes<"objective-c++", ["mm"]>,
- LangToSuffixes<"objective-c++-header", ["hmm"]>,
- LangToSuffixes<"objective-c", ["m"]>,
- LangToSuffixes<"objective-c-header", ["hm"]>,
- LangToSuffixes<"assembler", ["s"]>,
- LangToSuffixes<"assembler-with-cpp", ["S"]>,
- LangToSuffixes<"llvm-assembler", ["ll"]>,
- LangToSuffixes<"llvm-bitcode", ["bc"]>,
- LangToSuffixes<"object-code", ["o", "*empty*"]>,
- LangToSuffixes<"static-library", ["a", "lib"]>,
- LangToSuffixes<"executable", ["out"]>
- ]>;
+def LanguageMap : LanguageMap<[
+ (lang_to_suffixes "c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]),
+ (lang_to_suffixes "c++-header", "hpp"),
+ (lang_to_suffixes "c", "c"),
+ (lang_to_suffixes "c-header", "h"),
+ (lang_to_suffixes "c-cpp-output", "i"),
+ (lang_to_suffixes "objective-c-cpp-output", "mi"),
+ (lang_to_suffixes "objective-c++", "mm"),
+ (lang_to_suffixes "objective-c++-header", "hmm"),
+ (lang_to_suffixes "objective-c", "m"),
+ (lang_to_suffixes "objective-c-header", "hm"),
+ (lang_to_suffixes "assembler", "s"),
+ (lang_to_suffixes "assembler-with-cpp", "S"),
+ (lang_to_suffixes "llvm-assembler", "ll"),
+ (lang_to_suffixes "llvm-bitcode", "bc"),
+ (lang_to_suffixes "object-code", ["o", "*empty*"]),
+ (lang_to_suffixes "static-library", ["a", "lib"]),
+ (lang_to_suffixes "executable", ["out"])
+]>;
// Compilation graph
def CompilationGraph : CompilationGraph<[
- Edge<"root", "llvm_gcc_c">,
- Edge<"root", "llvm_gcc_assembler">,
- Edge<"root", "llvm_gcc_cpp">,
- Edge<"root", "llvm_gcc_m">,
- Edge<"root", "llvm_gcc_mxx">,
- Edge<"root", "llc">,
-
- Edge<"root", "llvm_gcc_c_pch">,
- Edge<"root", "llvm_gcc_cpp_pch">,
- Edge<"root", "llvm_gcc_m_pch">,
- Edge<"root", "llvm_gcc_mxx_pch">,
-
- Edge<"llvm_gcc_c", "llc">,
- Edge<"llvm_gcc_cpp", "llc">,
- Edge<"llvm_gcc_m", "llc">,
- Edge<"llvm_gcc_mxx", "llc">,
- Edge<"llvm_as", "llc">,
-
- OptionalEdge<"root", "llvm_as",
- (case (switch_on "emit-llvm"), (inc_weight))>,
- OptionalEdge<"llvm_gcc_c", "opt", (case (switch_on "opt"), (inc_weight))>,
- OptionalEdge<"llvm_gcc_cpp", "opt", (case (switch_on "opt"), (inc_weight))>,
- OptionalEdge<"llvm_gcc_m", "opt", (case (switch_on "opt"), (inc_weight))>,
- OptionalEdge<"llvm_gcc_mxx", "opt", (case (switch_on "opt"), (inc_weight))>,
- OptionalEdge<"llvm_as", "opt", (case (switch_on "opt"), (inc_weight))>,
- Edge<"opt", "llc">,
-
- Edge<"llc", "llvm_gcc_assembler">,
- Edge<"llvm_gcc_assembler", "llvm_gcc_linker">,
- OptionalEdge<"llvm_gcc_assembler", "llvm_gcc_cpp_linker",
+ (edge "root", "llvm_gcc_c"),
+ (edge "root", "llvm_gcc_assembler"),
+ (edge "root", "llvm_gcc_cpp"),
+ (edge "root", "llvm_gcc_m"),
+ (edge "root", "llvm_gcc_mxx"),
+ (edge "root", "llc"),
+
+ (edge "root", "llvm_gcc_c_pch"),
+ (edge "root", "llvm_gcc_cpp_pch"),
+ (edge "root", "llvm_gcc_m_pch"),
+ (edge "root", "llvm_gcc_mxx_pch"),
+
+ (edge "llvm_gcc_c", "llc"),
+ (edge "llvm_gcc_cpp", "llc"),
+ (edge "llvm_gcc_m", "llc"),
+ (edge "llvm_gcc_mxx", "llc"),
+ (edge "llvm_as", "llc"),
+
+ (optional_edge "root", "llvm_as",
+ (case (switch_on "emit-llvm"), (inc_weight))),
+ (optional_edge "llvm_gcc_c", "opt",
+ (case (switch_on "opt"), (inc_weight))),
+ (optional_edge "llvm_gcc_cpp", "opt",
+ (case (switch_on "opt"), (inc_weight))),
+ (optional_edge "llvm_gcc_m", "opt",
+ (case (switch_on "opt"), (inc_weight))),
+ (optional_edge "llvm_gcc_mxx", "opt",
+ (case (switch_on "opt"), (inc_weight))),
+ (optional_edge "llvm_as", "opt",
+ (case (switch_on "opt"), (inc_weight))),
+ (edge "opt", "llc"),
+
+ (edge "llc", "llvm_gcc_assembler"),
+ (edge "llvm_gcc_assembler", "llvm_gcc_linker"),
+ (optional_edge "llvm_gcc_assembler", "llvm_gcc_cpp_linker",
(case
(or (input_languages_contain "c++"),
(input_languages_contain "objective-c++")),
(inc_weight),
(or (parameter_equals "linker", "g++"),
- (parameter_equals "linker", "c++")), (inc_weight))>,
+ (parameter_equals "linker", "c++")), (inc_weight))),
- Edge<"root", "llvm_gcc_linker">,
- OptionalEdge<"root", "llvm_gcc_cpp_linker",
+ (edge "root", "llvm_gcc_linker"),
+ (optional_edge "root", "llvm_gcc_cpp_linker",
(case
(or (input_languages_contain "c++"),
(input_languages_contain "objective-c++")),
(inc_weight),
(or (parameter_equals "linker", "g++"),
- (parameter_equals "linker", "c++")), (inc_weight))>
- ]>;
+ (parameter_equals "linker", "c++")), (inc_weight)))
+]>;
Modified: llvm/trunk/tools/llvmc/src/Clang.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Clang.td?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/src/Clang.td (original)
+++ llvm/trunk/tools/llvmc/src/Clang.td Mon Aug 23 18:21:23 2010
@@ -70,18 +70,18 @@
// Compilation graph
def ClangCompilationGraph : CompilationGraph<[
- OptionalEdge<"root", "clang_c",
- (case (switch_on "clang"), (inc_weight))>,
- OptionalEdge<"root", "clang_cpp",
- (case (switch_on "clang"), (inc_weight))>,
- OptionalEdge<"root", "clang_objective_c",
- (case (switch_on "clang"), (inc_weight))>,
- OptionalEdge<"root", "clang_objective_cpp",
- (case (switch_on "clang"), (inc_weight))>,
- Edge<"clang_c", "llc">,
- Edge<"clang_cpp", "llc">,
- Edge<"clang_objective_c", "llc">,
- Edge<"clang_objective_cpp", "llc">,
- OptionalEdge<"llc", "as", (case (switch_on "clang"), (inc_weight))>,
- Edge<"as", "llvm_ld">
+ (optional_edge "root", "clang_c",
+ (case (switch_on "clang"), (inc_weight))),
+ (optional_edge "root", "clang_cpp",
+ (case (switch_on "clang"), (inc_weight))),
+ (optional_edge "root", "clang_objective_c",
+ (case (switch_on "clang"), (inc_weight))),
+ (optional_edge "root", "clang_objective_cpp",
+ (case (switch_on "clang"), (inc_weight))),
+ (edge "clang_c", "llc"),
+ (edge "clang_cpp", "llc"),
+ (edge "clang_objective_c", "llc"),
+ (edge "clang_objective_cpp", "llc"),
+ (optional_edge "llc", "as", (case (switch_on "clang"), (inc_weight))),
+ (edge "as", "llvm_ld")
]>;
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=111862&r1=111861&r2=111862&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon Aug 23 18:21:23 2010
@@ -33,6 +33,7 @@
/// Typedefs
typedef std::vector<Record*> RecordVector;
+typedef std::vector<const DagInit*> DagVector;
typedef std::vector<std::string> StrVector;
//===----------------------------------------------------------------------===//
@@ -109,11 +110,6 @@
throw GetOperatorName(d) + ": too few arguments!";
}
-// IsDagEmpty - is this DAG marked with an empty marker?
-bool IsDagEmpty (const DagInit& d) {
- return GetOperatorName(d) == "empty_dag_marker";
-}
-
// EscapeVariableName - Escape commas and other symbols not allowed
// in the C++ variable names. Makes it possible to use options named
// like "Wa," (useful for prefix options).
@@ -622,7 +618,6 @@
((Obj)->*(h))(Dag, IndentLevel, O);
}
-
template <typename H>
typename HandlerTable<H>::HandlerMap HandlerTable<H>::Handlers_;
@@ -791,7 +786,6 @@
OptionDescription OD(Type, Name);
-
CheckNumberOfArguments(d, 2);
if (OD.isAlias()) {
@@ -820,15 +814,14 @@
/// CollectOptionDescriptions - Collects option properties from all
/// OptionLists.
-void CollectOptionDescriptions (RecordVector::const_iterator B,
- RecordVector::const_iterator E,
+void CollectOptionDescriptions (const RecordVector& V,
OptionDescriptions& OptDescs)
{
// For every OptionList:
- for (; B!=E; ++B) {
- RecordVector::value_type T = *B;
+ for (RecordVector::const_iterator B = V.begin(),
+ E = V.end(); B!=E; ++B) {
// Throws an exception if the value does not exist.
- ListInit* PropList = T->getValueAsListInit("options");
+ ListInit* PropList = (*B)->getValueAsListInit("options");
// For every option description in this list:
// collect the information and
@@ -1005,12 +998,12 @@
/// CollectToolDescriptions - Gather information about tool properties
/// from the parsed TableGen data (basically a wrapper for the
/// CollectToolProperties function object).
-void CollectToolDescriptions (RecordVector::const_iterator B,
- RecordVector::const_iterator E,
+void CollectToolDescriptions (const RecordVector& Tools,
ToolDescriptions& ToolDescs)
{
// Iterate over a properties list of every Tool definition
- for (;B!=E;++B) {
+ for (RecordVector::const_iterator B = Tools.begin(),
+ E = Tools.end(); B!=E; ++B) {
const Record* T = *B;
// Throws an exception if the value does not exist.
ListInit* PropList = T->getValueAsListInit("properties");
@@ -1026,13 +1019,16 @@
/// FillInEdgeVector - Merge all compilation graph definitions into
/// one single edge list.
-void FillInEdgeVector(RecordVector::const_iterator B,
- RecordVector::const_iterator E, RecordVector& Out) {
- for (; B != E; ++B) {
- const ListInit* edges = (*B)->getValueAsListInit("edges");
-
- for (unsigned i = 0; i < edges->size(); ++i)
- Out.push_back(edges->getElementAsRecord(i));
+void FillInEdgeVector(const RecordVector& CompilationGraphs,
+ DagVector& Out) {
+ for (RecordVector::const_iterator B = CompilationGraphs.begin(),
+ E = CompilationGraphs.end(); B != E; ++B) {
+ const ListInit* Edges = (*B)->getValueAsListInit("edges");
+
+ for (ListInit::const_iterator B = Edges->begin(),
+ E = Edges->end(); B != E; ++B) {
+ Out.push_back(&InitPtrToDag(*B));
+ }
}
}
@@ -1053,18 +1049,18 @@
/// FilterNotInGraph - Filter out from ToolDescs all Tools not
/// mentioned in the compilation graph definition.
-void FilterNotInGraph (const RecordVector& EdgeVector,
+void FilterNotInGraph (const DagVector& EdgeVector,
ToolDescriptions& ToolDescs) {
// List all tools mentioned in the graph.
llvm::StringSet<> ToolsInGraph;
- for (RecordVector::const_iterator B = EdgeVector.begin(),
+ for (DagVector::const_iterator B = EdgeVector.begin(),
E = EdgeVector.end(); B != E; ++B) {
- const Record* Edge = *B;
- const std::string& NodeA = Edge->getValueAsString("a");
- const std::string& NodeB = Edge->getValueAsString("b");
+ const DagInit* Edge = *B;
+ const std::string& NodeA = InitPtrToString(Edge->getArg(0));
+ const std::string& NodeB = InitPtrToString(Edge->getArg(1));
if (NodeA != "root")
ToolsInGraph.insert(NodeA);
@@ -1095,7 +1091,7 @@
/// TypecheckGraph - Check that names for output and input languages
/// on all edges do match.
-void TypecheckGraph (const RecordVector& EdgeVector,
+void TypecheckGraph (const DagVector& EdgeVector,
const ToolDescriptions& ToolDescs) {
StringMap<StringSet<> > ToolToInLang;
StringMap<std::string> ToolToOutLang;
@@ -1104,11 +1100,11 @@
StringMap<std::string>::iterator IAE = ToolToOutLang.end();
StringMap<StringSet<> >::iterator IBE = ToolToInLang.end();
- for (RecordVector::const_iterator B = EdgeVector.begin(),
+ for (DagVector::const_iterator B = EdgeVector.begin(),
E = EdgeVector.end(); B != E; ++B) {
- const Record* Edge = *B;
- const std::string& NodeA = Edge->getValueAsString("a");
- const std::string& NodeB = Edge->getValueAsString("b");
+ const DagInit* Edge = *B;
+ const std::string& NodeA = InitPtrToString(Edge->getArg(0));
+ const std::string& NodeB = InitPtrToString(Edge->getArg(1));
StringMap<std::string>::iterator IA = ToolToOutLang.find(NodeA);
StringMap<StringSet<> >::iterator IB = ToolToInLang.find(NodeB);
@@ -1250,7 +1246,7 @@
/// CheckForSuperfluousOptions - Check that there are no side
/// effect-free options (specified only in the OptionList). Otherwise,
/// output a warning.
-void CheckForSuperfluousOptions (const RecordVector& Edges,
+void CheckForSuperfluousOptions (const DagVector& EdgeVector,
const ToolDescriptions& ToolDescs,
const OptionDescriptions& OptDescs) {
llvm::StringSet<> nonSuperfluousOptions;
@@ -1268,13 +1264,13 @@
// Add all options mentioned in the 'case' clauses of the
// OptionalEdges of the compilation graph to the set of
// non-superfluous options.
- for (RecordVector::const_iterator B = Edges.begin(), E = Edges.end();
- B != E; ++B) {
- const Record* Edge = *B;
- DagInit& Weight = *Edge->getValueAsDag("weight");
-
- if (!IsDagEmpty(Weight))
+ for (DagVector::const_iterator B = EdgeVector.begin(),
+ E = EdgeVector.end(); B != E; ++B) {
+ const DagInit* Edge = *B;
+ if (Edge->getNumArgs() > 2) {
+ const DagInit& Weight = InitPtrToDag(Edge->getArg(2));
WalkCase(&Weight, ExtractOptionNames(nonSuperfluousOptions), Id());
+ }
}
// Check that all options in OptDescs belong to the set of
@@ -2616,31 +2612,72 @@
O << "}\n\n";
}
+class DoEmitPopulateLanguageMap;
+typedef void (DoEmitPopulateLanguageMap::* DoEmitPopulateLanguageMapHandler)
+(const DagInit& D);
+
+class DoEmitPopulateLanguageMap
+: public HandlerTable<DoEmitPopulateLanguageMapHandler>
+{
+private:
+ raw_ostream& O_;
+
+public:
+
+ explicit DoEmitPopulateLanguageMap (raw_ostream& O) : O_(O) {
+ if (!staticMembersInitialized_) {
+ AddHandler("lang_to_suffixes",
+ &DoEmitPopulateLanguageMap::onLangToSuffixes);
+
+ staticMembersInitialized_ = true;
+ }
+ }
+
+ void operator() (Init* I) {
+ InvokeDagInitHandler(this, I);
+ }
+
+private:
+
+ void onLangToSuffixes (const DagInit& d) {
+ CheckNumberOfArguments(d, 2);
+
+ const std::string& Lang = InitPtrToString(d.getArg(0));
+ Init* Suffixes = d.getArg(1);
+
+ // Second argument to lang_to_suffixes is either a single string...
+ if (typeid(*Suffixes) == typeid(StringInit)) {
+ O_.indent(Indent1) << "langMap[\"" << InitPtrToString(Suffixes)
+ << "\"] = \"" << Lang << "\";\n";
+ }
+ // ...or a list of strings.
+ else {
+ const ListInit& Lst = InitPtrToList(Suffixes);
+ assert(Lst.size() != 0);
+ for (ListInit::const_iterator B = Lst.begin(), E = Lst.end();
+ B != E; ++B) {
+ O_.indent(Indent1) << "langMap[\"" << InitPtrToString(*B)
+ << "\"] = \"" << Lang << "\";\n";
+ }
+ }
+ }
+
+};
+
/// EmitPopulateLanguageMap - Emit the PopulateLanguageMap() function.
void EmitPopulateLanguageMap (const RecordKeeper& Records, raw_ostream& O)
{
O << "int PopulateLanguageMap (LanguageMap& langMap) {\n";
- const RecordVector& LanguageMaps =
+ // For each LangMap:
+ const RecordVector& LangMaps =
Records.getAllDerivedDefinitions("LanguageMap");
- for (RecordVector::const_iterator B = LanguageMaps.begin(),
- E = LanguageMaps.end(); B!=E; ++B) {
- ListInit* LangsToSuffixesList = (*B)->getValueAsListInit("map");
- if (!LangsToSuffixesList)
- throw "Error in the language map definition!";
-
- for (unsigned i = 0; i < LangsToSuffixesList->size(); ++i) {
- const Record* LangToSuffixes = LangsToSuffixesList->getElementAsRecord(i);
-
- const std::string& Lang = LangToSuffixes->getValueAsString("lang");
- const ListInit* Suffixes = LangToSuffixes->getValueAsListInit("suffixes");
-
- for (unsigned i = 0; i < Suffixes->size(); ++i)
- O.indent(Indent1) << "langMap[\""
- << InitPtrToString(Suffixes->getElement(i))
- << "\"] = \"" << Lang << "\";\n";
- }
+ for (RecordVector::const_iterator B = LangMaps.begin(),
+ E = LangMaps.end(); B!=E; ++B) {
+ ListInit* LangMap = (*B)->getValueAsListInit("map");
+ std::for_each(LangMap->begin(), LangMap->end(),
+ DoEmitPopulateLanguageMap(O));
}
O << '\n';
@@ -2681,7 +2718,7 @@
/// EmitEdgeClass - Emit a single Edge# class.
void EmitEdgeClass (unsigned N, const std::string& Target,
- DagInit* Case, const OptionDescriptions& OptDescs,
+ const DagInit* Case, const OptionDescriptions& OptDescs,
raw_ostream& O) {
// Class constructor.
@@ -2704,24 +2741,26 @@
}
/// EmitEdgeClasses - Emit Edge* classes that represent graph edges.
-void EmitEdgeClasses (const RecordVector& EdgeVector,
+void EmitEdgeClasses (const DagVector& EdgeVector,
const OptionDescriptions& OptDescs,
raw_ostream& O) {
int i = 0;
- for (RecordVector::const_iterator B = EdgeVector.begin(),
+ for (DagVector::const_iterator B = EdgeVector.begin(),
E = EdgeVector.end(); B != E; ++B) {
- const Record* Edge = *B;
- const std::string& NodeB = Edge->getValueAsString("b");
- DagInit& Weight = *Edge->getValueAsDag("weight");
+ const DagInit* Edge = *B;
+ const std::string& NodeB = InitPtrToString(Edge->getArg(1));
+
+ if (Edge->getNumArgs() > 2) {
+ const DagInit* Weight = &InitPtrToDag(Edge->getArg(2));
+ EmitEdgeClass(i, NodeB, Weight, OptDescs, O);
+ }
- if (!IsDagEmpty(Weight))
- EmitEdgeClass(i, NodeB, &Weight, OptDescs, O);
++i;
}
}
/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraph() function.
-void EmitPopulateCompilationGraph (const RecordVector& EdgeVector,
+void EmitPopulateCompilationGraph (const DagVector& EdgeVector,
const ToolDescriptions& ToolDescs,
raw_ostream& O)
{
@@ -2736,19 +2775,18 @@
// Insert edges.
int i = 0;
- for (RecordVector::const_iterator B = EdgeVector.begin(),
+ for (DagVector::const_iterator B = EdgeVector.begin(),
E = EdgeVector.end(); B != E; ++B) {
- const Record* Edge = *B;
- const std::string& NodeA = Edge->getValueAsString("a");
- const std::string& NodeB = Edge->getValueAsString("b");
- DagInit& Weight = *Edge->getValueAsDag("weight");
+ const DagInit* Edge = *B;
+ const std::string& NodeA = InitPtrToString(Edge->getArg(0));
+ const std::string& NodeB = InitPtrToString(Edge->getArg(1));
O.indent(Indent1) << "if (int ret = G.insertEdge(\"" << NodeA << "\", ";
- if (IsDagEmpty(Weight))
- O << "new SimpleEdge(\"" << NodeB << "\")";
- else
+ if (Edge->getNumArgs() > 2)
O << "new Edge" << i << "()";
+ else
+ O << "new SimpleEdge(\"" << NodeB << "\")";
O << "))\n";
O.indent(Indent2) << "return ret;\n";
@@ -2961,7 +2999,7 @@
struct DriverData {
OptionDescriptions OptDescs;
ToolDescriptions ToolDescs;
- RecordVector Edges;
+ DagVector Edges;
bool HasSink;
};
@@ -2982,19 +3020,17 @@
// Collect option properties.
const RecordVector& OptionLists =
Records.getAllDerivedDefinitions("OptionList");
- CollectOptionDescriptions(OptionLists.begin(), OptionLists.end(),
- Data.OptDescs);
+ CollectOptionDescriptions(OptionLists, Data.OptDescs);
// Collect tool properties.
const RecordVector& Tools = Records.getAllDerivedDefinitions("Tool");
- CollectToolDescriptions(Tools.begin(), Tools.end(), Data.ToolDescs);
+ CollectToolDescriptions(Tools, Data.ToolDescs);
Data.HasSink = HasSink(Data.ToolDescs);
// Collect compilation graph edges.
const RecordVector& CompilationGraphs =
Records.getAllDerivedDefinitions("CompilationGraph");
- FillInEdgeVector(CompilationGraphs.begin(), CompilationGraphs.end(),
- Data.Edges);
+ FillInEdgeVector(CompilationGraphs, Data.Edges);
}
/// CheckDriverData - Perform some sanity checks on the collected data.
@@ -3035,6 +3071,7 @@
EmitToolClassDefinition(*(*B), Data.OptDescs, O);
// Emit Edge# classes.
+ // TODO: check for edge/optional_edge dag markers.
EmitEdgeClasses(Data.Edges, Data.OptDescs, O);
O << "} // End anonymous namespace.\n\n";
More information about the llvm-commits
mailing list