1 include "llvm/CompilerDriver/Common.td"
3 def Priority : PluginPriority<1>;
5 def Options : OptionList<[
7 (switch_option "E", (extern)),
8 (switch_option "S", (extern)),
9 (switch_option "c", (extern)),
10 (switch_option "fsyntax-only", (extern)),
11 (switch_option "emit-llvm", (extern)),
12 (switch_option "pthread", (extern)),
13 (parameter_list_option "I", (extern)),
14 (parameter_list_option "include", (extern)),
15 (parameter_list_option "L", (extern)),
16 (parameter_list_option "l", (extern)),
17 (prefix_list_option "Wa,", (extern)),
18 (prefix_list_option "Wl,", (extern)),
20 (switch_option "clang", (help "Use Clang instead of llvm-gcc"))
23 class clang_based<string language, string cmd, string ext_E> : Tool<
24 [(in_language language),
25 (out_language "llvm-bitcode"),
28 (actions (case (switch_on "E"),
29 [(forward "E"), (stop_compilation), (output_suffix ext_E)],
30 (and (switch_on "E"), (empty "o")), (no_out_file),
31 (switch_on "fsyntax-only"), (stop_compilation),
32 (switch_on ["S", "emit-llvm"]),
33 [(append_cmd "-emit-llvm"),
34 (stop_compilation), (output_suffix "ll")],
35 (not (switch_on ["S", "emit-llvm"])),
36 (append_cmd "-emit-llvm-bc"),
37 (switch_on ["c", "emit-llvm"]),
39 (not_empty "include"), (forward "include"),
40 (not_empty "I"), (forward "I"))),
44 def clang_c : clang_based<"c", "clang -x c", "i">;
45 def clang_cpp : clang_based<"c++", "clang -x c++", "i">;
46 def clang_objective_c : clang_based<"objective-c",
47 "clang -x objective-c", "mi">;
48 def clang_objective_cpp : clang_based<"objective-c++",
49 "clang -x objective-c++", "mi">;
52 [(in_language "assembler"),
53 (out_language "object-code"),
56 (actions (case (not_empty "Wa,"), (forward_value "Wa,"),
57 (switch_on "c"), (stop_compilation)))
62 [(in_language "object-code"),
63 (out_language "executable"),
64 (output_suffix "out"),
65 (command "llvm-ld -native -disable-internalize"),
67 (switch_on "pthread"), (append_cmd "-lpthread"),
68 (not_empty "L"), (forward "L"),
69 (not_empty "l"), (forward "l"),
70 (not_empty "Wl,"), (forward_value "Wl,"))),
76 def LanguageMap : LanguageMap<[
77 LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
78 LangToSuffixes<"c", ["c"]>,
79 LangToSuffixes<"objective-c", ["m"]>,
80 LangToSuffixes<"c-cpp-output", ["i"]>,
81 LangToSuffixes<"objective-c-cpp-output", ["mi"]>
86 def CompilationGraph : CompilationGraph<[
87 OptionalEdge<"root", "clang_c",
88 (case (switch_on "clang"), (inc_weight))>,
89 OptionalEdge<"root", "clang_cpp",
90 (case (switch_on "clang"), (inc_weight))>,
91 OptionalEdge<"root", "clang_objective_c",
92 (case (switch_on "clang"), (inc_weight))>,
93 OptionalEdge<"root", "clang_objective_cpp",
94 (case (switch_on "clang"), (inc_weight))>,
95 Edge<"clang_c", "llc">,
96 Edge<"clang_cpp", "llc">,
97 Edge<"clang_objective_c", "llc">,
98 Edge<"clang_objective_cpp", "llc">,
99 OptionalEdge<"llc", "as", (case (switch_on "clang"), (inc_weight))>,
100 Edge<"as", "llvm_ld">