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