summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-12-15 18:09:07 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-12-15 18:09:07 +0000
commit40a6fcdb85efd93fe0e36c9552cfb0b18b5eacd6 (patch)
tree076117cdf3579003f07cad4cdf0593347ce58150 /tools
parente7908924d847e63b02bc82bfaa1709ab9c774dcd (diff)
downloadFreeBSD-src-40a6fcdb85efd93fe0e36c9552cfb0b18b5eacd6.zip
FreeBSD-src-40a6fcdb85efd93fe0e36c9552cfb0b18b5eacd6.tar.gz
Update LLVM to 91430.
Diffstat (limited to 'tools')
-rw-r--r--tools/llvmc/doc/LLVMC-Reference.rst80
-rw-r--r--tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td20
-rw-r--r--tools/llvmc/plugins/Base/Base.td.in39
-rw-r--r--tools/llvmc/plugins/Base/Hooks.cpp33
-rw-r--r--tools/llvmc/plugins/Clang/Clang.td4
-rw-r--r--tools/opt/opt.cpp7
6 files changed, 135 insertions, 48 deletions
diff --git a/tools/llvmc/doc/LLVMC-Reference.rst b/tools/llvmc/doc/LLVMC-Reference.rst
index 102795e..4d80a2a 100644
--- a/tools/llvmc/doc/LLVMC-Reference.rst
+++ b/tools/llvmc/doc/LLVMC-Reference.rst
@@ -336,8 +336,8 @@ separate option groups syntactically.
it is synonymous with ``required``. Incompatible with ``required`` and
``zero_or_one``.
- - ``zero_or_one`` - the option can be specified zero or one times. Useful
- only for list options in conjunction with ``multi_val``. Incompatible with
+ - ``optional`` - the option can be specified zero or one times. Useful only
+ for list options in conjunction with ``multi_val``. Incompatible with
``required`` and ``one_or_more``.
- ``hidden`` - the description of this option will not appear in
@@ -347,19 +347,30 @@ separate option groups syntactically.
- ``really_hidden`` - the option will not be mentioned in any help
output.
+ - ``comma_separated`` - Indicates that any commas specified for an option's
+ value should be used to split the value up into multiple values for the
+ option. This property is valid only for list options. In conjunction with
+ ``forward_value`` can be used to implement option forwarding in style of
+ gcc's ``-Wa,``.
+
- ``multi_val n`` - this option takes *n* arguments (can be useful in some
special cases). Usage example: ``(parameter_list_option "foo", (multi_val
3))``; the command-line syntax is '-foo a b c'. Only list options can have
- this attribute; you can, however, use the ``one_or_more``, ``zero_or_one``
+ this attribute; you can, however, use the ``one_or_more``, ``optional``
and ``required`` properties.
- ``init`` - this option has a default value, either a string (if it is a
- parameter), or a boolean (if it is a switch; boolean constants are called
- ``true`` and ``false``). List options can't have this attribute. Usage
- examples: ``(switch_option "foo", (init true))``; ``(prefix_option "bar",
- (init "baz"))``.
+ parameter), or a boolean (if it is a switch; as in C++, boolean constants
+ are called ``true`` and ``false``). List options can't have ``init``
+ attribute.
+ Usage examples: ``(switch_option "foo", (init true))``; ``(prefix_option
+ "bar", (init "baz"))``.
+
+ - ``extern`` - this option is defined in some other plugin, see `below`__.
+
+ __ extern_
- - ``extern`` - this option is defined in some other plugin, see below.
+.. _extern:
External options
----------------
@@ -547,7 +558,11 @@ The complete list of all currently implemented tool properties follows.
- ``actions`` - A single big ``case`` expression that specifies how
this tool reacts on command-line options (described in more detail
- below).
+ `below`__).
+
+__ actions_
+
+.. _actions:
Actions
-------
@@ -585,35 +600,42 @@ The list of all possible actions follows.
* Possible actions:
- - ``append_cmd`` - append a string to the tool invocation
- command.
- Example: ``(case (switch_on "pthread"), (append_cmd
- "-lpthread"))``
+ - ``append_cmd`` - Append a string to the tool invocation command.
+ Example: ``(case (switch_on "pthread"), (append_cmd "-lpthread"))``.
- - ``error`` - exit with error.
+ - ``error`` - Exit with error.
Example: ``(error "Mixing -c and -S is not allowed!")``.
- - ``warning`` - print a warning.
+ - ``warning`` - Print a warning.
Example: ``(warning "Specifying both -O1 and -O2 is meaningless!")``.
- - ``forward`` - forward an option unchanged. Example: ``(forward "Wall")``.
+ - ``forward`` - Forward the option unchanged.
+ Example: ``(forward "Wall")``.
- - ``forward_as`` - Change the name of an option, but forward the
- argument unchanged.
+ - ``forward_as`` - Change the option's name, but forward the argument
+ unchanged.
Example: ``(forward_as "O0", "--disable-optimization")``.
- - ``output_suffix`` - modify the output suffix of this
- tool.
+ - ``forward_value`` - Forward only option's value. Cannot be used with switch
+ options (since they don't have values), but works fine with lists.
+ Example: ``(forward_value "Wa,")``.
+
+ - ``forward_transformed_value`` - As above, but applies a hook to the
+ option's value before forwarding (see `below`__). When
+ ``forward_transformed_value`` is applied to a list
+ option, the hook must have signature
+ ``std::string hooks::HookName (const std::vector<std::string>&)``.
+ Example: ``(forward_transformed_value "m", "ConvertToMAttr")``.
+
+ __ hooks_
+
+ - ``output_suffix`` - Modify the output suffix of this tool.
Example: ``(output_suffix "i")``.
- - ``stop_compilation`` - stop compilation after this tool processes
- its input. Used without arguments.
+ - ``stop_compilation`` - Stop compilation after this tool processes its
+ input. Used without arguments.
+ Example: ``(stop_compilation)``.
- - ``unpack_values`` - used for for splitting and forwarding
- comma-separated lists of options, e.g. ``-Wa,-foo=bar,-baz`` is
- converted to ``-foo=bar -baz`` and appended to the tool invocation
- command.
- Example: ``(unpack_values "Wa,")``.
Language map
============
@@ -760,6 +782,8 @@ accessible only in the C++ code (i.e. hooks). Use the following code::
extern const char* ProgramName;
}
+ namespace hooks {
+
std::string MyHook() {
//...
if (strcmp(ProgramName, "mydriver") == 0) {
@@ -767,6 +791,8 @@ accessible only in the C++ code (i.e. hooks). Use the following code::
}
+ } // end namespace hooks
+
In general, you're encouraged not to make the behaviour dependent on the
executable file name, and use command-line switches instead. See for example how
the ``Base`` plugin behaves when it needs to choose the correct linker options
diff --git a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
index df9b99e..5e6f6cb 100644
--- a/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
+++ b/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
@@ -41,9 +41,9 @@ def OptionList : OptionList<[
// (help "Optimization level 2. (Default)")),
// (parameter_option "pre-RA-sched",
// (help "Example of an option that is passed to llc")),
- (prefix_list_option "Wa,",
+ (prefix_list_option "Wa,", (comma_separated),
(help "Pass options to native assembler")),
- (prefix_list_option "Wl,",
+ (prefix_list_option "Wl,", (comma_separated),
(help "Pass options to native linker"))
// (prefix_list_option "Wllc,",
// (help "Pass options to llc")),
@@ -58,11 +58,11 @@ class clang_based<string language, string cmd, string ext_E> : Tool<
(output_suffix "bc"),
(cmd_line (case
(switch_on "E"),
- (case
+ (case
(not_empty "o"), !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
(default), !strconcat(cmd, " -E $INFILE")),
(default), !strconcat(cmd, " $INFILE -o $OUTFILE"))),
- (actions (case
+ (actions (case
(and (multiple_input_files), (or (switch_on "S"), (switch_on "c"))),
(error "cannot specify -o with -c or -S with multiple files"),
(switch_on "E"), [(stop_compilation), (output_suffix ext_E)],
@@ -138,7 +138,7 @@ def gpasm : Tool<[
(actions (case
(switch_on "c"), (stop_compilation),
(switch_on "g"), (append_cmd "-g"),
- (not_empty "Wa,"), (unpack_values "Wa,")))
+ (not_empty "Wa,"), (forward_value "Wa,")))
]>;
def mplink : Tool<[
@@ -147,13 +147,13 @@ def mplink : Tool<[
(output_suffix "cof"),
(cmd_line "$CALL(GetBinDir)mplink.exe -k $CALL(GetStdLinkerScriptsDir) -l $CALL(GetStdLibsDir) -p 16f1937 intrinsics.lib devices.lib $INFILE -o $OUTFILE"),
(actions (case
- (not_empty "Wl,"), (unpack_values "Wl,"),
+ (not_empty "Wl,"), (forward_value "Wl,"),
(not_empty "L"), (forward_as "L", "-l"),
(not_empty "K"), (forward_as "K", "-k"),
(not_empty "m"), (forward "m"),
// (not_empty "l"), [(unpack_values "l"),(append_cmd ".lib")])),
- (not_empty "k"), (unpack_values "k"),
- (not_empty "l"), (unpack_values "l"))),
+ (not_empty "k"), (forward_value "k"),
+ (not_empty "l"), (forward_value "l"))),
(join)
]>;
@@ -175,13 +175,13 @@ def LanguageMap : LanguageMap<[
def CompilationGraph : CompilationGraph<[
Edge<"root", "clang_cc">,
Edge<"root", "llvm_ld">,
- OptionalEdge<"root", "llvm_ld_optimizer", (case
+ OptionalEdge<"root", "llvm_ld_optimizer", (case
(switch_on "S"), (inc_weight),
(switch_on "c"), (inc_weight))>,
Edge<"root", "gpasm">,
Edge<"root", "mplink">,
Edge<"clang_cc", "llvm_ld">,
- OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case
+ OptionalEdge<"clang_cc", "llvm_ld_optimizer", (case
(switch_on "S"), (inc_weight),
(switch_on "c"), (inc_weight))>,
Edge<"llvm_ld", "pic16passes">,
diff --git a/tools/llvmc/plugins/Base/Base.td.in b/tools/llvmc/plugins/Base/Base.td.in
index 125e95c..8f928cc 100644
--- a/tools/llvmc/plugins/Base/Base.td.in
+++ b/tools/llvmc/plugins/Base/Base.td.in
@@ -38,12 +38,22 @@ def OptList : OptionList<[
(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",
+ (help "Generate code for a 64-bit environment"), (hidden)),
(switch_option "fPIC",
(help "Relocation model: PIC"), (hidden)),
(switch_option "mdynamic-no-pic",
(help "Relocation model: dynamic-no-pic"), (hidden)),
(parameter_option "linker",
(help "Choose linker (possible values: gcc, g++)")),
+ (parameter_option "mtune",
+ (help "Target a specific CPU type"), (hidden)),
+ (parameter_option "march",
+ (help "A synonym for -mtune"), (hidden)),
+ (parameter_option "mcpu",
+ (help "A deprecated synonym for -mtune"), (hidden)),
(parameter_option "MF",
(help "Specify a file to write dependencies to"), (hidden)),
(parameter_option "MT",
@@ -61,9 +71,9 @@ def OptList : OptionList<[
(help "Add a directory to include path")),
(prefix_list_option "D",
(help "Define a macro")),
- (prefix_list_option "Wa,",
+ (prefix_list_option "Wa,", (comma_separated),
(help "Pass options to assembler")),
- (prefix_list_option "Wllc,",
+ (prefix_list_option "Wllc,", (comma_separated),
(help "Pass options to llc")),
(prefix_list_option "L",
(help "Add a directory to link path")),
@@ -71,8 +81,11 @@ def OptList : OptionList<[
(help "Search a library when linking")),
(prefix_list_option "Wl,",
(help "Pass options to linker")),
- (prefix_list_option "Wo,",
- (help "Pass options to opt"))
+ (prefix_list_option "Wo,", (comma_separated),
+ (help "Pass options to opt")),
+ (prefix_list_option "m",
+ (help "Enable or disable various extensions (-mmmx, -msse, etc.)"),
+ (hidden))
]>;
// Option preprocessor.
@@ -119,6 +132,12 @@ class llvm_gcc_based <string cmd_prefix, string in_lang, string E_ext> : Tool<
(not_empty "I"), (forward "I"),
(not_empty "F"), (forward "F"),
(not_empty "D"), (forward "D"),
+ (not_empty "march"), (forward "march"),
+ (not_empty "mtune"), (forward "mtune"),
+ (not_empty "mcpu"), (forward "mcpu"),
+ (not_empty "m"), (forward "m"),
+ (switch_on "m32"), (forward "m32"),
+ (switch_on "m64"), (forward "m64"),
(switch_on "O1"), (forward "O1"),
(switch_on "O2"), (forward "O2"),
(switch_on "O3"), (forward "O3"),
@@ -140,7 +159,7 @@ def opt : Tool<
[(in_language "llvm-bitcode"),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (actions (case (not_empty "Wo,"), (unpack_values "Wo,"),
+ (actions (case (not_empty "Wo,"), (forward_value "Wo,"),
(switch_on "O1"), (forward "O1"),
(switch_on "O2"), (forward "O2"),
(switch_on "O3"), (forward "O3"))),
@@ -162,7 +181,7 @@ def llvm_gcc_assembler : Tool<
(cmd_line "@LLVMGCCCOMMAND@ -c -x assembler $INFILE -o $OUTFILE"),
(actions (case
(switch_on "c"), (stop_compilation),
- (not_empty "Wa,"), (unpack_values "Wa,")))
+ (not_empty "Wa,"), (forward_value "Wa,")))
]>;
def llc : Tool<
@@ -179,7 +198,11 @@ 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 "Wllc,"), (unpack_values "Wllc,")))
+ (not_empty "march"), (forward "mcpu"),
+ (not_empty "mtune"), (forward "mcpu"),
+ (not_empty "mcpu"), (forward "mcpu"),
+ (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"),
+ (not_empty "Wllc,"), (forward_value "Wllc,")))
]>;
// Base class for linkers
@@ -195,6 +218,8 @@ class llvm_gcc_based_linker <string cmd_prefix> : Tool<
(not_empty "F"), (forward "F"),
(not_empty "framework"), (forward "framework"),
(not_empty "weak_framework"), (forward "weak_framework"),
+ (switch_on "m32"), (forward "m32"),
+ (switch_on "m64"), (forward "m64"),
(not_empty "l"), (forward "l"),
(not_empty "Wl,"), (forward "Wl,")))
]>;
diff --git a/tools/llvmc/plugins/Base/Hooks.cpp b/tools/llvmc/plugins/Base/Hooks.cpp
new file mode 100644
index 0000000..661a914
--- /dev/null
+++ b/tools/llvmc/plugins/Base/Hooks.cpp
@@ -0,0 +1,33 @@
+#include <string>
+#include <vector>
+
+namespace hooks {
+typedef std::vector<std::string> StrVec;
+
+/// ConvertToMAttr - Convert -m* and -mno-* to -mattr=+*,-*
+std::string ConvertToMAttr(const StrVec& Opts) {
+ std::string out("-mattr=");
+
+ bool firstIter = true;
+ for (StrVec::const_iterator B = Opts.begin(), E = Opts.end(); B!=E; ++B) {
+ const std::string& Arg = *B;
+
+ if (firstIter)
+ firstIter = false;
+ else
+ out += ",";
+
+ if (Arg.find("no-") == 0 && Arg[3] != 0) {
+ out += '-';
+ out += Arg.c_str() + 3;
+ }
+ else {
+ out += '+';
+ out += Arg;
+ }
+ }
+
+ return out;
+}
+
+}
diff --git a/tools/llvmc/plugins/Clang/Clang.td b/tools/llvmc/plugins/Clang/Clang.td
index a179c53..ac8ac15 100644
--- a/tools/llvmc/plugins/Clang/Clang.td
+++ b/tools/llvmc/plugins/Clang/Clang.td
@@ -68,7 +68,7 @@ def as : Tool<
(out_language "object-code"),
(output_suffix "o"),
(cmd_line "as $INFILE -o $OUTFILE"),
- (actions (case (not_empty "Wa,"), (unpack_values "Wa,"),
+ (actions (case (not_empty "Wa,"), (forward_value "Wa,"),
(switch_on "c"), (stop_compilation)))
]>;
@@ -82,7 +82,7 @@ def llvm_ld : Tool<
(switch_on "pthread"), (append_cmd "-lpthread"),
(not_empty "L"), (forward "L"),
(not_empty "l"), (forward "l"),
- (not_empty "Wl,"), (unpack_values "Wl,"))),
+ (not_empty "Wl,"), (forward_value "Wl,"))),
(join)
]>;
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 12bb2ec..50a2e39 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -30,6 +30,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/StandardPasses.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/raw_ostream.h"
@@ -340,12 +341,14 @@ void AddStandardLinkPasses(PassManager &PM) {
// main for opt
//
int main(int argc, char **argv) {
- llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
+ sys::PrintStackTraceOnErrorSignal();
+ llvm::PrettyStackTraceProgram X(argc, argv);
+
+ llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
LLVMContext &Context = getGlobalContext();
cl::ParseCommandLineOptions(argc, argv,
"llvm .bc -> .bc modular optimizer and analysis printer\n");
- sys::PrintStackTraceOnErrorSignal();
// Allocate a full target machine description only if necessary.
// FIXME: The choice of target should be controllable on the command line.
OpenPOWER on IntegriCloud