@@ -48,12 +48,12 @@ static cl::opt<bool> ExpandMIOperandInfo(
48
48
namespace {
49
49
50
50
class InstrInfoEmitter {
51
- RecordKeeper &Records;
52
- CodeGenDAGPatterns CDP;
51
+ const RecordKeeper &Records;
52
+ const CodeGenDAGPatterns CDP;
53
53
const CodeGenSchedModels &SchedModels;
54
54
55
55
public:
56
- InstrInfoEmitter (RecordKeeper &R)
56
+ InstrInfoEmitter (const RecordKeeper &R)
57
57
: Records(R), CDP(R), SchedModels(CDP.getTargetInfo().getSchedModels()) {}
58
58
59
59
// run - Output the instruction set description.
@@ -88,8 +88,8 @@ class InstrInfoEmitter {
88
88
// / Write verifyInstructionPredicates methods.
89
89
void emitFeatureVerifier (raw_ostream &OS, const CodeGenTarget &Target);
90
90
void emitRecord (const CodeGenInstruction &Inst, unsigned Num,
91
- Record *InstrInfo,
92
- std::map<std::vector<Record *>, unsigned > &EL,
91
+ const Record *InstrInfo,
92
+ std::map<std::vector<const Record *>, unsigned > &EL,
93
93
const OperandInfoMapTy &OperandInfo, raw_ostream &OS);
94
94
void emitOperandTypeMappings (
95
95
raw_ostream &OS, const CodeGenTarget &Target,
@@ -136,7 +136,7 @@ InstrInfoEmitter::GetOperandInfo(const CodeGenInstruction &Inst) {
136
136
// registers in their multi-operand operands. It may also be an anonymous
137
137
// operand, which has a single operand, but no declared class for the
138
138
// operand.
139
- DagInit *MIOI = Op.MIOperandInfo ;
139
+ const DagInit *MIOI = Op.MIOperandInfo ;
140
140
141
141
if (!MIOI || MIOI->getNumArgs () == 0 ) {
142
142
// Single, anonymous, operand.
@@ -356,10 +356,11 @@ void InstrInfoEmitter::emitOperandTypeMappings(
356
356
ArrayRef<const CodeGenInstruction *> NumberedInstructions) {
357
357
358
358
StringRef Namespace = Target.getInstNamespace ();
359
- std::vector<Record *> Operands = Records.getAllDerivedDefinitions (" Operand" );
360
- std::vector<Record *> RegisterOperands =
359
+ ArrayRef<const Record *> Operands =
360
+ Records.getAllDerivedDefinitions (" Operand" );
361
+ ArrayRef<const Record *> RegisterOperands =
361
362
Records.getAllDerivedDefinitions (" RegisterOperand" );
362
- std::vector< Record *> RegisterClasses =
363
+ ArrayRef< const Record *> RegisterClasses =
363
364
Records.getAllDerivedDefinitions (" RegisterClass" );
364
365
365
366
OS << " #ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM\n " ;
@@ -370,9 +371,9 @@ void InstrInfoEmitter::emitOperandTypeMappings(
370
371
OS << " enum OperandType {\n " ;
371
372
372
373
unsigned EnumVal = 0 ;
373
- for (const std::vector< Record *> * RecordsToAdd :
374
- {& Operands, & RegisterOperands, & RegisterClasses}) {
375
- for (const Record *Op : * RecordsToAdd) {
374
+ for (ArrayRef< const Record *> RecordsToAdd :
375
+ {Operands, RegisterOperands, RegisterClasses}) {
376
+ for (const Record *Op : RecordsToAdd) {
376
377
if (!Op->isAnonymous ())
377
378
OS << " " << Op->getName () << " = " << EnumVal << " ,\n " ;
378
379
++EnumVal;
@@ -764,8 +765,8 @@ void InstrInfoEmitter::emitFeatureVerifier(raw_ostream &OS,
764
765
}
765
766
}
766
767
767
- llvm::sort (FeatureBitsets, [&](const std::vector <const Record *> & A,
768
- const std::vector <const Record *> & B) {
768
+ llvm::sort (FeatureBitsets, [&](ArrayRef <const Record *> A,
769
+ ArrayRef <const Record *> B) {
769
770
if (A.size () < B.size ())
770
771
return true ;
771
772
if (A.size () > B.size ())
@@ -928,9 +929,9 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
928
929
emitSourceFileHeader (" Target Instruction Enum Values and Descriptors" , OS);
929
930
emitEnums (OS);
930
931
931
- CodeGenTarget &Target = CDP.getTargetInfo ();
932
+ const CodeGenTarget &Target = CDP.getTargetInfo ();
932
933
const std::string &TargetName = std::string (Target.getName ());
933
- Record *InstrInfo = Target.getInstructionSet ();
934
+ const Record *InstrInfo = Target.getInstructionSet ();
934
935
935
936
// Collect all of the operand info records.
936
937
Records.startTimer (" Collect operand info" );
@@ -941,11 +942,11 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
941
942
942
943
// Collect all of the instruction's implicit uses and defs.
943
944
Records.startTimer (" Collect uses/defs" );
944
- std::map<std::vector<Record *>, unsigned > EmittedLists;
945
- std::vector<std::vector<Record *>> ImplicitLists;
945
+ std::map<std::vector<const Record *>, unsigned > EmittedLists;
946
+ std::vector<std::vector<const Record *>> ImplicitLists;
946
947
unsigned ImplicitListSize = 0 ;
947
948
for (const CodeGenInstruction *II : Target.getInstructionsByEnumValue ()) {
948
- std::vector<Record *> ImplicitOps = II->ImplicitUses ;
949
+ std::vector<const Record *> ImplicitOps = II->ImplicitUses ;
949
950
llvm::append_range (ImplicitOps, II->ImplicitDefs );
950
951
if (EmittedLists.insert ({ImplicitOps, ImplicitListSize}).second ) {
951
952
ImplicitLists.push_back (ImplicitOps);
@@ -1175,8 +1176,8 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
1175
1176
}
1176
1177
1177
1178
void InstrInfoEmitter::emitRecord (
1178
- const CodeGenInstruction &Inst, unsigned Num, Record *InstrInfo,
1179
- std::map<std::vector<Record *>, unsigned > &EmittedLists,
1179
+ const CodeGenInstruction &Inst, unsigned Num, const Record *InstrInfo,
1180
+ std::map<std::vector<const Record *>, unsigned > &EmittedLists,
1180
1181
const OperandInfoMapTy &OperandInfoMap, raw_ostream &OS) {
1181
1182
int MinOperands = 0 ;
1182
1183
if (!Inst.Operands .empty ())
@@ -1195,11 +1196,11 @@ void InstrInfoEmitter::emitRecord(
1195
1196
<< Inst.TheDef ->getValueAsInt (" Size" ) << " ,\t "
1196
1197
<< SchedModels.getSchedClassIdx (Inst) << " ,\t " ;
1197
1198
1198
- CodeGenTarget &Target = CDP.getTargetInfo ();
1199
+ const CodeGenTarget &Target = CDP.getTargetInfo ();
1199
1200
1200
1201
// Emit the implicit use/def list...
1201
1202
OS << Inst.ImplicitUses .size () << " ,\t " << Inst.ImplicitDefs .size () << " ,\t " ;
1202
- std::vector<Record *> ImplicitOps = Inst.ImplicitUses ;
1203
+ std::vector<const Record *> ImplicitOps = Inst.ImplicitUses ;
1203
1204
llvm::append_range (ImplicitOps, Inst.ImplicitDefs );
1204
1205
OS << Target.getName () << " ImpOpBase + " << EmittedLists[ImplicitOps]
1205
1206
<< " ,\t " ;
0 commit comments