diff options
author | Eric Christopher <echristo@gmail.com> | 2015-08-27 00:05:52 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-08-27 00:05:52 +0000 |
commit | 2b4a725e0a74dfa289e84ab7926382d12419abc0 (patch) | |
tree | 627153d111d9594e139016543b0a69774b979c76 /clang/lib/Basic/Targets.cpp | |
parent | c50738f139b99fa07da2aff8ef7a9b927bcaa1b9 (diff) | |
download | bcm5719-llvm-2b4a725e0a74dfa289e84ab7926382d12419abc0.tar.gz bcm5719-llvm-2b4a725e0a74dfa289e84ab7926382d12419abc0.zip |
Pass in a cpu to initDefaultFeatures so that we can share this code
with multiple uses of feature map construction.
Note: We could make this a static function on TargetInfo if we
fix the x86 port needing to check the triple in an isolated case.
llvm-svn: 246128
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index d945280d31a..bfeba9b5184 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -863,7 +863,8 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - void initDefaultFeatures(llvm::StringMap<bool> &Features) const override; + void initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const override; bool handleTargetFeatures(std::vector<std::string> &Features, DiagnosticsEngine &Diags) override; @@ -1262,7 +1263,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, // __NO_FPRS__ } -void PPCTargetInfo::initDefaultFeatures(llvm::StringMap<bool> &Features) const { +void PPCTargetInfo::initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const { Features["altivec"] = llvm::StringSwitch<bool>(CPU) .Case("7400", true) .Case("g4", true) @@ -2372,7 +2374,8 @@ public: // initDefaultFeatures which calls this repeatedly. static void setFeatureEnabledImpl(llvm::StringMap<bool> &Features, StringRef Name, bool Enabled); - void initDefaultFeatures(llvm::StringMap<bool> &Features) const override; + void initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const override; bool hasFeature(StringRef Feature) const override; bool handleTargetFeatures(std::vector<std::string> &Features, DiagnosticsEngine &Diags) override; @@ -2498,14 +2501,15 @@ bool X86TargetInfo::setFPMath(StringRef Name) { return false; } -void X86TargetInfo::initDefaultFeatures(llvm::StringMap<bool> &Features) const { +void X86TargetInfo::initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const { // FIXME: This *really* should not be here. // X86_64 always has SSE2. if (getTriple().getArch() == llvm::Triple::x86_64) setFeatureEnabledImpl(Features, "sse2", true); - switch (CPU) { + switch (getCPUKind(CPU)) { case CK_Generic: case CK_i386: case CK_i486: @@ -4375,7 +4379,8 @@ public: } // FIXME: This should be based on Arch attributes, not CPU names. - void initDefaultFeatures(llvm::StringMap<bool> &Features) const override { + void initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const override { if (CPU == "arm1136jf-s" || CPU == "arm1176jzf-s" || CPU == "mpcore") Features["vfp2"] = true; else if (CPU == "cortex-a8" || CPU == "cortex-a9") { @@ -5818,7 +5823,8 @@ public: return CPUKnown; } - void initDefaultFeatures(llvm::StringMap<bool> &Features) const override { + void initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const override { if (CPU == "zEC12") Features["transactional-execution"] = true; if (CPU == "z13") { @@ -6185,7 +6191,8 @@ public: .Default(false); } const std::string& getCPU() const { return CPU; } - void initDefaultFeatures(llvm::StringMap<bool> &Features) const override { + void initDefaultFeatures(llvm::StringMap<bool> &Features, + StringRef CPU) const override { if (CPU == "octeon") Features["mips64r2"] = Features["cnmips"] = true; else @@ -7475,7 +7482,7 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, // Compute the default target features, we need the target to handle this // because features may have dependencies on one another. llvm::StringMap<bool> Features; - Target->initDefaultFeatures(Features); + Target->initDefaultFeatures(Features, Opts->CPU); // Apply the user specified deltas. if (!Target->handleUserFeatures(Features, Opts->FeaturesAsWritten, Diags)) |