[llvm] [TableGen][GISel] Extract common function for determining MI's regclass (PR #120135)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 12:21:40 PST 2024
================
@@ -2070,68 +2113,24 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
// The root of the match also has constraints on the register bank so that it
// matches the result instruction.
- unsigned OpIdx = 0;
unsigned N = std::min(DstExpDefs, SrcNumDefs);
for (unsigned I = 0; I < N; ++I) {
- const TypeSetByHwMode &VTy = Src.getExtType(I);
+ const auto &DstIOperand = DstI.Operands[I];
- const auto &DstIOperand = DstI.Operands[OpIdx];
- PointerUnion<const Record *, const CodeGenRegisterClass *> MatchedRC =
- DstIOperand.Rec;
- if (DstIName == "COPY_TO_REGCLASS") {
- MatchedRC = getInitValueAsRegClass(Dst.getChild(1).getLeafValue());
-
- if (MatchedRC.isNull())
- return failedImport(
- "COPY_TO_REGCLASS operand #1 isn't a register class");
- } else if (DstIName == "REG_SEQUENCE") {
- MatchedRC = getInitValueAsRegClass(Dst.getChild(0).getLeafValue());
- if (MatchedRC.isNull())
- return failedImport("REG_SEQUENCE operand #0 isn't a register class");
- } else if (DstIName == "EXTRACT_SUBREG") {
- const CodeGenRegisterClass *InferredClass =
- inferRegClassFromPattern(Dst.getChild(0));
- if (!InferredClass)
- return failedImport(
- "Could not infer class for EXTRACT_SUBREG operand #0");
-
- // We can assume that a subregister is in the same bank as it's super
- // register.
- MatchedRC = InferredClass->getDef();
----------------
s-barannikov wrote:
Here is the difference in behavior: previously we were satisfied with the class of the operand, now we actually try to infer the class of the result. This is a bit slower, but it looks like we would have tried to infer it later anyway (and bailed out if we couldn't).
https://github.com/llvm/llvm-project/pull/120135
More information about the llvm-commits
mailing list