aboutsummaryrefslogtreecommitdiff
path: root/include/llvm
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
commit3c2d4bf97fa96fe171883cd80e4ea93fc43563e6 (patch)
tree736e1e2b833b3475c24a0569a546870cf25dd5fb /include/llvm
parent0c794b87253bcd597f87960632f8654a151f37ec (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/ADT/Triple.h6
-rw-r--r--include/llvm/Target/TargetRegistry.h18
2 files changed, 20 insertions, 4 deletions
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index 7ae2c3033d..5c8244c638 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -95,7 +95,7 @@ public:
/// @{
Triple() : Data(""), Arch(InvalidArch) {}
- explicit Triple(const char *Str) : Data(Str), Arch(InvalidArch) {}
+ explicit Triple(const StringRef &Str) : Data(Str), Arch(InvalidArch) {}
explicit Triple(const char *ArchStr, const char *VendorStr, const char *OSStr)
: Data(ArchStr), Arch(InvalidArch) {
Data += '-';
@@ -212,6 +212,10 @@ public:
/// getOSTypeName - Get the canonical name for the \arg Kind vendor.
static const char *getOSTypeName(OSType Kind);
+ /// getArchTypeForLLVMName - The canonical type for the given LLVM
+ /// architecture name (e.g., "x86").
+ static ArchType getArchTypeForLLVMName(const StringRef &Str);
+
/// @}
};
diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h
index 9b164ba23e..93991dc687 100644
--- a/include/llvm/Target/TargetRegistry.h
+++ b/include/llvm/Target/TargetRegistry.h
@@ -51,6 +51,7 @@ namespace llvm {
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
const Module &,
+ const std::string &,
const std::string &);
typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
TargetMachine &,
@@ -110,12 +111,21 @@ namespace llvm {
/// hasAsmParser - Check if this target supports .s parsing.
bool hasAsmParser() const { return AsmParserCtorFn != 0; }
- /// createTargetMachine - Create a target specific machine implementation.
+ /// createTargetMachine - Create a target specific machine implementation
+ /// for the module \arg M and \arg Triple.
+ ///
+ /// \arg M - This argument is used for some machines to access the target
+ /// data.
+ /// \arg Triple - This argument is used to determine the target machine
+ /// feature set; it should always be provided. Generally this should be
+ /// either the target triple from the module, or the target triple of the
+ /// host if that does not exist.
TargetMachine *createTargetMachine(const Module &M,
+ const std::string &Triple,
const std::string &Features) const {
if (!TargetMachineCtorFn)
return 0;
- return TargetMachineCtorFn(*this, M, Features);
+ return TargetMachineCtorFn(*this, M, Triple, Features);
}
/// createAsmPrinter - Create a target specific assembly printer pass.
@@ -325,8 +335,9 @@ namespace llvm {
private:
static TargetMachine *Allocator(const Target &T, const Module &M,
+ const std::string &TT,
const std::string &FS) {
- return new TargetMachineImpl(T, M.getTargetTriple(), FS);
+ return new TargetMachineImpl(T, TT, FS);
}
};
@@ -338,6 +349,7 @@ namespace llvm {
private:
static TargetMachine *Allocator(const Target &T, const Module &M,
+ const std::string &TT,
const std::string &FS) {
return new TargetMachineImpl(T, M, FS);
}