diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index a76ea32de3e..9294cd55767 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -155,8 +155,7 @@ void DAGISelEmitter::run(raw_ostream &OS) { } } - Matcher *TheMatcher = new ScopeMatcher(&PatternMatchers[0], - PatternMatchers.size()); + Matcher *TheMatcher = new ScopeMatcher(PatternMatchers); TheMatcher = OptimizeMatcher(TheMatcher, CGP); //Matcher->dump(); diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 70031fa6d3b..8d01ffcc5f5 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -10,6 +10,7 @@ #ifndef TBLGEN_DAGISELMATCHER_H #define TBLGEN_DAGISELMATCHER_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -188,8 +189,8 @@ protected: class ScopeMatcher : public Matcher { SmallVector Children; public: - ScopeMatcher(Matcher *const *children, unsigned numchildren) - : Matcher(Scope), Children(children, children+numchildren) { + ScopeMatcher(ArrayRef children) + : Matcher(Scope), Children(children.begin(), children.end()) { } virtual ~ScopeMatcher(); @@ -502,9 +503,8 @@ private: class SwitchOpcodeMatcher : public Matcher { SmallVector, 8> Cases; public: - SwitchOpcodeMatcher(const std::pair *cases, - unsigned numcases) - : Matcher(SwitchOpcode), Cases(cases, cases+numcases) {} + SwitchOpcodeMatcher(ArrayRef > cases) + : Matcher(SwitchOpcode), Cases(cases.begin(), cases.end()) {} static inline bool classof(const Matcher *N) { return N->getKind() == SwitchOpcode; @@ -556,9 +556,8 @@ private: class SwitchTypeMatcher : public Matcher { SmallVector, 8> Cases; public: - SwitchTypeMatcher(const std::pair *cases, - unsigned numcases) - : Matcher(SwitchType), Cases(cases, cases+numcases) {} + SwitchTypeMatcher(ArrayRef > cases) + : Matcher(SwitchType), Cases(cases.begin(), cases.end()) {} static inline bool classof(const Matcher *N) { return N->getKind() == SwitchType; @@ -901,8 +900,8 @@ private: class EmitMergeInputChainsMatcher : public Matcher { SmallVector ChainNodes; public: - EmitMergeInputChainsMatcher(const unsigned *nodes, unsigned NumNodes) - : Matcher(EmitMergeInputChains), ChainNodes(nodes, nodes+NumNodes) {} + EmitMergeInputChainsMatcher(ArrayRef nodes) + : Matcher(EmitMergeInputChains), ChainNodes(nodes.begin(), nodes.end()) {} unsigned getNumNodes() const { return ChainNodes.size(); } @@ -994,13 +993,13 @@ class EmitNodeMatcherCommon : public Matcher { int NumFixedArityOperands; public: EmitNodeMatcherCommon(const std::string &opcodeName, - const MVT::SimpleValueType *vts, unsigned numvts, - const unsigned *operands, unsigned numops, + ArrayRef vts, + ArrayRef operands, bool hasChain, bool hasInGlue, bool hasOutGlue, bool hasmemrefs, int numfixedarityoperands, bool isMorphNodeTo) : Matcher(isMorphNodeTo ? MorphNodeTo : EmitNode), OpcodeName(opcodeName), - VTs(vts, vts+numvts), Operands(operands, operands+numops), + VTs(vts.begin(), vts.end()), Operands(operands.begin(), operands.end()), HasChain(hasChain), HasInGlue(hasInGlue), HasOutGlue(hasOutGlue), HasMemRefs(hasmemrefs), NumFixedArityOperands(numfixedarityoperands) {} @@ -1044,12 +1043,12 @@ class EmitNodeMatcher : public EmitNodeMatcherCommon { unsigned FirstResultSlot; public: EmitNodeMatcher(const std::string &opcodeName, - const MVT::SimpleValueType *vts, unsigned numvts, - const unsigned *operands, unsigned numops, + ArrayRef vts, + ArrayRef operands, bool hasChain, bool hasInFlag, bool hasOutFlag, bool hasmemrefs, int numfixedarityoperands, unsigned firstresultslot) - : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain, + : EmitNodeMatcherCommon(opcodeName, vts, operands, hasChain, hasInFlag, hasOutFlag, hasmemrefs, numfixedarityoperands, false), FirstResultSlot(firstresultslot) {} @@ -1067,12 +1066,12 @@ class MorphNodeToMatcher : public EmitNodeMatcherCommon { const PatternToMatch &Pattern; public: MorphNodeToMatcher(const std::string &opcodeName, - const MVT::SimpleValueType *vts, unsigned numvts, - const unsigned *operands, unsigned numops, + ArrayRef vts, + ArrayRef operands, bool hasChain, bool hasInFlag, bool hasOutFlag, bool hasmemrefs, int numfixedarityoperands, const PatternToMatch &pattern) - : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain, + : EmitNodeMatcherCommon(opcodeName, vts, operands, hasChain, hasInFlag, hasOutFlag, hasmemrefs, numfixedarityoperands, true), Pattern(pattern) { @@ -1091,8 +1090,8 @@ public: class MarkGlueResultsMatcher : public Matcher { SmallVector GlueResultNodes; public: - MarkGlueResultsMatcher(const unsigned *nodes, unsigned NumNodes) - : Matcher(MarkGlueResults), GlueResultNodes(nodes, nodes+NumNodes) {} + MarkGlueResultsMatcher(ArrayRef nodes) + : Matcher(MarkGlueResults), GlueResultNodes(nodes.begin(), nodes.end()) {} unsigned getNumNodes() const { return GlueResultNodes.size(); } @@ -1120,9 +1119,9 @@ class CompleteMatchMatcher : public Matcher { SmallVector Results; const PatternToMatch &Pattern; public: - CompleteMatchMatcher(const unsigned *results, unsigned numresults, + CompleteMatchMatcher(ArrayRef results, const PatternToMatch &pattern) - : Matcher(CompleteMatch), Results(results, results+numresults), + : Matcher(CompleteMatch), Results(results.begin(), results.end()), Pattern(pattern) {} unsigned getNumResults() const { return Results.size(); } diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp index ed41631456b..a64b180f777 100644 --- a/utils/TableGen/DAGISelMatcherGen.cpp +++ b/utils/TableGen/DAGISelMatcherGen.cpp @@ -850,8 +850,7 @@ EmitResultInstructionAsOperand(const TreePatternNode *N, "Node has no result"); AddMatcher(new EmitNodeMatcher(II.Namespace+"::"+II.TheDef->getName(), - ResultVTs.data(), ResultVTs.size(), - InstOps.data(), InstOps.size(), + ResultVTs, InstOps, NodeHasChain, TreeHasInGlue, TreeHasOutGlue, NodeHasMemRefs, NumFixedArityOperands, NextRecordedOperandNo)); @@ -907,8 +906,7 @@ void MatcherGen::EmitResultCode() { // merge them together into a token factor. This informs the generated code // what all the chained nodes are. if (!MatchedChainNodes.empty()) - AddMatcher(new EmitMergeInputChainsMatcher - (MatchedChainNodes.data(), MatchedChainNodes.size())); + AddMatcher(new EmitMergeInputChainsMatcher(MatchedChainNodes)); // Codegen the root of the result pattern, capturing the resulting values. SmallVector Ops; @@ -949,10 +947,9 @@ void MatcherGen::EmitResultCode() { // If the matched pattern covers nodes which define a glue result, emit a node // that tells the matcher about them so that it can update their results. if (!MatchedGlueResultNodes.empty()) - AddMatcher(new MarkGlueResultsMatcher(MatchedGlueResultNodes.data(), - MatchedGlueResultNodes.size())); + AddMatcher(new MarkGlueResultsMatcher(MatchedGlueResultNodes)); - AddMatcher(new CompleteMatchMatcher(Ops.data(), Ops.size(), Pattern)); + AddMatcher(new CompleteMatchMatcher(Ops, Pattern)); } diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 82e5d63be58..8fde8ce5bc0 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -136,8 +136,7 @@ static void ContractNodes(OwningPtr &MatcherPtr, const SmallVectorImpl &VTs = EN->getVTList(); const SmallVectorImpl &Operands = EN->getOperandList(); MatcherPtr.reset(new MorphNodeToMatcher(EN->getOpcodeName(), - VTs.data(), VTs.size(), - Operands.data(),Operands.size(), + VTs, Operands, EN->hasChain(), EN->hasInFlag(), EN->hasOutFlag(), EN->hasMemRefs(), @@ -380,7 +379,7 @@ static void FactorNodes(OwningPtr &MatcherPtr) { EqualMatchers[i] = Tmp; } - Shared->setNext(new ScopeMatcher(&EqualMatchers[0], EqualMatchers.size())); + Shared->setNext(new ScopeMatcher(EqualMatchers)); // Recursively factor the newly created node. FactorNodes(Shared->getNextPtr()); @@ -455,7 +454,7 @@ static void FactorNodes(OwningPtr &MatcherPtr) { Cases.push_back(std::make_pair(&COM->getOpcode(), COM->getNext())); } - MatcherPtr.reset(new SwitchOpcodeMatcher(&Cases[0], Cases.size())); + MatcherPtr.reset(new SwitchOpcodeMatcher(Cases)); return; } @@ -482,7 +481,7 @@ static void FactorNodes(OwningPtr &MatcherPtr) { } Matcher *Entries[2] = { PrevMatcher, MatcherWithoutCTM }; - Cases[Entry-1].second = new ScopeMatcher(Entries, 2); + Cases[Entry-1].second = new ScopeMatcher(Entries); continue; } @@ -491,7 +490,7 @@ static void FactorNodes(OwningPtr &MatcherPtr) { } if (Cases.size() != 1) { - MatcherPtr.reset(new SwitchTypeMatcher(&Cases[0], Cases.size())); + MatcherPtr.reset(new SwitchTypeMatcher(Cases)); } else { // If we factored and ended up with one case, create it now. MatcherPtr.reset(new CheckTypeMatcher(Cases[0].first, 0));