Do not generate empty 'if's for the output_suffix property.
[oota-llvm.git] / tools / llvmc2 / Tools.td
1 //===- Tools.td - Tools description for the LLVMCC  --------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains descriptions of the various build tools run by llvmcc.
11 //
12 //===----------------------------------------------------------------------===//
13
14 // TOTHINK: Open issue: should we use DAG lists in Tool specifications
15 // or change to something like
16
17 // def LLVMGccC : < Tool<
18 // [ InLanguage<"c">,
19 //   PrefixListOption<"Wl", [UnpackValues, PropertyName<Arg>, ...]>
20 //  ...] ?
21
22 // DAG lists look more aesthetically pleasing to me.
23
24 def llvm_gcc_c : Tool<
25 [(in_language "c"),
26  (out_language "llvm-bitcode"),
27  (output_suffix "bc"),
28  (cmd_line (case
29             (switch_on "E"),
30               "llvm-g++ -E -x c $INFILE -o $OUTFILE",
31             (default),
32               "llvm-g++ -c -x c $INFILE -o $OUTFILE -emit-llvm")),
33  (switch_option "E", (stop_compilation),(output_suffix "i"),
34    (help "Stop after the preprocessing stage, do not run the compiler")),
35  (sink)
36 ]>;
37
38 def llvm_gcc_cpp : Tool<
39 [(in_language "c++"),
40  (out_language "llvm-bitcode"),
41  (output_suffix "bc"),
42  (cmd_line (case
43             (switch_on "E"),
44               "llvm-g++ -E -x c++ $INFILE -o $OUTFILE",
45             (default),
46               "llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm")),
47  (switch_option "E", (stop_compilation), (output_suffix "i")),
48  (sink)
49 ]>;
50
51 def opt : Tool<
52 [(in_language "llvm-bitcode"),
53  (out_language "llvm-bitcode"),
54  (switch_option "opt", (help "Enable opt")),
55  (output_suffix "bc"),
56  (cmd_line "opt $INFILE -o $OUTFILE")
57 ]>;
58
59 def llvm_as : Tool<
60 [(in_language "llvm-assembler"),
61  (out_language "llvm-bitcode"),
62  (output_suffix "bc"),
63  (cmd_line "llvm-as $INFILE -o $OUTFILE")
64 ]>;
65
66 def llc : Tool<
67 [(in_language "llvm-bitcode"),
68  (out_language "assembler"),
69  (output_suffix "s"),
70  (switch_option "S", (stop_compilation),
71                 (help "Stop after compilation, do not assemble")),
72  (cmd_line "llc -f $INFILE -o $OUTFILE")
73 ]>;
74
75 def llvm_gcc_assembler : Tool<
76 [(in_language "assembler"),
77  (out_language "object-code"),
78  (output_suffix "o"),
79  (cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
80  (switch_option "c", (stop_compilation),
81                 (help "Compile and assemble, but do not link")),
82  (prefix_list_option "Wa,", (unpack_values), (help "pass options to assembler"))
83 ]>;
84
85 // Default linker
86 def llvm_gcc_linker : Tool<
87 [(in_language "object-code"),
88  (out_language "executable"),
89  (output_suffix "out"),
90  (cmd_line "llvm-gcc $INFILE -o $OUTFILE"),
91  (join),
92  (prefix_list_option "L", (forward), (help "add a directory to link path")),
93  (prefix_list_option "l", (forward), (help "search a library when linking")),
94  (prefix_list_option "Wl,", (unpack_values), (help "pass options to linker"))
95 ]>;
96
97 // Alternative linker for C++
98 def llvm_gcc_cpp_linker : Tool<
99 [(in_language "object-code"),
100  (out_language "executable"),
101  (output_suffix "out"),
102  (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
103  (join),
104  (parameter_option "linker",
105                    (help "Choose linker (possible values: gcc, g++)")),
106  (prefix_list_option "L", (forward)),
107  (prefix_list_option "l", (forward)),
108  (prefix_list_option "Wl,", (unpack_values))
109 ]>;
110
111 // Language map
112
113 def LanguageMap : LanguageMap<
114     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
115      LangToSuffixes<"c", ["c"]>,
116      LangToSuffixes<"assembler", ["s"]>,
117      LangToSuffixes<"llvm-assembler", ["ll"]>,
118      LangToSuffixes<"llvm-bitcode", ["bc"]>,
119      LangToSuffixes<"object-code", ["o"]>,
120      LangToSuffixes<"executable", ["out"]>
121      ]>;