llvm.org GIT mirror llvm / 6161412
[TableGen] Use range-based for loops. Also fix one loop to not use some index name as an outer loop. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257156 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 4 years ago
1 changed file(s) with 20 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
108108
109109 O << " case " << FirstInst.CGI->Namespace << "::"
110110 << FirstInst.CGI->TheDef->getName() << ":\n";
111 for (unsigned i = 0, e = SimilarInsts.size(); i != e; ++i)
112 O << " case " << SimilarInsts[i].CGI->Namespace << "::"
113 << SimilarInsts[i].CGI->TheDef->getName() << ":\n";
111 for (const AsmWriterInst &AWI : SimilarInsts)
112 O << " case " << AWI.CGI->Namespace << "::"
113 << AWI.CGI->TheDef->getName() << ":\n";
114114 for (unsigned i = 0, e = FirstInst.Operands.size(); i != e; ++i) {
115115 if (i != DifferingOperand) {
116116 // If the operand is the same for all instructions, just print it.
124124 FirstInst.CGI->TheDef->getName(),
125125 FirstInst.Operands[i]));
126126
127 for (unsigned si = 0, e = SimilarInsts.size(); si != e; ++si) {
128 AsmWriterInst &AWI = SimilarInsts[si];
127 for (const AsmWriterInst &AWI : SimilarInsts) {
129128 OpsToPrint.push_back(std::make_pair(AWI.CGI->Namespace+"::"+
130129 AWI.CGI->TheDef->getName(),
131130 AWI.Operands[i]));
297296
298297 // Add all strings to the string table upfront so it can generate an optimized
299298 // representation.
300 for (unsigned i = 0, e = NumberedInstructions->size(); i != e; ++i) {
301 AsmWriterInst *AWI = CGIAWIMap[NumberedInstructions->at(i)];
299 for (const CodeGenInstruction *Inst : *NumberedInstructions) {
300 AsmWriterInst *AWI = CGIAWIMap[Inst];
302301 if (AWI &&
303302 AWI->Operands[0].OperandType ==
304303 AsmWriterOperand::isLiteralTextOperand &&
312311 StringTable.layout();
313312
314313 unsigned MaxStringIdx = 0;
315 for (unsigned i = 0, e = NumberedInstructions->size(); i != e; ++i) {
316 AsmWriterInst *AWI = CGIAWIMap[NumberedInstructions->at(i)];
314 for (const CodeGenInstruction *Inst : *NumberedInstructions) {
315 AsmWriterInst *AWI = CGIAWIMap[Inst];
317316 unsigned Idx;
318317 if (!AWI) {
319318 // Something not handled by the asmwriter printer.
471470 << " default: llvm_unreachable(\"Invalid command number.\");\n";
472471
473472 // Print out all the cases.
474 for (unsigned i = 0, e = Commands.size(); i != e; ++i) {
475 O << " case " << i << ":\n";
476 O << Commands[i];
473 for (unsigned j = 0, e = Commands.size(); j != e; ++j) {
474 O << " case " << j << ":\n";
475 O << Commands[j];
477476 O << " break;\n";
478477 }
479478 O << " }\n\n";
601600 << "\n";
602601
603602 if (hasAltNames) {
604 for (unsigned i = 0, e = AltNameIndices.size(); i < e; ++i)
605 emitRegisterNameString(O, AltNameIndices[i]->getName(), Registers);
603 for (const Record *R : AltNameIndices)
604 emitRegisterNameString(O, R->getName(), Registers);
606605 } else
607606 emitRegisterNameString(O, "", Registers);
608607
609608 if (hasAltNames) {
610609 O << " switch(AltIdx) {\n"
611610 << " default: llvm_unreachable(\"Invalid register alt name index!\");\n";
612 for (unsigned i = 0, e = AltNameIndices.size(); i < e; ++i) {
613 std::string AltName(AltNameIndices[i]->getName());
611 for (const Record *R : AltNameIndices) {
612 std::string AltName(R->getName());
614613 std::string Prefix = !Namespace.empty() ? Namespace + "::" : "";
615614 O << " case " << Prefix << AltName << ":\n"
616615 << " assert(*(AsmStrs" << AltName << "+RegAsmOffset"
797796 typedef std::set, AliasPriorityComparator>
798797 AliasWithPriority;
799798 std::map AliasMap;
800 for (std::vector::iterator
801 I = AllInstAliases.begin(), E = AllInstAliases.end(); I != E; ++I) {
802 const Record *R = *I;
799 for (Record *R : AllInstAliases) {
803800 int Priority = R->getValueAsInt("EmitPriority");
804801 if (Priority < 1)
805802 continue; // Aliases with priority 0 are never emitted.
807804 const DagInit *DI = R->getValueAsDag("ResultInst");
808805 const DefInit *Op = cast(DI->getOperator());
809806 AliasMap[getQualifiedName(Op->getDef())].insert(
810 std::make_pair(CodeGenInstAlias(*I, Variant, Target), Priority));
807 std::make_pair(CodeGenInstAlias(R, Variant, Target), Priority));
811808 }
812809
813810 // A map of which conditions need to be met for each instruction operand
975972
976973 CasesO.indent(2) << "case " << Entry.first << ":\n";
977974
978 for (std::vector::iterator
979 II = UniqueIAPs.begin(), IE = UniqueIAPs.end(); II != IE; ++II) {
980 IAPrinter *IAP = *II;
975 for (IAPrinter *IAP : UniqueIAPs) {
981976 CasesO.indent(4);
982977 IAP->print(CasesO);
983978 CasesO << '\n';
11071102 // Compute the CodeGenInstruction -> AsmWriterInst mapping. Note that not
11081103 // all machine instructions are necessarily being printed, so there may be
11091104 // target instructions not in this map.
1110 for (unsigned i = 0, e = Instructions.size(); i != e; ++i)
1111 CGIAWIMap.insert(std::make_pair(Instructions[i].CGI, &Instructions[i]));
1105 for (AsmWriterInst &AWI : Instructions)
1106 CGIAWIMap.insert(std::make_pair(AWI.CGI, &AWI));
11121107 }
11131108
11141109 void AsmWriterEmitter::run(raw_ostream &O) {