@@ -582,13 +582,13 @@ class TreePredicateFn {
582
582
// / If non-null, indicates that this predicate is a predefined memory VT
583
583
// / predicate for a load/store and returns the ValueType record for the memory
584
584
// / VT.
585
- Record *getMemoryVT () const ;
585
+ const Record *getMemoryVT () const ;
586
586
// / If non-null, indicates that this predicate is a predefined memory VT
587
587
// / predicate (checking only the scalar type) for load/store and returns the
588
588
// / ValueType record for the memory VT.
589
- Record *getScalarMemoryVT () const ;
589
+ const Record *getScalarMemoryVT () const ;
590
590
591
- ListInit *getAddressSpaces () const ;
591
+ const ListInit *getAddressSpaces () const ;
592
592
int64_t getMinAlignment () const ;
593
593
594
594
// If true, indicates that GlobalISel-based C++ code was supplied.
@@ -634,7 +634,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
634
634
// / OperatorOrVal - The Record for the operator if this is an interior node
635
635
// / (not a leaf) or the init value (e.g. the "GPRC" record, or "7") for a
636
636
// / leaf.
637
- PointerUnion<const Record *, Init *> OperatorOrVal;
637
+ PointerUnion<const Record *, const Init *> OperatorOrVal;
638
638
639
639
// / Name - The name given to this node with the :$foo notation.
640
640
// /
@@ -648,7 +648,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
648
648
649
649
// / TransformFn - The transformation function to execute on this node before
650
650
// / it can be substituted into the resulting instruction on a pattern match.
651
- Record *TransformFn;
651
+ const Record *TransformFn;
652
652
653
653
std::vector<TreePatternNodePtr> Children;
654
654
@@ -664,7 +664,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
664
664
ResultPerm.resize (NumResults);
665
665
std::iota (ResultPerm.begin (), ResultPerm.end (), 0 );
666
666
}
667
- TreePatternNode (Init *val, unsigned NumResults) // leaf ctor
667
+ TreePatternNode (const Init *val, unsigned NumResults) // leaf ctor
668
668
: OperatorOrVal(val), TransformFn(nullptr ) {
669
669
Types.resize (NumResults);
670
670
ResultPerm.resize (NumResults);
@@ -685,7 +685,7 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
685
685
NamesAsPredicateArg.push_back (N);
686
686
}
687
687
688
- bool isLeaf () const { return isa<Init *>(OperatorOrVal); }
688
+ bool isLeaf () const { return isa<const Init *>(OperatorOrVal); }
689
689
690
690
// Type accessors.
691
691
unsigned getNumTypes () const { return Types.size (); }
@@ -713,9 +713,9 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
713
713
unsigned getResultIndex (unsigned ResNo) const { return ResultPerm[ResNo]; }
714
714
void setResultIndex (unsigned ResNo, unsigned RI) { ResultPerm[ResNo] = RI; }
715
715
716
- Init *getLeafValue () const {
716
+ const Init *getLeafValue () const {
717
717
assert (isLeaf ());
718
- return cast<Init *>(OperatorOrVal);
718
+ return cast<const Init *>(OperatorOrVal);
719
719
}
720
720
const Record *getOperator () const {
721
721
assert (!isLeaf ());
@@ -766,8 +766,8 @@ class TreePatternNode : public RefCountedBase<TreePatternNode> {
766
766
addPredicateCall (TreePredicateCall (Fn, Scope));
767
767
}
768
768
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; }
771
771
772
772
// / getIntrinsicInfo - If this node corresponds to an intrinsic, return the
773
773
// / CodeGenIntrinsic information for it, otherwise return a null pointer.
@@ -901,14 +901,14 @@ class TreePattern {
901
901
// / ComplexPattern. This records the ComplexPattern instance and the operand
902
902
// / number for each operand encountered in a ComplexPattern to aid in that
903
903
// / check.
904
- StringMap<std::pair<Record *, unsigned >> ComplexPatternOperands;
904
+ StringMap<std::pair<const Record *, unsigned >> ComplexPatternOperands;
905
905
906
906
TypeInfer Infer;
907
907
908
908
public:
909
909
// / TreePattern constructor - Parse the specified DagInits into the
910
910
// / current record.
911
- TreePattern (const Record *TheRec, ListInit *RawPat, bool isInput,
911
+ TreePattern (const Record *TheRec, const ListInit *RawPat, bool isInput,
912
912
CodeGenDAGPatterns &ise);
913
913
TreePattern (const Record *TheRec, DagInit *Pat, bool isInput,
914
914
CodeGenDAGPatterns &ise);
@@ -1013,24 +1013,24 @@ struct DAGDefaultOperand {
1013
1013
class DAGInstruction {
1014
1014
std::vector<const Record *> Results;
1015
1015
std::vector<const Record *> Operands;
1016
- std::vector<Record *> ImpResults;
1016
+ std::vector<const Record *> ImpResults;
1017
1017
TreePatternNodePtr SrcPattern;
1018
1018
TreePatternNodePtr ResultPattern;
1019
1019
1020
1020
public:
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 ) {}
1029
1029
1030
1030
unsigned getNumResults () const { return Results.size (); }
1031
1031
unsigned getNumOperands () const { return Operands.size (); }
1032
1032
unsigned getNumImpResults () const { return ImpResults.size (); }
1033
- const std::vector< Record *> & getImpResults () const { return ImpResults; }
1033
+ ArrayRef< const Record *> getImpResults () const { return ImpResults; }
1034
1034
1035
1035
const Record *getResult (unsigned RN) const {
1036
1036
assert (RN < Results.size ());
@@ -1042,7 +1042,7 @@ class DAGInstruction {
1042
1042
return Operands[ON];
1043
1043
}
1044
1044
1045
- Record *getImpResult (unsigned RN) const {
1045
+ const Record *getImpResult (unsigned RN) const {
1046
1046
assert (RN < ImpResults.size ());
1047
1047
return ImpResults[RN];
1048
1048
}
@@ -1058,7 +1058,7 @@ class PatternToMatch {
1058
1058
ListInit *Predicates; // Top level predicate conditions to match.
1059
1059
TreePatternNodePtr SrcPattern; // Source pattern to match.
1060
1060
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.
1062
1062
std::string HwModeFeatures;
1063
1063
int AddedComplexity; // Add to matching pattern complexity.
1064
1064
bool GISelShouldIgnore; // Should GlobalISel ignore importing this pattern.
@@ -1067,27 +1067,27 @@ class PatternToMatch {
1067
1067
public:
1068
1068
PatternToMatch (const Record *srcrecord, ListInit *preds,
1069
1069
TreePatternNodePtr src, TreePatternNodePtr dst,
1070
- std::vector< Record *> dstregs, int complexity, unsigned uid,
1070
+ ArrayRef< const Record *> dstregs, int complexity, unsigned uid,
1071
1071
bool ignore, const Twine &hwmodefeatures = " " )
1072
1072
: 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) {}
1076
1075
1077
1076
const Record *getSrcRecord () const { return SrcRecord; }
1078
1077
ListInit *getPredicates () const { return Predicates; }
1079
1078
TreePatternNode &getSrcPattern () const { return *SrcPattern; }
1080
1079
TreePatternNodePtr getSrcPatternShared () const { return SrcPattern; }
1081
1080
TreePatternNode &getDstPattern () const { return *DstPattern; }
1082
1081
TreePatternNodePtr getDstPatternShared () const { return DstPattern; }
1083
- const std::vector< Record *> & getDstRegs () const { return Dstregs; }
1082
+ ArrayRef< const Record *> getDstRegs () const { return Dstregs; }
1084
1083
StringRef getHwModeFeatures () const { return HwModeFeatures; }
1085
1084
int getAddedComplexity () const { return AddedComplexity; }
1086
1085
bool getGISelShouldIgnore () const { return GISelShouldIgnore; }
1087
1086
unsigned getID () const { return ID; }
1088
1087
1089
1088
std::string getPredicateCheck () const ;
1090
- void getPredicateRecords (SmallVectorImpl<Record *> &PredicateRecs) const ;
1089
+ void
1090
+ getPredicateRecords (SmallVectorImpl<const Record *> &PredicateRecs) const ;
1091
1091
1092
1092
// / Compute the complexity metric for the input pattern. This roughly
1093
1093
// / corresponds to the number of nodes that are covered.
@@ -1113,8 +1113,8 @@ class CodeGenDAGPatterns {
1113
1113
std::map<const Record *, DAGInstruction, LessRecordByID> Instructions;
1114
1114
1115
1115
// 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;
1118
1118
1119
1119
// / PatternsToMatch - All of the things we are matching on the DAG. The first
1120
1120
// / value is the pattern to match, the second pattern is the result to
@@ -1136,7 +1136,7 @@ class CodeGenDAGPatterns {
1136
1136
const CodeGenTarget &getTargetInfo () const { return Target; }
1137
1137
const TypeSetByHwMode &getLegalTypes () const { return LegalVTS; }
1138
1138
1139
- Record *getSDNodeNamed (StringRef Name) const ;
1139
+ const Record *getSDNodeNamed (StringRef Name) const ;
1140
1140
1141
1141
const SDNodeInfo &getSDNodeInfo (const Record *R) const {
1142
1142
auto F = SDNodes.find (R);
@@ -1170,7 +1170,7 @@ class CodeGenDAGPatterns {
1170
1170
llvm_unreachable (" Bad intrinsic ID!" );
1171
1171
}
1172
1172
1173
- unsigned getIntrinsicID (Record *R) const {
1173
+ unsigned getIntrinsicID (const Record *R) const {
1174
1174
for (unsigned i = 0 , e = Intrinsics.size (); i != e; ++i)
1175
1175
if (Intrinsics[i].TheDef == R)
1176
1176
return i;
@@ -1209,7 +1209,7 @@ class CodeGenDAGPatterns {
1209
1209
1210
1210
// / Parse the Pattern for an instruction, and insert the result in DAGInsts.
1211
1211
typedef std::map<const Record *, DAGInstruction, LessRecordByID> DAGInstMap;
1212
- void parseInstructionPattern (CodeGenInstruction &CGI, ListInit *Pattern,
1212
+ void parseInstructionPattern (CodeGenInstruction &CGI, const ListInit *Pattern,
1213
1213
DAGInstMap &DAGInsts);
1214
1214
1215
1215
const DAGInstruction &getInstruction (const Record *R) const {
@@ -1218,11 +1218,13 @@ class CodeGenDAGPatterns {
1218
1218
return F->second ;
1219
1219
}
1220
1220
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 {
1223
1225
return intrinsic_w_chain_sdnode;
1224
1226
}
1225
- Record *get_intrinsic_wo_chain_sdnode () const {
1227
+ const Record *get_intrinsic_wo_chain_sdnode () const {
1226
1228
return intrinsic_wo_chain_sdnode;
1227
1229
}
1228
1230
@@ -1248,15 +1250,15 @@ class CodeGenDAGPatterns {
1248
1250
1249
1251
void ParseOnePattern (const Record *TheDef, TreePattern &Pattern,
1250
1252
TreePattern &Result,
1251
- const std::vector< Record *> & InstImpResults,
1253
+ ArrayRef< const Record *> InstImpResults,
1252
1254
bool ShouldIgnore = false );
1253
1255
void AddPatternToMatch (TreePattern *Pattern, PatternToMatch &&PTM);
1254
1256
void FindPatternInputsAndOutputs (
1255
1257
TreePattern &I, TreePatternNodePtr Pat,
1256
1258
std::map<std::string, TreePatternNodePtr> &InstInputs,
1257
1259
MapVector<std::string, TreePatternNodePtr,
1258
1260
std::map<std::string, unsigned >> &InstResults,
1259
- std::vector<Record *> &InstImpResults);
1261
+ std::vector<const Record *> &InstImpResults);
1260
1262
unsigned getNewUID ();
1261
1263
};
1262
1264
0 commit comments