diff options
author | Alexis Perry-Holby <AlexisPerry@users.noreply.github.com> | 2024-06-25 11:39:35 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-25 18:39:35 +0100 |
commit | a790279bf2a8be2f9c42bf80f55a63933e398d0e (patch) | |
tree | c9f2be9657baf65c09860fbb5b548c8d06bf79e1 /flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | |
parent | 928b7808406b893b24edb8d8462491dc82f9ce43 (diff) | |
download | llvm-a790279bf2a8be2f9c42bf80f55a63933e398d0e.zip llvm-a790279bf2a8be2f9c42bf80f55a63933e398d0e.tar.gz llvm-a790279bf2a8be2f9c42bf80f55a63933e398d0e.tar.bz2 |
[flang] Add basic -mtune support (#95043)
This PR adds -mtune as a valid flang flag and passes the information
through to LLVM IR as an attribute on all functions. No specific
architecture optimizations are added at this time.
Diffstat (limited to 'flang/lib/Optimizer/CodeGen/TargetRewrite.cpp')
-rw-r--r-- | flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp index 8199c5e..a101295 100644 --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -89,6 +89,9 @@ public: if (!forcedTargetCPU.empty()) fir::setTargetCPU(mod, forcedTargetCPU); + if (!forcedTuneCPU.empty()) + fir::setTuneCPU(mod, forcedTuneCPU); + if (!forcedTargetFeatures.empty()) fir::setTargetFeatures(mod, forcedTargetFeatures); @@ -106,7 +109,8 @@ public: auto specifics = fir::CodeGenSpecifics::get( mod.getContext(), fir::getTargetTriple(mod), fir::getKindMapping(mod), - fir::getTargetCPU(mod), fir::getTargetFeatures(mod), *dl); + fir::getTargetCPU(mod), fir::getTargetFeatures(mod), *dl, + fir::getTuneCPU(mod)); setMembers(specifics.get(), &rewriter, &*dl); @@ -672,12 +676,18 @@ public: auto targetCPU = specifics->getTargetCPU(); mlir::StringAttr targetCPUAttr = targetCPU.empty() ? nullptr : mlir::StringAttr::get(ctx, targetCPU); + auto tuneCPU = specifics->getTuneCPU(); + mlir::StringAttr tuneCPUAttr = + tuneCPU.empty() ? nullptr : mlir::StringAttr::get(ctx, tuneCPU); auto targetFeaturesAttr = specifics->getTargetFeatures(); for (auto fn : mod.getOps<mlir::func::FuncOp>()) { if (targetCPUAttr) fn->setAttr("target_cpu", targetCPUAttr); + if (tuneCPUAttr) + fn->setAttr("tune_cpu", tuneCPUAttr); + if (targetFeaturesAttr) fn->setAttr("target_features", targetFeaturesAttr); |