2828#include < tuple>
2929using namespace llvm ;
3030
31- cl::OptionCategory AsmParserCat (" Options for -gen-asm-parser" );
32- cl::OptionCategory AsmWriterCat (" Options for -gen-asm-writer" );
31+ static cl::OptionCategory AsmParserCat (" Options for -gen-asm-parser" );
32+ static cl::OptionCategory AsmWriterCat (" Options for -gen-asm-writer" );
3333
3434static cl::opt<unsigned >
3535 AsmParserNum (" asmparsernum" , cl::init(0 ),
@@ -64,9 +64,9 @@ StringRef llvm::getEnumName(MVT::SimpleValueType T) {
6464std::string llvm::getQualifiedName (const Record *R) {
6565 std::string Namespace;
6666 if (R->getValue (" Namespace" ))
67- Namespace = std::string ( R->getValueAsString (" Namespace" ));
67+ Namespace = R->getValueAsString (" Namespace" ). str ( );
6868 if (Namespace.empty ())
69- return std::string ( R->getName ());
69+ return R->getName (). str ( );
7070 return Namespace + " ::" + R->getName ().str ();
7171}
7272
@@ -166,14 +166,15 @@ CodeGenRegBank &CodeGenTarget::getRegBank() const {
166166const CodeGenRegisterClass *CodeGenTarget::getSuperRegForSubReg (
167167 const ValueTypeByHwMode &ValueTy, CodeGenRegBank &RegBank,
168168 const CodeGenSubRegIndex *SubIdx, bool MustBeAllocatable) const {
169- std::vector<CodeGenRegisterClass *> Candidates;
169+ std::vector<const CodeGenRegisterClass *> Candidates;
170170 auto &RegClasses = RegBank.getRegClasses ();
171171
172172 // Try to find a register class which supports ValueTy, and also contains
173173 // SubIdx.
174- for (CodeGenRegisterClass &RC : RegClasses) {
174+ for (const CodeGenRegisterClass &RC : RegClasses) {
175175 // Is there a subclass of this class which contains this subregister index?
176- CodeGenRegisterClass *SubClassWithSubReg = RC.getSubClassWithSubReg (SubIdx);
176+ const CodeGenRegisterClass *SubClassWithSubReg =
177+ RC.getSubClassWithSubReg (SubIdx);
177178 if (!SubClassWithSubReg)
178179 continue ;
179180
@@ -268,14 +269,14 @@ void CodeGenTarget::ReadInstructions() const {
268269}
269270
270271static const CodeGenInstruction *GetInstByName (
271- const char * Name,
272+ StringRef Name,
272273 const DenseMap<const Record *, std::unique_ptr<CodeGenInstruction>> &Insts,
273274 const RecordKeeper &Records) {
274275 const Record *Rec = Records.getDef (Name);
275276
276277 const auto I = Insts.find (Rec);
277278 if (!Rec || I == Insts.end ())
278- PrintFatalError (Twine ( " Could not find '" ) + Name + " ' instruction!" );
279+ PrintFatalError (" Could not find '" + Name + " ' instruction!" );
279280 return I->second .get ();
280281}
281282
@@ -292,8 +293,8 @@ unsigned CodeGenTarget::getNumFixedInstructions() {
292293// / their enum value.
293294void CodeGenTarget::ComputeInstrsByEnum () const {
294295 const auto &Insts = getInstructions ();
295- for (const char *const *p = FixedInstrs; *p; ++p ) {
296- const CodeGenInstruction *Instr = GetInstByName (*p , Insts, Records);
296+ for (const char *Name : FixedInstrs) {
297+ const CodeGenInstruction *Instr = GetInstByName (Name , Insts, Records);
297298 assert (Instr && " Missing target independent instruction" );
298299 assert (Instr->Namespace == " TargetOpcode" && " Bad namespace" );
299300 InstrsByEnum.push_back (Instr);
@@ -324,9 +325,8 @@ void CodeGenTarget::ComputeInstrsByEnum() const {
324325 });
325326
326327 // Assign an enum value to each instruction according to the sorted order.
327- unsigned Num = 0 ;
328- for (const CodeGenInstruction *Inst : InstrsByEnum)
329- Inst->EnumVal = Num++;
328+ for (const auto &[Idx, Inst] : enumerate(InstrsByEnum))
329+ const_cast <CodeGenInstruction *>(Inst)->EnumVal = Idx;
330330}
331331
332332// / isLittleEndianEncoding - Return whether this target encodes its instruction
0 commit comments