@@ -26,8 +26,8 @@ using namespace X86Disassembler;
2626namespace {
2727
2828class X86InstrMappingEmitter {
29- RecordKeeper &Records;
30- CodeGenTarget Target;
29+ const RecordKeeper &Records;
30+ const CodeGenTarget Target;
3131
3232 // Hold all pontentially compressible EVEX instructions
3333 std::vector<const CodeGenInstruction *> PreCompressionInsts;
@@ -44,7 +44,7 @@ class X86InstrMappingEmitter {
4444 PredicateInstMap PredicateInsts;
4545
4646public:
47- X86InstrMappingEmitter (RecordKeeper &R) : Records(R), Target(R) {}
47+ X86InstrMappingEmitter (const RecordKeeper &R) : Records(R), Target(R) {}
4848
4949 // run - Output X86 EVEX compression tables.
5050 void run (raw_ostream &OS);
@@ -63,8 +63,8 @@ class X86InstrMappingEmitter {
6363 void printClassDef (raw_ostream &OS);
6464 // Prints the given table as a C++ array of type X86TableEntry under the guard
6565 // \p Macro.
66- void printTable (const std::vector <Entry> & Table, StringRef Name,
67- StringRef Macro, raw_ostream &OS);
66+ void printTable (ArrayRef <Entry> Table, StringRef Name, StringRef Macro ,
67+ raw_ostream &OS);
6868};
6969
7070void X86InstrMappingEmitter::printClassDef (raw_ostream &OS) {
@@ -90,9 +90,8 @@ static void printMacroEnd(StringRef Macro, raw_ostream &OS) {
9090 OS << " #endif // " << Macro << " \n\n " ;
9191}
9292
93- void X86InstrMappingEmitter::printTable (const std::vector<Entry> &Table,
94- StringRef Name, StringRef Macro,
95- raw_ostream &OS) {
93+ void X86InstrMappingEmitter::printTable (ArrayRef<Entry> Table, StringRef Name,
94+ StringRef Macro, raw_ostream &OS) {
9695 printMacroBegin (Macro, OS);
9796
9897 OS << " static const X86TableEntry " << Name << " [] = {\n " ;
@@ -220,7 +219,7 @@ void X86InstrMappingEmitter::emitCompressEVEXTable(
220219 assert (NewRec && " Instruction not found!" );
221220 NewInst = &Target.getInstruction (NewRec);
222221 } else if (Name.ends_with (" _EVEX" )) {
223- if (auto *NewRec = Records.getDef (Name.drop_back (5 )))
222+ if (const auto *NewRec = Records.getDef (Name.drop_back (5 )))
224223 NewInst = &Target.getInstruction (NewRec);
225224 } else if (Name.ends_with (" _ND" ))
226225 // Leave it to ND2NONND table.
@@ -319,7 +318,7 @@ void X86InstrMappingEmitter::emitND2NonNDTable(
319318 if (!isInteresting (Rec) || NoCompressSet.find (Name) != NoCompressSet.end ())
320319 continue ;
321320 if (ManualMap.find (Name) != ManualMap.end ()) {
322- auto *NewRec = Records.getDef (ManualMap.at (Rec->getName ()));
321+ const auto *NewRec = Records.getDef (ManualMap.at (Rec->getName ()));
323322 assert (NewRec && " Instruction not found!" );
324323 auto &NewInst = Target.getInstruction (NewRec);
325324 Table.push_back (std::pair (Inst, &NewInst));
@@ -328,10 +327,10 @@ void X86InstrMappingEmitter::emitND2NonNDTable(
328327
329328 if (!Name.ends_with (" _ND" ))
330329 continue ;
331- auto *NewRec = Records.getDef (Name.drop_back (3 ));
330+ const auto *NewRec = Records.getDef (Name.drop_back (3 ));
332331 if (!NewRec)
333332 continue ;
334- auto &NewInst = Target.getInstruction (NewRec);
333+ const auto &NewInst = Target.getInstruction (NewRec);
335334 if (isRegisterOperand (NewInst.Operands [0 ].Rec ))
336335 Table.push_back (std::pair (Inst, &NewInst));
337336 }
@@ -353,15 +352,15 @@ void X86InstrMappingEmitter::emitSSE2AVXTable(
353352 if (!isInteresting (Rec))
354353 continue ;
355354 if (ManualMap.find (Name) != ManualMap.end ()) {
356- auto *NewRec = Records.getDef (ManualMap.at (Rec->getName ()));
355+ const auto *NewRec = Records.getDef (ManualMap.at (Rec->getName ()));
357356 assert (NewRec && " Instruction not found!" );
358- auto &NewInst = Target.getInstruction (NewRec);
357+ const auto &NewInst = Target.getInstruction (NewRec);
359358 Table.push_back (std::pair (Inst, &NewInst));
360359 continue ;
361360 }
362361
363362 std::string NewName = (" V" + Name).str ();
364- auto *AVXRec = Records.getDef (NewName);
363+ const auto *AVXRec = Records.getDef (NewName);
365364 if (!AVXRec)
366365 continue ;
367366 auto &AVXInst = Target.getInstruction (AVXRec);
0 commit comments