summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-11-04 14:58:56 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-11-04 14:58:56 +0000
commit7ff99155c39edd73ebf1c6adfa023b1048fee9a4 (patch)
treeb4dc751bcee540346911aa4115729eff2f991657 /tools
parentd1f06de484602e72707476a6152974847bac1570 (diff)
downloadFreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.zip
FreeBSD-src-7ff99155c39edd73ebf1c6adfa023b1048fee9a4.tar.gz
Update LLVM to r86025.
Diffstat (limited to 'tools')
-rw-r--r--tools/gold/gold-plugin.cpp64
-rw-r--r--tools/lli/lli.cpp3
-rw-r--r--tools/llvm-mc/AsmLexer.h2
-rw-r--r--tools/llvm-mc/llvm-mc.cpp6
-rw-r--r--tools/llvmc/doc/LLVMC-Reference.rst74
-rw-r--r--tools/opt/opt.cpp6
6 files changed, 112 insertions, 43 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index b1562d1..0e1db1b 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -46,9 +46,6 @@ namespace {
int api_version = 0;
int gold_version = 0;
- bool generate_api_file = false;
- const char *as_path = NULL;
-
struct claimed_file {
lto_module_t M;
void *handle;
@@ -60,6 +57,37 @@ namespace {
std::vector<sys::Path> Cleanup;
}
+namespace options {
+ bool generate_api_file = false;
+ const char *as_path = NULL;
+ // Additional options to pass into the code generator.
+ // Note: This array will contain all plugin options which are not claimed
+ // as plugin exclusive to pass to the code generator.
+ // For example, "generate-api-file" and "as"options are for the plugin
+ // use only and will not be passed.
+ std::vector<std::string> extra;
+
+ void process_plugin_option(const char* opt)
+ {
+ if (opt == NULL)
+ return;
+
+ if (strcmp("generate-api-file", opt) == 0) {
+ generate_api_file = true;
+ } else if (strncmp("as=", opt, 3) == 0) {
+ if (as_path) {
+ (*message)(LDPL_WARNING, "Path to as specified twice. "
+ "Discarding %s", opt);
+ } else {
+ as_path = strdup(opt + 3);
+ }
+ } else {
+ // Save this option to pass to the code generator.
+ extra.push_back(std::string(opt));
+ }
+ }
+}
+
ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
int *claimed);
ld_plugin_status all_symbols_read_hook(void);
@@ -103,18 +131,7 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
//output_type = LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC;
break;
case LDPT_OPTION:
- if (strcmp("generate-api-file", tv->tv_u.tv_string) == 0) {
- generate_api_file = true;
- } else if (strncmp("as=", tv->tv_u.tv_string, 3) == 0) {
- if (as_path) {
- (*message)(LDPL_WARNING, "Path to as specified twice. "
- "Discarding %s", tv->tv_u.tv_string);
- } else {
- as_path = strdup(tv->tv_u.tv_string + 3);
- }
- } else {
- (*message)(LDPL_WARNING, "Ignoring flag %s", tv->tv_u.tv_string);
- }
+ options::process_plugin_option(tv->tv_u.tv_string);
break;
case LDPT_REGISTER_CLAIM_FILE_HOOK: {
ld_plugin_register_claim_file callback;
@@ -307,7 +324,7 @@ ld_plugin_status all_symbols_read_hook(void) {
lto_codegen_add_module(cg, I->M);
std::ofstream api_file;
- if (generate_api_file) {
+ if (options::generate_api_file) {
api_file.open("apifile.txt", std::ofstream::out | std::ofstream::trunc);
if (!api_file.is_open()) {
(*message)(LDPL_FATAL, "Unable to open apifile.txt for writing.");
@@ -329,13 +346,13 @@ ld_plugin_status all_symbols_read_hook(void) {
lto_codegen_add_must_preserve_symbol(cg, I->syms[i].name);
anySymbolsPreserved = true;
- if (generate_api_file)
+ if (options::generate_api_file)
api_file << I->syms[i].name << "\n";
}
}
}
- if (generate_api_file)
+ if (options::generate_api_file)
api_file.close();
if (!anySymbolsPreserved) {
@@ -347,10 +364,17 @@ ld_plugin_status all_symbols_read_hook(void) {
lto_codegen_set_pic_model(cg, output_type);
lto_codegen_set_debug_model(cg, LTO_DEBUG_MODEL_DWARF);
- if (as_path) {
- sys::Path p = sys::Program::FindProgramByName(as_path);
+ if (options::as_path) {
+ sys::Path p = sys::Program::FindProgramByName(options::as_path);
lto_codegen_set_assembler_path(cg, p.c_str());
}
+ // Pass through extra options to the code generator.
+ if (!options::extra.empty()) {
+ for (std::vector<std::string>::iterator it = options::extra.begin();
+ it != options::extra.end(); ++it) {
+ lto_codegen_debug_options(cg, (*it).c_str());
+ }
+ }
size_t bufsize = 0;
const char *buffer = static_cast<const char *>(lto_codegen_compile(cg,
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 4578c4e..218bb93 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -165,8 +165,7 @@ int main(int argc, char **argv, char * const *envp) {
EE->RegisterJITEventListener(createOProfileJITEventListener());
- if (NoLazyCompilation)
- EE->DisableLazyCompilation();
+ EE->DisableLazyCompilation(NoLazyCompilation);
// If the user specifically requested an argv[0] to pass into the program,
// do it now.
diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h
index 0696abc..ce292f6 100644
--- a/tools/llvm-mc/AsmLexer.h
+++ b/tools/llvm-mc/AsmLexer.h
@@ -17,7 +17,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCAsmLexer.h"
#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/System/DataTypes.h"
#include <string>
#include <cassert>
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index 329efe9..76552b8 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -70,9 +70,9 @@ IncludeDirs("I", cl::desc("Directory of include files"),
cl::value_desc("directory"), cl::Prefix);
static cl::opt<std::string>
-TripleName("triple", cl::desc("Target triple to assemble for,"
- "see -version for available targets"),
- cl::init(LLVM_HOSTTRIPLE));
+TripleName("triple", cl::desc("Target triple to assemble for, "
+ "see -version for available targets"),
+ cl::init(LLVM_HOSTTRIPLE));
enum ActionType {
AC_AsLex,
diff --git a/tools/llvmc/doc/LLVMC-Reference.rst b/tools/llvmc/doc/LLVMC-Reference.rst
index 7041bd1..b92ab69 100644
--- a/tools/llvmc/doc/LLVMC-Reference.rst
+++ b/tools/llvmc/doc/LLVMC-Reference.rst
@@ -431,8 +431,16 @@ use TableGen inheritance instead.
* Possible tests are:
- - ``switch_on`` - Returns true if a given command-line switch is
- provided by the user. Example: ``(switch_on "opt")``.
+ - ``switch_on`` - Returns true if a given command-line switch is provided by
+ the user. Can be given a list as argument, in that case ``(switch_on ["foo",
+ "bar", "baz"])`` is equivalent to ``(and (switch_on "foo"), (switch_on
+ "bar"), (switch_on "baz"))``.
+ Example: ``(switch_on "opt")``.
+
+ - ``any_switch_on`` - Given a list of switch options, returns true if any of
+ the switches is turned on.
+ Example: ``(any_switch_on ["foo", "bar", "baz"])`` is equivalent to ``(or
+ (switch_on "foo"), (switch_on "bar"), (switch_on "baz"))``.
- ``parameter_equals`` - Returns true if a command-line parameter equals
a given value.
@@ -446,18 +454,28 @@ use TableGen inheritance instead.
belongs to the current input language set.
Example: ``(input_languages_contain "c++")``.
- - ``in_language`` - Evaluates to true if the input file language
- equals to the argument. At the moment works only with ``cmd_line``
- and ``actions`` (on non-join nodes).
+ - ``in_language`` - Evaluates to true if the input file language is equal to
+ the argument. At the moment works only with ``cmd_line`` and ``actions`` (on
+ non-join nodes).
Example: ``(in_language "c++")``.
- - ``not_empty`` - Returns true if a given option (which should be
- either a parameter or a parameter list) is set by the
- user.
+ - ``not_empty`` - Returns true if a given option (which should be either a
+ parameter or a parameter list) is set by the user. Like ``switch_on``, can
+ be also given a list as argument.
Example: ``(not_empty "o")``.
+ - ``any_not_empty`` - Returns true if ``not_empty`` returns true for any of
+ the options in the list.
+ Example: ``(any_not_empty ["foo", "bar", "baz"])`` is equivalent to ``(or
+ (not_empty "foo"), (not_empty "bar"), (not_empty "baz"))``.
+
- ``empty`` - The opposite of ``not_empty``. Equivalent to ``(not (not_empty
- X))``. Provided for convenience.
+ X))``. Provided for convenience. Can be given a list as argument.
+
+ - ``any_not_empty`` - Returns true if ``not_empty`` returns true for any of
+ the options in the list.
+ Example: ``(any_empty ["foo", "bar", "baz"])`` is equivalent to ``(not (and
+ (not_empty "foo"), (not_empty "bar"), (not_empty "baz")))``.
- ``single_input_file`` - Returns true if there was only one input file
provided on the command-line. Used without arguments:
@@ -572,11 +590,13 @@ The list of all possible actions follows.
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!")``.
- - ``forward`` - forward an option unchanged.
- Example: ``(forward "Wall")``.
+ - ``warning`` - print a warning.
+ Example: ``(warning "Specifying both -O1 and -O2 is meaningless!")``.
+
+ - ``forward`` - forward an option unchanged. Example: ``(forward "Wall")``.
- ``forward_as`` - Change the name of an option, but forward the
argument unchanged.
@@ -619,6 +639,36 @@ linked with the root node. Since tools are not allowed to have
multiple output languages, for nodes "inside" the graph the input and
output languages should match. This is enforced at compile-time.
+Option preprocessor
+===================
+
+It is sometimes useful to run error-checking code before processing the
+compilation graph. For example, if optimization options "-O1" and "-O2" are
+implemented as switches, we might want to output a warning if the user invokes
+the driver with both of these options enabled.
+
+The ``OptionPreprocessor`` feature is reserved specially for these
+occasions. Example (adapted from the built-in Base plugin)::
+
+ def Preprocess : OptionPreprocessor<
+ (case (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])),
+ [(unset_option ["O0", "O1", "O2"]),
+ (warning "Multiple -O options specified, defaulted to -O3.")],
+ (and (switch_on "O2"), (any_switch_on ["O0", "O1"])),
+ (unset_option ["O0", "O1"]),
+ (and (switch_on "O1"), (switch_on "O0")),
+ (unset_option "O0"))
+ >;
+
+Here, ``OptionPreprocessor`` is used to unset all spurious optimization options
+(so that they are not forwarded to the compiler).
+
+``OptionPreprocessor`` is basically a single big ``case`` expression, which is
+evaluated only once right after the plugin is loaded. The only allowed actions
+in ``OptionPreprocessor`` are ``error``, ``warning`` and a special action
+``unset_option``, which, as the name suggests, unsets a given option. For
+convenience, ``unset_option`` also works on lists.
+
More advanced topics
====================
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 1950a73..12bb2ec 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -132,10 +132,6 @@ DefaultDataLayout("default-data-layout",
cl::desc("data layout string to use if not specified by module"),
cl::value_desc("layout-string"), cl::init(""));
-static cl::opt<bool>
-NoDefaultDataLayout("no-default-data-layout",
- cl::desc("no data layout assumptions unless module specifies data layout"));
-
// ---------- Define Printers for module and function passes ------------
namespace {
@@ -401,7 +397,7 @@ int main(int argc, char **argv) {
const std::string &ModuleDataLayout = M.get()->getDataLayout();
if (!ModuleDataLayout.empty())
TD = new TargetData(ModuleDataLayout);
- else if (!NoDefaultDataLayout)
+ else if (!DefaultDataLayout.empty())
TD = new TargetData(DefaultDataLayout);
if (TD)
OpenPOWER on IntegriCloud