From 7eb649c303bf271511a220479db6d8a04a1a8ab9 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Sun, 15 Oct 2017 17:51:07 +0000 Subject: [PATCH] Revert r315863: [globalisel][tablegen] Import ComplexPattern when used as an operator A large number of bots are failing on an ambiguous constructor call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315866 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../CodeGen/GlobalISel/InstructionSelector.h | 11 +- .../GlobalISel/InstructionSelectorImpl.h | 24 +--- .../GlobalISel/InstructionSelector.cpp | 2 +- .../AArch64/AArch64InstructionSelector.cpp | 13 +- test/TableGen/GlobalISelEmitter.td | 32 ++--- utils/TableGen/GlobalISelEmitter.cpp | 130 +++++------------- 6 files changed, 53 insertions(+), 159 deletions(-) diff --git a/include/llvm/CodeGen/GlobalISel/InstructionSelector.h b/include/llvm/CodeGen/GlobalISel/InstructionSelector.h index d86f02b8ae2..3cc1d35cc5c 100644 --- a/include/llvm/CodeGen/GlobalISel/InstructionSelector.h +++ b/include/llvm/CodeGen/GlobalISel/InstructionSelector.h @@ -17,7 +17,6 @@ #define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/Optional.h" #include #include #include @@ -208,11 +207,6 @@ enum { /// - InsnID - Instruction ID to modify /// - RendererID - The renderer to call GIR_ComplexRenderer, - /// Render sub-operands of complex operands to the specified instruction - /// - InsnID - Instruction ID to modify - /// - RendererID - The renderer to call - /// - RenderOpID - The suboperand to render. - GIR_ComplexSubOperandRenderer, /// Render a G_CONSTANT operator as a sign-extended immediate. /// - NewInsnID - Instruction ID to modify @@ -271,13 +265,12 @@ public: virtual bool select(MachineInstr &I) const = 0; protected: - using ComplexRendererFn = - Optional, 4>>; + using ComplexRendererFn = std::function; using RecordedMIVector = SmallVector; using NewMIVector = SmallVector; struct MatcherState { - std::vector Renderers; + std::vector Renderers; RecordedMIVector MIs; MatcherState(unsigned MaxRenderers); diff --git a/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h b/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h index d5400177f82..d4cb1326fb8 100644 --- a/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h +++ b/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h @@ -273,14 +273,12 @@ bool InstructionSelector::executeMatchTable( << "), ComplexPredicateID=" << ComplexPredicateID << ")\n"); assert(State.MIs[InsnID] != nullptr && "Used insn before defined"); // FIXME: Use std::invoke() when it's available. - ComplexRendererFn Renderer = - (ISel.*MatcherInfo.ComplexPredicates[ComplexPredicateID])( - State.MIs[InsnID]->getOperand(OpIdx)); - if (Renderer.hasValue()) - State.Renderers[RendererID] = Renderer.getValue(); - else + if (!(State.Renderers[RendererID] = + (ISel.*MatcherInfo.ComplexPredicates[ComplexPredicateID])( + State.MIs[InsnID]->getOperand(OpIdx)))) { if (handleReject() == RejectAndGiveUp) return false; + } break; } @@ -474,23 +472,11 @@ bool InstructionSelector::executeMatchTable( int64_t InsnID = MatchTable[CurrentIdx++]; int64_t RendererID = MatchTable[CurrentIdx++]; assert(OutMIs[InsnID] && "Attempted to add to undefined instruction"); - for (const auto &RenderOpFn : State.Renderers[RendererID]) - RenderOpFn(OutMIs[InsnID]); + State.Renderers[RendererID](OutMIs[InsnID]); DEBUG(dbgs() << CurrentIdx << ": GIR_ComplexRenderer(OutMIs[" << InsnID << "], " << RendererID << ")\n"); break; } - case GIR_ComplexSubOperandRenderer: { - int64_t InsnID = MatchTable[CurrentIdx++]; - int64_t RendererID = MatchTable[CurrentIdx++]; - int64_t RenderOpID = MatchTable[CurrentIdx++]; - assert(OutMIs[InsnID] && "Attempted to add to undefined instruction"); - State.Renderers[RendererID][RenderOpID](OutMIs[InsnID]); - DEBUG(dbgs() << CurrentIdx << ": GIR_ComplexSubOperandRenderer(OutMIs[" - << InsnID << "], " << RendererID << ", " << RenderOpID - << ")\n"); - break; - } case GIR_CopyConstantAsSImm: { int64_t NewInsnID = MatchTable[CurrentIdx++]; diff --git a/lib/CodeGen/GlobalISel/InstructionSelector.cpp b/lib/CodeGen/GlobalISel/InstructionSelector.cpp index e1cbb8dddfb..46966ccd60c 100644 --- a/lib/CodeGen/GlobalISel/InstructionSelector.cpp +++ b/lib/CodeGen/GlobalISel/InstructionSelector.cpp @@ -29,7 +29,7 @@ using namespace llvm; InstructionSelector::MatcherState::MatcherState(unsigned MaxRenderers) - : Renderers(MaxRenderers, {}), MIs() {} + : Renderers(MaxRenderers, nullptr), MIs() {} InstructionSelector::InstructionSelector() = default; diff --git a/lib/Target/AArch64/AArch64InstructionSelector.cpp b/lib/Target/AArch64/AArch64InstructionSelector.cpp index ca93d1feaa6..88259ffdf00 100644 --- a/lib/Target/AArch64/AArch64InstructionSelector.cpp +++ b/lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -1367,13 +1367,13 @@ AArch64InstructionSelector::selectArithImmed(MachineOperand &Root) const { else if (Root.isReg()) { MachineInstr *Def = MRI.getVRegDef(Root.getReg()); if (Def->getOpcode() != TargetOpcode::G_CONSTANT) - return None; + return nullptr; MachineOperand &Op1 = Def->getOperand(1); if (!Op1.isCImm() || Op1.getCImm()->getBitWidth() > 64) - return None; + return nullptr; Immed = Op1.getCImm()->getZExtValue(); } else - return None; + return nullptr; unsigned ShiftAmt; @@ -1383,13 +1383,10 @@ AArch64InstructionSelector::selectArithImmed(MachineOperand &Root) const { ShiftAmt = 12; Immed = Immed >> 12; } else - return None; + return nullptr; unsigned ShVal = AArch64_AM::getShifterImm(AArch64_AM::LSL, ShiftAmt); - return {{ - [=](MachineInstrBuilder &MIB) { MIB.addImm(Immed); }, - [=](MachineInstrBuilder &MIB) { MIB.addImm(ShVal); }, - }}; + return [=](MachineInstrBuilder &MIB) { MIB.addImm(Immed).addImm(ShVal); }; } namespace llvm { diff --git a/test/TableGen/GlobalISelEmitter.td b/test/TableGen/GlobalISelEmitter.td index 609d1c5ec51..f7ade225f2e 100644 --- a/test/TableGen/GlobalISelEmitter.td +++ b/test/TableGen/GlobalISelEmitter.td @@ -31,12 +31,6 @@ def complex : Operand, ComplexPattern { def gi_complex : GIComplexOperandMatcher, GIComplexPatternEquiv; -def complex_rr : Operand, ComplexPattern { - let MIOperandInfo = (ops GPR32, GPR32); -} -def gi_complex_rr : - GIComplexOperandMatcher, - GIComplexPatternEquiv; def m1 : OperandWithDefaultOps ; def Z : OperandWithDefaultOps ; @@ -62,7 +56,6 @@ def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; } // CHECK-NEXT: MatcherInfo({TypeObjects, FeatureBitsets, I64ImmPredicateFns, APIntImmPredicateFns, APFloatImmPredicateFns, { // CHECK-NEXT: nullptr, // GICP_Invalid // CHECK-NEXT: &MyTargetInstructionSelector::selectComplexPattern, // gi_complex -// CHECK-NEXT: &MyTargetInstructionSelector::selectComplexPatternRR, // gi_complex_rr // CHECK-NEXT: }}) // CHECK-NEXT: #endif // ifdef GET_GLOBALISEL_TEMPORARIES_INIT @@ -114,7 +107,6 @@ def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; } // CHECK-NEXT: enum { // CHECK-NEXT: GICP_Invalid, // CHECK-NEXT: GICP_gi_complex, -// CHECK-NEXT: GICP_gi_complex_rr, // CHECK-NEXT: }; // CHECK-LABEL: // PatFrag predicates. @@ -188,13 +180,9 @@ def HasC : Predicate<"Subtarget->hasC()"> { let RecomputePerFunction = 1; } // CHECK-NEXT: // Label 0: @[[LABEL]] def INSN3 : I<(outs GPR32:$dst), - (ins GPR32Op:$src1, GPR32:$src2a, GPR32:$src2b, GPR32:$src3, complex:$src4, i32imm:$src5a, i32imm:$src5b), []>; -def : Pat<(select GPR32:$src1, (complex_rr GPR32:$src2a, GPR32:$src2b), - (select GPR32:$src3, - complex:$src4, - (complex i32imm:$src5a, i32imm:$src5b))), - (INSN3 GPR32:$src1, GPR32:$src2b, GPR32:$src2a, GPR32:$src3, - complex:$src4, i32imm:$src5a, i32imm:$src5b)>; + (ins GPR32Op:$src1, complex:$src2, GPR32:$src3, complex:$src4, complex:$src5), []>; +def : Pat<(select GPR32:$src1, complex:$src2, (select GPR32:$src3, complex:$src4, complex:$src5)), + (INSN3 GPR32:$src1, complex:$src2, GPR32:$src3, complex:$src4, complex:$src5)>; //===- Test a pattern with multiple ComplexPattern operands. --------------===// // @@ -210,9 +198,9 @@ def : Pat<(select GPR32:$src1, (complex_rr GPR32:$src2a, GPR32:$src2b), // CHECK-NEXT: // MIs[0] src1 // CHECK-NEXT: GIM_CheckType, /*MI*/0, /*Op*/1, /*Type*/GILLT_s32, // CHECK-NEXT: GIM_CheckRegBankForClass, /*MI*/0, /*Op*/1, /*RC*/MyTarget::GPR32RegClassID, -// CHECK-NEXT: // MIs[0] Operand 2 +// CHECK-NEXT: // MIs[0] src2 // CHECK-NEXT: GIM_CheckType, /*MI*/0, /*Op*/2, /*Type*/GILLT_s32, -// CHECK-NEXT: GIM_CheckComplexPattern, /*MI*/0, /*Op*/2, /*Renderer*/0, GICP_gi_complex_rr, +// CHECK-NEXT: GIM_CheckComplexPattern, /*MI*/0, /*Op*/2, /*Renderer*/0, GICP_gi_complex, // CHECK-NEXT: // MIs[0] Operand 3 // CHECK-NEXT: GIM_CheckType, /*MI*/0, /*Op*/3, /*Type*/GILLT_s32, // CHECK-NEXT: GIM_CheckOpcode, /*MI*/1, TargetOpcode::G_SELECT, @@ -224,20 +212,18 @@ def : Pat<(select GPR32:$src1, (complex_rr GPR32:$src2a, GPR32:$src2b), // CHECK-NEXT: // MIs[1] src4 // CHECK-NEXT: GIM_CheckType, /*MI*/1, /*Op*/2, /*Type*/GILLT_s32, // CHECK-NEXT: GIM_CheckComplexPattern, /*MI*/1, /*Op*/2, /*Renderer*/1, GICP_gi_complex, -// CHECK-NEXT: // MIs[1] Operand 3 +// CHECK-NEXT: // MIs[1] src5 // CHECK-NEXT: GIM_CheckType, /*MI*/1, /*Op*/3, /*Type*/GILLT_s32, // CHECK-NEXT: GIM_CheckComplexPattern, /*MI*/1, /*Op*/3, /*Renderer*/2, GICP_gi_complex, // CHECK-NEXT: GIM_CheckIsSafeToFold, /*InsnID*/1, -// CHECK-NEXT: // (select:{ *:[i32] } GPR32:{ *:[i32] }:$src1, (complex_rr:{ *:[i32] } GPR32:{ *:[i32] }:$src2a, GPR32:{ *:[i32] }:$src2b), (select:{ *:[i32] } GPR32:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src4, (complex:{ *:[i32] } i32imm:{ *:[i32] }:$src5a, i32imm:{ *:[i32] }:$src5b))) => (INSN3:{ *:[i32] } GPR32:{ *:[i32] }:$src1, GPR32:{ *:[i32] }:$src2b, GPR32:{ *:[i32] }:$src2a, GPR32:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src4, i32imm:{ *:[i32] }:$src5a, i32imm:{ *:[i32] }:$src5b) +// CHECK-NEXT: // (select:{ *:[i32] } GPR32:{ *:[i32] }:$src1, complex:{ *:[i32] }:$src2, (select:{ *:[i32] } GPR32:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src4, complex:{ *:[i32] }:$src5)) => (INSN3:{ *:[i32] } GPR32:{ *:[i32] }:$src1, complex:{ *:[i32] }:$src2, GPR32:{ *:[i32] }:$src3, complex:{ *:[i32] }:$src4, complex:{ *:[i32] }:$src5) // CHECK-NEXT: GIR_BuildMI, /*InsnID*/0, /*Opcode*/MyTarget::INSN3, // CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/0, // dst // CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/0, /*OpIdx*/1, // src1 -// CHECK-NEXT: GIR_ComplexSubOperandRenderer, /*InsnID*/0, /*RendererID*/0, /*SubOperand*/1, // src2b -// CHECK-NEXT: GIR_ComplexSubOperandRenderer, /*InsnID*/0, /*RendererID*/0, /*SubOperand*/0, // src2a +// CHECK-NEXT: GIR_ComplexRenderer, /*InsnID*/0, /*RendererID*/0, // CHECK-NEXT: GIR_Copy, /*NewInsnID*/0, /*OldInsnID*/1, /*OpIdx*/1, // src3 // CHECK-NEXT: GIR_ComplexRenderer, /*InsnID*/0, /*RendererID*/1, -// CHECK-NEXT: GIR_ComplexSubOperandRenderer, /*InsnID*/0, /*RendererID*/2, /*SubOperand*/0, // src5a -// CHECK-NEXT: GIR_ComplexSubOperandRenderer, /*InsnID*/0, /*RendererID*/2, /*SubOperand*/1, // src5b +// CHECK-NEXT: GIR_ComplexRenderer, /*InsnID*/0, /*RendererID*/2, // CHECK-NEXT: GIR_EraseFromParent, /*InsnID*/0, // CHECK-NEXT: GIR_ConstrainSelectedInstOperands, /*InsnID*/0, // CHECK-NEXT: GIR_Done, diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index e19b4392689..bbc396967c0 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -203,12 +203,7 @@ std::string explainOperator(Record *Operator) { if (Operator->isSubClassOf("Intrinsic")) return (" (Operator is an Intrinsic, " + Operator->getName() + ")").str(); - if (Operator->isSubClassOf("ComplexPattern")) - return (" (Operator is an unmapped ComplexPattern, " + Operator->getName() + - ")") - .str(); - - return (" (Operator " + Operator->getName() + " not understood)").str(); + return " (Operator not understood)"; } /// Helper function to let the emitter report skip reason error messages. @@ -519,17 +514,10 @@ class RuleMatcher { ArrayRef SrcLoc; - typedef std::tuple - DefinedComplexPatternSubOperand; - typedef StringMap - DefinedComplexPatternSubOperandMap; - /// A map of Symbolic Names to ComplexPattern sub-operands. - DefinedComplexPatternSubOperandMap ComplexSubOperands; - public: RuleMatcher(ArrayRef SrcLoc) : Matchers(), Actions(), InsnVariableIDs(), DefinedOperands(), - NextInsnVarID(0), SrcLoc(SrcLoc), ComplexSubOperands() {} + NextInsnVarID(0), SrcLoc(SrcLoc) {} RuleMatcher(RuleMatcher &&Other) = default; RuleMatcher &operator=(RuleMatcher &&Other) = default; @@ -559,20 +547,6 @@ public: void defineOperand(StringRef SymbolicName, OperandMatcher &OM); - void defineComplexSubOperand(StringRef SymbolicName, Record *ComplexPattern, - unsigned RendererID, unsigned SubOperandID) { - assert(ComplexSubOperands.count(SymbolicName) == 0 && "Already defined"); - ComplexSubOperands[SymbolicName] = - std::make_tuple(ComplexPattern, RendererID, SubOperandID); - } - Optional - getComplexSubOperand(StringRef SymbolicName) const { - const auto &I = ComplexSubOperands.find(SymbolicName); - if (I == ComplexSubOperands.end()) - return None; - return I->second; - } - const InstructionMatcher &getInstructionMatcher(StringRef SymbolicName) const; const OperandMatcher &getOperandMatcher(StringRef Name) const; @@ -1566,9 +1540,6 @@ private: /// The renderer number. This must be unique within a rule since it's used to /// identify a temporary variable to hold the renderer function. unsigned RendererID; - /// When provided, this is the suboperand of the ComplexPattern operand to - /// render. Otherwise all the suboperands will be rendered. - Optional SubOperand; unsigned getNumOperands() const { return TheDef.getValueAsDag("Operands")->getNumArgs(); @@ -1576,26 +1547,19 @@ private: public: RenderComplexPatternOperand(unsigned InsnID, const Record &TheDef, - StringRef SymbolicName, unsigned RendererID, - Optional SubOperand = None) + StringRef SymbolicName, unsigned RendererID) : OperandRenderer(OR_ComplexPattern), InsnID(InsnID), TheDef(TheDef), - SymbolicName(SymbolicName), RendererID(RendererID), - SubOperand(SubOperand) {} + SymbolicName(SymbolicName), RendererID(RendererID) {} static bool classof(const OperandRenderer *R) { return R->getKind() == OR_ComplexPattern; } void emitRenderOpcodes(MatchTable &Table, RuleMatcher &Rule) const override { - Table << MatchTable::Opcode(SubOperand.hasValue() ? "GIR_ComplexSubOperandRenderer" - : "GIR_ComplexRenderer") + Table << MatchTable::Opcode("GIR_ComplexRenderer") << MatchTable::Comment("InsnID") << MatchTable::IntValue(InsnID) << MatchTable::Comment("RendererID") - << MatchTable::IntValue(RendererID); - if (SubOperand.hasValue()) - Table << MatchTable::Comment("SubOperand") - << MatchTable::IntValue(SubOperand.getValue()); - Table << MatchTable::Comment(SymbolicName) << MatchTable::LineBreak; + << MatchTable::IntValue(RendererID) << MatchTable::LineBreak; } }; @@ -2064,12 +2028,11 @@ private: Record *findNodeEquiv(Record *N) const; Error importRulePredicates(RuleMatcher &M, ArrayRef Predicates); - Expected createAndImportSelDAGMatcher( - RuleMatcher &Rule, InstructionMatcher &InsnMatcher, - const TreePatternNode *Src, unsigned &TempOpIdx) const; - Error importComplexPatternOperandMatcher(OperandMatcher &OM, Record *R, - unsigned &TempOpIdx) const; - Error importChildMatcher(RuleMatcher &Rule, InstructionMatcher &InsnMatcher, + Expected + createAndImportSelDAGMatcher(InstructionMatcher &InsnMatcher, + const TreePatternNode *Src, + unsigned &TempOpIdx) const; + Error importChildMatcher(InstructionMatcher &InsnMatcher, const TreePatternNode *SrcChild, unsigned OpIdx, unsigned &TempOpIdx) const; Expected @@ -2133,9 +2096,10 @@ GlobalISelEmitter::importRulePredicates(RuleMatcher &M, return Error::success(); } -Expected GlobalISelEmitter::createAndImportSelDAGMatcher( - RuleMatcher &Rule, InstructionMatcher &InsnMatcher, - const TreePatternNode *Src, unsigned &TempOpIdx) const { +Expected +GlobalISelEmitter::createAndImportSelDAGMatcher(InstructionMatcher &InsnMatcher, + const TreePatternNode *Src, + unsigned &TempOpIdx) const { Record *SrcGIEquivOrNull = nullptr; const CodeGenInstruction *SrcGIOrNull = nullptr; @@ -2232,8 +2196,8 @@ Expected GlobalISelEmitter::createAndImportSelDAGMatcher( return failedImport("Expected IntInit containing instrinsic ID)"); } - if (auto Error = importChildMatcher(Rule, InsnMatcher, SrcChild, OpIdx++, - TempOpIdx)) + if (auto Error = + importChildMatcher(InsnMatcher, SrcChild, OpIdx++, TempOpIdx)) return std::move(Error); } } @@ -2241,20 +2205,7 @@ Expected GlobalISelEmitter::createAndImportSelDAGMatcher( return InsnMatcher; } -Error GlobalISelEmitter::importComplexPatternOperandMatcher( - OperandMatcher &OM, Record *R, unsigned &TempOpIdx) const { - const auto &ComplexPattern = ComplexPatternEquivs.find(R); - if (ComplexPattern == ComplexPatternEquivs.end()) - return failedImport("SelectionDAG ComplexPattern (" + R->getName() + - ") not mapped to GlobalISel"); - - OM.addPredicate(OM, *ComplexPattern->second); - TempOpIdx++; - return Error::success(); -} - -Error GlobalISelEmitter::importChildMatcher(RuleMatcher &Rule, - InstructionMatcher &InsnMatcher, +Error GlobalISelEmitter::importChildMatcher(InstructionMatcher &InsnMatcher, const TreePatternNode *SrcChild, unsigned OpIdx, unsigned &TempOpIdx) const { @@ -2287,26 +2238,6 @@ Error GlobalISelEmitter::importChildMatcher(RuleMatcher &Rule, // Check for nested instructions. if (!SrcChild->isLeaf()) { - if (SrcChild->getOperator()->isSubClassOf("ComplexPattern")) { - // When a ComplexPattern is used as an operator, it should do the same - // thing as when used as a leaf. However, the children of the operator - // name the sub-operands that make up the complex operand and we must - // prepare to reference them in the renderer too. - unsigned RendererID = TempOpIdx; - if (auto Error = importComplexPatternOperandMatcher( - OM, SrcChild->getOperator(), TempOpIdx)) - return Error; - - for (unsigned i = 0, e = SrcChild->getNumChildren(); i != e; ++i) { - auto *SubOperand = SrcChild->getChild(i); - if (!SubOperand->getName().empty()) - Rule.defineComplexSubOperand(SubOperand->getName(), - SrcChild->getOperator(), RendererID, i); - } - - return Error::success(); - } - auto MaybeInsnOperand = OM.addPredicate( InsnMatcher.getRuleMatcher(), SrcChild->getName()); if (!MaybeInsnOperand.hasValue()) { @@ -2319,7 +2250,7 @@ Error GlobalISelEmitter::importChildMatcher(RuleMatcher &Rule, // Map the node to a gMIR instruction. InstructionOperandMatcher &InsnOperand = **MaybeInsnOperand; auto InsnMatcherOrError = createAndImportSelDAGMatcher( - Rule, InsnOperand.getInsnMatcher(), SrcChild, TempOpIdx); + InsnOperand.getInsnMatcher(), SrcChild, TempOpIdx); if (auto Error = InsnMatcherOrError.takeError()) return Error; @@ -2352,8 +2283,17 @@ Error GlobalISelEmitter::importChildMatcher(RuleMatcher &Rule, } // Check for ComplexPattern's. - if (ChildRec->isSubClassOf("ComplexPattern")) - return importComplexPatternOperandMatcher(OM, ChildRec, TempOpIdx); + if (ChildRec->isSubClassOf("ComplexPattern")) { + const auto &ComplexPattern = ComplexPatternEquivs.find(ChildRec); + if (ComplexPattern == ComplexPatternEquivs.end()) + return failedImport("SelectionDAG ComplexPattern (" + + ChildRec->getName() + ") not mapped to GlobalISel"); + + OM.addPredicate(OM, + *ComplexPattern->second); + TempOpIdx++; + return Error::success(); + } if (ChildRec->isSubClassOf("ImmLeaf")) { return failedImport( @@ -2375,14 +2315,6 @@ Error GlobalISelEmitter::importExplicitUseRenderer( DstChild->getTransformFn()->getName()); } - const auto &SubOperand = Rule.getComplexSubOperand(DstChild->getName()); - if (SubOperand.hasValue()) { - DstMIBuilder.addRenderer( - 0, *std::get<0>(*SubOperand), DstChild->getName(), - std::get<1>(*SubOperand), std::get<2>(*SubOperand)); - return Error::success(); - } - if (!DstChild->isLeaf()) { // We accept 'bb' here. It's an operator because BasicBlockSDNode isn't // inline, but in MI it's just another operand. @@ -2620,7 +2552,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { InstructionMatcher &InsnMatcherTemp = M.addInstructionMatcher(Src->getName()); unsigned TempOpIdx = 0; auto InsnMatcherOrError = - createAndImportSelDAGMatcher(M, InsnMatcherTemp, Src, TempOpIdx); + createAndImportSelDAGMatcher(InsnMatcherTemp, Src, TempOpIdx); if (auto Error = InsnMatcherOrError.takeError()) return std::move(Error); InstructionMatcher &InsnMatcher = InsnMatcherOrError.get(); -- 2.40.0