Skip to content

Commit

Permalink
[RISCV] Make RISCVISAInfo::updateMaxELen extension checking more robu…
Browse files Browse the repository at this point in the history
…st. Add inference from V extension. (#90650)

We weren't fully checking that we parsed Zve*x/f/d correctly. This could
break if new extension is added that starts with Zve.

We were assuming the Zve64d is present whenever V is so we only
inferred from Zve*. It's more correct to infer ELEN from V itself too.
  • Loading branch information
topperc committed Apr 30, 2024
1 parent 70ada5b commit 05d04f0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions llvm/lib/TargetParser/RISCVISAInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,19 +929,28 @@ void RISCVISAInfo::updateMinVLen() {
}

void RISCVISAInfo::updateMaxELen() {
assert(MaxELenFp == 0 && MaxELen == 0);
if (Exts.count("v")) {
MaxELenFp = std::max(MaxELenFp, 64u);
MaxELen = std::max(MaxELen, 64u);
}

// handles EEW restriction by sub-extension zve
for (auto const &Ext : Exts) {
StringRef ExtName = Ext.first;
bool IsZveExt = ExtName.consume_front("zve");
if (IsZveExt) {
if (ExtName.back() == 'f')
MaxELenFp = std::max(MaxELenFp, 32u);
if (ExtName.back() == 'd')
else if (ExtName.back() == 'd')
MaxELenFp = std::max(MaxELenFp, 64u);
else if (ExtName.back() != 'x')
continue;

ExtName = ExtName.drop_back();
unsigned ZveELen;
ExtName.getAsInteger(10, ZveELen);
MaxELen = std::max(MaxELen, ZveELen);
if (!ExtName.getAsInteger(10, ZveELen))
MaxELen = std::max(MaxELen, ZveELen);
}
}
}
Expand Down

0 comments on commit 05d04f0

Please sign in to comment.