Make it possible to use the generalised 'case' construct in the cmd_line 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 -emit-llvm",
31             (default),
32               "llvm-g++ -c -x c $INFILE -o $OUTFILE -emit-llvm")),
33  // TOFIX: Preprocessed files currently have suffix ".bc".
34  (switch_option "E", (stop_compilation),
35     // Make this possible:
36     // (output_suffix "i"),
37    (help "Stop after the preprocessing stage, do not run the compiler")),
38  (sink)
39 ]>;
40
41 def llvm_gcc_cpp : Tool<
42 [(in_language "c++"),
43  (out_language "llvm-bitcode"),
44  (output_suffix "bc"),
45  (cmd_line (case
46             (switch_on "E"),
47               "llvm-g++ -E -x c++ $INFILE -o $OUTFILE -emit-llvm",
48             (default),
49               "llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm")),
50  (switch_option "E", (stop_compilation)),
51  (sink)
52 ]>;
53
54 def opt : Tool<
55 [(in_language "llvm-bitcode"),
56  (out_language "llvm-bitcode"),
57  (switch_option "opt", (help "Enable opt")),
58  (output_suffix "bc"),
59  (cmd_line "opt $INFILE -o $OUTFILE")
60 ]>;
61
62 def llvm_as : Tool<
63 [(in_language "llvm-assembler"),
64  (out_language "llvm-bitcode"),
65  (output_suffix "bc"),
66  (cmd_line "llvm-as $INFILE -o $OUTFILE")
67 ]>;
68
69 def llc : Tool<
70 [(in_language "llvm-bitcode"),
71  (out_language "assembler"),
72  (output_suffix "s"),
73  (switch_option "S", (stop_compilation),
74                 (help "Stop after compilation, do not assemble")),
75  (cmd_line "llc -f $INFILE -o $OUTFILE")
76 ]>;
77
78 def llvm_gcc_assembler : Tool<
79 [(in_language "assembler"),
80  (out_language "object-code"),
81  (output_suffix "o"),
82  (cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
83  (switch_option "c", (stop_compilation),
84                 (help "Compile and assemble, but do not link")),
85  (prefix_list_option "Wa,", (unpack_values), (help "pass options to assembler"))
86 ]>;
87
88 // Default linker
89 def llvm_gcc_linker : Tool<
90 [(in_language "object-code"),
91  (out_language "executable"),
92  (output_suffix "out"),
93  (cmd_line "llvm-gcc $INFILE -o $OUTFILE"),
94  (join),
95  (prefix_list_option "L", (forward), (help "add a directory to link path")),
96  (prefix_list_option "l", (forward), (help "search a library when linking")),
97  (prefix_list_option "Wl,", (unpack_values), (help "pass options to linker"))
98 ]>;
99
100 // Alternative linker for C++
101 def llvm_gcc_cpp_linker : Tool<
102 [(in_language "object-code"),
103  (out_language "executable"),
104  (output_suffix "out"),
105  (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
106  (join),
107  (parameter_option "linker",
108                    (help "Choose linker (possible values: gcc, g++)")),
109  (prefix_list_option "L", (forward)),
110  (prefix_list_option "l", (forward)),
111  (prefix_list_option "Wl,", (unpack_values))
112 ]>;
113
114 // Language map
115
116 def LanguageMap : LanguageMap<
117     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
118      LangToSuffixes<"c", ["c"]>,
119      LangToSuffixes<"assembler", ["s"]>,
120      LangToSuffixes<"llvm-assembler", ["ll"]>,
121      LangToSuffixes<"llvm-bitcode", ["bc"]>,
122      LangToSuffixes<"object-code", ["o"]>,
123      LangToSuffixes<"executable", ["out"]>
124      ]>;