blob: 8a871ad3ff6002ec14a6533a5f7ef9376d461baa [file] [log] [blame]
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +00001//===- Base.td - LLVMC toolchain descriptions --------------*- tablegen -*-===//
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +00002//
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//
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000010// This file contains compilation graph description used by llvmc.
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +000011//
12//===----------------------------------------------------------------------===//
13
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000014// Options
15
16def OptList : OptionList<[
17 (switch_option "emit-llvm",
18 (help "Emit LLVM .ll files instead of native object files")),
19 (switch_option "E",
20 (help "Stop after the preprocessing stage, do not run the compiler")),
21 (switch_option "fsyntax-only",
22 (help "Stop after checking the input for syntax errors")),
23 (switch_option "opt",
24 (help "Enable opt")),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000025 (switch_option "O0",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000026 (help "Turn off optimization"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000027 (switch_option "O1",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000028 (help "Optimization level 1"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000029 (switch_option "O2",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000030 (help "Optimization level 2"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000031 (switch_option "O3",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000032 (help "Optimization level 3"), (zero_or_more)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000033 (switch_option "S",
34 (help "Stop after compilation, do not assemble")),
35 (switch_option "c",
36 (help "Compile and assemble, but do not link")),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +000037 (switch_option "m32",
38 (help "Generate code for a 32-bit environment"), (hidden)),
39 (switch_option "m64",
40 (help "Generate code for a 64-bit environment"), (hidden)),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +000041 (switch_option "fPIC",
42 (help "Relocation model: PIC"), (hidden)),
43 (switch_option "mdynamic-no-pic",
44 (help "Relocation model: dynamic-no-pic"), (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000045 (parameter_option "linker",
46 (help "Choose linker (possible values: gcc, g++)")),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000047 (parameter_option "mtune",
Mikhail Glushenkov02894132010-11-22 17:10:09 +000048 (help "Target a specific CPU type"), (forward_not_split)),
Mikhail Glushenkov325f69d2010-11-28 00:31:13 +000049 (parameter_list_option "march",
50 (help "Generate code for the specified machine type")),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000051 (parameter_option "mcpu",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000052 (help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)),
Mikhail Glushenkov73e78092010-12-15 01:22:10 +000053 (parameter_option "mabi",
54 (help "Generate code for the specified ABI"), (hidden)),
55 (parameter_option "mfloat-abi",
56 (help "Specifies which floating-point ABI to use"), (hidden)),
Mikhail Glushenkovb88c6f62010-02-13 22:37:00 +000057 (switch_option "mfix-and-continue",
58 (help "Needed by gdb to load .o files dynamically"), (hidden)),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000059 (parameter_option "MF",
60 (help "Specify a file to write dependencies to"), (hidden)),
Mikhail Glushenkovbc56d862010-01-02 08:27:10 +000061 (parameter_list_option "MT",
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000062 (help "Change the name of the rule emitted by dependency generation"),
63 (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000064 (parameter_list_option "include",
65 (help "Include the named file prior to preprocessing")),
Mikhail Glushenkov967edd02010-01-26 14:55:30 +000066 (parameter_list_option "iquote",
67 (help "Search dir only for files requested with #inlcude \"file\""),
68 (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000069 (prefix_list_option "I",
70 (help "Add a directory to include path")),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000071 (prefix_list_option "D",
72 (help "Define a macro")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000073 (parameter_list_option "Xpreprocessor", (hidden),
74 (help "Pass options to preprocessor")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000075 (prefix_list_option "Wa,", (comma_separated),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000076 (help "Pass options to assembler")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000077 (parameter_list_option "Xassembler", (hidden),
78 (help "Pass options to assembler")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000079 (prefix_list_option "Wllc,", (comma_separated),
Mikhail Glushenkov46801022009-03-31 18:33:54 +000080 (help "Pass options to llc")),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000081 (prefix_list_option "Wl,",
Mikhail Glushenkovba71d672008-12-11 22:19:14 +000082 (help "Pass options to linker")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000083 (parameter_list_option "Xlinker", (hidden),
84 (help "Pass options to linker")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000085 (prefix_list_option "Wo,", (comma_separated),
Mikhail Glushenkov84612022009-12-07 17:03:21 +000086 (help "Pass options to opt")),
87 (prefix_list_option "m",
88 (help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +000089 (hidden))
90]>;
91
92def LinkerOptList : OptionList<[
93 (prefix_list_option "L",
94 (help "Add a directory to link path")),
95 (prefix_list_option "l",
96 (help "Search a library when linking")),
97 (parameter_option "filelist", (hidden),
98 (help "Link the files listed in file")),
99 (switch_option "nostartfiles",
100 (help "Do not use the standard system startup files when linking"),
101 (hidden)),
102 (switch_option "nodefaultlibs",
103 (help "Do not use the standard system libraries when linking"), (hidden)),
104 (switch_option "nostdlib",
105 (help
106 "Do not use the standard system startup files or libraries when linking"),
107 (hidden)),
108 (switch_option "pie",
109 (help "Produce a position independent executable"), (hidden)),
110 (switch_option "rdynamic",
111 (help "Add all symbols to the dynamic export table"), (hidden)),
112 (switch_option "s",
113 (help "Strip all symbols"), (hidden)),
114 (switch_option "static",
115 (help "Do not link against shared libraries"), (hidden)),
116 (switch_option "static-libgcc",
117 (help "Use static libgcc"), (hidden)),
118 (switch_option "shared",
119 (help "Create a DLL instead of the regular executable")),
120 (switch_option "shared-libgcc",
121 (help "Use shared libgcc"), (hidden)),
122 (parameter_option "T",
123 (help "Read linker script"), (hidden)),
124 (parameter_option "u",
125 (help "Start with undefined reference to SYMBOL"), (hidden)),
126 (switch_option "pthread",
127 (help "Enable threads")),
128
129 // TODO: Add a conditional compilation mechanism to make Darwin-only options
130 // like '-arch' really Darwin-only.
131 (parameter_option "arch",
132 (help "Compile for the specified target architecture"), (hidden)),
133 (prefix_list_option "F",
134 (help "Add a directory to framework search path")),
135 (parameter_list_option "framework",
136 (help "Specifies a framework to link against")),
137 (parameter_list_option "weak_framework",
138 (help "Specifies a framework to weakly link against"), (hidden)),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000139 (switch_option "dynamiclib", (hidden),
140 (help "Produce a dynamic library")),
141 (switch_option "prebind", (hidden),
142 (help "Prebind all undefined symbols")),
143 (switch_option "dead_strip", (hidden),
144 (help "Remove unreachable blocks of code")),
145 (switch_option "single_module", (hidden),
146 (help "Build the library so it contains only one module")),
Mikhail Glushenkov9f2a0802010-02-23 09:04:18 +0000147 (parameter_option "install_name", (hidden),
148 (help "File name the library will be installed in")),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000149 (parameter_option "compatibility_version", (hidden),
150 (help "Compatibility version number")),
151 (parameter_option "current_version", (hidden),
152 (help "Current version number"))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000153]>;
154
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000155// Option preprocessor.
156
157def Preprocess : OptionPreprocessor<
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000158(case (not (any_switch_on "O0", "O1", "O2", "O3")),
Mikhail Glushenkov994dbe02009-12-17 07:49:16 +0000159 (set_option "O2"),
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000160 (and (switch_on "O3"), (any_switch_on "O0", "O1", "O2")),
161 (unset_option "O0", "O1", "O2"),
162 (and (switch_on "O2"), (any_switch_on "O0", "O1")),
163 (unset_option "O0", "O1"),
164 (switch_on "O1", "O0"),
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000165 (unset_option "O0"))
166>;
167
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000168// Tools
169
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000170class llvm_gcc_based <string cmd, string in_lang, string E_ext, dag out_lang,
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000171 string out_ext> : Tool<
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000172[(in_language in_lang),
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000173 out_lang,
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000174 (output_suffix out_ext),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000175 (command cmd),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000176 (actions
177 (case
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000178 (and (not_empty "o"),
179 (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
Mikhail Glushenkovad981bf2009-09-28 01:16:42 +0000180 (error "cannot specify -o with -c or -S with multiple files"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000181 (switch_on "E"),
182 [(forward "E"), (stop_compilation), (output_suffix E_ext)],
183 (and (switch_on "E"), (empty "o")), (no_out_file),
Mikhail Glushenkov37249452010-09-22 09:00:41 +0000184
185 // ('-emit-llvm') && !('opt') -> stop compilation
186 (and (switch_on "emit-llvm"), (not (switch_on "opt"))),
187 (stop_compilation),
188 // ('-S' && '-emit-llvm') && !('opt') -> output .ll
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000189 (and (switch_on "emit-llvm", "S"), (not (switch_on "opt"))),
Mikhail Glushenkov37249452010-09-22 09:00:41 +0000190 [(forward "S"), (output_suffix "ll")],
191 // Ususally just output .bc
192 (not (switch_on "fsyntax-only")),
193 [(append_cmd "-c"), (append_cmd "-emit-llvm")],
194
195 // -fsyntax-only
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000196 (switch_on "fsyntax-only"), [(forward "fsyntax-only"),
197 (no_out_file), (stop_compilation)],
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000198
199 // Forwards
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000200 (not_empty "Xpreprocessor"), (forward "Xpreprocessor"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000201 (not_empty "include"), (forward "include"),
Mikhail Glushenkov967edd02010-01-26 14:55:30 +0000202 (not_empty "iquote"), (forward "iquote"),
Mikhail Glushenkov97955002009-12-01 06:51:30 +0000203 (not_empty "save-temps"), (append_cmd "-save-temps"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000204 (not_empty "I"), (forward "I"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000205 (not_empty "F"), (forward "F"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000206 (not_empty "D"), (forward "D"),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000207 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000208 (not_empty "march"), (forward "march"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000209 (not_empty "mcpu"), (forward "mcpu"),
Mikhail Glushenkov02894132010-11-22 17:10:09 +0000210 (not_empty "mtune"), (forward "mtune"),
Mikhail Glushenkov73e78092010-12-15 01:22:10 +0000211 (not_empty "mabi"), (forward "mabi"),
212 (not_empty "mfloat-abi"), (forward "mfloat-abi"),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000213 (not_empty "m"), (forward "m"),
Mikhail Glushenkovb88c6f62010-02-13 22:37:00 +0000214 (switch_on "mfix-and-continue"), (forward "mfix-and-continue"),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +0000215 (switch_on "m32"), (forward "m32"),
216 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkov364cf752010-01-02 08:27:23 +0000217 (switch_on "O0"), (forward "O0"),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000218 (switch_on "O1"), (forward "O1"),
219 (switch_on "O2"), (forward "O2"),
220 (switch_on "O3"), (forward "O3"),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +0000221 (switch_on "fPIC"), (forward "fPIC"),
222 (switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000223 (not_empty "MF"), (forward "MF"),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +0000224 (not_empty "MT"), (forward "MT"))),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000225 (sink)
226]>;
227
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000228class llvm_gcc_comp_based <string cmd, string in_lang, string E_ext>
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000229: llvm_gcc_based<cmd, in_lang, E_ext,
230 (out_language "llvm-bitcode", "object-code"), "bc">;
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000231
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000232class llvm_gcc_pch_based <string cmd, string in_lang, string E_ext>
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000233: llvm_gcc_based<cmd, in_lang, E_ext,
234 (out_language "precompiled-header"), "gch">;
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000235
236def llvm_gcc_c : llvm_gcc_comp_based
237 <"@LLVMGCCCOMMAND@ -x c", "c", "i">;
238def llvm_gcc_cpp : llvm_gcc_comp_based
239 <"@LLVMGXXCOMMAND@ -x c++", "c++", "i">;
240def llvm_gcc_m : llvm_gcc_comp_based
241 <"@LLVMGCCCOMMAND@ -x objective-c", "objective-c", "mi">;
242def llvm_gcc_mxx : llvm_gcc_comp_based
243 <"@LLVMGCCCOMMAND@ -x objective-c++", "objective-c++", "mi">;
244
245def llvm_gcc_c_pch : llvm_gcc_pch_based
246 <"@LLVMGCCCOMMAND@ -x c-header", "c-header", "i">;
247def llvm_gcc_cpp_pch : llvm_gcc_pch_based
248 <"@LLVMGXXCOMMAND@ -x c++-header", "c++-header", "i">;
249def llvm_gcc_m_pch : llvm_gcc_pch_based
250 <"@LLVMGCCCOMMAND@ -x objective-c-header", "objective-c-header", "mi">;
251def llvm_gcc_mxx_pch : llvm_gcc_pch_based
252 <"@LLVMGCCCOMMAND@ -x objective-c++-header", "objective-c++-header", "mi">;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000253
254def opt : Tool<
255[(in_language "llvm-bitcode"),
256 (out_language "llvm-bitcode"),
Mikhail Glushenkovc9aa78d2010-09-22 09:00:35 +0000257 (output_suffix "opt.bc"),
Mikhail Glushenkov37249452010-09-22 09:00:41 +0000258 (actions (case (switch_on "emit-llvm"), (stop_compilation),
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000259 (switch_on "emit-llvm", "S"),
Mikhail Glushenkov37249452010-09-22 09:00:41 +0000260 [(append_cmd "-S"), (output_suffix "ll")],
261 (not_empty "Wo,"), (forward_value "Wo,"),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000262 (switch_on "O1"), (forward "O1"),
263 (switch_on "O2"), (forward "O2"),
264 (switch_on "O3"), (forward "O3"))),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000265 (command "opt -f")
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000266]>;
267
268def llvm_as : Tool<
269[(in_language "llvm-assembler"),
270 (out_language "llvm-bitcode"),
271 (output_suffix "bc"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000272 (command "llvm-as"),
Mikhail Glushenkov3ab68892009-10-09 05:45:01 +0000273 (actions (case (switch_on "emit-llvm"), (stop_compilation)))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000274]>;
275
276def llvm_gcc_assembler : Tool<
277[(in_language "assembler"),
278 (out_language "object-code"),
279 (output_suffix "o"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000280 (command "@LLVMGCCCOMMAND@ -c -x assembler"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000281 (actions (case
282 (switch_on "c"), (stop_compilation),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000283 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000284 (not_empty "Xassembler"), (forward "Xassembler"),
Mikhail Glushenkovbebea872010-12-15 01:22:05 +0000285 (not_empty "march"), (forward "march"),
286 (not_empty "mcpu"), (forward "mcpu"),
287 (not_empty "mtune"), (forward "mtune"),
Mikhail Glushenkov73e78092010-12-15 01:22:10 +0000288 (not_empty "mabi"), (forward "mabi"),
289 (not_empty "mfloat-abi"), (forward "mfloat-abi"),
Mikhail Glushenkov62d1da02010-03-31 23:51:55 +0000290 (switch_on "m32"), (forward "m32"),
291 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000292 (not_empty "Wa,"), (forward "Wa,")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000293]>;
294
295def llc : Tool<
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000296[(in_language "llvm-bitcode", "llvm-assembler"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000297 (out_language "assembler"),
298 (output_suffix "s"),
Dan Gohman281ead42010-04-29 18:46:52 +0000299 (command "llc"),
Mikhail Glushenkov46801022009-03-31 18:33:54 +0000300 (actions (case
301 (switch_on "S"), (stop_compilation),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000302 (switch_on "O0"), (forward "O0"),
303 (switch_on "O1"), (forward "O1"),
304 (switch_on "O2"), (forward "O2"),
305 (switch_on "O3"), (forward "O3"),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +0000306 (switch_on "fPIC"), (append_cmd "-relocation-model=pic"),
307 (switch_on "mdynamic-no-pic"),
308 (append_cmd "-relocation-model=dynamic-no-pic"),
Mikhail Glushenkov325f69d2010-11-28 00:31:13 +0000309 (not_empty "march"), (forward_transformed_value
310 "march", "ConvertMArchToMAttr"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000311 (not_empty "mcpu"), (forward "mcpu"),
Mikhail Glushenkov02894132010-11-22 17:10:09 +0000312 (and (not_empty "mtune"), (empty "mcpu")),
313 (forward_as "mtune", "-mcpu"),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000314 (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +0000315 (not_empty "Wllc,"), (forward_value "Wllc,")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000316]>;
317
318// Base class for linkers
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000319class llvm_gcc_based_linker <string cmd, dag on_empty> : Tool<
Mikhail Glushenkov17ef94f2010-10-23 07:32:46 +0000320[(in_language "object-code", "static-library", "dynamic-library"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000321 (out_language "executable"),
322 (output_suffix "out"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000323 (command cmd),
Mikhail Glushenkov002dd182010-07-01 01:00:32 +0000324 (works_on_empty (case (and (not_empty "filelist"), on_empty), true,
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +0000325 (default), false)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000326 (join),
327 (actions (case
328 (switch_on "pthread"), (append_cmd "-lpthread"),
329 (not_empty "L"), (forward "L"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000330 (not_empty "F"), (forward "F"),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000331 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000332 (not_empty "framework"), (forward "framework"),
333 (not_empty "weak_framework"), (forward "weak_framework"),
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +0000334 (not_empty "filelist"), (forward "filelist"),
Mikhail Glushenkovbebea872010-12-15 01:22:05 +0000335 (not_empty "march"), (forward "march"),
336 (not_empty "mcpu"), (forward "mcpu"),
337 (not_empty "mtune"), (forward "mtune"),
Mikhail Glushenkov73e78092010-12-15 01:22:10 +0000338 (not_empty "mabi"), (forward "mabi"),
339 (not_empty "mfloat-abi"), (forward "mfloat-abi"),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +0000340 (switch_on "m32"), (forward "m32"),
341 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000342 (not_empty "l"), (forward "l"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000343 (not_empty "Xlinker"), (forward "Xlinker"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000344 (not_empty "Wl,"), (forward "Wl,"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000345 (switch_on "nostartfiles"), (forward "nostartfiles"),
346 (switch_on "nodefaultlibs"), (forward "nodefaultlibs"),
347 (switch_on "nostdlib"), (forward "nostdlib"),
348 (switch_on "pie"), (forward "pie"),
349 (switch_on "rdynamic"), (forward "rdynamic"),
350 (switch_on "s"), (forward "s"),
351 (switch_on "static"), (forward "static"),
352 (switch_on "static-libgcc"), (forward "static-libgcc"),
Mikhail Glushenkovcbf1aa92010-04-03 02:00:03 +0000353 (switch_on "shared"), (forward "shared"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000354 (switch_on "shared-libgcc"), (forward "shared-libgcc"),
355 (not_empty "T"), (forward "T"),
356 (not_empty "u"), (forward "u"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000357 (switch_on "dynamiclib"), (forward "dynamiclib"),
358 (switch_on "prebind"), (forward "prebind"),
359 (switch_on "dead_strip"), (forward "dead_strip"),
360 (switch_on "single_module"), (forward "single_module"),
361 (not_empty "compatibility_version"),
362 (forward "compatibility_version"),
Mikhail Glushenkov9f2a0802010-02-23 09:04:18 +0000363 (not_empty "current_version"), (forward "current_version"),
364 (not_empty "install_name"), (forward "install_name")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000365]>;
366
367// Default linker
Mikhail Glushenkov002dd182010-07-01 01:00:32 +0000368def llvm_gcc_linker : llvm_gcc_based_linker<"@LLVMGCCCOMMAND@",
369 (not (or (parameter_equals "linker", "g++"),
370 (parameter_equals "linker", "c++")))>;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000371// Alternative linker for C++
Mikhail Glushenkov002dd182010-07-01 01:00:32 +0000372def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@",
373 (or (parameter_equals "linker", "g++"),
374 (parameter_equals "linker", "c++"))>;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000375
376// Language map
377
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000378def LanguageMap : LanguageMap<[
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000379 (lang_to_suffixes "precompiled-header", ["gch", "pch"]),
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000380 (lang_to_suffixes "c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]),
381 (lang_to_suffixes "c++-header", "hpp"),
382 (lang_to_suffixes "c", "c"),
383 (lang_to_suffixes "c-header", "h"),
384 (lang_to_suffixes "c-cpp-output", "i"),
385 (lang_to_suffixes "objective-c-cpp-output", "mi"),
386 (lang_to_suffixes "objective-c++", "mm"),
387 (lang_to_suffixes "objective-c++-header", "hmm"),
388 (lang_to_suffixes "objective-c", "m"),
389 (lang_to_suffixes "objective-c-header", "hm"),
390 (lang_to_suffixes "assembler", "s"),
391 (lang_to_suffixes "assembler-with-cpp", "S"),
392 (lang_to_suffixes "llvm-assembler", "ll"),
393 (lang_to_suffixes "llvm-bitcode", "bc"),
394 (lang_to_suffixes "object-code", ["o", "*empty*"]),
395 (lang_to_suffixes "static-library", ["a", "lib"]),
Mikhail Glushenkov743547f2010-09-02 14:06:21 +0000396 (lang_to_suffixes "dynamic-library", ["so", "dylib", "dll"]),
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000397 (lang_to_suffixes "executable", "out")
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000398]>;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000399
400// Compilation graph
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +0000401
Mikhail Glushenkov0d08db02008-05-06 16:35:25 +0000402def CompilationGraph : CompilationGraph<[
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000403 (edge "root", "llvm_gcc_c"),
404 (edge "root", "llvm_gcc_assembler"),
405 (edge "root", "llvm_gcc_cpp"),
406 (edge "root", "llvm_gcc_m"),
407 (edge "root", "llvm_gcc_mxx"),
408 (edge "root", "llc"),
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000409
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000410 (edge "root", "llvm_gcc_c_pch"),
411 (edge "root", "llvm_gcc_cpp_pch"),
412 (edge "root", "llvm_gcc_m_pch"),
413 (edge "root", "llvm_gcc_mxx_pch"),
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000414
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000415 (edge "llvm_gcc_c", "llc"),
416 (edge "llvm_gcc_cpp", "llc"),
417 (edge "llvm_gcc_m", "llc"),
418 (edge "llvm_gcc_mxx", "llc"),
419 (edge "llvm_as", "llc"),
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000420
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000421 (optional_edge "root", "llvm_as",
422 (case (switch_on "emit-llvm"), (inc_weight))),
423 (optional_edge "llvm_gcc_c", "opt",
424 (case (switch_on "opt"), (inc_weight))),
425 (optional_edge "llvm_gcc_cpp", "opt",
426 (case (switch_on "opt"), (inc_weight))),
427 (optional_edge "llvm_gcc_m", "opt",
428 (case (switch_on "opt"), (inc_weight))),
429 (optional_edge "llvm_gcc_mxx", "opt",
430 (case (switch_on "opt"), (inc_weight))),
431 (optional_edge "llvm_as", "opt",
432 (case (switch_on "opt"), (inc_weight))),
433 (edge "opt", "llc"),
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000434
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000435 (edge "llc", "llvm_gcc_assembler"),
436 (edge "llvm_gcc_assembler", "llvm_gcc_linker"),
437 (optional_edge "llvm_gcc_assembler", "llvm_gcc_cpp_linker",
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000438 (case
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000439 (or (input_languages_contain "c++"),
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000440 (input_languages_contain "objective-c++")),
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000441 (inc_weight),
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000442 (or (parameter_equals "linker", "g++"),
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000443 (parameter_equals "linker", "c++")), (inc_weight))),
Mikhail Glushenkov35a85e82008-05-06 18:10:20 +0000444
Mikhail Glushenkov978d4982008-05-06 18:13:00 +0000445
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000446 (edge "root", "llvm_gcc_linker"),
447 (optional_edge "root", "llvm_gcc_cpp_linker",
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000448 (case
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000449 (or (input_languages_contain "c++"),
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000450 (input_languages_contain "objective-c++")),
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000451 (inc_weight),
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000452 (or (parameter_equals "linker", "g++"),
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000453 (parameter_equals "linker", "c++")), (inc_weight)))
454]>;