2009-10-08 04:40:28 +00:00
|
|
|
//===- Base.td - LLVMC toolchain descriptions --------------*- tablegen -*-===//
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-10-08 04:40:28 +00:00
|
|
|
// This file contains compilation graph description used by llvmc.
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-12-11 10:38:06 +00:00
|
|
|
// Options
|
|
|
|
|
|
|
|
def OptList : OptionList<[
|
|
|
|
(switch_option "emit-llvm",
|
|
|
|
(help "Emit LLVM .ll files instead of native object files")),
|
|
|
|
(switch_option "E",
|
|
|
|
(help "Stop after the preprocessing stage, do not run the compiler")),
|
|
|
|
(switch_option "fsyntax-only",
|
|
|
|
(help "Stop after checking the input for syntax errors")),
|
|
|
|
(switch_option "opt",
|
|
|
|
(help "Enable opt")),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_option "O0",
|
2010-03-05 04:46:39 +00:00
|
|
|
(help "Turn off optimization"), (zero_or_more)),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_option "O1",
|
2010-03-05 04:46:39 +00:00
|
|
|
(help "Optimization level 1"), (zero_or_more)),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_option "O2",
|
2010-03-05 04:46:39 +00:00
|
|
|
(help "Optimization level 2"), (zero_or_more)),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_option "O3",
|
2010-03-05 04:46:39 +00:00
|
|
|
(help "Optimization level 3"), (zero_or_more)),
|
2008-12-11 10:38:06 +00:00
|
|
|
(switch_option "S",
|
|
|
|
(help "Stop after compilation, do not assemble")),
|
|
|
|
(switch_option "c",
|
|
|
|
(help "Compile and assemble, but do not link")),
|
2009-12-04 06:38:45 +00:00
|
|
|
(switch_option "m32",
|
|
|
|
(help "Generate code for a 32-bit environment"), (hidden)),
|
|
|
|
(switch_option "m64",
|
|
|
|
(help "Generate code for a 64-bit environment"), (hidden)),
|
2009-12-01 09:47:11 +00:00
|
|
|
(switch_option "fPIC",
|
|
|
|
(help "Relocation model: PIC"), (hidden)),
|
|
|
|
(switch_option "mdynamic-no-pic",
|
|
|
|
(help "Relocation model: dynamic-no-pic"), (hidden)),
|
2008-12-11 10:38:06 +00:00
|
|
|
(parameter_option "linker",
|
|
|
|
(help "Choose linker (possible values: gcc, g++)")),
|
2009-12-04 06:38:28 +00:00
|
|
|
(parameter_option "mtune",
|
2010-11-22 17:10:09 +00:00
|
|
|
(help "Target a specific CPU type"), (forward_not_split)),
|
2010-11-28 00:31:13 +00:00
|
|
|
(parameter_list_option "march",
|
|
|
|
(help "Generate code for the specified machine type")),
|
2009-12-04 06:38:28 +00:00
|
|
|
(parameter_option "mcpu",
|
2010-02-23 14:29:42 +00:00
|
|
|
(help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)),
|
2010-12-15 01:22:20 +00:00
|
|
|
(parameter_option "mfpu",
|
|
|
|
(help "Specify type of floating point unit"),
|
|
|
|
(hidden), (forward_not_split)),
|
2010-12-15 01:22:10 +00:00
|
|
|
(parameter_option "mabi",
|
|
|
|
(help "Generate code for the specified ABI"), (hidden)),
|
|
|
|
(parameter_option "mfloat-abi",
|
|
|
|
(help "Specifies which floating-point ABI to use"), (hidden)),
|
2010-02-13 22:37:00 +00:00
|
|
|
(switch_option "mfix-and-continue",
|
|
|
|
(help "Needed by gdb to load .o files dynamically"), (hidden)),
|
2009-10-08 04:40:28 +00:00
|
|
|
(parameter_option "MF",
|
|
|
|
(help "Specify a file to write dependencies to"), (hidden)),
|
2010-01-02 08:27:10 +00:00
|
|
|
(parameter_list_option "MT",
|
2009-10-08 04:40:28 +00:00
|
|
|
(help "Change the name of the rule emitted by dependency generation"),
|
|
|
|
(hidden)),
|
2008-12-11 10:38:06 +00:00
|
|
|
(parameter_list_option "include",
|
|
|
|
(help "Include the named file prior to preprocessing")),
|
2010-01-26 14:55:30 +00:00
|
|
|
(parameter_list_option "iquote",
|
|
|
|
(help "Search dir only for files requested with #inlcude \"file\""),
|
|
|
|
(hidden)),
|
2008-12-11 10:38:06 +00:00
|
|
|
(prefix_list_option "I",
|
|
|
|
(help "Add a directory to include path")),
|
2009-10-08 04:40:28 +00:00
|
|
|
(prefix_list_option "D",
|
|
|
|
(help "Define a macro")),
|
2010-02-23 09:05:15 +00:00
|
|
|
(parameter_list_option "Xpreprocessor", (hidden),
|
|
|
|
(help "Pass options to preprocessor")),
|
2009-12-07 18:25:54 +00:00
|
|
|
(prefix_list_option "Wa,", (comma_separated),
|
2008-12-11 10:38:06 +00:00
|
|
|
(help "Pass options to assembler")),
|
2010-02-23 09:05:15 +00:00
|
|
|
(parameter_list_option "Xassembler", (hidden),
|
|
|
|
(help "Pass options to assembler")),
|
2009-12-07 18:25:54 +00:00
|
|
|
(prefix_list_option "Wllc,", (comma_separated),
|
2009-03-31 18:33:54 +00:00
|
|
|
(help "Pass options to llc")),
|
2008-12-11 10:38:06 +00:00
|
|
|
(prefix_list_option "Wl,",
|
2008-12-11 22:19:14 +00:00
|
|
|
(help "Pass options to linker")),
|
2010-02-23 09:05:15 +00:00
|
|
|
(parameter_list_option "Xlinker", (hidden),
|
|
|
|
(help "Pass options to linker")),
|
2009-12-07 18:25:54 +00:00
|
|
|
(prefix_list_option "Wo,", (comma_separated),
|
2009-12-07 17:03:21 +00:00
|
|
|
(help "Pass options to opt")),
|
|
|
|
(prefix_list_option "m",
|
|
|
|
(help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
|
2010-09-21 11:57:04 +00:00
|
|
|
(hidden))
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def LinkerOptList : OptionList<[
|
|
|
|
(prefix_list_option "L",
|
|
|
|
(help "Add a directory to link path")),
|
|
|
|
(prefix_list_option "l",
|
|
|
|
(help "Search a library when linking")),
|
|
|
|
(parameter_option "filelist", (hidden),
|
|
|
|
(help "Link the files listed in file")),
|
|
|
|
(switch_option "nostartfiles",
|
|
|
|
(help "Do not use the standard system startup files when linking"),
|
|
|
|
(hidden)),
|
|
|
|
(switch_option "nodefaultlibs",
|
|
|
|
(help "Do not use the standard system libraries when linking"), (hidden)),
|
|
|
|
(switch_option "nostdlib",
|
|
|
|
(help
|
|
|
|
"Do not use the standard system startup files or libraries when linking"),
|
|
|
|
(hidden)),
|
|
|
|
(switch_option "pie",
|
|
|
|
(help "Produce a position independent executable"), (hidden)),
|
|
|
|
(switch_option "rdynamic",
|
|
|
|
(help "Add all symbols to the dynamic export table"), (hidden)),
|
|
|
|
(switch_option "s",
|
|
|
|
(help "Strip all symbols"), (hidden)),
|
|
|
|
(switch_option "static",
|
|
|
|
(help "Do not link against shared libraries"), (hidden)),
|
|
|
|
(switch_option "static-libgcc",
|
|
|
|
(help "Use static libgcc"), (hidden)),
|
|
|
|
(switch_option "shared",
|
|
|
|
(help "Create a DLL instead of the regular executable")),
|
|
|
|
(switch_option "shared-libgcc",
|
|
|
|
(help "Use shared libgcc"), (hidden)),
|
|
|
|
(parameter_option "T",
|
|
|
|
(help "Read linker script"), (hidden)),
|
|
|
|
(parameter_option "u",
|
|
|
|
(help "Start with undefined reference to SYMBOL"), (hidden)),
|
|
|
|
(switch_option "pthread",
|
|
|
|
(help "Enable threads")),
|
|
|
|
|
|
|
|
// TODO: Add a conditional compilation mechanism to make Darwin-only options
|
|
|
|
// like '-arch' really Darwin-only.
|
|
|
|
(parameter_option "arch",
|
|
|
|
(help "Compile for the specified target architecture"), (hidden)),
|
|
|
|
(prefix_list_option "F",
|
|
|
|
(help "Add a directory to framework search path")),
|
|
|
|
(parameter_list_option "framework",
|
|
|
|
(help "Specifies a framework to link against")),
|
|
|
|
(parameter_list_option "weak_framework",
|
|
|
|
(help "Specifies a framework to weakly link against"), (hidden)),
|
2010-02-13 22:37:13 +00:00
|
|
|
(switch_option "dynamiclib", (hidden),
|
|
|
|
(help "Produce a dynamic library")),
|
|
|
|
(switch_option "prebind", (hidden),
|
|
|
|
(help "Prebind all undefined symbols")),
|
|
|
|
(switch_option "dead_strip", (hidden),
|
|
|
|
(help "Remove unreachable blocks of code")),
|
|
|
|
(switch_option "single_module", (hidden),
|
|
|
|
(help "Build the library so it contains only one module")),
|
2010-02-23 09:04:18 +00:00
|
|
|
(parameter_option "install_name", (hidden),
|
|
|
|
(help "File name the library will be installed in")),
|
2010-02-13 22:37:13 +00:00
|
|
|
(parameter_option "compatibility_version", (hidden),
|
|
|
|
(help "Compatibility version number")),
|
|
|
|
(parameter_option "current_version", (hidden),
|
|
|
|
(help "Current version number"))
|
2008-12-11 10:38:06 +00:00
|
|
|
]>;
|
|
|
|
|
2009-10-17 20:09:29 +00:00
|
|
|
// Option preprocessor.
|
|
|
|
|
|
|
|
def Preprocess : OptionPreprocessor<
|
2010-10-23 07:32:46 +00:00
|
|
|
(case (not (any_switch_on "O0", "O1", "O2", "O3")),
|
2009-12-17 07:49:16 +00:00
|
|
|
(set_option "O2"),
|
2010-10-23 07:32:46 +00:00
|
|
|
(and (switch_on "O3"), (any_switch_on "O0", "O1", "O2")),
|
|
|
|
(unset_option "O0", "O1", "O2"),
|
|
|
|
(and (switch_on "O2"), (any_switch_on "O0", "O1")),
|
|
|
|
(unset_option "O0", "O1"),
|
|
|
|
(switch_on "O1", "O0"),
|
2009-10-17 20:09:29 +00:00
|
|
|
(unset_option "O0"))
|
|
|
|
>;
|
|
|
|
|
2008-12-11 10:38:06 +00:00
|
|
|
// Tools
|
|
|
|
|
2010-10-23 07:32:46 +00:00
|
|
|
class llvm_gcc_based <string cmd, string in_lang, string E_ext, dag out_lang,
|
2010-10-14 11:22:06 +00:00
|
|
|
string out_ext> : Tool<
|
2008-12-11 10:38:06 +00:00
|
|
|
[(in_language in_lang),
|
2010-10-23 07:32:46 +00:00
|
|
|
out_lang,
|
2010-09-21 14:59:47 +00:00
|
|
|
(output_suffix out_ext),
|
2010-09-21 11:57:04 +00:00
|
|
|
(command cmd),
|
2008-12-11 10:38:06 +00:00
|
|
|
(actions
|
|
|
|
(case
|
2010-02-23 09:04:44 +00:00
|
|
|
(and (not_empty "o"),
|
|
|
|
(multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
|
2009-09-28 01:16:42 +00:00
|
|
|
(error "cannot specify -o with -c or -S with multiple files"),
|
2010-02-23 09:04:44 +00:00
|
|
|
(switch_on "E"),
|
|
|
|
[(forward "E"), (stop_compilation), (output_suffix E_ext)],
|
|
|
|
(and (switch_on "E"), (empty "o")), (no_out_file),
|
2010-09-22 09:00:41 +00:00
|
|
|
|
|
|
|
// ('-emit-llvm') && !('opt') -> stop compilation
|
|
|
|
(and (switch_on "emit-llvm"), (not (switch_on "opt"))),
|
|
|
|
(stop_compilation),
|
|
|
|
// ('-S' && '-emit-llvm') && !('opt') -> output .ll
|
2010-10-23 07:32:46 +00:00
|
|
|
(and (switch_on "emit-llvm", "S"), (not (switch_on "opt"))),
|
2010-09-22 09:00:41 +00:00
|
|
|
[(forward "S"), (output_suffix "ll")],
|
|
|
|
// Ususally just output .bc
|
|
|
|
(not (switch_on "fsyntax-only")),
|
|
|
|
[(append_cmd "-c"), (append_cmd "-emit-llvm")],
|
|
|
|
|
|
|
|
// -fsyntax-only
|
2010-02-23 09:04:44 +00:00
|
|
|
(switch_on "fsyntax-only"), [(forward "fsyntax-only"),
|
|
|
|
(no_out_file), (stop_compilation)],
|
|
|
|
|
|
|
|
// Forwards
|
2010-02-23 09:05:15 +00:00
|
|
|
(not_empty "Xpreprocessor"), (forward "Xpreprocessor"),
|
2008-12-11 10:38:06 +00:00
|
|
|
(not_empty "include"), (forward "include"),
|
2010-01-26 14:55:30 +00:00
|
|
|
(not_empty "iquote"), (forward "iquote"),
|
2009-12-01 06:51:30 +00:00
|
|
|
(not_empty "save-temps"), (append_cmd "-save-temps"),
|
2009-10-08 06:03:38 +00:00
|
|
|
(not_empty "I"), (forward "I"),
|
2009-12-01 05:59:55 +00:00
|
|
|
(not_empty "F"), (forward "F"),
|
2009-10-08 06:03:38 +00:00
|
|
|
(not_empty "D"), (forward "D"),
|
2010-01-26 14:55:44 +00:00
|
|
|
(not_empty "arch"), (forward "arch"),
|
2009-12-04 06:38:28 +00:00
|
|
|
(not_empty "march"), (forward "march"),
|
|
|
|
(not_empty "mcpu"), (forward "mcpu"),
|
2010-11-22 17:10:09 +00:00
|
|
|
(not_empty "mtune"), (forward "mtune"),
|
2010-12-15 01:22:20 +00:00
|
|
|
(not_empty "mfpu"), (forward "mfpu"),
|
2010-12-15 01:22:10 +00:00
|
|
|
(not_empty "mabi"), (forward "mabi"),
|
|
|
|
(not_empty "mfloat-abi"), (forward "mfloat-abi"),
|
2009-12-07 17:03:21 +00:00
|
|
|
(not_empty "m"), (forward "m"),
|
2010-02-13 22:37:00 +00:00
|
|
|
(switch_on "mfix-and-continue"), (forward "mfix-and-continue"),
|
2009-12-04 06:38:45 +00:00
|
|
|
(switch_on "m32"), (forward "m32"),
|
|
|
|
(switch_on "m64"), (forward "m64"),
|
2010-01-02 08:27:23 +00:00
|
|
|
(switch_on "O0"), (forward "O0"),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_on "O1"), (forward "O1"),
|
|
|
|
(switch_on "O2"), (forward "O2"),
|
|
|
|
(switch_on "O3"), (forward "O3"),
|
2009-12-01 09:47:11 +00:00
|
|
|
(switch_on "fPIC"), (forward "fPIC"),
|
|
|
|
(switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"),
|
2009-10-08 06:03:38 +00:00
|
|
|
(not_empty "MF"), (forward "MF"),
|
2009-10-08 04:40:28 +00:00
|
|
|
(not_empty "MT"), (forward "MT"))),
|
2008-12-11 10:38:06 +00:00
|
|
|
(sink)
|
|
|
|
]>;
|
|
|
|
|
2010-09-21 14:59:47 +00:00
|
|
|
class llvm_gcc_comp_based <string cmd, string in_lang, string E_ext>
|
2010-10-23 07:32:46 +00:00
|
|
|
: llvm_gcc_based<cmd, in_lang, E_ext,
|
|
|
|
(out_language "llvm-bitcode", "object-code"), "bc">;
|
2010-09-21 14:59:47 +00:00
|
|
|
|
|
|
|
class llvm_gcc_pch_based <string cmd, string in_lang, string E_ext>
|
2010-10-23 07:32:46 +00:00
|
|
|
: llvm_gcc_based<cmd, in_lang, E_ext,
|
|
|
|
(out_language "precompiled-header"), "gch">;
|
2010-09-21 14:59:47 +00:00
|
|
|
|
|
|
|
def llvm_gcc_c : llvm_gcc_comp_based
|
|
|
|
<"@LLVMGCCCOMMAND@ -x c", "c", "i">;
|
|
|
|
def llvm_gcc_cpp : llvm_gcc_comp_based
|
|
|
|
<"@LLVMGXXCOMMAND@ -x c++", "c++", "i">;
|
|
|
|
def llvm_gcc_m : llvm_gcc_comp_based
|
|
|
|
<"@LLVMGCCCOMMAND@ -x objective-c", "objective-c", "mi">;
|
|
|
|
def llvm_gcc_mxx : llvm_gcc_comp_based
|
|
|
|
<"@LLVMGCCCOMMAND@ -x objective-c++", "objective-c++", "mi">;
|
2010-02-23 09:04:33 +00:00
|
|
|
|
2010-09-21 14:59:47 +00:00
|
|
|
def llvm_gcc_c_pch : llvm_gcc_pch_based
|
|
|
|
<"@LLVMGCCCOMMAND@ -x c-header", "c-header", "i">;
|
|
|
|
def llvm_gcc_cpp_pch : llvm_gcc_pch_based
|
|
|
|
<"@LLVMGXXCOMMAND@ -x c++-header", "c++-header", "i">;
|
|
|
|
def llvm_gcc_m_pch : llvm_gcc_pch_based
|
|
|
|
<"@LLVMGCCCOMMAND@ -x objective-c-header", "objective-c-header", "mi">;
|
|
|
|
def llvm_gcc_mxx_pch : llvm_gcc_pch_based
|
|
|
|
<"@LLVMGCCCOMMAND@ -x objective-c++-header", "objective-c++-header", "mi">;
|
2008-12-11 10:38:06 +00:00
|
|
|
|
|
|
|
def opt : Tool<
|
|
|
|
[(in_language "llvm-bitcode"),
|
|
|
|
(out_language "llvm-bitcode"),
|
2010-09-22 09:00:35 +00:00
|
|
|
(output_suffix "opt.bc"),
|
2010-09-22 09:00:41 +00:00
|
|
|
(actions (case (switch_on "emit-llvm"), (stop_compilation),
|
2010-10-23 07:32:46 +00:00
|
|
|
(switch_on "emit-llvm", "S"),
|
2010-09-22 09:00:41 +00:00
|
|
|
[(append_cmd "-S"), (output_suffix "ll")],
|
|
|
|
(not_empty "Wo,"), (forward_value "Wo,"),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_on "O1"), (forward "O1"),
|
|
|
|
(switch_on "O2"), (forward "O2"),
|
|
|
|
(switch_on "O3"), (forward "O3"))),
|
2010-02-23 09:04:44 +00:00
|
|
|
(command "opt -f")
|
2008-12-11 10:38:06 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def llvm_as : Tool<
|
|
|
|
[(in_language "llvm-assembler"),
|
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2010-02-23 09:04:44 +00:00
|
|
|
(command "llvm-as"),
|
2011-02-19 00:33:27 +00:00
|
|
|
(actions (case (and (switch_on "emit-llvm"), (not (switch_on "opt"))),
|
|
|
|
(stop_compilation)))
|
2008-12-11 10:38:06 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def llvm_gcc_assembler : Tool<
|
|
|
|
[(in_language "assembler"),
|
|
|
|
(out_language "object-code"),
|
|
|
|
(output_suffix "o"),
|
2010-02-23 09:04:44 +00:00
|
|
|
(command "@LLVMGCCCOMMAND@ -c -x assembler"),
|
2008-12-11 10:38:06 +00:00
|
|
|
(actions (case
|
|
|
|
(switch_on "c"), (stop_compilation),
|
2010-01-26 14:55:44 +00:00
|
|
|
(not_empty "arch"), (forward "arch"),
|
2010-02-23 09:05:15 +00:00
|
|
|
(not_empty "Xassembler"), (forward "Xassembler"),
|
2010-12-15 01:22:05 +00:00
|
|
|
(not_empty "march"), (forward "march"),
|
|
|
|
(not_empty "mcpu"), (forward "mcpu"),
|
|
|
|
(not_empty "mtune"), (forward "mtune"),
|
2010-12-15 01:22:10 +00:00
|
|
|
(not_empty "mabi"), (forward "mabi"),
|
|
|
|
(not_empty "mfloat-abi"), (forward "mfloat-abi"),
|
2010-03-31 23:51:55 +00:00
|
|
|
(switch_on "m32"), (forward "m32"),
|
|
|
|
(switch_on "m64"), (forward "m64"),
|
2010-02-23 09:05:15 +00:00
|
|
|
(not_empty "Wa,"), (forward "Wa,")))
|
2008-12-11 10:38:06 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def llc : Tool<
|
2010-10-23 07:32:46 +00:00
|
|
|
[(in_language "llvm-bitcode", "llvm-assembler"),
|
2008-12-11 10:38:06 +00:00
|
|
|
(out_language "assembler"),
|
|
|
|
(output_suffix "s"),
|
2010-04-29 18:46:52 +00:00
|
|
|
(command "llc"),
|
2009-03-31 18:33:54 +00:00
|
|
|
(actions (case
|
|
|
|
(switch_on "S"), (stop_compilation),
|
2009-10-17 20:07:49 +00:00
|
|
|
(switch_on "O0"), (forward "O0"),
|
|
|
|
(switch_on "O1"), (forward "O1"),
|
|
|
|
(switch_on "O2"), (forward "O2"),
|
|
|
|
(switch_on "O3"), (forward "O3"),
|
2009-12-01 09:47:11 +00:00
|
|
|
(switch_on "fPIC"), (append_cmd "-relocation-model=pic"),
|
|
|
|
(switch_on "mdynamic-no-pic"),
|
|
|
|
(append_cmd "-relocation-model=dynamic-no-pic"),
|
2010-11-28 00:31:13 +00:00
|
|
|
(not_empty "march"), (forward_transformed_value
|
|
|
|
"march", "ConvertMArchToMAttr"),
|
2010-12-15 01:22:20 +00:00
|
|
|
(not_empty "mcpu"), (forward_transformed_value "mcpu", "ConvertMCpu"),
|
2010-11-22 17:10:09 +00:00
|
|
|
(and (not_empty "mtune"), (empty "mcpu")),
|
|
|
|
(forward_as "mtune", "-mcpu"),
|
2010-12-15 01:22:20 +00:00
|
|
|
(not_empty "mfpu"), (forward_transformed_value "mfpu", "ConvertMFpu"),
|
2009-12-07 17:03:21 +00:00
|
|
|
(not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
|
2009-12-07 18:25:54 +00:00
|
|
|
(not_empty "Wllc,"), (forward_value "Wllc,")))
|
2008-12-11 10:38:06 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
// Base class for linkers
|
2010-09-21 11:57:04 +00:00
|
|
|
class llvm_gcc_based_linker <string cmd, dag on_empty> : Tool<
|
2010-10-23 07:32:46 +00:00
|
|
|
[(in_language "object-code", "static-library", "dynamic-library"),
|
2008-12-11 10:38:06 +00:00
|
|
|
(out_language "executable"),
|
|
|
|
(output_suffix "out"),
|
2010-09-21 11:57:04 +00:00
|
|
|
(command cmd),
|
2010-07-01 01:00:32 +00:00
|
|
|
(works_on_empty (case (and (not_empty "filelist"), on_empty), true,
|
2010-02-23 09:04:28 +00:00
|
|
|
(default), false)),
|
2008-12-11 10:38:06 +00:00
|
|
|
(join),
|
|
|
|
(actions (case
|
|
|
|
(switch_on "pthread"), (append_cmd "-lpthread"),
|
|
|
|
(not_empty "L"), (forward "L"),
|
2009-12-01 05:59:55 +00:00
|
|
|
(not_empty "F"), (forward "F"),
|
2010-01-26 14:55:44 +00:00
|
|
|
(not_empty "arch"), (forward "arch"),
|
2009-12-01 05:59:55 +00:00
|
|
|
(not_empty "framework"), (forward "framework"),
|
|
|
|
(not_empty "weak_framework"), (forward "weak_framework"),
|
2010-02-23 09:04:28 +00:00
|
|
|
(not_empty "filelist"), (forward "filelist"),
|
2010-12-15 01:22:05 +00:00
|
|
|
(not_empty "march"), (forward "march"),
|
|
|
|
(not_empty "mcpu"), (forward "mcpu"),
|
|
|
|
(not_empty "mtune"), (forward "mtune"),
|
2010-12-15 01:22:10 +00:00
|
|
|
(not_empty "mabi"), (forward "mabi"),
|
|
|
|
(not_empty "mfloat-abi"), (forward "mfloat-abi"),
|
2009-12-04 06:38:45 +00:00
|
|
|
(switch_on "m32"), (forward "m32"),
|
|
|
|
(switch_on "m64"), (forward "m64"),
|
2008-12-11 10:38:06 +00:00
|
|
|
(not_empty "l"), (forward "l"),
|
2010-02-23 09:05:15 +00:00
|
|
|
(not_empty "Xlinker"), (forward "Xlinker"),
|
2010-02-13 22:37:13 +00:00
|
|
|
(not_empty "Wl,"), (forward "Wl,"),
|
2010-09-21 11:57:04 +00:00
|
|
|
(switch_on "nostartfiles"), (forward "nostartfiles"),
|
|
|
|
(switch_on "nodefaultlibs"), (forward "nodefaultlibs"),
|
|
|
|
(switch_on "nostdlib"), (forward "nostdlib"),
|
|
|
|
(switch_on "pie"), (forward "pie"),
|
|
|
|
(switch_on "rdynamic"), (forward "rdynamic"),
|
|
|
|
(switch_on "s"), (forward "s"),
|
|
|
|
(switch_on "static"), (forward "static"),
|
|
|
|
(switch_on "static-libgcc"), (forward "static-libgcc"),
|
2010-04-03 02:00:03 +00:00
|
|
|
(switch_on "shared"), (forward "shared"),
|
2010-09-21 11:57:04 +00:00
|
|
|
(switch_on "shared-libgcc"), (forward "shared-libgcc"),
|
|
|
|
(not_empty "T"), (forward "T"),
|
|
|
|
(not_empty "u"), (forward "u"),
|
2010-02-13 22:37:13 +00:00
|
|
|
(switch_on "dynamiclib"), (forward "dynamiclib"),
|
|
|
|
(switch_on "prebind"), (forward "prebind"),
|
|
|
|
(switch_on "dead_strip"), (forward "dead_strip"),
|
|
|
|
(switch_on "single_module"), (forward "single_module"),
|
|
|
|
(not_empty "compatibility_version"),
|
|
|
|
(forward "compatibility_version"),
|
2010-02-23 09:04:18 +00:00
|
|
|
(not_empty "current_version"), (forward "current_version"),
|
|
|
|
(not_empty "install_name"), (forward "install_name")))
|
2008-12-11 10:38:06 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
// Default linker
|
2010-07-01 01:00:32 +00:00
|
|
|
def llvm_gcc_linker : llvm_gcc_based_linker<"@LLVMGCCCOMMAND@",
|
|
|
|
(not (or (parameter_equals "linker", "g++"),
|
|
|
|
(parameter_equals "linker", "c++")))>;
|
2008-12-11 10:38:06 +00:00
|
|
|
// Alternative linker for C++
|
2010-07-01 01:00:32 +00:00
|
|
|
def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@",
|
|
|
|
(or (parameter_equals "linker", "g++"),
|
|
|
|
(parameter_equals "linker", "c++"))>;
|
2008-12-11 10:38:06 +00:00
|
|
|
|
|
|
|
// Language map
|
|
|
|
|
2010-08-23 23:21:23 +00:00
|
|
|
def LanguageMap : LanguageMap<[
|
2010-09-21 14:59:47 +00:00
|
|
|
(lang_to_suffixes "precompiled-header", ["gch", "pch"]),
|
2010-08-23 23:21:23 +00:00
|
|
|
(lang_to_suffixes "c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]),
|
|
|
|
(lang_to_suffixes "c++-header", "hpp"),
|
|
|
|
(lang_to_suffixes "c", "c"),
|
|
|
|
(lang_to_suffixes "c-header", "h"),
|
|
|
|
(lang_to_suffixes "c-cpp-output", "i"),
|
|
|
|
(lang_to_suffixes "objective-c-cpp-output", "mi"),
|
|
|
|
(lang_to_suffixes "objective-c++", "mm"),
|
|
|
|
(lang_to_suffixes "objective-c++-header", "hmm"),
|
|
|
|
(lang_to_suffixes "objective-c", "m"),
|
|
|
|
(lang_to_suffixes "objective-c-header", "hm"),
|
|
|
|
(lang_to_suffixes "assembler", "s"),
|
|
|
|
(lang_to_suffixes "assembler-with-cpp", "S"),
|
|
|
|
(lang_to_suffixes "llvm-assembler", "ll"),
|
|
|
|
(lang_to_suffixes "llvm-bitcode", "bc"),
|
|
|
|
(lang_to_suffixes "object-code", ["o", "*empty*"]),
|
|
|
|
(lang_to_suffixes "static-library", ["a", "lib"]),
|
2010-09-02 14:06:21 +00:00
|
|
|
(lang_to_suffixes "dynamic-library", ["so", "dylib", "dll"]),
|
2010-10-14 11:22:06 +00:00
|
|
|
(lang_to_suffixes "executable", "out")
|
2010-08-23 23:21:23 +00:00
|
|
|
]>;
|
2008-12-11 10:38:06 +00:00
|
|
|
|
|
|
|
// Compilation graph
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-06 16:35:25 +00:00
|
|
|
def CompilationGraph : CompilationGraph<[
|
2010-08-23 23:21:23 +00:00
|
|
|
(edge "root", "llvm_gcc_c"),
|
|
|
|
(edge "root", "llvm_gcc_assembler"),
|
|
|
|
(edge "root", "llvm_gcc_cpp"),
|
|
|
|
(edge "root", "llvm_gcc_m"),
|
|
|
|
(edge "root", "llvm_gcc_mxx"),
|
|
|
|
(edge "root", "llc"),
|
2008-11-17 17:29:18 +00:00
|
|
|
|
2010-08-23 23:21:23 +00:00
|
|
|
(edge "root", "llvm_gcc_c_pch"),
|
|
|
|
(edge "root", "llvm_gcc_cpp_pch"),
|
|
|
|
(edge "root", "llvm_gcc_m_pch"),
|
|
|
|
(edge "root", "llvm_gcc_mxx_pch"),
|
2010-02-23 09:04:33 +00:00
|
|
|
|
2010-08-23 23:21:23 +00:00
|
|
|
(edge "llvm_gcc_c", "llc"),
|
|
|
|
(edge "llvm_gcc_cpp", "llc"),
|
|
|
|
(edge "llvm_gcc_m", "llc"),
|
|
|
|
(edge "llvm_gcc_mxx", "llc"),
|
|
|
|
(edge "llvm_as", "llc"),
|
2008-11-17 17:29:18 +00:00
|
|
|
|
2010-08-23 23:21:23 +00:00
|
|
|
(optional_edge "root", "llvm_as",
|
2011-02-19 00:33:27 +00:00
|
|
|
(case (or (switch_on "emit-llvm"),
|
|
|
|
(switch_on "opt")), (inc_weight))),
|
2010-08-23 23:21:23 +00:00
|
|
|
(optional_edge "llvm_gcc_c", "opt",
|
|
|
|
(case (switch_on "opt"), (inc_weight))),
|
|
|
|
(optional_edge "llvm_gcc_cpp", "opt",
|
|
|
|
(case (switch_on "opt"), (inc_weight))),
|
|
|
|
(optional_edge "llvm_gcc_m", "opt",
|
|
|
|
(case (switch_on "opt"), (inc_weight))),
|
|
|
|
(optional_edge "llvm_gcc_mxx", "opt",
|
|
|
|
(case (switch_on "opt"), (inc_weight))),
|
|
|
|
(optional_edge "llvm_as", "opt",
|
|
|
|
(case (switch_on "opt"), (inc_weight))),
|
|
|
|
(edge "opt", "llc"),
|
2008-11-17 17:29:18 +00:00
|
|
|
|
2010-08-23 23:21:23 +00:00
|
|
|
(edge "llc", "llvm_gcc_assembler"),
|
|
|
|
(edge "llvm_gcc_assembler", "llvm_gcc_linker"),
|
|
|
|
(optional_edge "llvm_gcc_assembler", "llvm_gcc_cpp_linker",
|
2008-05-30 06:08:50 +00:00
|
|
|
(case
|
2008-11-08 03:25:47 +00:00
|
|
|
(or (input_languages_contain "c++"),
|
2008-11-17 17:29:18 +00:00
|
|
|
(input_languages_contain "objective-c++")),
|
2008-11-08 03:25:47 +00:00
|
|
|
(inc_weight),
|
2008-05-30 06:08:50 +00:00
|
|
|
(or (parameter_equals "linker", "g++"),
|
2010-08-23 23:21:23 +00:00
|
|
|
(parameter_equals "linker", "c++")), (inc_weight))),
|
2008-05-06 18:10:20 +00:00
|
|
|
|
2008-05-06 18:13:00 +00:00
|
|
|
|
2010-08-23 23:21:23 +00:00
|
|
|
(edge "root", "llvm_gcc_linker"),
|
|
|
|
(optional_edge "root", "llvm_gcc_cpp_linker",
|
2008-05-30 06:08:50 +00:00
|
|
|
(case
|
2008-11-08 03:25:47 +00:00
|
|
|
(or (input_languages_contain "c++"),
|
2008-11-17 17:29:18 +00:00
|
|
|
(input_languages_contain "objective-c++")),
|
2008-11-08 03:25:47 +00:00
|
|
|
(inc_weight),
|
2008-05-30 06:08:50 +00:00
|
|
|
(or (parameter_equals "linker", "g++"),
|
2010-08-23 23:21:23 +00:00
|
|
|
(parameter_equals "linker", "c++")), (inc_weight)))
|
|
|
|
]>;
|