From b0f1f2331d95ef29e654038ed1e8a5a9573e0f77 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 31 Oct 2017 21:54:52 +0000 Subject: [PATCH] Revert r317040: [globalisel][tablegen] Keep track of the insertion point while adding BuildMIAction's. NFC The same bots fail but I believe I know what the issue is now. These bots are missing the const_iterator versions of insert/emplace/etc. that were introduced in C++11. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317042 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/GlobalISelEmitter.cpp | 110 ++++++++------------------- 1 file changed, 33 insertions(+), 77 deletions(-) diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index 417a915f523..9a38d925278 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -517,11 +517,6 @@ class MatchAction; /// Generates code to check that a match rule matches. class RuleMatcher { -public: - using ActionVec = std::vector>; - using const_action_iterator = ActionVec::const_iterator; - -protected: /// A list of matchers that all need to succeed for the current rule to match. /// FIXME: This currently supports a single match position but could be /// extended to support multiple positions to support div/rem fusion or @@ -530,7 +525,7 @@ protected: /// A list of actions that need to be taken when all predicates in this rule /// have succeeded. - ActionVec Actions; + std::vector> Actions; using DefinedInsnVariablesMap = std::map; @@ -576,9 +571,6 @@ public: const std::vector &getRequiredFeatures() const; template Kind &addAction(Args &&... args); - template - const_action_iterator insertAction(const_action_iterator InsertPt, - Args &&... args); /// Define an instruction without emitting any code to do so. /// This is used for the root of the match. @@ -614,12 +606,6 @@ public: (void)R; } - const_action_iterator actions_begin() const { return Actions.begin(); } - const_action_iterator actions_end() const { return Actions.end(); } - iterator_range actions() const { - return make_range(actions_begin(), actions_end()); - } - void defineOperand(StringRef SymbolicName, OperandMatcher &OM); void defineComplexSubOperand(StringRef SymbolicName, Record *ComplexPattern, @@ -656,8 +642,6 @@ public: InstructionMatcher &insnmatcher_front() const { return *Matchers.front(); } }; -using const_action_iterator = RuleMatcher::const_action_iterator; - template class PredicateListMatcher { private: typedef std::vector> PredicateVec; @@ -1958,30 +1942,11 @@ const std::vector &RuleMatcher::getRequiredFeatures() const { return RequiredFeatures; } -// Emplaces an action of the specified Kind at the end of the action list. -// -// Returns a reference to the newly created action. -// -// Like std::vector::emplace_back(), may invalidate all iterators if the new -// size exceeds the capacity. Otherwise, only invalidates the past-the-end -// iterator. template Kind &RuleMatcher::addAction(Args &&... args) { Actions.emplace_back(llvm::make_unique(std::forward(args)...)); return *static_cast(Actions.back().get()); } -// Emplaces an action of the specified Kind before the given insertion point. -// -// Returns an iterator pointing at the newly created instruction. -// -// Like std::vector::insert(), may invalidate all iterators if the new size -// exceeds the capacity. Otherwise, only invalidates the iterators from the -// insertion point onwards. -template -const_action_iterator RuleMatcher::insertAction(const_action_iterator InsertPt, - Args &&... args) { - return Actions.insert(InsertPt, llvm::make_unique(std::forward(args)...)); -} unsigned RuleMatcher::implicitlyDefineInsnVar(const InstructionMatcher &Matcher) { @@ -2260,18 +2225,15 @@ private: Expected createAndImportInstructionRenderer(RuleMatcher &M, const TreePatternNode *Dst); - Expected - createInstructionRenderer(const_action_iterator InsertPt, RuleMatcher &M, - const TreePatternNode *Dst); + Expected + createInstructionRenderer(RuleMatcher &M, const TreePatternNode *Dst); void importExplicitDefRenderers(BuildMIAction &DstMIBuilder); - Expected - importExplicitUseRenderers(const_action_iterator InsertPt, RuleMatcher &M, - BuildMIAction &DstMIBuilder, + Expected + importExplicitUseRenderers(RuleMatcher &M, BuildMIAction &DstMIBuilder, const llvm::TreePatternNode *Dst); - Expected - importExplicitUseRenderer(const_action_iterator InsertPt, RuleMatcher &Rule, - BuildMIAction &DstMIBuilder, - TreePatternNode *DstChild) const; + Error importExplicitUseRenderer(RuleMatcher &Rule, + BuildMIAction &DstMIBuilder, + TreePatternNode *DstChild) const; Error importDefaultOperandRenderers(BuildMIAction &DstMIBuilder, DagInit *DefaultOps) const; Error @@ -2601,9 +2563,9 @@ Error GlobalISelEmitter::importChildMatcher(RuleMatcher &Rule, return failedImport("Src pattern child is an unsupported kind"); } -Expected GlobalISelEmitter::importExplicitUseRenderer( - const_action_iterator InsertPt, RuleMatcher &Rule, - BuildMIAction &DstMIBuilder, TreePatternNode *DstChild) const { +Error GlobalISelEmitter::importExplicitUseRenderer( + RuleMatcher &Rule, BuildMIAction &DstMIBuilder, + TreePatternNode *DstChild) const { if (DstChild->getTransformFn() != nullptr) { return failedImport("Dst pattern child has transform fn " + DstChild->getTransformFn()->getName()); @@ -2614,7 +2576,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( DstMIBuilder.addRenderer( 0, *std::get<0>(*SubOperand), DstChild->getName(), std::get<1>(*SubOperand), std::get<2>(*SubOperand)); - return InsertPt; + return Error::success(); } if (!DstChild->isLeaf()) { @@ -2624,7 +2586,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( auto &ChildSDNI = CGP.getSDNodeInfo(DstChild->getOperator()); if (ChildSDNI.getSDClassName() == "BasicBlockSDNode") { DstMIBuilder.addRenderer(0, DstChild->getName()); - return InsertPt; + return Error::success(); } } @@ -2635,11 +2597,11 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( if (DstChild->getOperator()->getName() == "imm") { DstMIBuilder.addRenderer(0, DstChild->getName()); - return InsertPt; + return Error::success(); } else if (DstChild->getOperator()->getName() == "fpimm") { DstMIBuilder.addRenderer( 0, DstChild->getName()); - return InsertPt; + return Error::success(); } return failedImport("Dst pattern child isn't a leaf node or an MBB" + llvm::to_string(*DstChild)); @@ -2661,7 +2623,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( if (ChildRec->isSubClassOf("Register")) { DstMIBuilder.addRenderer(0, ChildRec); - return InsertPt; + return Error::success(); } if (ChildRec->isSubClassOf("RegisterClass") || @@ -2671,11 +2633,11 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( !ChildRec->isValueUnset("GIZeroRegister")) { DstMIBuilder.addRenderer( 0, DstChild->getName(), ChildRec->getValueAsDef("GIZeroRegister")); - return InsertPt; + return Error::success(); } DstMIBuilder.addRenderer(0, DstChild->getName()); - return InsertPt; + return Error::success(); } if (ChildRec->isSubClassOf("ComplexPattern")) { @@ -2688,7 +2650,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( DstMIBuilder.addRenderer( 0, *ComplexPattern->second, DstChild->getName(), OM.getAllocatedTemporariesBaseID()); - return InsertPt; + return Error::success(); } if (ChildRec->isSubClassOf("SDNodeXForm")) @@ -2704,26 +2666,22 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( Expected GlobalISelEmitter::createAndImportInstructionRenderer( RuleMatcher &M, const TreePatternNode *Dst) { - auto InsertPtOrError = createInstructionRenderer(M.actions_end(), M, Dst); - if (auto Error = InsertPtOrError.takeError()) + auto DstMIBuilderOrError = createInstructionRenderer(M, Dst); + if (auto Error = DstMIBuilderOrError.takeError()) return std::move(Error); - const_action_iterator InsertPt = InsertPtOrError.get(); - BuildMIAction &DstMIBuilder = *static_cast(InsertPt->get()); + BuildMIAction &DstMIBuilder = DstMIBuilderOrError.get(); importExplicitDefRenderers(DstMIBuilder); - if (auto Error = importExplicitUseRenderers(InsertPt, M, DstMIBuilder, Dst) - .takeError()) + if (auto Error = importExplicitUseRenderers(M, DstMIBuilder, Dst).takeError()) return std::move(Error); return DstMIBuilder; } -Expected -GlobalISelEmitter::createInstructionRenderer(const_action_iterator InsertPt, - RuleMatcher &M, - const TreePatternNode *Dst) { +Expected GlobalISelEmitter::createInstructionRenderer( + RuleMatcher &M, const TreePatternNode *Dst) { Record *DstOp = Dst->getOperator(); if (!DstOp->isSubClassOf("Instruction")) { if (DstOp->isSubClassOf("ValueType")) @@ -2740,9 +2698,9 @@ GlobalISelEmitter::createInstructionRenderer(const_action_iterator InsertPt, else if (DstI->TheDef->getName() == "EXTRACT_SUBREG") DstI = &Target.getInstruction(RK.getDef("COPY")); - InsertPt = M.insertAction(InsertPt, 0, DstI); + auto &DstMIBuilder = M.addAction(0, DstI); - return InsertPt; + return DstMIBuilder; } void GlobalISelEmitter::importExplicitDefRenderers( @@ -2754,8 +2712,8 @@ void GlobalISelEmitter::importExplicitDefRenderers( } } -Expected GlobalISelEmitter::importExplicitUseRenderers( - const_action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder, +Expected GlobalISelEmitter::importExplicitUseRenderers( + RuleMatcher &M, BuildMIAction &DstMIBuilder, const llvm::TreePatternNode *Dst) { const CodeGenInstruction *DstI = DstMIBuilder.getCGI(); CodeGenInstruction *OrigDstI = &Target.getInstruction(Dst->getOperator()); @@ -2781,7 +2739,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( DstMIBuilder.addRenderer( 0, Dst->getChild(0)->getName(), SubIdx); - return InsertPt; + return DstMIBuilder; } return failedImport("EXTRACT_SUBREG child #1 is not a subreg index"); @@ -2814,11 +2772,9 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( continue; } - auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder, - Dst->getChild(Child)); - if (auto Error = InsertPtOrError.takeError()) + if (auto Error = + importExplicitUseRenderer(M, DstMIBuilder, Dst->getChild(Child))) return std::move(Error); - InsertPt = InsertPtOrError.get(); ++Child; } @@ -2829,7 +2785,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( " explicit ones and " + llvm::to_string(NumDefaultOps) + " default ones"); - return InsertPt; + return DstMIBuilder; } Error GlobalISelEmitter::importDefaultOperandRenderers( -- 2.40.0