@@ -582,13 +582,13 @@ class TreePredicateFn {
582582 // / If non-null, indicates that this predicate is a predefined memory VT
583583 // / predicate for a load/store and returns the ValueType record for the memory
584584 // / VT.
585- Record *getMemoryVT () const ;
585+ const Record *getMemoryVT () const ;
586586 // / If non-null, indicates that this predicate is a predefined memory VT
587587 // / predicate (checking only the scalar type) for load/store and returns the
588588 // / ValueType record for the memory VT.
589- Record *getScalarMemoryVT () const ;
589+ const Record *getScalarMemoryVT () const ;
590590
591- ListInit *getAddressSpaces () const ;
591+ const ListInit *getAddressSpaces () const ;
592592 int64_t getMinAlignment () const ;
593593
594594 // If true, indicates that GlobalISel-based C++ code was supplied.
@@ -634,7 +634,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
634634 // / OperatorOrVal - The Record for the operator if this is an interior node
635635 // / (not a leaf) or the init value (e.g. the "GPRC" record, or "7") for a
636636 // / leaf.
637- PointerUnion<const Record *, Init *> OperatorOrVal;
637+ PointerUnion<const Record *, const Init *> OperatorOrVal;
638638
639639 // / Name - The name given to this node with the :$foo notation.
640640 // /
@@ -648,7 +648,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
648648
649649 // / TransformFn - The transformation function to execute on this node before
650650 // / it can be substituted into the resulting instruction on a pattern match.
651- Record *TransformFn;
651+ const Record *TransformFn;
652652
653653 std::vector<TreePatternNodePtr> Children;
654654
@@ -664,7 +664,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
664664 ResultPerm.resize (NumResults);
665665 std::iota (ResultPerm.begin (), ResultPerm.end (), 0 );
666666 }
667- TreePatternNode (Init *val, unsigned NumResults) // leaf ctor
667+ TreePatternNode (const Init *val, unsigned NumResults) // leaf ctor
668668 : OperatorOrVal(val), TransformFn(nullptr ) {
669669 Types.resize (NumResults);
670670 ResultPerm.resize (NumResults);
@@ -685,7 +685,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
685685 NamesAsPredicateArg.push_back (N);
686686 }
687687
688- bool isLeaf () const { return isa<Init *>(OperatorOrVal); }
688+ bool isLeaf () const { return isa<const Init *>(OperatorOrVal); }
689689
690690 // Type accessors.
691691 unsigned getNumTypes () const { return Types.size (); }
@@ -713,9 +713,9 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
713713 unsigned getResultIndex (unsigned ResNo) const { return ResultPerm[ResNo]; }
714714 void setResultIndex (unsigned ResNo, unsigned RI) { ResultPerm[ResNo] = RI; }
715715
716- Init *getLeafValue () const {
716+ const Init *getLeafValue () const {
717717 assert (isLeaf ());
718- return cast<Init *>(OperatorOrVal);
718+ return cast<const Init *>(OperatorOrVal);
719719 }
720720 const Record *getOperator () const {
721721 assert (!isLeaf ());
@@ -766,8 +766,8 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
766766 addPredicateCall (TreePredicateCall (Fn, Scope));
767767 }
768768
769- Record *getTransformFn () const { return TransformFn; }
770- void setTransformFn (Record *Fn) { TransformFn = Fn; }
769+ const Record *getTransformFn () const { return TransformFn; }
770+ void setTransformFn (const Record *Fn) { TransformFn = Fn; }
771771
772772 // / getIntrinsicInfo - If this node corresponds to an intrinsic, return the
773773 // / CodeGenIntrinsic information for it, otherwise return a null pointer.
@@ -901,14 +901,14 @@ class TreePattern {
901901 // / ComplexPattern. This records the ComplexPattern instance and the operand
902902 // / number for each operand encountered in a ComplexPattern to aid in that
903903 // / check.
904- StringMap<std::pair<Record *, unsigned >> ComplexPatternOperands;
904+ StringMap<std::pair<const Record *, unsigned >> ComplexPatternOperands;
905905
906906 TypeInfer Infer;
907907
908908public:
909909 // / TreePattern constructor - Parse the specified DagInits into the
910910 // / current record.
911- TreePattern (const Record *TheRec, ListInit *RawPat, bool isInput,
911+ TreePattern (const Record *TheRec, const ListInit *RawPat, bool isInput,
912912 CodeGenDAGPatterns &ise);
913913 TreePattern (const Record *TheRec, DagInit *Pat, bool isInput,
914914 CodeGenDAGPatterns &ise);
@@ -1013,24 +1013,24 @@ struct DAGDefaultOperand {
10131013class DAGInstruction {
10141014 std::vector<const Record *> Results;
10151015 std::vector<const Record *> Operands;
1016- std::vector<Record *> ImpResults;
1016+ std::vector<const Record *> ImpResults;
10171017 TreePatternNodePtr SrcPattern;
10181018 TreePatternNodePtr ResultPattern;
10191019
10201020public:
1021- DAGInstruction (std::vector<const Record *> &&results ,
1022- std::vector<const Record *> &&operands ,
1023- std::vector<Record *> &&impresults ,
1024- TreePatternNodePtr srcpattern = nullptr ,
1025- TreePatternNodePtr resultpattern = nullptr )
1026- : Results(std::move(results )), Operands(std::move(operands )),
1027- ImpResults (std::move(impresults )), SrcPattern(srcpattern ),
1028- ResultPattern(resultpattern ) {}
1021+ DAGInstruction (std::vector<const Record *> &&Results ,
1022+ std::vector<const Record *> &&Operands ,
1023+ std::vector<const Record *> &&ImpResults ,
1024+ TreePatternNodePtr SrcPattern = nullptr ,
1025+ TreePatternNodePtr ResultPattern = nullptr )
1026+ : Results(std::move(Results )), Operands(std::move(Operands )),
1027+ ImpResults (std::move(ImpResults )), SrcPattern(SrcPattern ),
1028+ ResultPattern(ResultPattern ) {}
10291029
10301030 unsigned getNumResults () const { return Results.size (); }
10311031 unsigned getNumOperands () const { return Operands.size (); }
10321032 unsigned getNumImpResults () const { return ImpResults.size (); }
1033- const std::vector< Record *> & getImpResults () const { return ImpResults; }
1033+ ArrayRef< const Record *> getImpResults () const { return ImpResults; }
10341034
10351035 const Record *getResult (unsigned RN) const {
10361036 assert (RN < Results.size ());
@@ -1042,7 +1042,7 @@ class DAGInstruction {
10421042 return Operands[ON];
10431043 }
10441044
1045- Record *getImpResult (unsigned RN) const {
1045+ const Record *getImpResult (unsigned RN) const {
10461046 assert (RN < ImpResults.size ());
10471047 return ImpResults[RN];
10481048 }
@@ -1058,7 +1058,7 @@ class PatternToMatch {
10581058 ListInit *Predicates; // Top level predicate conditions to match.
10591059 TreePatternNodePtr SrcPattern; // Source pattern to match.
10601060 TreePatternNodePtr DstPattern; // Resulting pattern.
1061- std::vector<Record *> Dstregs; // Physical register defs being matched.
1061+ std::vector<const Record *> Dstregs; // Physical register defs being matched.
10621062 std::string HwModeFeatures;
10631063 int AddedComplexity; // Add to matching pattern complexity.
10641064 bool GISelShouldIgnore; // Should GlobalISel ignore importing this pattern.
@@ -1067,27 +1067,27 @@ class PatternToMatch {
10671067public:
10681068 PatternToMatch (const Record *srcrecord, ListInit *preds,
10691069 TreePatternNodePtr src, TreePatternNodePtr dst,
1070- std::vector< Record *> dstregs, int complexity, unsigned uid,
1070+ ArrayRef< const Record *> dstregs, int complexity, unsigned uid,
10711071 bool ignore, const Twine &hwmodefeatures = " " )
10721072 : SrcRecord(srcrecord), Predicates(preds), SrcPattern(src),
1073- DstPattern (dst), Dstregs(std::move(dstregs)),
1074- HwModeFeatures(hwmodefeatures.str()), AddedComplexity(complexity),
1075- GISelShouldIgnore(ignore), ID(uid) {}
1073+ DstPattern (dst), Dstregs(dstregs), HwModeFeatures(hwmodefeatures.str()),
1074+ AddedComplexity(complexity), GISelShouldIgnore(ignore), ID(uid) {}
10761075
10771076 const Record *getSrcRecord () const { return SrcRecord; }
10781077 ListInit *getPredicates () const { return Predicates; }
10791078 TreePatternNode &getSrcPattern () const { return *SrcPattern; }
10801079 TreePatternNodePtr getSrcPatternShared () const { return SrcPattern; }
10811080 TreePatternNode &getDstPattern () const { return *DstPattern; }
10821081 TreePatternNodePtr getDstPatternShared () const { return DstPattern; }
1083- const std::vector< Record *> & getDstRegs () const { return Dstregs; }
1082+ ArrayRef< const Record *> getDstRegs () const { return Dstregs; }
10841083 StringRef getHwModeFeatures () const { return HwModeFeatures; }
10851084 int getAddedComplexity () const { return AddedComplexity; }
10861085 bool getGISelShouldIgnore () const { return GISelShouldIgnore; }
10871086 unsigned getID () const { return ID; }
10881087
10891088 std::string getPredicateCheck () const ;
1090- void getPredicateRecords (SmallVectorImpl<Record *> &PredicateRecs) const ;
1089+ void
1090+ getPredicateRecords (SmallVectorImpl<const Record *> &PredicateRecs) const ;
10911091
10921092 // / Compute the complexity metric for the input pattern. This roughly
10931093 // / corresponds to the number of nodes that are covered.
@@ -1113,8 +1113,8 @@ class CodeGenDAGPatterns {
11131113 std::map<const Record *, DAGInstruction, LessRecordByID> Instructions;
11141114
11151115 // Specific SDNode definitions:
1116- Record *intrinsic_void_sdnode;
1117- Record *intrinsic_w_chain_sdnode, *intrinsic_wo_chain_sdnode;
1116+ const Record *intrinsic_void_sdnode;
1117+ const Record *intrinsic_w_chain_sdnode, *intrinsic_wo_chain_sdnode;
11181118
11191119 // / PatternsToMatch - All of the things we are matching on the DAG. The first
11201120 // / value is the pattern to match, the second pattern is the result to
@@ -1136,7 +1136,7 @@ class CodeGenDAGPatterns {
11361136 const CodeGenTarget &getTargetInfo () const { return Target; }
11371137 const TypeSetByHwMode &getLegalTypes () const { return LegalVTS; }
11381138
1139- Record *getSDNodeNamed (StringRef Name) const ;
1139+ const Record *getSDNodeNamed (StringRef Name) const ;
11401140
11411141 const SDNodeInfo &getSDNodeInfo (const Record *R) const {
11421142 auto F = SDNodes.find (R);
@@ -1170,7 +1170,7 @@ class CodeGenDAGPatterns {
11701170 llvm_unreachable (" Bad intrinsic ID!" );
11711171 }
11721172
1173- unsigned getIntrinsicID (Record *R) const {
1173+ unsigned getIntrinsicID (const Record *R) const {
11741174 for (unsigned i = 0 , e = Intrinsics.size (); i != e; ++i)
11751175 if (Intrinsics[i].TheDef == R)
11761176 return i;
@@ -1209,7 +1209,7 @@ class CodeGenDAGPatterns {
12091209
12101210 // / Parse the Pattern for an instruction, and insert the result in DAGInsts.
12111211 typedef std::map<const Record *, DAGInstruction, LessRecordByID> DAGInstMap;
1212- void parseInstructionPattern (CodeGenInstruction &CGI, ListInit *Pattern,
1212+ void parseInstructionPattern (CodeGenInstruction &CGI, const ListInit *Pattern,
12131213 DAGInstMap &DAGInsts);
12141214
12151215 const DAGInstruction &getInstruction (const Record *R) const {
@@ -1218,11 +1218,13 @@ class CodeGenDAGPatterns {
12181218 return F->second ;
12191219 }
12201220
1221- Record *get_intrinsic_void_sdnode () const { return intrinsic_void_sdnode; }
1222- Record *get_intrinsic_w_chain_sdnode () const {
1221+ const Record *get_intrinsic_void_sdnode () const {
1222+ return intrinsic_void_sdnode;
1223+ }
1224+ const Record *get_intrinsic_w_chain_sdnode () const {
12231225 return intrinsic_w_chain_sdnode;
12241226 }
1225- Record *get_intrinsic_wo_chain_sdnode () const {
1227+ const Record *get_intrinsic_wo_chain_sdnode () const {
12261228 return intrinsic_wo_chain_sdnode;
12271229 }
12281230
@@ -1248,15 +1250,15 @@ class CodeGenDAGPatterns {
12481250
12491251 void ParseOnePattern (const Record *TheDef, TreePattern &Pattern,
12501252 TreePattern &Result,
1251- const std::vector< Record *> & InstImpResults,
1253+ ArrayRef< const Record *> InstImpResults,
12521254 bool ShouldIgnore = false );
12531255 void AddPatternToMatch (TreePattern *Pattern, PatternToMatch &&PTM);
12541256 void FindPatternInputsAndOutputs (
12551257 TreePattern &I, TreePatternNodePtr Pat,
12561258 std::map<std::string, TreePatternNodePtr> &InstInputs,
12571259 MapVector<std::string, TreePatternNodePtr,
12581260 std::map<std::string, unsigned >> &InstResults,
1259- std::vector<Record *> &InstImpResults);
1261+ std::vector<const Record *> &InstImpResults);
12601262 unsigned getNewUID ();
12611263};
12621264
0 commit comments