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