Add LLVMC2 tool definitions for Objective-C and Objective-C++.
[oota-llvm.git] / include / llvm / CompilerDriver / Tools.td
1 //===- Tools.td - Tools description for LLVMC2 -------------*- 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 llvmc2.
11 //
12 //===----------------------------------------------------------------------===//
13
14 def llvm_gcc_c : Tool<
15 [(in_language "c"),
16  (out_language "llvm-bitcode"),
17  (output_suffix "bc"),
18  (cmd_line (case
19             (switch_on "E"),
20               (case (not_empty "o"),
21                     "llvm-gcc -E -x c++ $INFILE -o $OUTFILE",
22                     (default),
23                     "llvm-gcc -E -x c++ $INFILE"),
24             (default),
25               "llvm-gcc -c -x c $INFILE -o $OUTFILE -emit-llvm")),
26  (switch_option "E", (stop_compilation),
27    (help "Stop after the preprocessing stage, do not run the compiler")),
28  (sink)
29 ]>;
30
31 def llvm_gcc_cpp : Tool<
32 [(in_language "c++"),
33  (out_language "llvm-bitcode"),
34  (output_suffix "bc"),
35  (cmd_line (case
36             (switch_on "E"),
37               (case (not_empty "o"),
38                     "llvm-g++ -E -x c++ $INFILE -o $OUTFILE",
39                     (default),
40                     "llvm-g++ -E -x c++ $INFILE"),
41             (default),
42               "llvm-g++ -c -x c++ $INFILE -o $OUTFILE -emit-llvm")),
43  (switch_option "E", (stop_compilation)),
44  (sink)
45 ]>;
46
47 def llvm_gcc_m : Tool<
48 [(in_language "objective-c"),
49  (out_language "llvm-bitcode"),
50  (output_suffix "bc"),
51  (cmd_line (case
52             (switch_on "E"),
53               (case (not_empty "o"),
54                     "llvm-gcc -E -x objective-c $INFILE -o $OUTFILE",
55                     (default),
56                     "llvm-gcc -E -x objective-c $INFILE"),
57             (default),
58               "llvm-gcc -c -x objective-c $INFILE -o $OUTFILE -emit-llvm")),
59  (switch_option "E", (stop_compilation)),
60  (sink)
61 ]>;
62
63 def llvm_gcc_mxx : Tool<
64 [(in_language "objective-c++"),
65  (out_language "llvm-bitcode"),
66  (output_suffix "bc"),
67  (cmd_line (case
68             (switch_on "E"),
69               (case (not_empty "o"),
70                     "llvm-gcc -E -x objective-c++ $INFILE -o $OUTFILE",
71                     (default),
72                     "llvm-gcc -E -x objective-c++ $INFILE"),
73             (default),
74               "llvm-gcc -c -x objective-c++ $INFILE -o $OUTFILE -emit-llvm")),
75  (switch_option "E", (stop_compilation)),
76  (sink)
77 ]>;
78
79 def opt : Tool<
80 [(in_language "llvm-bitcode"),
81  (out_language "llvm-bitcode"),
82  (switch_option "opt", (help "Enable opt")),
83  (output_suffix "bc"),
84  (cmd_line "opt -f $INFILE -o $OUTFILE")
85 ]>;
86
87 def llvm_as : Tool<
88 [(in_language "llvm-assembler"),
89  (out_language "llvm-bitcode"),
90  (output_suffix "bc"),
91  (cmd_line "llvm-as $INFILE -o $OUTFILE")
92 ]>;
93
94 def llc : Tool<
95 [(in_language "llvm-bitcode"),
96  (out_language "assembler"),
97  (output_suffix "s"),
98  (switch_option "S", (stop_compilation),
99                 (help "Stop after compilation, do not assemble")),
100  (cmd_line "llc -f $INFILE -o $OUTFILE")
101 ]>;
102
103 def llvm_gcc_assembler : Tool<
104 [(in_language "assembler"),
105  (out_language "object-code"),
106  (output_suffix "o"),
107  (cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
108  (switch_option "c", (stop_compilation),
109                 (help "Compile and assemble, but do not link")),
110  (prefix_list_option "Wa,", (unpack_values), (help "Pass options to assembler"))
111 ]>;
112
113 // Default linker
114 def llvm_gcc_linker : Tool<
115 [(in_language "object-code"),
116  (out_language "executable"),
117  (output_suffix "out"),
118  (cmd_line "llvm-gcc $INFILE -o $OUTFILE"),
119  (join),
120  (prefix_list_option "L", (forward), (help "Add a directory to link path")),
121  (prefix_list_option "l", (forward), (help "Search a library when linking")),
122  (prefix_list_option "Wl,", (unpack_values), (help "Pass options to linker"))
123 ]>;
124
125 // Alternative linker for C++
126 def llvm_gcc_cpp_linker : Tool<
127 [(in_language "object-code"),
128  (out_language "executable"),
129  (output_suffix "out"),
130  (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
131  (join),
132  (parameter_option "linker",
133                    (help "Choose linker (possible values: gcc, g++)")),
134  (prefix_list_option "L", (forward)),
135  (prefix_list_option "l", (forward)),
136  (prefix_list_option "Wl,", (unpack_values))
137 ]>;
138
139 // Language map
140
141 def LanguageMap : LanguageMap<
142     [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
143      LangToSuffixes<"c", ["c"]>,
144      LangToSuffixes<"objective-c++", ["mm"]>,
145      LangToSuffixes<"objective-c", ["m"]>,
146      LangToSuffixes<"assembler", ["s"]>,
147      LangToSuffixes<"llvm-assembler", ["ll"]>,
148      LangToSuffixes<"llvm-bitcode", ["bc"]>,
149      LangToSuffixes<"object-code", ["o"]>,
150      LangToSuffixes<"executable", ["out"]>
151      ]>;