[flang-commits] [flang] [Flang][RISCV] Set vscale_range based off zvl*b (PR #77277)
Philip Reames via flang-commits
flang-commits at lists.llvm.org
Wed Jan 10 10:15:32 PST 2024
================
@@ -712,13 +714,55 @@ void CodeGenAction::lowerHLFIRToFIR() {
static std::optional<std::pair<unsigned, unsigned>>
getVScaleRange(CompilerInstance &ci) {
const auto &langOpts = ci.getInvocation().getLangOpts();
- if (langOpts.VScaleMin || langOpts.VScaleMax)
- return std::pair<unsigned, unsigned>(
- langOpts.VScaleMin ? langOpts.VScaleMin : 1, langOpts.VScaleMax);
+ const auto targetOpts = ci.getInvocation().getTargetOpts();
+ const llvm::Triple triple(targetOpts.triple);
+
+ if (triple.isAArch64()) {
+ if (langOpts.VScaleMin || langOpts.VScaleMax)
+ return std::pair<unsigned, unsigned>(
+ langOpts.VScaleMin ? langOpts.VScaleMin : 1, langOpts.VScaleMax);
+
+ std::string featuresStr = ci.getTargetFeatures();
+ if (featuresStr.find("+sve") != std::string::npos)
+ return std::pair<unsigned, unsigned>(1, 16);
+ } else if (triple.isRISCV()) {
----------------
preames wrote:
Minor, but if we're going to making this fully conditional on target, go ahead and duplicate the
return std::nullopt; and use early return pattern here instead of the else-if chain.
https://github.com/llvm/llvm-project/pull/77277
More information about the flang-commits
mailing list