blob: a53ac9e65cc084b324ef448f3fd90e697b9d0c8c [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
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +000014
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000015// Options
16
17def OptList : OptionList<[
18 (switch_option "emit-llvm",
19 (help "Emit LLVM .ll files instead of native object files")),
20 (switch_option "E",
21 (help "Stop after the preprocessing stage, do not run the compiler")),
22 (switch_option "fsyntax-only",
23 (help "Stop after checking the input for syntax errors")),
24 (switch_option "opt",
25 (help "Enable opt")),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000026 (switch_option "O0",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000027 (help "Turn off optimization"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000028 (switch_option "O1",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000029 (help "Optimization level 1"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000030 (switch_option "O2",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000031 (help "Optimization level 2"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000032 (switch_option "O3",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000033 (help "Optimization level 3"), (zero_or_more)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000034 (switch_option "S",
35 (help "Stop after compilation, do not assemble")),
36 (switch_option "c",
37 (help "Compile and assemble, but do not link")),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +000038 (switch_option "m32",
39 (help "Generate code for a 32-bit environment"), (hidden)),
40 (switch_option "m64",
41 (help "Generate code for a 64-bit environment"), (hidden)),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +000042 (switch_option "fPIC",
43 (help "Relocation model: PIC"), (hidden)),
44 (switch_option "mdynamic-no-pic",
45 (help "Relocation model: dynamic-no-pic"), (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000046 (parameter_option "linker",
47 (help "Choose linker (possible values: gcc, g++)")),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000048 (parameter_option "mtune",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000049 (help "Target a specific CPU type"), (hidden), (forward_not_split)),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000050 (parameter_option "march",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000051 (help "A synonym for -mtune"), (hidden), (forward_not_split)),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000052 (parameter_option "mcpu",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000053 (help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)),
Mikhail Glushenkovb88c6f62010-02-13 22:37:00 +000054 (switch_option "mfix-and-continue",
55 (help "Needed by gdb to load .o files dynamically"), (hidden)),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000056 (parameter_option "MF",
57 (help "Specify a file to write dependencies to"), (hidden)),
Mikhail Glushenkovbc56d862010-01-02 08:27:10 +000058 (parameter_list_option "MT",
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000059 (help "Change the name of the rule emitted by dependency generation"),
60 (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000061 (parameter_list_option "include",
62 (help "Include the named file prior to preprocessing")),
Mikhail Glushenkov967edd02010-01-26 14:55:30 +000063 (parameter_list_option "iquote",
64 (help "Search dir only for files requested with #inlcude \"file\""),
65 (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000066 (prefix_list_option "I",
67 (help "Add a directory to include path")),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000068 (prefix_list_option "D",
69 (help "Define a macro")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000070 (parameter_list_option "Xpreprocessor", (hidden),
71 (help "Pass options to preprocessor")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000072 (prefix_list_option "Wa,", (comma_separated),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000073 (help "Pass options to assembler")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000074 (parameter_list_option "Xassembler", (hidden),
75 (help "Pass options to assembler")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000076 (prefix_list_option "Wllc,", (comma_separated),
Mikhail Glushenkov46801022009-03-31 18:33:54 +000077 (help "Pass options to llc")),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000078 (prefix_list_option "Wl,",
Mikhail Glushenkovba71d672008-12-11 22:19:14 +000079 (help "Pass options to linker")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000080 (parameter_list_option "Xlinker", (hidden),
81 (help "Pass options to linker")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000082 (prefix_list_option "Wo,", (comma_separated),
Mikhail Glushenkov84612022009-12-07 17:03:21 +000083 (help "Pass options to opt")),
84 (prefix_list_option "m",
85 (help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +000086 (hidden))
87]>;
88
89def LinkerOptList : OptionList<[
90 (prefix_list_option "L",
91 (help "Add a directory to link path")),
92 (prefix_list_option "l",
93 (help "Search a library when linking")),
94 (parameter_option "filelist", (hidden),
95 (help "Link the files listed in file")),
96 (switch_option "nostartfiles",
97 (help "Do not use the standard system startup files when linking"),
98 (hidden)),
99 (switch_option "nodefaultlibs",
100 (help "Do not use the standard system libraries when linking"), (hidden)),
101 (switch_option "nostdlib",
102 (help
103 "Do not use the standard system startup files or libraries when linking"),
104 (hidden)),
105 (switch_option "pie",
106 (help "Produce a position independent executable"), (hidden)),
107 (switch_option "rdynamic",
108 (help "Add all symbols to the dynamic export table"), (hidden)),
109 (switch_option "s",
110 (help "Strip all symbols"), (hidden)),
111 (switch_option "static",
112 (help "Do not link against shared libraries"), (hidden)),
113 (switch_option "static-libgcc",
114 (help "Use static libgcc"), (hidden)),
115 (switch_option "shared",
116 (help "Create a DLL instead of the regular executable")),
117 (switch_option "shared-libgcc",
118 (help "Use shared libgcc"), (hidden)),
119 (parameter_option "T",
120 (help "Read linker script"), (hidden)),
121 (parameter_option "u",
122 (help "Start with undefined reference to SYMBOL"), (hidden)),
123 (switch_option "pthread",
124 (help "Enable threads")),
125
126 // TODO: Add a conditional compilation mechanism to make Darwin-only options
127 // like '-arch' really Darwin-only.
128 (parameter_option "arch",
129 (help "Compile for the specified target architecture"), (hidden)),
130 (prefix_list_option "F",
131 (help "Add a directory to framework search path")),
132 (parameter_list_option "framework",
133 (help "Specifies a framework to link against")),
134 (parameter_list_option "weak_framework",
135 (help "Specifies a framework to weakly link against"), (hidden)),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000136 (switch_option "dynamiclib", (hidden),
137 (help "Produce a dynamic library")),
138 (switch_option "prebind", (hidden),
139 (help "Prebind all undefined symbols")),
140 (switch_option "dead_strip", (hidden),
141 (help "Remove unreachable blocks of code")),
142 (switch_option "single_module", (hidden),
143 (help "Build the library so it contains only one module")),
Mikhail Glushenkov9f2a0802010-02-23 09:04:18 +0000144 (parameter_option "install_name", (hidden),
145 (help "File name the library will be installed in")),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000146 (parameter_option "compatibility_version", (hidden),
147 (help "Compatibility version number")),
148 (parameter_option "current_version", (hidden),
149 (help "Current version number"))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000150]>;
151
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000152// Option preprocessor.
153
154def Preprocess : OptionPreprocessor<
Mikhail Glushenkov994dbe02009-12-17 07:49:16 +0000155(case (not (any_switch_on ["O0", "O1", "O2", "O3"])),
156 (set_option "O2"),
157 (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])),
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000158 (unset_option ["O0", "O1", "O2"]),
159 (and (switch_on "O2"), (any_switch_on ["O0", "O1"])),
160 (unset_option ["O0", "O1"]),
Mikhail Glushenkov3a481e32010-01-01 03:50:51 +0000161 (switch_on ["O1", "O0"]),
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000162 (unset_option "O0"))
163>;
164
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000165// Tools
166
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000167class llvm_gcc_based <string cmd, string in_lang,
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000168 string E_ext, list<string> out_lang,
169 string out_ext> : Tool<
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000170[(in_language in_lang),
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000171 (out_language out_lang),
172 (output_suffix out_ext),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000173 (command cmd),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000174 (actions
175 (case
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000176 (and (not_empty "o"),
177 (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
Mikhail Glushenkovad981bf2009-09-28 01:16:42 +0000178 (error "cannot specify -o with -c or -S with multiple files"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000179 (switch_on "E"),
180 [(forward "E"), (stop_compilation), (output_suffix E_ext)],
181 (and (switch_on "E"), (empty "o")), (no_out_file),
Mikhail Glushenkov37249452010-09-22 09:00:41 +0000182
183 // ('-emit-llvm') && !('opt') -> stop compilation
184 (and (switch_on "emit-llvm"), (not (switch_on "opt"))),
185 (stop_compilation),
186 // ('-S' && '-emit-llvm') && !('opt') -> output .ll
187 (and (switch_on ["emit-llvm", "S"]), (not (switch_on "opt"))),
188 [(forward "S"), (output_suffix "ll")],
189 // Ususally just output .bc
190 (not (switch_on "fsyntax-only")),
191 [(append_cmd "-c"), (append_cmd "-emit-llvm")],
192
193 // -fsyntax-only
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000194 (switch_on "fsyntax-only"), [(forward "fsyntax-only"),
195 (no_out_file), (stop_compilation)],
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000196
197 // Forwards
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000198 (not_empty "Xpreprocessor"), (forward "Xpreprocessor"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000199 (not_empty "include"), (forward "include"),
Mikhail Glushenkov967edd02010-01-26 14:55:30 +0000200 (not_empty "iquote"), (forward "iquote"),
Mikhail Glushenkov97955002009-12-01 06:51:30 +0000201 (not_empty "save-temps"), (append_cmd "-save-temps"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000202 (not_empty "I"), (forward "I"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000203 (not_empty "F"), (forward "F"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000204 (not_empty "D"), (forward "D"),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000205 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000206 (not_empty "march"), (forward "march"),
207 (not_empty "mtune"), (forward "mtune"),
208 (not_empty "mcpu"), (forward "mcpu"),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000209 (not_empty "m"), (forward "m"),
Mikhail Glushenkovb88c6f62010-02-13 22:37:00 +0000210 (switch_on "mfix-and-continue"), (forward "mfix-and-continue"),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +0000211 (switch_on "m32"), (forward "m32"),
212 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkov364cf752010-01-02 08:27:23 +0000213 (switch_on "O0"), (forward "O0"),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000214 (switch_on "O1"), (forward "O1"),
215 (switch_on "O2"), (forward "O2"),
216 (switch_on "O3"), (forward "O3"),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +0000217 (switch_on "fPIC"), (forward "fPIC"),
218 (switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000219 (not_empty "MF"), (forward "MF"),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +0000220 (not_empty "MT"), (forward "MT"))),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000221 (sink)
222]>;
223
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000224class llvm_gcc_comp_based <string cmd, string in_lang, string E_ext>
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000225: llvm_gcc_based<cmd, in_lang, E_ext, ["llvm-bitcode", "object-code"], "bc">;
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000226
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000227class llvm_gcc_pch_based <string cmd, string in_lang, string E_ext>
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000228: llvm_gcc_based<cmd, in_lang, E_ext, ["precompiled-header"], "gch">;
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000229
230def llvm_gcc_c : llvm_gcc_comp_based
231 <"@LLVMGCCCOMMAND@ -x c", "c", "i">;
232def llvm_gcc_cpp : llvm_gcc_comp_based
233 <"@LLVMGXXCOMMAND@ -x c++", "c++", "i">;
234def llvm_gcc_m : llvm_gcc_comp_based
235 <"@LLVMGCCCOMMAND@ -x objective-c", "objective-c", "mi">;
236def llvm_gcc_mxx : llvm_gcc_comp_based
237 <"@LLVMGCCCOMMAND@ -x objective-c++", "objective-c++", "mi">;
238
239def llvm_gcc_c_pch : llvm_gcc_pch_based
240 <"@LLVMGCCCOMMAND@ -x c-header", "c-header", "i">;
241def llvm_gcc_cpp_pch : llvm_gcc_pch_based
242 <"@LLVMGXXCOMMAND@ -x c++-header", "c++-header", "i">;
243def llvm_gcc_m_pch : llvm_gcc_pch_based
244 <"@LLVMGCCCOMMAND@ -x objective-c-header", "objective-c-header", "mi">;
245def llvm_gcc_mxx_pch : llvm_gcc_pch_based
246 <"@LLVMGCCCOMMAND@ -x objective-c++-header", "objective-c++-header", "mi">;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000247
248def opt : Tool<
249[(in_language "llvm-bitcode"),
250 (out_language "llvm-bitcode"),
Mikhail Glushenkovc9aa78d2010-09-22 09:00:35 +0000251 (output_suffix "opt.bc"),
Mikhail Glushenkov37249452010-09-22 09:00:41 +0000252 (actions (case (switch_on "emit-llvm"), (stop_compilation),
253 (switch_on ["emit-llvm", "S"]),
254 [(append_cmd "-S"), (output_suffix "ll")],
255 (not_empty "Wo,"), (forward_value "Wo,"),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000256 (switch_on "O1"), (forward "O1"),
257 (switch_on "O2"), (forward "O2"),
258 (switch_on "O3"), (forward "O3"))),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000259 (command "opt -f")
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000260]>;
261
262def llvm_as : Tool<
263[(in_language "llvm-assembler"),
264 (out_language "llvm-bitcode"),
265 (output_suffix "bc"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000266 (command "llvm-as"),
Mikhail Glushenkov3ab68892009-10-09 05:45:01 +0000267 (actions (case (switch_on "emit-llvm"), (stop_compilation)))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000268]>;
269
270def llvm_gcc_assembler : Tool<
271[(in_language "assembler"),
272 (out_language "object-code"),
273 (output_suffix "o"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000274 (command "@LLVMGCCCOMMAND@ -c -x assembler"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000275 (actions (case
276 (switch_on "c"), (stop_compilation),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000277 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000278 (not_empty "Xassembler"), (forward "Xassembler"),
Mikhail Glushenkov62d1da02010-03-31 23:51:55 +0000279 (switch_on "m32"), (forward "m32"),
280 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000281 (not_empty "Wa,"), (forward "Wa,")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000282]>;
283
284def llc : Tool<
Mikhail Glushenkov3ab68892009-10-09 05:45:01 +0000285[(in_language ["llvm-bitcode", "llvm-assembler"]),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000286 (out_language "assembler"),
287 (output_suffix "s"),
Dan Gohman281ead42010-04-29 18:46:52 +0000288 (command "llc"),
Mikhail Glushenkov46801022009-03-31 18:33:54 +0000289 (actions (case
290 (switch_on "S"), (stop_compilation),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000291 (switch_on "O0"), (forward "O0"),
292 (switch_on "O1"), (forward "O1"),
293 (switch_on "O2"), (forward "O2"),
294 (switch_on "O3"), (forward "O3"),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +0000295 (switch_on "fPIC"), (append_cmd "-relocation-model=pic"),
296 (switch_on "mdynamic-no-pic"),
297 (append_cmd "-relocation-model=dynamic-no-pic"),
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000298 (not_empty "march"), (forward_as "march", "-mcpu"),
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +0000299 (not_empty "mtune"), (forward_as "mtune", "-mcpu"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000300 (not_empty "mcpu"), (forward "mcpu"),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000301 (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +0000302 (not_empty "Wllc,"), (forward_value "Wllc,")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000303]>;
304
305// Base class for linkers
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000306class llvm_gcc_based_linker <string cmd, dag on_empty> : Tool<
Mikhail Glushenkov743547f2010-09-02 14:06:21 +0000307[(in_language ["object-code", "static-library", "dynamic-library"]),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000308 (out_language "executable"),
309 (output_suffix "out"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000310 (command cmd),
Mikhail Glushenkov002dd182010-07-01 01:00:32 +0000311 (works_on_empty (case (and (not_empty "filelist"), on_empty), true,
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +0000312 (default), false)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000313 (join),
314 (actions (case
315 (switch_on "pthread"), (append_cmd "-lpthread"),
316 (not_empty "L"), (forward "L"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000317 (not_empty "F"), (forward "F"),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000318 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000319 (not_empty "framework"), (forward "framework"),
320 (not_empty "weak_framework"), (forward "weak_framework"),
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +0000321 (not_empty "filelist"), (forward "filelist"),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +0000322 (switch_on "m32"), (forward "m32"),
323 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000324 (not_empty "l"), (forward "l"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000325 (not_empty "Xlinker"), (forward "Xlinker"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000326 (not_empty "Wl,"), (forward "Wl,"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000327 (switch_on "nostartfiles"), (forward "nostartfiles"),
328 (switch_on "nodefaultlibs"), (forward "nodefaultlibs"),
329 (switch_on "nostdlib"), (forward "nostdlib"),
330 (switch_on "pie"), (forward "pie"),
331 (switch_on "rdynamic"), (forward "rdynamic"),
332 (switch_on "s"), (forward "s"),
333 (switch_on "static"), (forward "static"),
334 (switch_on "static-libgcc"), (forward "static-libgcc"),
Mikhail Glushenkovcbf1aa92010-04-03 02:00:03 +0000335 (switch_on "shared"), (forward "shared"),
Mikhail Glushenkovb4c7a122010-09-21 11:57:04 +0000336 (switch_on "shared-libgcc"), (forward "shared-libgcc"),
337 (not_empty "T"), (forward "T"),
338 (not_empty "u"), (forward "u"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000339 (switch_on "dynamiclib"), (forward "dynamiclib"),
340 (switch_on "prebind"), (forward "prebind"),
341 (switch_on "dead_strip"), (forward "dead_strip"),
342 (switch_on "single_module"), (forward "single_module"),
343 (not_empty "compatibility_version"),
344 (forward "compatibility_version"),
Mikhail Glushenkov9f2a0802010-02-23 09:04:18 +0000345 (not_empty "current_version"), (forward "current_version"),
346 (not_empty "install_name"), (forward "install_name")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000347]>;
348
349// Default linker
Mikhail Glushenkov002dd182010-07-01 01:00:32 +0000350def llvm_gcc_linker : llvm_gcc_based_linker<"@LLVMGCCCOMMAND@",
351 (not (or (parameter_equals "linker", "g++"),
352 (parameter_equals "linker", "c++")))>;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000353// Alternative linker for C++
Mikhail Glushenkov002dd182010-07-01 01:00:32 +0000354def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@",
355 (or (parameter_equals "linker", "g++"),
356 (parameter_equals "linker", "c++"))>;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000357
358// Language map
359
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000360def LanguageMap : LanguageMap<[
Mikhail Glushenkov47e87db2010-09-21 14:59:47 +0000361 (lang_to_suffixes "precompiled-header", ["gch", "pch"]),
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000362 (lang_to_suffixes "c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]),
363 (lang_to_suffixes "c++-header", "hpp"),
364 (lang_to_suffixes "c", "c"),
365 (lang_to_suffixes "c-header", "h"),
366 (lang_to_suffixes "c-cpp-output", "i"),
367 (lang_to_suffixes "objective-c-cpp-output", "mi"),
368 (lang_to_suffixes "objective-c++", "mm"),
369 (lang_to_suffixes "objective-c++-header", "hmm"),
370 (lang_to_suffixes "objective-c", "m"),
371 (lang_to_suffixes "objective-c-header", "hm"),
372 (lang_to_suffixes "assembler", "s"),
373 (lang_to_suffixes "assembler-with-cpp", "S"),
374 (lang_to_suffixes "llvm-assembler", "ll"),
375 (lang_to_suffixes "llvm-bitcode", "bc"),
376 (lang_to_suffixes "object-code", ["o", "*empty*"]),
377 (lang_to_suffixes "static-library", ["a", "lib"]),
Mikhail Glushenkov743547f2010-09-02 14:06:21 +0000378 (lang_to_suffixes "dynamic-library", ["so", "dylib", "dll"]),
Mikhail Glushenkovdea1c5b2010-10-14 11:22:06 +0000379 (lang_to_suffixes "executable", "out")
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000380]>;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000381
382// Compilation graph
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +0000383
Mikhail Glushenkov0d08db02008-05-06 16:35:25 +0000384def CompilationGraph : CompilationGraph<[
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000385 (edge "root", "llvm_gcc_c"),
386 (edge "root", "llvm_gcc_assembler"),
387 (edge "root", "llvm_gcc_cpp"),
388 (edge "root", "llvm_gcc_m"),
389 (edge "root", "llvm_gcc_mxx"),
390 (edge "root", "llc"),
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000391
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000392 (edge "root", "llvm_gcc_c_pch"),
393 (edge "root", "llvm_gcc_cpp_pch"),
394 (edge "root", "llvm_gcc_m_pch"),
395 (edge "root", "llvm_gcc_mxx_pch"),
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000396
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000397 (edge "llvm_gcc_c", "llc"),
398 (edge "llvm_gcc_cpp", "llc"),
399 (edge "llvm_gcc_m", "llc"),
400 (edge "llvm_gcc_mxx", "llc"),
401 (edge "llvm_as", "llc"),
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000402
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000403 (optional_edge "root", "llvm_as",
404 (case (switch_on "emit-llvm"), (inc_weight))),
405 (optional_edge "llvm_gcc_c", "opt",
406 (case (switch_on "opt"), (inc_weight))),
407 (optional_edge "llvm_gcc_cpp", "opt",
408 (case (switch_on "opt"), (inc_weight))),
409 (optional_edge "llvm_gcc_m", "opt",
410 (case (switch_on "opt"), (inc_weight))),
411 (optional_edge "llvm_gcc_mxx", "opt",
412 (case (switch_on "opt"), (inc_weight))),
413 (optional_edge "llvm_as", "opt",
414 (case (switch_on "opt"), (inc_weight))),
415 (edge "opt", "llc"),
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000416
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000417 (edge "llc", "llvm_gcc_assembler"),
418 (edge "llvm_gcc_assembler", "llvm_gcc_linker"),
419 (optional_edge "llvm_gcc_assembler", "llvm_gcc_cpp_linker",
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000420 (case
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000421 (or (input_languages_contain "c++"),
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000422 (input_languages_contain "objective-c++")),
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000423 (inc_weight),
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000424 (or (parameter_equals "linker", "g++"),
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000425 (parameter_equals "linker", "c++")), (inc_weight))),
Mikhail Glushenkov35a85e82008-05-06 18:10:20 +0000426
Mikhail Glushenkov978d4982008-05-06 18:13:00 +0000427
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000428 (edge "root", "llvm_gcc_linker"),
429 (optional_edge "root", "llvm_gcc_cpp_linker",
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000430 (case
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000431 (or (input_languages_contain "c++"),
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000432 (input_languages_contain "objective-c++")),
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000433 (inc_weight),
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000434 (or (parameter_equals "linker", "g++"),
Mikhail Glushenkovd9a73162010-08-23 23:21:23 +0000435 (parameter_equals "linker", "c++")), (inc_weight)))
436]>;