summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-08-09 21:09:46 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-08-09 21:09:46 +0000
commit4ef89f5200bbabf5bdb79616940f6be8b130399a (patch)
treedbec341dae528c3518efa6bd7019b769e1d1eca3
parentc0dc36b2130949cb5d766126d281b8b3ed4f088b (diff)
downloadbcm5719-llvm-4ef89f5200bbabf5bdb79616940f6be8b130399a.tar.gz
bcm5719-llvm-4ef89f5200bbabf5bdb79616940f6be8b130399a.zip
Make it possible to set the target triple and expose that with an option in the
gold plugin. llvm-svn: 110604
-rw-r--r--llvm/include/llvm-c/lto.h6
-rw-r--r--llvm/tools/gold/gold-plugin.cpp7
-rw-r--r--llvm/tools/lto/LTOModule.cpp5
-rw-r--r--llvm/tools/lto/LTOModule.h1
-rw-r--r--llvm/tools/lto/lto.cpp8
-rw-r--r--llvm/tools/lto/lto.exports1
6 files changed, 28 insertions, 0 deletions
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index 93f37605a41..d16a38bd3be 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -135,6 +135,12 @@ lto_module_dispose(lto_module_t mod);
extern const char*
lto_module_get_target_triple(lto_module_t mod);
+/**
+ * Sets triple string with which the object will be codegened.
+ */
+extern void
+lto_module_set_target_triple(lto_module_t mod, const char *triple);
+
/**
* Returns the number of symbols in the object module.
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index 2d0f5bd3af3..e7161a64a8e 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -68,6 +68,7 @@ namespace options {
static std::string as_path;
static std::vector<std::string> pass_through;
static std::string extra_library_path;
+ static std::string triple;
// 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.
@@ -95,6 +96,8 @@ namespace options {
} else if (opt.startswith("pass-through=")) {
llvm::StringRef item = opt.substr(strlen("pass-through="));
pass_through.push_back(item.str());
+ } else if (opt == "mtriple=") {
+ triple = opt.substr(strlen("mtriple="));
} else if (opt == "emit-llvm") {
generate_bc_file = BC_ONLY;
} else if (opt == "also-emit-llvm") {
@@ -270,6 +273,10 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
lto_get_error_message());
return LDPS_ERR;
}
+
+ if (!options::triple.empty())
+ lto_module_set_target_triple(cf.M, options::triple.c_str());
+
cf.handle = file->handle;
unsigned sym_count = lto_module_get_num_symbols(cf.M);
cf.syms.reserve(sym_count);
diff --git a/llvm/tools/lto/LTOModule.cpp b/llvm/tools/lto/LTOModule.cpp
index 0870205a778..d386bacdfc9 100644
--- a/llvm/tools/lto/LTOModule.cpp
+++ b/llvm/tools/lto/LTOModule.cpp
@@ -153,6 +153,11 @@ const char* LTOModule::getTargetTriple()
return _module->getTargetTriple().c_str();
}
+void LTOModule::setTargetTriple(const char *triple)
+{
+ _module->setTargetTriple(triple);
+}
+
void LTOModule::addDefinedFunctionSymbol(Function* f, Mangler &mangler)
{
// add to list of defined symbols
diff --git a/llvm/tools/lto/LTOModule.h b/llvm/tools/lto/LTOModule.h
index 7f475d40aa0..a19acc0d737 100644
--- a/llvm/tools/lto/LTOModule.h
+++ b/llvm/tools/lto/LTOModule.h
@@ -55,6 +55,7 @@ struct LTOModule {
std::string& errMsg);
const char* getTargetTriple();
+ void setTargetTriple(const char*);
uint32_t getSymbolCount();
lto_symbol_attributes getSymbolAttributes(uint32_t index);
const char* getSymbolName(uint32_t index);
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index cc841bdf034..a299dd187d6 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -120,6 +120,14 @@ const char* lto_module_get_target_triple(lto_module_t mod)
return mod->getTargetTriple();
}
+//
+// sets triple string with which the object will be codegened.
+//
+void lto_module_set_target_triple(lto_module_t mod, const char *triple)
+{
+ return mod->setTargetTriple(triple);
+}
+
//
// returns the number of symbols in the object module
diff --git a/llvm/tools/lto/lto.exports b/llvm/tools/lto/lto.exports
index 9011cf602b1..a686b788457 100644
--- a/llvm/tools/lto/lto.exports
+++ b/llvm/tools/lto/lto.exports
@@ -6,6 +6,7 @@ lto_module_get_num_symbols
lto_module_get_symbol_attribute
lto_module_get_symbol_name
lto_module_get_target_triple
+lto_module_set_target_triple
lto_module_is_object_file
lto_module_is_object_file_for_target
lto_module_is_object_file_in_memory
OpenPOWER on IntegriCloud