@@ -143,10 +143,11 @@ class X86FoldTablesEmitter {
143
143
typedef std::map<const CodeGenInstruction *, X86FoldTableEntry,
144
144
CompareInstrsByEnum>
145
145
FoldTable;
146
- // std::vector for each folding table.
147
- // Table2Addr - Holds instructions which their memory form performs load+store
148
- // Table#i - Holds instructions which the their memory form perform a load OR
149
- // a store, and their #i'th operand is folded.
146
+ // Table2Addr - Holds instructions which their memory form performs
147
+ // load+store.
148
+ //
149
+ // Table#i - Holds instructions which the their memory form
150
+ // performs a load OR a store, and their #i'th operand is folded.
150
151
FoldTable Table2Addr;
151
152
FoldTable Table0;
152
153
FoldTable Table1;
@@ -168,7 +169,7 @@ class X86FoldTablesEmitter {
168
169
bool IsManual = false );
169
170
170
171
// Generates X86FoldTableEntry with the given instructions and fill it with
171
- // the appropriate flags - then adds it to Table .
172
+ // the appropriate flags, then adds it to a memory fold table .
172
173
void addEntryWithFlags (FoldTable &Table, const CodeGenInstruction *RegInst,
173
174
const CodeGenInstruction *MemInst, uint16_t S,
174
175
unsigned FoldedIdx, bool IsManual);
@@ -300,6 +301,8 @@ class IsMatch {
300
301
const Record *MemRec = MemInst->TheDef ;
301
302
302
303
// EVEX_B means different things for memory and register forms.
304
+ // register form: rounding control or SAE
305
+ // memory form: broadcast
303
306
if (RegRI.HasEVEX_B || MemRI.HasEVEX_B )
304
307
return false ;
305
308
@@ -582,6 +585,13 @@ void X86FoldTablesEmitter::run(raw_ostream &O) {
582
585
583
586
Record *AsmWriter = Target.getAsmWriter ();
584
587
unsigned Variant = AsmWriter->getValueAsInt (" Variant" );
588
+ auto FixUp = [&](const CodeGenInstruction *RegInst) {
589
+ StringRef RegInstName = RegInst->TheDef ->getName ();
590
+ if (RegInstName.ends_with (" _REV" ) || RegInstName.ends_with (" _alt" ))
591
+ if (auto *RegAltRec = Records.getDef (RegInstName.drop_back (4 )))
592
+ RegInst = &Target.getInstruction (RegAltRec);
593
+ return RegInst;
594
+ };
585
595
// For each memory form instruction, try to find its register form
586
596
// instruction.
587
597
for (const CodeGenInstruction *MemInst : MemInsts) {
@@ -598,13 +608,7 @@ void X86FoldTablesEmitter::run(raw_ostream &O) {
598
608
599
609
auto Match = find_if (OpcRegInsts, IsMatch (MemInst, Variant));
600
610
if (Match != OpcRegInsts.end ()) {
601
- const CodeGenInstruction *RegInst = *Match;
602
- StringRef RegInstName = RegInst->TheDef ->getName ();
603
- if (RegInstName.ends_with (" _REV" ) || RegInstName.ends_with (" _alt" ))
604
- if (auto *RegAltRec = Records.getDef (RegInstName.drop_back (4 )))
605
- RegInst = &Target.getInstruction (RegAltRec);
606
-
607
- updateTables (RegInst, MemInst);
611
+ updateTables (FixUp (*Match), MemInst);
608
612
OpcRegInsts.erase (Match);
609
613
}
610
614
}
0 commit comments