llvm.org GIT mirror llvm / eb6a662
[X86] Make the X86FoldTablesEmitter functional again. Fix the spacing in the output to make it easier to diff. Fix a few other formatting issues in the manual table. And remove some old FIXMEs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362287 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 2 months ago
2 changed file(s) with 41 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
247247 { X86::XOR64rr, X86::XOR64mr, 0 },
248248 { X86::XOR8ri, X86::XOR8mi, 0 },
249249 { X86::XOR8ri8, X86::XOR8mi8, 0 },
250 { X86::XOR8rr, X86::XOR8mr, 0 }
250 { X86::XOR8rr, X86::XOR8mr, 0 },
251251 };
252252
253253 static const X86MemoryFoldTableEntry MemoryFoldTable0[] = {
613613 { X86::SQRTSSr, X86::SQRTSSm, 0 },
614614 { X86::T1MSKC32rr, X86::T1MSKC32rm, 0 },
615615 { X86::T1MSKC64rr, X86::T1MSKC64rm, 0 },
616 // FIXME: TEST*rr EAX,EAX ---> CMP [mem], 0
617616 { X86::TZCNT16rr, X86::TZCNT16rm, 0 },
618617 { X86::TZCNT32rr, X86::TZCNT32rm, 0 },
619618 { X86::TZCNT64rr, X86::TZCNT64rm, 0 },
648647 { X86::VCOMISSrr_Int, X86::VCOMISSrm_Int, TB_NO_REVERSE },
649648 { X86::VCVTDQ2PDYrr, X86::VCVTDQ2PDYrm, 0 },
650649 { X86::VCVTDQ2PDZ128rr, X86::VCVTDQ2PDZ128rm, TB_NO_REVERSE },
651 { X86::VCVTDQ2PDZ256rr, X86::VCVTDQ2PDZ256rm, 0 },
650 { X86::VCVTDQ2PDZ256rr, X86::VCVTDQ2PDZ256rm, 0 },
652651 { X86::VCVTDQ2PDZrr, X86::VCVTDQ2PDZrm, 0 },
653652 { X86::VCVTDQ2PDrr, X86::VCVTDQ2PDrm, TB_NO_REVERSE },
654653 { X86::VCVTDQ2PSYrr, X86::VCVTDQ2PSYrm, 0 },
15171516 { X86::SUBSDrr_Int, X86::SUBSDrm_Int, TB_NO_REVERSE },
15181517 { X86::SUBSSrr, X86::SUBSSrm, 0 },
15191518 { X86::SUBSSrr_Int, X86::SUBSSrm_Int, TB_NO_REVERSE },
1520 // FIXME: TEST*rr -> swapped operand of TEST *mr.
15211519 { X86::UNPCKHPDrr, X86::UNPCKHPDrm, TB_ALIGN_16 },
15221520 { X86::UNPCKHPSrr, X86::UNPCKHPSrm, TB_ALIGN_16 },
15231521 { X86::UNPCKLPDrr, X86::UNPCKLPDrm, TB_ALIGN_16 },
1212
1313 #include "CodeGenTarget.h"
1414 #include "X86RecognizableInstr.h"
15 #include "llvm/Support/FormattedStream.h"
1516 #include "llvm/TableGen/Error.h"
1617 #include "llvm/TableGen/TableGenBackend.h"
1718
107108 const CodeGenInstruction *MemInst)
108109 : RegInst(RegInst), MemInst(MemInst) {}
109110
110 friend raw_ostream &operator<<(raw_ostream &OS,
111 const X86FoldTableEntry &E) {
112 OS << "{ X86::" << E.RegInst->TheDef->getName()
113 << ", X86::" << E.MemInst->TheDef->getName() << ", ";
114
115 if (E.IsLoad)
111 void print(formatted_raw_ostream &OS) const {
112 OS.indent(2);
113 OS << "{ X86::" << RegInst->TheDef->getName() << ",";
114 OS.PadToColumn(40);
115 OS << "X86::" << MemInst->TheDef->getName() << ",";
116 OS.PadToColumn(75);
117
118 if (IsLoad)
116119 OS << "TB_FOLDED_LOAD | ";
117 if (E.IsStore)
120 if (IsStore)
118121 OS << "TB_FOLDED_STORE | ";
119 if (E.CannotUnfold)
122 if (CannotUnfold)
120123 OS << "TB_NO_REVERSE | ";
121 if (E.IsAligned)
122 OS << "TB_ALIGN_" << E.Alignment << " | ";
124 if (IsAligned)
125 OS << "TB_ALIGN_" << Alignment << " | ";
123126
124127 OS << "0 },\n";
125
126 return OS;
127128 }
128129 };
129130
143144 X86FoldTablesEmitter(RecordKeeper &R) : Records(R), Target(R) {}
144145
145146 // run - Generate the 6 X86 memory fold tables.
146 void run(raw_ostream &OS);
147 void run(formatted_raw_ostream &OS);
147148
148149 private:
149150 // Decides to which table to add the entry with the given instructions.
161162 // Print the given table as a static const C++ array of type
162163 // X86MemoryFoldTableEntry.
163164 void printTable(const FoldTable &Table, StringRef TableName,
164 raw_ostream &OS) {
165 formatted_raw_ostream &OS) {
165166 OS << "static const X86MemoryFoldTableEntry MemoryFold" << TableName
166167 << "[] = {\n";
167168
168169 for (const X86FoldTableEntry &E : Table)
169 OS << E;
170
171 OS << "};\n";
170 E.print(OS);
171
172 OS << "};\n\n";
172173 }
173174 };
174175
175176 // Return true if one of the instruction's operands is a RST register class
176177 static bool hasRSTRegClass(const CodeGenInstruction *Inst) {
177178 return any_of(Inst->Operands, [](const CGIOperandList::OperandInfo &OpIn) {
178 return OpIn.Rec->getName() == "RST";
179 return OpIn.Rec->getName() == "RST" || OpIn.Rec->getName() == "RSTi";
179180 });
180181 }
181182
346347 MemRec->getValueAsBit("hasLockPrefix") ||
347348 RegRec->getValueAsBit("hasNoTrackPrefix") !=
348349 MemRec->getValueAsBit("hasNoTrackPrefix") ||
349 !equalBitsInits(RegRec->getValueAsBitsInit("EVEX_LL"),
350 MemRec->getValueAsBitsInit("EVEX_LL")) ||
351 !equalBitsInits(RegRec->getValueAsBitsInit("VEX_WPrefix"),
352 MemRec->getValueAsBitsInit("VEX_WPrefix")) ||
350 RegRec->getValueAsBit("hasVEX_L") !=
351 MemRec->getValueAsBit("hasVEX_L") ||
352 RegRec->getValueAsBit("hasEVEX_L2") !=
353 MemRec->getValueAsBit("hasEVEX_L2") ||
354 RegRec->getValueAsBit("ignoresVEX_L") !=
355 MemRec->getValueAsBit("ignoresVEX_L") ||
356 RegRec->getValueAsBit("HasVEX_W") !=
357 MemRec->getValueAsBit("HasVEX_W") ||
358 RegRec->getValueAsBit("IgnoresVEX_W") !=
359 MemRec->getValueAsBit("IgnoresVEX_W") ||
360 RegRec->getValueAsBit("EVEX_W1_VEX_W0") !=
361 MemRec->getValueAsBit("EVEX_W1_VEX_W0") ||
353362 // Instruction's format - The register form's "Form" field should be
354363 // the opposite of the memory form's "Form" field.
355364 !areOppositeForms(RegRec->getValueAsBitsInit("FormBits"),
422431 (MemFormNum == X86Local::MRM6m && RegFormNum == X86Local::MRM6r) ||
423432 (MemFormNum == X86Local::MRM7m && RegFormNum == X86Local::MRM7r) ||
424433 (MemFormNum == X86Local::MRMXm && RegFormNum == X86Local::MRMXr) ||
434 (MemFormNum == X86Local::MRMXmCC && RegFormNum == X86Local::MRMXrCC) ||
425435 (MemFormNum == X86Local::MRMDestMem &&
426436 RegFormNum == X86Local::MRMDestReg) ||
427437 (MemFormNum == X86Local::MRMSrcMem &&
429439 (MemFormNum == X86Local::MRMSrcMem4VOp3 &&
430440 RegFormNum == X86Local::MRMSrcReg4VOp3) ||
431441 (MemFormNum == X86Local::MRMSrcMemOp4 &&
432 RegFormNum == X86Local::MRMSrcRegOp4))
442 RegFormNum == X86Local::MRMSrcRegOp4) ||
443 (MemFormNum == X86Local::MRMSrcMemCC &&
444 RegFormNum == X86Local::MRMSrcRegCC))
433445 return true;
434446
435447 return false;
559571 return;
560572 }
561573
562 void X86FoldTablesEmitter::run(raw_ostream &OS) {
574 void X86FoldTablesEmitter::run(formatted_raw_ostream &OS) {
563575 emitSourceFileHeader("X86 fold tables", OS);
564576
565577 // Holds all memory instructions
640652 &(Target.getInstruction(MemInstIter)), Entry.Strategy);
641653 }
642654
643 // Print all tables to raw_ostream OS.
655 // Print all tables.
644656 printTable(Table2Addr, "Table2Addr", OS);
645657 printTable(Table0, "Table0", OS);
646658 printTable(Table1, "Table1", OS);
651663
652664 namespace llvm {
653665
654 void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS) {
666 void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &o) {
667 formatted_raw_ostream OS(o);
655668 X86FoldTablesEmitter(RK).run(OS);
656669 }
657670 } // namespace llvm