[llvm-branch-commits] [llvm] [TableGen][AsmMatcher] Emit arithmetic for linear register coercion. NFCI (PR #241974)
Alexander Richardson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Nov 17 14:20:24 PST 2026
================
@@ -2092,6 +2094,42 @@ getConverterOperandID(const std::string &Name,
return ID;
}
+static bool
+tryEmitLinearRegCoercion(CodeGenRegBank &RegBank, raw_ostream &OS,
+ ArrayRef<AsmMatcherInfo::RegConversion> Conversions) {
+ if (Conversions.size() < 2)
+ return false;
+ auto getEnum = [&](const Record *R) { return RegBank.getReg(R)->EnumValue; };
+ unsigned FirstFrom = getEnum(Conversions[0].From);
+ unsigned FirstTo = getEnum(Conversions[0].To);
+ if (getEnum(Conversions[1].To) <= FirstTo)
+ return false;
+ unsigned FromStride = getEnum(Conversions[1].From) - FirstFrom;
----------------
arichardson wrote:
I think it should be safe to add an assertion here, but they should be ordered since `getMembers()` returns values sorted by EnumValue.
https://github.com/llvm/llvm-project/pull/241974
More information about the llvm-branch-commits
mailing list