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