aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2020-08-19 15:58:16 -0700
committerCraig Topper <craig.topper@intel.com>2020-08-19 15:58:19 -0700
commit724f570ad25568acc3a33dcdce9cadd776de2382 (patch)
tree5c5682fd3efccf246b2545ae3f6f0f4fce99d3e4 /clang/lib/CodeGen/CodeGenModule.cpp
parent4a367114397ab5d175cb8b74ee6144978e7fdeba (diff)
downloadllvm-724f570ad25568acc3a33dcdce9cadd776de2382.zip
llvm-724f570ad25568acc3a33dcdce9cadd776de2382.tar.gz
llvm-724f570ad25568acc3a33dcdce9cadd776de2382.tar.bz2
[X86] Add support 'tune' in target attribute
This adds parsing and codegen support for tune in target attribute. I've implemented this so that arch in the target attribute implicitly disables tune from the command line. I'm not sure what gcc does here. But since -march implies -mtune. I assume 'arch' in the target attribute implies tune in the target attribute. Differential Revision: https://reviews.llvm.org/D86187
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 23d35f6..65e5e27a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1770,9 +1770,14 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
// the function.
if (TD) {
ParsedTargetAttr ParsedAttr = TD->parse();
- if (ParsedAttr.Architecture != "" &&
- getTarget().isValidCPUName(ParsedAttr.Architecture))
+ if (!ParsedAttr.Architecture.empty() &&
+ getTarget().isValidCPUName(ParsedAttr.Architecture)) {
TargetCPU = ParsedAttr.Architecture;
+ TuneCPU = ""; // Clear the tune CPU.
+ }
+ if (!ParsedAttr.Tune.empty() &&
+ getTarget().isValidCPUName(ParsedAttr.Tune))
+ TuneCPU = ParsedAttr.Tune;
}
} else {
// Otherwise just add the existing target cpu and target features to the
@@ -1780,11 +1785,11 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
Features = getTarget().getTargetOpts().Features;
}
- if (TargetCPU != "") {
+ if (!TargetCPU.empty()) {
Attrs.addAttribute("target-cpu", TargetCPU);
AddedAttr = true;
}
- if (TuneCPU != "") {
+ if (!TuneCPU.empty()) {
Attrs.addAttribute("tune-cpu", TuneCPU);
AddedAttr = true;
}
@@ -1826,6 +1831,7 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
// new ones should replace the old.
F->removeFnAttr("target-cpu");
F->removeFnAttr("target-features");
+ F->removeFnAttr("tune-cpu");
F->addAttributes(llvm::AttributeList::FunctionIndex, Attrs);
}
}