Index: test/TableGen/GlobalISelEmitter.td =================================================================== --- test/TableGen/GlobalISelEmitter.td +++ test/TableGen/GlobalISelEmitter.td @@ -9,6 +9,7 @@ def R0 : Register<"r0"> { let Namespace = "MyTarget"; } def GPR32 : RegisterClass<"MyTarget", [i32], 32, (add R0)>; +def GPR32Op : RegisterOperand; class I Pat> : Instruction { @@ -91,7 +92,7 @@ // CHECK-NEXT: } def : GINodeEquiv; -def INSN2 : I<(outs GPR32:$dst), (ins GPR32:$src1, complex:$src2, complex:$src3), []>; +def INSN2 : I<(outs GPR32:$dst), (ins GPR32Op:$src1, complex:$src2, complex:$src3), []>; def : Pat<(select GPR32:$src1, complex:$src2, complex:$src3), (INSN2 GPR32:$src1, complex:$src3, complex:$src2)>; Index: utils/TableGen/GlobalISelEmitter.cpp =================================================================== --- utils/TableGen/GlobalISelEmitter.cpp +++ utils/TableGen/GlobalISelEmitter.cpp @@ -1383,6 +1383,12 @@ return Error::success(); } + if (ChildRec->isSubClassOf("RegisterOperand")) { + OM.addPredicate( + Target.getRegisterClass(ChildRec->getValueAsDef("RegClass"))); + return Error::success(); + } + // Check for ComplexPattern's. if (ChildRec->isSubClassOf("ComplexPattern")) { const auto &ComplexPattern = ComplexPatternEquivs.find(ChildRec); @@ -1446,7 +1452,8 @@ return Error::success(); } - if (ChildRec->isSubClassOf("RegisterClass")) { + if (ChildRec->isSubClassOf("RegisterClass") || + ChildRec->isSubClassOf("RegisterOperand")) { DstMIBuilder.addRenderer(InsnMatcher, DstChild->getName()); return Error::success(); } @@ -1613,6 +1620,8 @@ const auto &DstIOperand = DstI.Operands[OpIdx]; Record *DstIOpRec = DstIOperand.Rec; + if (DstIOpRec->isSubClassOf("RegisterOperand")) + DstIOpRec = DstIOpRec->getValueAsDef("RegClass"); if (!DstIOpRec->isSubClassOf("RegisterClass")) return failedImport("Dst MI def isn't a register class");