@@ -48,12 +48,12 @@ static cl::opt<bool> ExpandMIOperandInfo(
4848namespace {
4949
5050class InstrInfoEmitter {
51- RecordKeeper &Records;
52- CodeGenDAGPatterns CDP;
51+ const RecordKeeper &Records;
52+ const CodeGenDAGPatterns CDP;
5353 const CodeGenSchedModels &SchedModels;
5454
5555public:
56- InstrInfoEmitter (RecordKeeper &R)
56+ InstrInfoEmitter (const RecordKeeper &R)
5757 : Records(R), CDP(R), SchedModels(CDP.getTargetInfo().getSchedModels()) {}
5858
5959 // run - Output the instruction set description.
@@ -88,8 +88,8 @@ class InstrInfoEmitter {
8888 // / Write verifyInstructionPredicates methods.
8989 void emitFeatureVerifier (raw_ostream &OS, const CodeGenTarget &Target);
9090 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,
9393 const OperandInfoMapTy &OperandInfo, raw_ostream &OS);
9494 void emitOperandTypeMappings (
9595 raw_ostream &OS, const CodeGenTarget &Target,
@@ -136,7 +136,7 @@ InstrInfoEmitter::GetOperandInfo(const CodeGenInstruction &Inst) {
136136 // registers in their multi-operand operands. It may also be an anonymous
137137 // operand, which has a single operand, but no declared class for the
138138 // operand.
139- DagInit *MIOI = Op.MIOperandInfo ;
139+ const DagInit *MIOI = Op.MIOperandInfo ;
140140
141141 if (!MIOI || MIOI->getNumArgs () == 0 ) {
142142 // Single, anonymous, operand.
@@ -356,10 +356,11 @@ void InstrInfoEmitter::emitOperandTypeMappings(
356356 ArrayRef<const CodeGenInstruction *> NumberedInstructions) {
357357
358358 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 =
361362 Records.getAllDerivedDefinitions (" RegisterOperand" );
362- std::vector< Record *> RegisterClasses =
363+ ArrayRef< const Record *> RegisterClasses =
363364 Records.getAllDerivedDefinitions (" RegisterClass" );
364365
365366 OS << " #ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM\n " ;
@@ -370,9 +371,9 @@ void InstrInfoEmitter::emitOperandTypeMappings(
370371 OS << " enum OperandType {\n " ;
371372
372373 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) {
376377 if (!Op->isAnonymous ())
377378 OS << " " << Op->getName () << " = " << EnumVal << " ,\n " ;
378379 ++EnumVal;
@@ -764,8 +765,8 @@ void InstrInfoEmitter::emitFeatureVerifier(raw_ostream &OS,
764765 }
765766 }
766767
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) {
769770 if (A.size () < B.size ())
770771 return true ;
771772 if (A.size () > B.size ())
@@ -928,9 +929,9 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
928929 emitSourceFileHeader (" Target Instruction Enum Values and Descriptors" , OS);
929930 emitEnums (OS);
930931
931- CodeGenTarget &Target = CDP.getTargetInfo ();
932+ const CodeGenTarget &Target = CDP.getTargetInfo ();
932933 const std::string &TargetName = std::string (Target.getName ());
933- Record *InstrInfo = Target.getInstructionSet ();
934+ const Record *InstrInfo = Target.getInstructionSet ();
934935
935936 // Collect all of the operand info records.
936937 Records.startTimer (" Collect operand info" );
@@ -941,11 +942,11 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
941942
942943 // Collect all of the instruction's implicit uses and defs.
943944 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;
946947 unsigned ImplicitListSize = 0 ;
947948 for (const CodeGenInstruction *II : Target.getInstructionsByEnumValue ()) {
948- std::vector<Record *> ImplicitOps = II->ImplicitUses ;
949+ std::vector<const Record *> ImplicitOps = II->ImplicitUses ;
949950 llvm::append_range (ImplicitOps, II->ImplicitDefs );
950951 if (EmittedLists.insert ({ImplicitOps, ImplicitListSize}).second ) {
951952 ImplicitLists.push_back (ImplicitOps);
@@ -1175,8 +1176,8 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
11751176}
11761177
11771178void 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,
11801181 const OperandInfoMapTy &OperandInfoMap, raw_ostream &OS) {
11811182 int MinOperands = 0 ;
11821183 if (!Inst.Operands .empty ())
@@ -1195,11 +1196,11 @@ void InstrInfoEmitter::emitRecord(
11951196 << Inst.TheDef ->getValueAsInt (" Size" ) << " ,\t "
11961197 << SchedModels.getSchedClassIdx (Inst) << " ,\t " ;
11971198
1198- CodeGenTarget &Target = CDP.getTargetInfo ();
1199+ const CodeGenTarget &Target = CDP.getTargetInfo ();
11991200
12001201 // Emit the implicit use/def list...
12011202 OS << Inst.ImplicitUses .size () << " ,\t " << Inst.ImplicitDefs .size () << " ,\t " ;
1202- std::vector<Record *> ImplicitOps = Inst.ImplicitUses ;
1203+ std::vector<const Record *> ImplicitOps = Inst.ImplicitUses ;
12031204 llvm::append_range (ImplicitOps, Inst.ImplicitDefs );
12041205 OS << Target.getName () << " ImpOpBase + " << EmittedLists[ImplicitOps]
12051206 << " ,\t " ;
0 commit comments