diff options
Diffstat (limited to 'tools/llvmc/src/Base.td.in')
-rw-r--r-- | tools/llvmc/src/Base.td.in | 188 |
1 files changed, 122 insertions, 66 deletions
diff --git a/tools/llvmc/src/Base.td.in b/tools/llvmc/src/Base.td.in index afc4053..cefaf48 100644 --- a/tools/llvmc/src/Base.td.in +++ b/tools/llvmc/src/Base.td.in @@ -35,8 +35,6 @@ def OptList : OptionList<[ (help "Stop after compilation, do not assemble")), (switch_option "c", (help "Compile and assemble, but do not link")), - (switch_option "pthread", - (help "Enable threads")), (switch_option "m32", (help "Generate code for a 32-bit environment"), (hidden)), (switch_option "m64", @@ -45,18 +43,10 @@ def OptList : OptionList<[ (help "Relocation model: PIC"), (hidden)), (switch_option "mdynamic-no-pic", (help "Relocation model: dynamic-no-pic"), (hidden)), - (switch_option "shared", - (help "Create a DLL instead of the regular executable")), (parameter_option "linker", (help "Choose linker (possible values: gcc, g++)")), (parameter_option "mtune", (help "Target a specific CPU type"), (hidden), (forward_not_split)), - - // 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)), (parameter_option "march", (help "A synonym for -mtune"), (hidden), (forward_not_split)), (parameter_option "mcpu", @@ -73,14 +63,6 @@ def OptList : OptionList<[ (parameter_list_option "iquote", (help "Search dir only for files requested with #inlcude \"file\""), (hidden)), - (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)), - (parameter_option "filelist", (hidden), - (help "Link the files listed in file")), - (prefix_list_option "F", - (help "Add a directory to framework search path")), (prefix_list_option "I", (help "Add a directory to include path")), (prefix_list_option "D", @@ -93,10 +75,6 @@ def OptList : OptionList<[ (help "Pass options to assembler")), (prefix_list_option "Wllc,", (comma_separated), (help "Pass options to llc")), - (prefix_list_option "L", - (help "Add a directory to link path")), - (prefix_list_option "l", - (help "Search a library when linking")), (prefix_list_option "Wl,", (help "Pass options to linker")), (parameter_list_option "Xlinker", (hidden), @@ -105,7 +83,56 @@ def OptList : OptionList<[ (help "Pass options to opt")), (prefix_list_option "m", (help "Enable or disable various extensions (-mmmx, -msse, etc.)"), - (hidden)), + (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)), (switch_option "dynamiclib", (hidden), (help "Produce a dynamic library")), (switch_option "prebind", (hidden), @@ -125,24 +152,24 @@ def OptList : OptionList<[ // Option preprocessor. def Preprocess : OptionPreprocessor< -(case (not (any_switch_on ["O0", "O1", "O2", "O3"])), +(case (not (any_switch_on "O0", "O1", "O2", "O3")), (set_option "O2"), - (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"]), + (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"), (unset_option "O0")) >; // Tools -class llvm_gcc_based <string cmd_prefix, string in_lang, - string E_ext, string out_lang> : Tool< +class llvm_gcc_based <string cmd, string in_lang, string E_ext, dag out_lang, + string out_ext> : Tool< [(in_language in_lang), - (out_language "llvm-bitcode"), - (output_suffix out_lang), - (command cmd_prefix), + out_lang, + (output_suffix out_ext), + (command cmd), (actions (case (and (not_empty "o"), @@ -151,14 +178,20 @@ class llvm_gcc_based <string cmd_prefix, string in_lang, (switch_on "E"), [(forward "E"), (stop_compilation), (output_suffix E_ext)], (and (switch_on "E"), (empty "o")), (no_out_file), - (switch_on ["emit-llvm", "S"]), - [(output_suffix "ll"), (stop_compilation)], - (switch_on ["emit-llvm", "c"]), (stop_compilation), + + // ('-emit-llvm') && !('opt') -> stop compilation + (and (switch_on "emit-llvm"), (not (switch_on "opt"))), + (stop_compilation), + // ('-S' && '-emit-llvm') && !('opt') -> output .ll + (and (switch_on "emit-llvm", "S"), (not (switch_on "opt"))), + [(forward "S"), (output_suffix "ll")], + // Ususally just output .bc + (not (switch_on "fsyntax-only")), + [(append_cmd "-c"), (append_cmd "-emit-llvm")], + + // -fsyntax-only (switch_on "fsyntax-only"), [(forward "fsyntax-only"), (no_out_file), (stop_compilation)], - (switch_on ["S", "emit-llvm"]), [(forward "S"), (forward "emit-llvm")], - (not (or (switch_on ["S", "emit-llvm"]), (switch_on "fsyntax-only"))), - [(append_cmd "-c"), (append_cmd "-emit-llvm")], // Forwards (not_empty "Xpreprocessor"), (forward "Xpreprocessor"), @@ -187,30 +220,40 @@ class llvm_gcc_based <string cmd_prefix, string in_lang, (sink) ]>; -def llvm_gcc_c : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c", "c", "i", "bc">; -def llvm_gcc_cpp : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++", "c++", "i", "bc">; -def llvm_gcc_m : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c", - "objective-c", "mi", "bc">; -def llvm_gcc_mxx : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++", - "objective-c++", "mi", "bc">; - -def llvm_gcc_c_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c-header", - "c-header", "i", "gch">; -def llvm_gcc_cpp_pch : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++-header", - "c++-header", - "i", "gch">; -def llvm_gcc_m_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c-header", - "objective-c-header", - "mi", "gch">; -def llvm_gcc_mxx_pch - : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++-header", - "objective-c++-header", "mi", "gch">; +class llvm_gcc_comp_based <string cmd, string in_lang, string E_ext> +: llvm_gcc_based<cmd, in_lang, E_ext, + (out_language "llvm-bitcode", "object-code"), "bc">; + +class llvm_gcc_pch_based <string cmd, string in_lang, string E_ext> +: llvm_gcc_based<cmd, in_lang, E_ext, + (out_language "precompiled-header"), "gch">; + +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">; + +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">; def opt : Tool< [(in_language "llvm-bitcode"), (out_language "llvm-bitcode"), - (output_suffix "bc"), - (actions (case (not_empty "Wo,"), (forward_value "Wo,"), + (output_suffix "opt.bc"), + (actions (case (switch_on "emit-llvm"), (stop_compilation), + (switch_on "emit-llvm", "S"), + [(append_cmd "-S"), (output_suffix "ll")], + (not_empty "Wo,"), (forward_value "Wo,"), (switch_on "O1"), (forward "O1"), (switch_on "O2"), (forward "O2"), (switch_on "O3"), (forward "O3"))), @@ -240,7 +283,7 @@ def llvm_gcc_assembler : Tool< ]>; def llc : Tool< -[(in_language ["llvm-bitcode", "llvm-assembler"]), +[(in_language "llvm-bitcode", "llvm-assembler"), (out_language "assembler"), (output_suffix "s"), (command "llc"), @@ -253,7 +296,7 @@ def llc : Tool< (switch_on "fPIC"), (append_cmd "-relocation-model=pic"), (switch_on "mdynamic-no-pic"), (append_cmd "-relocation-model=dynamic-no-pic"), - (not_empty "march"), (forward_as "mtune", "-mcpu"), + (not_empty "march"), (forward_as "march", "-mcpu"), (not_empty "mtune"), (forward_as "mtune", "-mcpu"), (not_empty "mcpu"), (forward "mcpu"), (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"), @@ -261,11 +304,11 @@ def llc : Tool< ]>; // Base class for linkers -class llvm_gcc_based_linker <string cmd_prefix, dag on_empty> : Tool< -[(in_language ["object-code", "static-library"]), +class llvm_gcc_based_linker <string cmd, dag on_empty> : Tool< +[(in_language "object-code", "static-library", "dynamic-library"), (out_language "executable"), (output_suffix "out"), - (command cmd_prefix), + (command cmd), (works_on_empty (case (and (not_empty "filelist"), on_empty), true, (default), false)), (join), @@ -282,7 +325,18 @@ class llvm_gcc_based_linker <string cmd_prefix, dag on_empty> : Tool< (not_empty "l"), (forward "l"), (not_empty "Xlinker"), (forward "Xlinker"), (not_empty "Wl,"), (forward "Wl,"), + (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"), (switch_on "shared"), (forward "shared"), + (switch_on "shared-libgcc"), (forward "shared-libgcc"), + (not_empty "T"), (forward "T"), + (not_empty "u"), (forward "u"), (switch_on "dynamiclib"), (forward "dynamiclib"), (switch_on "prebind"), (forward "prebind"), (switch_on "dead_strip"), (forward "dead_strip"), @@ -305,6 +359,7 @@ def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@", // Language map def LanguageMap : LanguageMap<[ + (lang_to_suffixes "precompiled-header", ["gch", "pch"]), (lang_to_suffixes "c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]), (lang_to_suffixes "c++-header", "hpp"), (lang_to_suffixes "c", "c"), @@ -321,7 +376,8 @@ def LanguageMap : LanguageMap<[ (lang_to_suffixes "llvm-bitcode", "bc"), (lang_to_suffixes "object-code", ["o", "*empty*"]), (lang_to_suffixes "static-library", ["a", "lib"]), - (lang_to_suffixes "executable", ["out"]) + (lang_to_suffixes "dynamic-library", ["so", "dylib", "dll"]), + (lang_to_suffixes "executable", "out") ]>; // Compilation graph |