aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2014-10-01 20:38:26 +0000
committerEric Christopher <echristo@gmail.com>2014-10-01 20:38:26 +0000
commit36448af7f5f43420a3be90f5bc78ef7ea39cd57d (patch)
tree0618252283ffdf2eba39358216343b0bbc6ddc5c /llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
parent12f4a7858199a367b0ddf3a5452f691a30c5eef0 (diff)
downloadllvm-36448af7f5f43420a3be90f5bc78ef7ea39cd57d.zip
llvm-36448af7f5f43420a3be90f5bc78ef7ea39cd57d.tar.gz
llvm-36448af7f5f43420a3be90f5bc78ef7ea39cd57d.tar.bz2
Rework the PPC TargetMachine so that the non-function specific
overrides happen at TargetMachine creation and not on every subtarget creation. llvm-svn: 218805
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetMachine.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index ed90e272..908e159 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -37,12 +37,39 @@ extern "C" void LLVMInitializePowerPCTarget() {
RegisterTargetMachine<PPC64TargetMachine> C(ThePPC64LETarget);
}
+static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL, StringRef TT) {
+ std::string FullFS = FS;
+ Triple TargetTriple(TT);
+
+ // Make sure 64-bit features are available when CPUname is generic
+ if (TargetTriple.getArch() == Triple::ppc64 ||
+ TargetTriple.getArch() == Triple::ppc64le) {
+ if (!FullFS.empty())
+ FullFS = "+64bit," + FullFS;
+ else
+ FullFS = "+64bit";
+ }
+
+ if (OL >= CodeGenOpt::Default) {
+ if (!FullFS.empty())
+ FullFS = "+crbits," + FullFS;
+ else
+ FullFS = "+crbits";
+ }
+ return FullFS;
+}
+
+// The FeatureString here is a little subtle. We are modifying the feature string
+// with what are (currently) non-function specific overrides as it goes into the
+// LLVMTargetMachine constructor and then using the stored value in the
+// Subtarget constructor below it.
PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL)
- : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
- Subtarget(TT, CPU, FS, *this, OL) {
+ : LLVMTargetMachine(T, TT, CPU, computeFSAdditions(FS, OL, TT), Options, RM,
+ CM, OL),
+ Subtarget(TT, CPU, TargetFS, *this, OL) {
initAsmInfo();
}