summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/CBackend/CBackend.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-03 04:03:51 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-03 04:03:51 +0000
commit0f16ea5c30c0c63f2c4107d997f8828185fb3f85 (patch)
treeb01704afa1594f6f82ff3e9e5609a43beec56d4c /llvm/lib/Target/CBackend/CBackend.cpp
parentb9a45a46f12640b82ae56e58faac8ddb70fd3ce4 (diff)
downloadbcm5719-llvm-0f16ea5c30c0c63f2c4107d997f8828185fb3f85.tar.gz
bcm5719-llvm-0f16ea5c30c0c63f2c4107d997f8828185fb3f85.zip
Pass target triple string in to TargetMachine constructor.
This is not just a matter of passing in the target triple from the module; currently backends are making decisions based on the build and host architecture. The goal is to migrate to making these decisions based off of the triple (in conjunction with the feature string). Thus most clients pass in the target triple, or the host triple if that is empty. This has one important change in the way behavior of the JIT and llc. For the JIT, it was previously selecting the Target based on the host (naturally), but it was setting the target machine features based on the triple from the module. Now it is setting the target machine features based on the triple of the host. For LLC, -march was previously only used to select the target, the target machine features were initialized from the module's triple (which may have been empty). Now the target triple is taken from the module, or the host's triple is used if that is empty. Then the triple is adjusted to match -march. The take away is that -march for llc is now used in conjunction with the host triple to initialize the subtarget. If users want more deterministic behavior from llc, they should use -mtriple, or set the triple in the input module. llvm-svn: 77946
Diffstat (limited to 'llvm/lib/Target/CBackend/CBackend.cpp')
-rw-r--r--llvm/lib/Target/CBackend/CBackend.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Target/CBackend/CBackend.cpp b/llvm/lib/Target/CBackend/CBackend.cpp
index 84f7c11e5d6..c014006f54c 100644
--- a/llvm/lib/Target/CBackend/CBackend.cpp
+++ b/llvm/lib/Target/CBackend/CBackend.cpp
@@ -24,6 +24,8 @@
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/InlineAsm.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/LoopInfo.h"
@@ -41,9 +43,7 @@
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/MathExtras.h"
+#include "llvm/System/Host.h"
#include "llvm/Config/config.h"
#include <algorithm>
#include <sstream>
@@ -3181,16 +3181,21 @@ std::string CWriter::InterpretASMConstraint(InlineAsm::ConstraintInfo& c) {
// Grab the translation table from TargetAsmInfo if it exists.
if (!TAsm) {
+ std::string Triple = TheModule->getTargetTriple();
+ if (Triple.empty())
+ Triple = llvm::sys::getHostTriple();
+
std::string E;
const Target *Match =
- TargetRegistry::lookupTarget(TheModule->getTargetTriple(),
- /*FallbackToHost=*/true,
+ TargetRegistry::lookupTarget(Triple,
+ /*FallbackToHost=*/false,
/*RequireJIT=*/false,
E);
if (Match) {
// Per platform Target Machines don't exist, so create it;
// this must be done only once.
- const TargetMachine* TM = Match->createTargetMachine(*TheModule, "");
+ const TargetMachine* TM = Match->createTargetMachine(*TheModule, Triple,
+ "");
TAsm = TM->getTargetAsmInfo();
}
}
OpenPOWER on IntegriCloud