Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 1 | //===- Base.td - LLVMC toolchain descriptions --------------*- tablegen -*-===// |
Anton Korobeynikov | ac67b7e | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 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 | // |
Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 10 | // This file contains compilation graph description used by llvmc. |
Anton Korobeynikov | ac67b7e | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Mikhail Glushenkov | e4a5ea3 | 2008-10-02 21:15:05 +0000 | [diff] [blame] | 14 | include "llvm/CompilerDriver/Common.td" |
Anton Korobeynikov | ac67b7e | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 15 | |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 16 | // Options |
| 17 | |
| 18 | def 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 Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 27 | (switch_option "O0", |
Mikhail Glushenkov | b5c4239 | 2010-03-05 04:46:39 +0000 | [diff] [blame] | 28 | (help "Turn off optimization"), (zero_or_more)), |
Mikhail Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 29 | (switch_option "O1", |
Mikhail Glushenkov | b5c4239 | 2010-03-05 04:46:39 +0000 | [diff] [blame] | 30 | (help "Optimization level 1"), (zero_or_more)), |
Mikhail Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 31 | (switch_option "O2", |
Mikhail Glushenkov | b5c4239 | 2010-03-05 04:46:39 +0000 | [diff] [blame] | 32 | (help "Optimization level 2"), (zero_or_more)), |
Mikhail Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 33 | (switch_option "O3", |
Mikhail Glushenkov | b5c4239 | 2010-03-05 04:46:39 +0000 | [diff] [blame] | 34 | (help "Optimization level 3"), (zero_or_more)), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 35 | (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 Glushenkov | fa8182e | 2009-12-04 06:38:45 +0000 | [diff] [blame] | 41 | (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 Glushenkov | 55cd767 | 2009-12-01 09:47:11 +0000 | [diff] [blame] | 45 | (switch_option "fPIC", |
| 46 | (help "Relocation model: PIC"), (hidden)), |
| 47 | (switch_option "mdynamic-no-pic", |
| 48 | (help "Relocation model: dynamic-no-pic"), (hidden)), |
Mikhail Glushenkov | cbf1aa9 | 2010-04-03 02:00:03 +0000 | [diff] [blame] | 49 | (switch_option "shared", |
| 50 | (help "Create a DLL instead of the regular executable")), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 51 | (parameter_option "linker", |
| 52 | (help "Choose linker (possible values: gcc, g++)")), |
Mikhail Glushenkov | 3ab4883 | 2009-12-04 06:38:28 +0000 | [diff] [blame] | 53 | (parameter_option "mtune", |
Mikhail Glushenkov | b5c2a5d | 2010-02-23 14:29:42 +0000 | [diff] [blame] | 54 | (help "Target a specific CPU type"), (hidden), (forward_not_split)), |
Mikhail Glushenkov | 058b3f5 | 2010-01-26 14:55:44 +0000 | [diff] [blame] | 55 | |
| 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 Glushenkov | 3ab4883 | 2009-12-04 06:38:28 +0000 | [diff] [blame] | 61 | (parameter_option "march", |
Mikhail Glushenkov | b5c2a5d | 2010-02-23 14:29:42 +0000 | [diff] [blame] | 62 | (help "A synonym for -mtune"), (hidden), (forward_not_split)), |
Mikhail Glushenkov | 3ab4883 | 2009-12-04 06:38:28 +0000 | [diff] [blame] | 63 | (parameter_option "mcpu", |
Mikhail Glushenkov | b5c2a5d | 2010-02-23 14:29:42 +0000 | [diff] [blame] | 64 | (help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)), |
Mikhail Glushenkov | b88c6f6 | 2010-02-13 22:37:00 +0000 | [diff] [blame] | 65 | (switch_option "mfix-and-continue", |
| 66 | (help "Needed by gdb to load .o files dynamically"), (hidden)), |
Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 67 | (parameter_option "MF", |
| 68 | (help "Specify a file to write dependencies to"), (hidden)), |
Mikhail Glushenkov | bc56d86 | 2010-01-02 08:27:10 +0000 | [diff] [blame] | 69 | (parameter_list_option "MT", |
Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 70 | (help "Change the name of the rule emitted by dependency generation"), |
| 71 | (hidden)), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 72 | (parameter_list_option "include", |
| 73 | (help "Include the named file prior to preprocessing")), |
Mikhail Glushenkov | 967edd0 | 2010-01-26 14:55:30 +0000 | [diff] [blame] | 74 | (parameter_list_option "iquote", |
| 75 | (help "Search dir only for files requested with #inlcude \"file\""), |
| 76 | (hidden)), |
Mikhail Glushenkov | 1851860 | 2009-12-01 05:59:55 +0000 | [diff] [blame] | 77 | (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 Glushenkov | be6ee7c | 2010-02-23 09:04:28 +0000 | [diff] [blame] | 81 | (parameter_option "filelist", (hidden), |
| 82 | (help "Link the files listed in file")), |
Mikhail Glushenkov | 1851860 | 2009-12-01 05:59:55 +0000 | [diff] [blame] | 83 | (prefix_list_option "F", |
| 84 | (help "Add a directory to framework search path")), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 85 | (prefix_list_option "I", |
| 86 | (help "Add a directory to include path")), |
Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 87 | (prefix_list_option "D", |
| 88 | (help "Define a macro")), |
Mikhail Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 89 | (parameter_list_option "Xpreprocessor", (hidden), |
| 90 | (help "Pass options to preprocessor")), |
Mikhail Glushenkov | 5b9b3ba | 2009-12-07 18:25:54 +0000 | [diff] [blame] | 91 | (prefix_list_option "Wa,", (comma_separated), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 92 | (help "Pass options to assembler")), |
Mikhail Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 93 | (parameter_list_option "Xassembler", (hidden), |
| 94 | (help "Pass options to assembler")), |
Mikhail Glushenkov | 5b9b3ba | 2009-12-07 18:25:54 +0000 | [diff] [blame] | 95 | (prefix_list_option "Wllc,", (comma_separated), |
Mikhail Glushenkov | 4680102 | 2009-03-31 18:33:54 +0000 | [diff] [blame] | 96 | (help "Pass options to llc")), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 97 | (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 Glushenkov | ba71d67 | 2008-12-11 22:19:14 +0000 | [diff] [blame] | 102 | (help "Pass options to linker")), |
Mikhail Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 103 | (parameter_list_option "Xlinker", (hidden), |
| 104 | (help "Pass options to linker")), |
Mikhail Glushenkov | 5b9b3ba | 2009-12-07 18:25:54 +0000 | [diff] [blame] | 105 | (prefix_list_option "Wo,", (comma_separated), |
Mikhail Glushenkov | 8461202 | 2009-12-07 17:03:21 +0000 | [diff] [blame] | 106 | (help "Pass options to opt")), |
| 107 | (prefix_list_option "m", |
| 108 | (help "Enable or disable various extensions (-mmmx, -msse, etc.)"), |
Mikhail Glushenkov | 49e496b | 2010-02-13 22:37:13 +0000 | [diff] [blame] | 109 | (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 Glushenkov | 9f2a080 | 2010-02-23 09:04:18 +0000 | [diff] [blame] | 118 | (parameter_option "install_name", (hidden), |
| 119 | (help "File name the library will be installed in")), |
Mikhail Glushenkov | 49e496b | 2010-02-13 22:37:13 +0000 | [diff] [blame] | 120 | (parameter_option "compatibility_version", (hidden), |
| 121 | (help "Compatibility version number")), |
| 122 | (parameter_option "current_version", (hidden), |
| 123 | (help "Current version number")) |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 124 | ]>; |
| 125 | |
Mikhail Glushenkov | 0a22fb6 | 2009-10-17 20:09:29 +0000 | [diff] [blame] | 126 | // Option preprocessor. |
| 127 | |
| 128 | def Preprocess : OptionPreprocessor< |
Mikhail Glushenkov | 994dbe0 | 2009-12-17 07:49:16 +0000 | [diff] [blame] | 129 | (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 Glushenkov | 0a22fb6 | 2009-10-17 20:09:29 +0000 | [diff] [blame] | 132 | (unset_option ["O0", "O1", "O2"]), |
| 133 | (and (switch_on "O2"), (any_switch_on ["O0", "O1"])), |
| 134 | (unset_option ["O0", "O1"]), |
Mikhail Glushenkov | 3a481e3 | 2010-01-01 03:50:51 +0000 | [diff] [blame] | 135 | (switch_on ["O1", "O0"]), |
Mikhail Glushenkov | 0a22fb6 | 2009-10-17 20:09:29 +0000 | [diff] [blame] | 136 | (unset_option "O0")) |
| 137 | >; |
| 138 | |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 139 | // Tools |
| 140 | |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 141 | class llvm_gcc_based <string cmd_prefix, string in_lang, |
| 142 | string E_ext, string out_lang> : Tool< |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 143 | [(in_language in_lang), |
| 144 | (out_language "llvm-bitcode"), |
Mikhail Glushenkov | fc2ee15 | 2010-02-23 09:05:06 +0000 | [diff] [blame] | 145 | (output_suffix out_lang), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 146 | (command cmd_prefix), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 147 | (actions |
| 148 | (case |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 149 | (and (not_empty "o"), |
| 150 | (multiple_input_files), (or (switch_on "S"), (switch_on "c"))), |
Mikhail Glushenkov | ad981bf | 2009-09-28 01:16:42 +0000 | [diff] [blame] | 151 | (error "cannot specify -o with -c or -S with multiple files"), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 152 | (switch_on "E"), |
| 153 | [(forward "E"), (stop_compilation), (output_suffix E_ext)], |
| 154 | (and (switch_on "E"), (empty "o")), (no_out_file), |
Mikhail Glushenkov | 99da5d7 | 2010-01-01 04:41:10 +0000 | [diff] [blame] | 155 | (switch_on ["emit-llvm", "S"]), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 156 | [(output_suffix "ll"), (stop_compilation)], |
Mikhail Glushenkov | 99da5d7 | 2010-01-01 04:41:10 +0000 | [diff] [blame] | 157 | (switch_on ["emit-llvm", "c"]), (stop_compilation), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 158 | (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 Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 165 | (not_empty "Xpreprocessor"), (forward "Xpreprocessor"), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 166 | (not_empty "include"), (forward "include"), |
Mikhail Glushenkov | 967edd0 | 2010-01-26 14:55:30 +0000 | [diff] [blame] | 167 | (not_empty "iquote"), (forward "iquote"), |
Mikhail Glushenkov | 9795500 | 2009-12-01 06:51:30 +0000 | [diff] [blame] | 168 | (not_empty "save-temps"), (append_cmd "-save-temps"), |
Mikhail Glushenkov | 976248d | 2009-10-08 06:03:38 +0000 | [diff] [blame] | 169 | (not_empty "I"), (forward "I"), |
Mikhail Glushenkov | 1851860 | 2009-12-01 05:59:55 +0000 | [diff] [blame] | 170 | (not_empty "F"), (forward "F"), |
Mikhail Glushenkov | 976248d | 2009-10-08 06:03:38 +0000 | [diff] [blame] | 171 | (not_empty "D"), (forward "D"), |
Mikhail Glushenkov | 058b3f5 | 2010-01-26 14:55:44 +0000 | [diff] [blame] | 172 | (not_empty "arch"), (forward "arch"), |
Mikhail Glushenkov | 3ab4883 | 2009-12-04 06:38:28 +0000 | [diff] [blame] | 173 | (not_empty "march"), (forward "march"), |
| 174 | (not_empty "mtune"), (forward "mtune"), |
| 175 | (not_empty "mcpu"), (forward "mcpu"), |
Mikhail Glushenkov | 8461202 | 2009-12-07 17:03:21 +0000 | [diff] [blame] | 176 | (not_empty "m"), (forward "m"), |
Mikhail Glushenkov | b88c6f6 | 2010-02-13 22:37:00 +0000 | [diff] [blame] | 177 | (switch_on "mfix-and-continue"), (forward "mfix-and-continue"), |
Mikhail Glushenkov | fa8182e | 2009-12-04 06:38:45 +0000 | [diff] [blame] | 178 | (switch_on "m32"), (forward "m32"), |
| 179 | (switch_on "m64"), (forward "m64"), |
Mikhail Glushenkov | 364cf75 | 2010-01-02 08:27:23 +0000 | [diff] [blame] | 180 | (switch_on "O0"), (forward "O0"), |
Mikhail Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 181 | (switch_on "O1"), (forward "O1"), |
| 182 | (switch_on "O2"), (forward "O2"), |
| 183 | (switch_on "O3"), (forward "O3"), |
Mikhail Glushenkov | 55cd767 | 2009-12-01 09:47:11 +0000 | [diff] [blame] | 184 | (switch_on "fPIC"), (forward "fPIC"), |
| 185 | (switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"), |
Mikhail Glushenkov | 976248d | 2009-10-08 06:03:38 +0000 | [diff] [blame] | 186 | (not_empty "MF"), (forward "MF"), |
Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 187 | (not_empty "MT"), (forward "MT"))), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 188 | (sink) |
| 189 | ]>; |
| 190 | |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 191 | def llvm_gcc_c : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c", "c", "i", "bc">; |
| 192 | def llvm_gcc_cpp : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++", "c++", "i", "bc">; |
Mikhail Glushenkov | 6d80d2b | 2009-10-08 04:40:28 +0000 | [diff] [blame] | 193 | def llvm_gcc_m : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c", |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 194 | "objective-c", "mi", "bc">; |
Mikhail Glushenkov | 4558f48 | 2009-04-21 19:46:10 +0000 | [diff] [blame] | 195 | def llvm_gcc_mxx : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++", |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 196 | "objective-c++", "mi", "bc">; |
| 197 | |
| 198 | def llvm_gcc_c_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c-header", |
| 199 | "c-header", "i", "gch">; |
| 200 | def llvm_gcc_cpp_pch : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++-header", |
| 201 | "c++-header", |
| 202 | "i", "gch">; |
| 203 | def llvm_gcc_m_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c-header", |
| 204 | "objective-c-header", |
| 205 | "mi", "gch">; |
| 206 | def llvm_gcc_mxx_pch |
| 207 | : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++-header", |
| 208 | "objective-c++-header", "mi", "gch">; |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 209 | |
| 210 | def opt : Tool< |
| 211 | [(in_language "llvm-bitcode"), |
| 212 | (out_language "llvm-bitcode"), |
| 213 | (output_suffix "bc"), |
Mikhail Glushenkov | 5b9b3ba | 2009-12-07 18:25:54 +0000 | [diff] [blame] | 214 | (actions (case (not_empty "Wo,"), (forward_value "Wo,"), |
Mikhail Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 215 | (switch_on "O1"), (forward "O1"), |
| 216 | (switch_on "O2"), (forward "O2"), |
| 217 | (switch_on "O3"), (forward "O3"))), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 218 | (command "opt -f") |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 219 | ]>; |
| 220 | |
| 221 | def llvm_as : Tool< |
| 222 | [(in_language "llvm-assembler"), |
| 223 | (out_language "llvm-bitcode"), |
| 224 | (output_suffix "bc"), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 225 | (command "llvm-as"), |
Mikhail Glushenkov | 3ab6889 | 2009-10-09 05:45:01 +0000 | [diff] [blame] | 226 | (actions (case (switch_on "emit-llvm"), (stop_compilation))) |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 227 | ]>; |
| 228 | |
| 229 | def llvm_gcc_assembler : Tool< |
| 230 | [(in_language "assembler"), |
| 231 | (out_language "object-code"), |
| 232 | (output_suffix "o"), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 233 | (command "@LLVMGCCCOMMAND@ -c -x assembler"), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 234 | (actions (case |
| 235 | (switch_on "c"), (stop_compilation), |
Mikhail Glushenkov | 058b3f5 | 2010-01-26 14:55:44 +0000 | [diff] [blame] | 236 | (not_empty "arch"), (forward "arch"), |
Mikhail Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 237 | (not_empty "Xassembler"), (forward "Xassembler"), |
Mikhail Glushenkov | 62d1da0 | 2010-03-31 23:51:55 +0000 | [diff] [blame] | 238 | (switch_on "m32"), (forward "m32"), |
| 239 | (switch_on "m64"), (forward "m64"), |
Mikhail Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 240 | (not_empty "Wa,"), (forward "Wa,"))) |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 241 | ]>; |
| 242 | |
| 243 | def llc : Tool< |
Mikhail Glushenkov | 3ab6889 | 2009-10-09 05:45:01 +0000 | [diff] [blame] | 244 | [(in_language ["llvm-bitcode", "llvm-assembler"]), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 245 | (out_language "assembler"), |
| 246 | (output_suffix "s"), |
Dan Gohman | 281ead4 | 2010-04-29 18:46:52 +0000 | [diff] [blame^] | 247 | (command "llc"), |
Mikhail Glushenkov | 4680102 | 2009-03-31 18:33:54 +0000 | [diff] [blame] | 248 | (actions (case |
| 249 | (switch_on "S"), (stop_compilation), |
Mikhail Glushenkov | 6b4967e | 2009-10-17 20:07:49 +0000 | [diff] [blame] | 250 | (switch_on "O0"), (forward "O0"), |
| 251 | (switch_on "O1"), (forward "O1"), |
| 252 | (switch_on "O2"), (forward "O2"), |
| 253 | (switch_on "O3"), (forward "O3"), |
Mikhail Glushenkov | 55cd767 | 2009-12-01 09:47:11 +0000 | [diff] [blame] | 254 | (switch_on "fPIC"), (append_cmd "-relocation-model=pic"), |
| 255 | (switch_on "mdynamic-no-pic"), |
| 256 | (append_cmd "-relocation-model=dynamic-no-pic"), |
Mikhail Glushenkov | b5c2a5d | 2010-02-23 14:29:42 +0000 | [diff] [blame] | 257 | (not_empty "march"), (forward_as "mtune", "-mcpu"), |
| 258 | (not_empty "mtune"), (forward_as "mtune", "-mcpu"), |
Mikhail Glushenkov | 3ab4883 | 2009-12-04 06:38:28 +0000 | [diff] [blame] | 259 | (not_empty "mcpu"), (forward "mcpu"), |
Mikhail Glushenkov | 8461202 | 2009-12-07 17:03:21 +0000 | [diff] [blame] | 260 | (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"), |
Mikhail Glushenkov | 5b9b3ba | 2009-12-07 18:25:54 +0000 | [diff] [blame] | 261 | (not_empty "Wllc,"), (forward_value "Wllc,"))) |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 262 | ]>; |
| 263 | |
| 264 | // Base class for linkers |
| 265 | class llvm_gcc_based_linker <string cmd_prefix> : Tool< |
Mikhail Glushenkov | c1b202a | 2010-04-19 17:25:38 +0000 | [diff] [blame] | 266 | [(in_language ["object-code", "static-library"]), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 267 | (out_language "executable"), |
| 268 | (output_suffix "out"), |
Mikhail Glushenkov | a34f97a | 2010-02-23 09:04:44 +0000 | [diff] [blame] | 269 | (command cmd_prefix), |
Mikhail Glushenkov | be6ee7c | 2010-02-23 09:04:28 +0000 | [diff] [blame] | 270 | (works_on_empty (case (not_empty "filelist"), true, |
| 271 | (default), false)), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 272 | (join), |
| 273 | (actions (case |
| 274 | (switch_on "pthread"), (append_cmd "-lpthread"), |
| 275 | (not_empty "L"), (forward "L"), |
Mikhail Glushenkov | 1851860 | 2009-12-01 05:59:55 +0000 | [diff] [blame] | 276 | (not_empty "F"), (forward "F"), |
Mikhail Glushenkov | 058b3f5 | 2010-01-26 14:55:44 +0000 | [diff] [blame] | 277 | (not_empty "arch"), (forward "arch"), |
Mikhail Glushenkov | 1851860 | 2009-12-01 05:59:55 +0000 | [diff] [blame] | 278 | (not_empty "framework"), (forward "framework"), |
| 279 | (not_empty "weak_framework"), (forward "weak_framework"), |
Mikhail Glushenkov | be6ee7c | 2010-02-23 09:04:28 +0000 | [diff] [blame] | 280 | (not_empty "filelist"), (forward "filelist"), |
Mikhail Glushenkov | fa8182e | 2009-12-04 06:38:45 +0000 | [diff] [blame] | 281 | (switch_on "m32"), (forward "m32"), |
| 282 | (switch_on "m64"), (forward "m64"), |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 283 | (not_empty "l"), (forward "l"), |
Mikhail Glushenkov | 130bede | 2010-02-23 09:05:15 +0000 | [diff] [blame] | 284 | (not_empty "Xlinker"), (forward "Xlinker"), |
Mikhail Glushenkov | 49e496b | 2010-02-13 22:37:13 +0000 | [diff] [blame] | 285 | (not_empty "Wl,"), (forward "Wl,"), |
Mikhail Glushenkov | cbf1aa9 | 2010-04-03 02:00:03 +0000 | [diff] [blame] | 286 | (switch_on "shared"), (forward "shared"), |
Mikhail Glushenkov | 49e496b | 2010-02-13 22:37:13 +0000 | [diff] [blame] | 287 | (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 Glushenkov | 9f2a080 | 2010-02-23 09:04:18 +0000 | [diff] [blame] | 293 | (not_empty "current_version"), (forward "current_version"), |
| 294 | (not_empty "install_name"), (forward "install_name"))) |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 295 | ]>; |
| 296 | |
| 297 | // Default linker |
Mikhail Glushenkov | 4558f48 | 2009-04-21 19:46:10 +0000 | [diff] [blame] | 298 | def llvm_gcc_linker : llvm_gcc_based_linker<"@LLVMGCCCOMMAND@">; |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 299 | // Alternative linker for C++ |
Mikhail Glushenkov | 4558f48 | 2009-04-21 19:46:10 +0000 | [diff] [blame] | 300 | def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@">; |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 301 | |
| 302 | // Language map |
| 303 | |
| 304 | def LanguageMap : LanguageMap< |
| 305 | [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>, |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 306 | LangToSuffixes<"c++-header", ["hpp"]>, |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 307 | LangToSuffixes<"c", ["c"]>, |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 308 | LangToSuffixes<"c-header", ["h"]>, |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 309 | LangToSuffixes<"c-cpp-output", ["i"]>, |
| 310 | LangToSuffixes<"objective-c-cpp-output", ["mi"]>, |
| 311 | LangToSuffixes<"objective-c++", ["mm"]>, |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 312 | LangToSuffixes<"objective-c++-header", ["hmm"]>, |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 313 | LangToSuffixes<"objective-c", ["m"]>, |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 314 | LangToSuffixes<"objective-c-header", ["hm"]>, |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 315 | LangToSuffixes<"assembler", ["s"]>, |
| 316 | LangToSuffixes<"assembler-with-cpp", ["S"]>, |
| 317 | LangToSuffixes<"llvm-assembler", ["ll"]>, |
| 318 | LangToSuffixes<"llvm-bitcode", ["bc"]>, |
Mikhail Glushenkov | 9660c5d | 2010-02-23 09:05:21 +0000 | [diff] [blame] | 319 | LangToSuffixes<"object-code", ["o", "*empty*"]>, |
Mikhail Glushenkov | c1b202a | 2010-04-19 17:25:38 +0000 | [diff] [blame] | 320 | LangToSuffixes<"static-library", ["a", "lib"]>, |
Mikhail Glushenkov | de1e521 | 2008-12-11 10:38:06 +0000 | [diff] [blame] | 321 | LangToSuffixes<"executable", ["out"]> |
| 322 | ]>; |
| 323 | |
| 324 | // Compilation graph |
Anton Korobeynikov | ac67b7e | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 325 | |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 326 | def CompilationGraph : CompilationGraph<[ |
Mikhail Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 327 | 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 Glushenkov | 57a7e94 | 2009-09-10 17:04:32 +0000 | [diff] [blame] | 332 | Edge<"root", "llc">, |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 333 | |
Mikhail Glushenkov | c6e0dbf | 2010-02-23 09:04:33 +0000 | [diff] [blame] | 334 | 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 Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 339 | 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 Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 344 | |
Mikhail Glushenkov | 3ab6889 | 2009-10-09 05:45:01 +0000 | [diff] [blame] | 345 | OptionalEdge<"root", "llvm_as", |
| 346 | (case (switch_on "emit-llvm"), (inc_weight))>, |
Mikhail Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 347 | 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 Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 353 | |
Mikhail Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 354 | Edge<"llc", "llvm_gcc_assembler">, |
| 355 | Edge<"llvm_gcc_assembler", "llvm_gcc_linker">, |
| 356 | OptionalEdge<"llvm_gcc_assembler", "llvm_gcc_cpp_linker", |
Mikhail Glushenkov | e5557f4 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 357 | (case |
Daniel Dunbar | 77e0c85 | 2008-11-08 03:25:47 +0000 | [diff] [blame] | 358 | (or (input_languages_contain "c++"), |
Mikhail Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 359 | (input_languages_contain "objective-c++")), |
Daniel Dunbar | 77e0c85 | 2008-11-08 03:25:47 +0000 | [diff] [blame] | 360 | (inc_weight), |
Mikhail Glushenkov | e5557f4 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 361 | (or (parameter_equals "linker", "g++"), |
| 362 | (parameter_equals "linker", "c++")), (inc_weight))>, |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 363 | |
Mikhail Glushenkov | 978d498 | 2008-05-06 18:13:00 +0000 | [diff] [blame] | 364 | |
Mikhail Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 365 | Edge<"root", "llvm_gcc_linker">, |
| 366 | OptionalEdge<"root", "llvm_gcc_cpp_linker", |
Mikhail Glushenkov | e5557f4 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 367 | (case |
Daniel Dunbar | 77e0c85 | 2008-11-08 03:25:47 +0000 | [diff] [blame] | 368 | (or (input_languages_contain "c++"), |
Mikhail Glushenkov | 0108877 | 2008-11-17 17:29:18 +0000 | [diff] [blame] | 369 | (input_languages_contain "objective-c++")), |
Daniel Dunbar | 77e0c85 | 2008-11-08 03:25:47 +0000 | [diff] [blame] | 370 | (inc_weight), |
Mikhail Glushenkov | e5557f4 | 2008-05-30 06:08:50 +0000 | [diff] [blame] | 371 | (or (parameter_equals "linker", "g++"), |
| 372 | (parameter_equals "linker", "c++")), (inc_weight))> |
Anton Korobeynikov | ac67b7e | 2008-03-23 08:57:20 +0000 | [diff] [blame] | 373 | ]>; |