blob: 23f46b7e57d0dbbfab5b97c1f9b3511330bb5e8e [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 Glushenkove4a5ea32008-10-02 21:15:05 +000014include "llvm/CompilerDriver/Common.td"
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +000015
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000016// Options
17
18def OptList : OptionList<[
19 (switch_option "emit-llvm",
20 (help "Emit LLVM .ll files instead of native object files")),
21 (switch_option "E",
22 (help "Stop after the preprocessing stage, do not run the compiler")),
23 (switch_option "fsyntax-only",
24 (help "Stop after checking the input for syntax errors")),
25 (switch_option "opt",
26 (help "Enable opt")),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000027 (switch_option "O0",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000028 (help "Turn off optimization"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000029 (switch_option "O1",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000030 (help "Optimization level 1"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000031 (switch_option "O2",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000032 (help "Optimization level 2"), (zero_or_more)),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +000033 (switch_option "O3",
Mikhail Glushenkovb5c42392010-03-05 04:46:39 +000034 (help "Optimization level 3"), (zero_or_more)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000035 (switch_option "S",
36 (help "Stop after compilation, do not assemble")),
37 (switch_option "c",
38 (help "Compile and assemble, but do not link")),
39 (switch_option "pthread",
40 (help "Enable threads")),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +000041 (switch_option "m32",
42 (help "Generate code for a 32-bit environment"), (hidden)),
43 (switch_option "m64",
44 (help "Generate code for a 64-bit environment"), (hidden)),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +000045 (switch_option "fPIC",
46 (help "Relocation model: PIC"), (hidden)),
47 (switch_option "mdynamic-no-pic",
48 (help "Relocation model: dynamic-no-pic"), (hidden)),
Mikhail Glushenkovcbf1aa92010-04-03 02:00:03 +000049 (switch_option "shared",
50 (help "Create a DLL instead of the regular executable")),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000051 (parameter_option "linker",
52 (help "Choose linker (possible values: gcc, g++)")),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000053 (parameter_option "mtune",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000054 (help "Target a specific CPU type"), (hidden), (forward_not_split)),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +000055
56 // TODO: Add a conditional compilation mechanism to make Darwin-only options
57 // like '-arch' really Darwin-only.
58
59 (parameter_option "arch",
60 (help "Compile for the specified target architecture"), (hidden)),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000061 (parameter_option "march",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000062 (help "A synonym for -mtune"), (hidden), (forward_not_split)),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +000063 (parameter_option "mcpu",
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +000064 (help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)),
Mikhail Glushenkovb88c6f62010-02-13 22:37:00 +000065 (switch_option "mfix-and-continue",
66 (help "Needed by gdb to load .o files dynamically"), (hidden)),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000067 (parameter_option "MF",
68 (help "Specify a file to write dependencies to"), (hidden)),
Mikhail Glushenkovbc56d862010-01-02 08:27:10 +000069 (parameter_list_option "MT",
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000070 (help "Change the name of the rule emitted by dependency generation"),
71 (hidden)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000072 (parameter_list_option "include",
73 (help "Include the named file prior to preprocessing")),
Mikhail Glushenkov967edd02010-01-26 14:55:30 +000074 (parameter_list_option "iquote",
75 (help "Search dir only for files requested with #inlcude \"file\""),
76 (hidden)),
Mikhail Glushenkov18518602009-12-01 05:59:55 +000077 (parameter_list_option "framework",
78 (help "Specifies a framework to link against")),
79 (parameter_list_option "weak_framework",
80 (help "Specifies a framework to weakly link against"), (hidden)),
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +000081 (parameter_option "filelist", (hidden),
82 (help "Link the files listed in file")),
Mikhail Glushenkov18518602009-12-01 05:59:55 +000083 (prefix_list_option "F",
84 (help "Add a directory to framework search path")),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000085 (prefix_list_option "I",
86 (help "Add a directory to include path")),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +000087 (prefix_list_option "D",
88 (help "Define a macro")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000089 (parameter_list_option "Xpreprocessor", (hidden),
90 (help "Pass options to preprocessor")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000091 (prefix_list_option "Wa,", (comma_separated),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000092 (help "Pass options to assembler")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +000093 (parameter_list_option "Xassembler", (hidden),
94 (help "Pass options to assembler")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +000095 (prefix_list_option "Wllc,", (comma_separated),
Mikhail Glushenkov46801022009-03-31 18:33:54 +000096 (help "Pass options to llc")),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +000097 (prefix_list_option "L",
98 (help "Add a directory to link path")),
99 (prefix_list_option "l",
100 (help "Search a library when linking")),
101 (prefix_list_option "Wl,",
Mikhail Glushenkovba71d672008-12-11 22:19:14 +0000102 (help "Pass options to linker")),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000103 (parameter_list_option "Xlinker", (hidden),
104 (help "Pass options to linker")),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +0000105 (prefix_list_option "Wo,", (comma_separated),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000106 (help "Pass options to opt")),
107 (prefix_list_option "m",
108 (help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000109 (hidden)),
110 (switch_option "dynamiclib", (hidden),
111 (help "Produce a dynamic library")),
112 (switch_option "prebind", (hidden),
113 (help "Prebind all undefined symbols")),
114 (switch_option "dead_strip", (hidden),
115 (help "Remove unreachable blocks of code")),
116 (switch_option "single_module", (hidden),
117 (help "Build the library so it contains only one module")),
Mikhail Glushenkov9f2a0802010-02-23 09:04:18 +0000118 (parameter_option "install_name", (hidden),
119 (help "File name the library will be installed in")),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000120 (parameter_option "compatibility_version", (hidden),
121 (help "Compatibility version number")),
122 (parameter_option "current_version", (hidden),
123 (help "Current version number"))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000124]>;
125
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000126// Option preprocessor.
127
128def Preprocess : OptionPreprocessor<
Mikhail Glushenkov994dbe02009-12-17 07:49:16 +0000129(case (not (any_switch_on ["O0", "O1", "O2", "O3"])),
130 (set_option "O2"),
131 (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])),
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000132 (unset_option ["O0", "O1", "O2"]),
133 (and (switch_on "O2"), (any_switch_on ["O0", "O1"])),
134 (unset_option ["O0", "O1"]),
Mikhail Glushenkov3a481e32010-01-01 03:50:51 +0000135 (switch_on ["O1", "O0"]),
Mikhail Glushenkov0a22fb62009-10-17 20:09:29 +0000136 (unset_option "O0"))
137>;
138
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000139// Tools
140
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000141class llvm_gcc_based <string cmd_prefix, string in_lang,
142 string E_ext, string out_lang> : Tool<
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000143[(in_language in_lang),
144 (out_language "llvm-bitcode"),
Mikhail Glushenkovfc2ee152010-02-23 09:05:06 +0000145 (output_suffix out_lang),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000146 (command cmd_prefix),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000147 (actions
148 (case
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000149 (and (not_empty "o"),
150 (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
Mikhail Glushenkovad981bf2009-09-28 01:16:42 +0000151 (error "cannot specify -o with -c or -S with multiple files"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000152 (switch_on "E"),
153 [(forward "E"), (stop_compilation), (output_suffix E_ext)],
154 (and (switch_on "E"), (empty "o")), (no_out_file),
Mikhail Glushenkov99da5d72010-01-01 04:41:10 +0000155 (switch_on ["emit-llvm", "S"]),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000156 [(output_suffix "ll"), (stop_compilation)],
Mikhail Glushenkov99da5d72010-01-01 04:41:10 +0000157 (switch_on ["emit-llvm", "c"]), (stop_compilation),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000158 (switch_on "fsyntax-only"), [(forward "fsyntax-only"),
159 (no_out_file), (stop_compilation)],
160 (switch_on ["S", "emit-llvm"]), [(forward "S"), (forward "emit-llvm")],
161 (not (or (switch_on ["S", "emit-llvm"]), (switch_on "fsyntax-only"))),
162 [(append_cmd "-c"), (append_cmd "-emit-llvm")],
163
164 // Forwards
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000165 (not_empty "Xpreprocessor"), (forward "Xpreprocessor"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000166 (not_empty "include"), (forward "include"),
Mikhail Glushenkov967edd02010-01-26 14:55:30 +0000167 (not_empty "iquote"), (forward "iquote"),
Mikhail Glushenkov97955002009-12-01 06:51:30 +0000168 (not_empty "save-temps"), (append_cmd "-save-temps"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000169 (not_empty "I"), (forward "I"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000170 (not_empty "F"), (forward "F"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000171 (not_empty "D"), (forward "D"),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000172 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000173 (not_empty "march"), (forward "march"),
174 (not_empty "mtune"), (forward "mtune"),
175 (not_empty "mcpu"), (forward "mcpu"),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000176 (not_empty "m"), (forward "m"),
Mikhail Glushenkovb88c6f62010-02-13 22:37:00 +0000177 (switch_on "mfix-and-continue"), (forward "mfix-and-continue"),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +0000178 (switch_on "m32"), (forward "m32"),
179 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkov364cf752010-01-02 08:27:23 +0000180 (switch_on "O0"), (forward "O0"),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000181 (switch_on "O1"), (forward "O1"),
182 (switch_on "O2"), (forward "O2"),
183 (switch_on "O3"), (forward "O3"),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +0000184 (switch_on "fPIC"), (forward "fPIC"),
185 (switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"),
Mikhail Glushenkov976248d2009-10-08 06:03:38 +0000186 (not_empty "MF"), (forward "MF"),
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +0000187 (not_empty "MT"), (forward "MT"))),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000188 (sink)
189]>;
190
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000191def llvm_gcc_c : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c", "c", "i", "bc">;
192def llvm_gcc_cpp : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++", "c++", "i", "bc">;
Mikhail Glushenkov6d80d2b2009-10-08 04:40:28 +0000193def llvm_gcc_m : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c",
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000194 "objective-c", "mi", "bc">;
Mikhail Glushenkov4558f482009-04-21 19:46:10 +0000195def llvm_gcc_mxx : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++",
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000196 "objective-c++", "mi", "bc">;
197
198def llvm_gcc_c_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c-header",
199 "c-header", "i", "gch">;
200def llvm_gcc_cpp_pch : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++-header",
201 "c++-header",
202 "i", "gch">;
203def llvm_gcc_m_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c-header",
204 "objective-c-header",
205 "mi", "gch">;
206def llvm_gcc_mxx_pch
207 : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++-header",
208 "objective-c++-header", "mi", "gch">;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000209
210def opt : Tool<
211[(in_language "llvm-bitcode"),
212 (out_language "llvm-bitcode"),
213 (output_suffix "bc"),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +0000214 (actions (case (not_empty "Wo,"), (forward_value "Wo,"),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000215 (switch_on "O1"), (forward "O1"),
216 (switch_on "O2"), (forward "O2"),
217 (switch_on "O3"), (forward "O3"))),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000218 (command "opt -f")
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000219]>;
220
221def llvm_as : Tool<
222[(in_language "llvm-assembler"),
223 (out_language "llvm-bitcode"),
224 (output_suffix "bc"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000225 (command "llvm-as"),
Mikhail Glushenkov3ab68892009-10-09 05:45:01 +0000226 (actions (case (switch_on "emit-llvm"), (stop_compilation)))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000227]>;
228
229def llvm_gcc_assembler : Tool<
230[(in_language "assembler"),
231 (out_language "object-code"),
232 (output_suffix "o"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000233 (command "@LLVMGCCCOMMAND@ -c -x assembler"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000234 (actions (case
235 (switch_on "c"), (stop_compilation),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000236 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000237 (not_empty "Xassembler"), (forward "Xassembler"),
Mikhail Glushenkov62d1da02010-03-31 23:51:55 +0000238 (switch_on "m32"), (forward "m32"),
239 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000240 (not_empty "Wa,"), (forward "Wa,")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000241]>;
242
243def llc : Tool<
Mikhail Glushenkov3ab68892009-10-09 05:45:01 +0000244[(in_language ["llvm-bitcode", "llvm-assembler"]),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000245 (out_language "assembler"),
246 (output_suffix "s"),
Dan Gohman281ead42010-04-29 18:46:52 +0000247 (command "llc"),
Mikhail Glushenkov46801022009-03-31 18:33:54 +0000248 (actions (case
249 (switch_on "S"), (stop_compilation),
Mikhail Glushenkov6b4967e2009-10-17 20:07:49 +0000250 (switch_on "O0"), (forward "O0"),
251 (switch_on "O1"), (forward "O1"),
252 (switch_on "O2"), (forward "O2"),
253 (switch_on "O3"), (forward "O3"),
Mikhail Glushenkov55cd7672009-12-01 09:47:11 +0000254 (switch_on "fPIC"), (append_cmd "-relocation-model=pic"),
255 (switch_on "mdynamic-no-pic"),
256 (append_cmd "-relocation-model=dynamic-no-pic"),
Mikhail Glushenkovb5c2a5d2010-02-23 14:29:42 +0000257 (not_empty "march"), (forward_as "mtune", "-mcpu"),
258 (not_empty "mtune"), (forward_as "mtune", "-mcpu"),
Mikhail Glushenkov3ab48832009-12-04 06:38:28 +0000259 (not_empty "mcpu"), (forward "mcpu"),
Mikhail Glushenkov84612022009-12-07 17:03:21 +0000260 (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
Mikhail Glushenkov5b9b3ba2009-12-07 18:25:54 +0000261 (not_empty "Wllc,"), (forward_value "Wllc,")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000262]>;
263
264// Base class for linkers
265class llvm_gcc_based_linker <string cmd_prefix> : Tool<
Mikhail Glushenkovc1b202a2010-04-19 17:25:38 +0000266[(in_language ["object-code", "static-library"]),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000267 (out_language "executable"),
268 (output_suffix "out"),
Mikhail Glushenkova34f97a2010-02-23 09:04:44 +0000269 (command cmd_prefix),
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +0000270 (works_on_empty (case (not_empty "filelist"), true,
271 (default), false)),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000272 (join),
273 (actions (case
274 (switch_on "pthread"), (append_cmd "-lpthread"),
275 (not_empty "L"), (forward "L"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000276 (not_empty "F"), (forward "F"),
Mikhail Glushenkov058b3f52010-01-26 14:55:44 +0000277 (not_empty "arch"), (forward "arch"),
Mikhail Glushenkov18518602009-12-01 05:59:55 +0000278 (not_empty "framework"), (forward "framework"),
279 (not_empty "weak_framework"), (forward "weak_framework"),
Mikhail Glushenkovbe6ee7c2010-02-23 09:04:28 +0000280 (not_empty "filelist"), (forward "filelist"),
Mikhail Glushenkovfa8182e2009-12-04 06:38:45 +0000281 (switch_on "m32"), (forward "m32"),
282 (switch_on "m64"), (forward "m64"),
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000283 (not_empty "l"), (forward "l"),
Mikhail Glushenkov130bede2010-02-23 09:05:15 +0000284 (not_empty "Xlinker"), (forward "Xlinker"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000285 (not_empty "Wl,"), (forward "Wl,"),
Mikhail Glushenkovcbf1aa92010-04-03 02:00:03 +0000286 (switch_on "shared"), (forward "shared"),
Mikhail Glushenkov49e496b2010-02-13 22:37:13 +0000287 (switch_on "dynamiclib"), (forward "dynamiclib"),
288 (switch_on "prebind"), (forward "prebind"),
289 (switch_on "dead_strip"), (forward "dead_strip"),
290 (switch_on "single_module"), (forward "single_module"),
291 (not_empty "compatibility_version"),
292 (forward "compatibility_version"),
Mikhail Glushenkov9f2a0802010-02-23 09:04:18 +0000293 (not_empty "current_version"), (forward "current_version"),
294 (not_empty "install_name"), (forward "install_name")))
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000295]>;
296
297// Default linker
Mikhail Glushenkov4558f482009-04-21 19:46:10 +0000298def llvm_gcc_linker : llvm_gcc_based_linker<"@LLVMGCCCOMMAND@">;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000299// Alternative linker for C++
Mikhail Glushenkov4558f482009-04-21 19:46:10 +0000300def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@">;
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000301
302// Language map
303
304def LanguageMap : LanguageMap<
305 [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000306 LangToSuffixes<"c++-header", ["hpp"]>,
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000307 LangToSuffixes<"c", ["c"]>,
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000308 LangToSuffixes<"c-header", ["h"]>,
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000309 LangToSuffixes<"c-cpp-output", ["i"]>,
310 LangToSuffixes<"objective-c-cpp-output", ["mi"]>,
311 LangToSuffixes<"objective-c++", ["mm"]>,
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000312 LangToSuffixes<"objective-c++-header", ["hmm"]>,
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000313 LangToSuffixes<"objective-c", ["m"]>,
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000314 LangToSuffixes<"objective-c-header", ["hm"]>,
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000315 LangToSuffixes<"assembler", ["s"]>,
316 LangToSuffixes<"assembler-with-cpp", ["S"]>,
317 LangToSuffixes<"llvm-assembler", ["ll"]>,
318 LangToSuffixes<"llvm-bitcode", ["bc"]>,
Mikhail Glushenkov9660c5d2010-02-23 09:05:21 +0000319 LangToSuffixes<"object-code", ["o", "*empty*"]>,
Mikhail Glushenkovc1b202a2010-04-19 17:25:38 +0000320 LangToSuffixes<"static-library", ["a", "lib"]>,
Mikhail Glushenkovde1e5212008-12-11 10:38:06 +0000321 LangToSuffixes<"executable", ["out"]>
322 ]>;
323
324// Compilation graph
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +0000325
Mikhail Glushenkov0d08db02008-05-06 16:35:25 +0000326def CompilationGraph : CompilationGraph<[
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000327 Edge<"root", "llvm_gcc_c">,
328 Edge<"root", "llvm_gcc_assembler">,
329 Edge<"root", "llvm_gcc_cpp">,
330 Edge<"root", "llvm_gcc_m">,
331 Edge<"root", "llvm_gcc_mxx">,
Mikhail Glushenkov57a7e942009-09-10 17:04:32 +0000332 Edge<"root", "llc">,
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000333
Mikhail Glushenkovc6e0dbf2010-02-23 09:04:33 +0000334 Edge<"root", "llvm_gcc_c_pch">,
335 Edge<"root", "llvm_gcc_cpp_pch">,
336 Edge<"root", "llvm_gcc_m_pch">,
337 Edge<"root", "llvm_gcc_mxx_pch">,
338
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000339 Edge<"llvm_gcc_c", "llc">,
340 Edge<"llvm_gcc_cpp", "llc">,
341 Edge<"llvm_gcc_m", "llc">,
342 Edge<"llvm_gcc_mxx", "llc">,
343 Edge<"llvm_as", "llc">,
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000344
Mikhail Glushenkov3ab68892009-10-09 05:45:01 +0000345 OptionalEdge<"root", "llvm_as",
346 (case (switch_on "emit-llvm"), (inc_weight))>,
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000347 OptionalEdge<"llvm_gcc_c", "opt", (case (switch_on "opt"), (inc_weight))>,
348 OptionalEdge<"llvm_gcc_cpp", "opt", (case (switch_on "opt"), (inc_weight))>,
349 OptionalEdge<"llvm_gcc_m", "opt", (case (switch_on "opt"), (inc_weight))>,
350 OptionalEdge<"llvm_gcc_mxx", "opt", (case (switch_on "opt"), (inc_weight))>,
351 OptionalEdge<"llvm_as", "opt", (case (switch_on "opt"), (inc_weight))>,
352 Edge<"opt", "llc">,
Mikhail Glushenkovd752c3f2008-05-06 16:36:50 +0000353
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000354 Edge<"llc", "llvm_gcc_assembler">,
355 Edge<"llvm_gcc_assembler", "llvm_gcc_linker">,
356 OptionalEdge<"llvm_gcc_assembler", "llvm_gcc_cpp_linker",
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000357 (case
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000358 (or (input_languages_contain "c++"),
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000359 (input_languages_contain "objective-c++")),
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000360 (inc_weight),
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000361 (or (parameter_equals "linker", "g++"),
362 (parameter_equals "linker", "c++")), (inc_weight))>,
Mikhail Glushenkov35a85e82008-05-06 18:10:20 +0000363
Mikhail Glushenkov978d4982008-05-06 18:13:00 +0000364
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000365 Edge<"root", "llvm_gcc_linker">,
366 OptionalEdge<"root", "llvm_gcc_cpp_linker",
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000367 (case
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000368 (or (input_languages_contain "c++"),
Mikhail Glushenkov01088772008-11-17 17:29:18 +0000369 (input_languages_contain "objective-c++")),
Daniel Dunbar77e0c852008-11-08 03:25:47 +0000370 (inc_weight),
Mikhail Glushenkove5557f42008-05-30 06:08:50 +0000371 (or (parameter_equals "linker", "g++"),
372 (parameter_equals "linker", "c++")), (inc_weight))>
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +0000373 ]>;