|
28 | 28 | #include <tuple> |
29 | 29 | using namespace llvm; |
30 | 30 |
|
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"); |
33 | 33 |
|
34 | 34 | static cl::opt<unsigned> |
35 | 35 | AsmParserNum("asmparsernum", cl::init(0), |
@@ -64,9 +64,9 @@ StringRef llvm::getEnumName(MVT::SimpleValueType T) { |
64 | 64 | std::string llvm::getQualifiedName(const Record *R) { |
65 | 65 | std::string Namespace; |
66 | 66 | if (R->getValue("Namespace")) |
67 | | - Namespace = std::string(R->getValueAsString("Namespace")); |
| 67 | + Namespace = R->getValueAsString("Namespace").str(); |
68 | 68 | if (Namespace.empty()) |
69 | | - return std::string(R->getName()); |
| 69 | + return R->getName().str(); |
70 | 70 | return Namespace + "::" + R->getName().str(); |
71 | 71 | } |
72 | 72 |
|
@@ -166,14 +166,15 @@ CodeGenRegBank &CodeGenTarget::getRegBank() const { |
166 | 166 | const CodeGenRegisterClass *CodeGenTarget::getSuperRegForSubReg( |
167 | 167 | const ValueTypeByHwMode &ValueTy, CodeGenRegBank &RegBank, |
168 | 168 | const CodeGenSubRegIndex *SubIdx, bool MustBeAllocatable) const { |
169 | | - std::vector<CodeGenRegisterClass *> Candidates; |
| 169 | + std::vector<const CodeGenRegisterClass *> Candidates; |
170 | 170 | auto &RegClasses = RegBank.getRegClasses(); |
171 | 171 |
|
172 | 172 | // Try to find a register class which supports ValueTy, and also contains |
173 | 173 | // SubIdx. |
174 | | - for (CodeGenRegisterClass &RC : RegClasses) { |
| 174 | + for (const CodeGenRegisterClass &RC : RegClasses) { |
175 | 175 | // 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); |
177 | 178 | if (!SubClassWithSubReg) |
178 | 179 | continue; |
179 | 180 |
|
@@ -268,32 +269,32 @@ void CodeGenTarget::ReadInstructions() const { |
268 | 269 | } |
269 | 270 |
|
270 | 271 | static const CodeGenInstruction *GetInstByName( |
271 | | - const char *Name, |
| 272 | + StringRef Name, |
272 | 273 | const DenseMap<const Record *, std::unique_ptr<CodeGenInstruction>> &Insts, |
273 | 274 | const RecordKeeper &Records) { |
274 | 275 | const Record *Rec = Records.getDef(Name); |
275 | 276 |
|
276 | 277 | const auto I = Insts.find(Rec); |
277 | 278 | if (!Rec || I == Insts.end()) |
278 | | - PrintFatalError(Twine("Could not find '") + Name + "' instruction!"); |
| 279 | + PrintFatalError("Could not find '" + Name + "' instruction!"); |
279 | 280 | return I->second.get(); |
280 | 281 | } |
281 | 282 |
|
282 | 283 | static const char *FixedInstrs[] = { |
283 | 284 | #define HANDLE_TARGET_OPCODE(OPC) #OPC, |
284 | 285 | #include "llvm/Support/TargetOpcodes.def" |
285 | | - nullptr}; |
| 286 | +}; |
286 | 287 |
|
287 | 288 | unsigned CodeGenTarget::getNumFixedInstructions() { |
288 | | - return std::size(FixedInstrs) - 1; |
| 289 | + return std::size(FixedInstrs); |
289 | 290 | } |
290 | 291 |
|
291 | 292 | /// Return all of the instructions defined by the target, ordered by |
292 | 293 | /// their enum value. |
293 | 294 | void CodeGenTarget::ComputeInstrsByEnum() const { |
294 | 295 | 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); |
297 | 298 | assert(Instr && "Missing target independent instruction"); |
298 | 299 | assert(Instr->Namespace == "TargetOpcode" && "Bad namespace"); |
299 | 300 | InstrsByEnum.push_back(Instr); |
@@ -324,9 +325,8 @@ void CodeGenTarget::ComputeInstrsByEnum() const { |
324 | 325 | }); |
325 | 326 |
|
326 | 327 | // 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 | + Inst->EnumVal = Idx; |
330 | 330 | } |
331 | 331 |
|
332 | 332 | /// isLittleEndianEncoding - Return whether this target encodes its instruction |
|
0 commit comments