aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2020-08-18 14:52:44 -0700
committerCraig Topper <craig.topper@intel.com>2020-08-18 15:13:19 -0700
commit4cbceb74bb5676d0181d4d0cab5194d90a42c2ec (patch)
treee285418c1cf5f30a805a652c48e54bab124f49e0 /clang/lib/CodeGen/CodeGenModule.cpp
parent2f0178585722ae289a71cfd81f9ca42235e3aefd (diff)
downloadllvm-4cbceb74bb5676d0181d4d0cab5194d90a42c2ec.zip
llvm-4cbceb74bb5676d0181d4d0cab5194d90a42c2ec.tar.gz
llvm-4cbceb74bb5676d0181d4d0cab5194d90a42c2ec.tar.bz2
[X86] Add basic support for -mtune command line option in clang
Building on the backend support from D85165. This parses the command line option in the driver, passes it on to CC1 and adds a function attribute. -Still need to support tune on the target attribute. -Need to use "generic" as the tuning by default. But need to change generic in the backend first. -Need to set tune if march is specified and mtune isn't. -May need to disable getHostCPUName's ability to guess CPU name from features when it doesn't have a family/model match for mtune=native. That's what gcc appears to do. Differential Revision: https://reviews.llvm.org/D85384
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ff35d94..23d35f6 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1749,6 +1749,7 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
// we have a decl for the function and it has a target attribute then
// parse that and add it to the feature set.
StringRef TargetCPU = getTarget().getTargetOpts().CPU;
+ StringRef TuneCPU = getTarget().getTargetOpts().TuneCPU;
std::vector<std::string> Features;
const auto *FD = dyn_cast_or_null<FunctionDecl>(GD.getDecl());
FD = FD ? FD->getMostRecentDecl() : FD;
@@ -1783,6 +1784,10 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
Attrs.addAttribute("target-cpu", TargetCPU);
AddedAttr = true;
}
+ if (TuneCPU != "") {
+ Attrs.addAttribute("tune-cpu", TuneCPU);
+ AddedAttr = true;
+ }
if (!Features.empty()) {
llvm::sort(Features);
Attrs.addAttribute("target-features", llvm::join(Features, ","));