@@ -54,11 +54,6 @@ ReMatPICStubLoad("remat-pic-stub-load",
54
54
X86InstrInfo::X86InstrInfo (X86TargetMachine &tm)
55
55
: TargetInstrInfoImpl(X86Insts, array_lengthof(X86Insts)),
56
56
TM(tm), RI(tm, *this ) {
57
- enum {
58
- TB_NOT_REVERSABLE = 1U << 31 ,
59
- TB_FLAGS = TB_NOT_REVERSABLE
60
- };
61
-
62
57
static const unsigned OpTbl2Addr[][2 ] = {
63
58
{ X86::ADC32ri, X86::ADC32mi },
64
59
{ X86::ADC32ri8, X86::ADC32mi8 },
@@ -69,15 +64,12 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
69
64
{ X86::ADD16ri, X86::ADD16mi },
70
65
{ X86::ADD16ri8, X86::ADD16mi8 },
71
66
{ X86::ADD16rr, X86::ADD16mr },
72
- { X86::ADD16rr_DB, X86::ADD16mr | TB_NOT_REVERSABLE },
73
67
{ X86::ADD32ri, X86::ADD32mi },
74
68
{ X86::ADD32ri8, X86::ADD32mi8 },
75
69
{ X86::ADD32rr, X86::ADD32mr },
76
- { X86::ADD32rr_DB, X86::ADD32mr | TB_NOT_REVERSABLE },
77
70
{ X86::ADD64ri32, X86::ADD64mi32 },
78
71
{ X86::ADD64ri8, X86::ADD64mi8 },
79
72
{ X86::ADD64rr, X86::ADD64mr },
80
- { X86::ADD64rr_DB, X86::ADD64mr | TB_NOT_REVERSABLE },
81
73
{ X86::ADD8ri, X86::ADD8mi },
82
74
{ X86::ADD8rr, X86::ADD8mr },
83
75
{ X86::AND16ri, X86::AND16mi },
@@ -222,21 +214,16 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
222
214
223
215
for (unsigned i = 0 , e = array_lengthof (OpTbl2Addr); i != e; ++i) {
224
216
unsigned RegOp = OpTbl2Addr[i][0 ];
225
- unsigned MemOp = OpTbl2Addr[i][1 ] & ~TB_FLAGS;
226
- assert (!RegOp2MemOpTable2Addr.count (RegOp) && " Duplicated entries?" );
227
- RegOp2MemOpTable2Addr[RegOp] = std::make_pair (MemOp, 0U );
228
-
229
- // If this is not a reversable operation (because there is a many->one)
230
- // mapping, don't insert the reverse of the operation into MemOp2RegOpTable.
231
- if (OpTbl2Addr[i][1 ] & TB_NOT_REVERSABLE)
232
- continue ;
233
-
217
+ unsigned MemOp = OpTbl2Addr[i][1 ];
218
+ if (!RegOp2MemOpTable2Addr.insert (std::make_pair (RegOp,
219
+ std::make_pair (MemOp,0 ))).second )
220
+ assert (false && " Duplicated entries?" );
234
221
// Index 0, folded load and store, no alignment requirement.
235
222
unsigned AuxInfo = 0 | (1 << 4 ) | (1 << 5 );
236
-
237
- assert (!MemOp2RegOpTable. count (MemOp) &&
238
- " Duplicated entries in unfolding maps? " );
239
- MemOp2RegOpTable[MemOp] = std::make_pair (RegOp, AuxInfo );
223
+ if (!MemOp2RegOpTable. insert ( std::make_pair (MemOp,
224
+ std::make_pair (RegOp,
225
+ AuxInfo))). second )
226
+ assert ( false && " Duplicated entries in unfolding maps? " );
240
227
}
241
228
242
229
// If the third value is 1, then it's folding either a load or a store.
@@ -466,11 +453,8 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
466
453
{ X86::ADC32rr, X86::ADC32rm, 0 },
467
454
{ X86::ADC64rr, X86::ADC64rm, 0 },
468
455
{ X86::ADD16rr, X86::ADD16rm, 0 },
469
- { X86::ADD16rr_DB, X86::ADD16rm | TB_NOT_REVERSABLE, 0 },
470
456
{ X86::ADD32rr, X86::ADD32rm, 0 },
471
- { X86::ADD32rr_DB, X86::ADD32rm | TB_NOT_REVERSABLE, 0 },
472
457
{ X86::ADD64rr, X86::ADD64rm, 0 },
473
- { X86::ADD64rr_DB, X86::ADD64rm | TB_NOT_REVERSABLE, 0 },
474
458
{ X86::ADD8rr, X86::ADD8rm, 0 },
475
459
{ X86::ADDPDrr, X86::ADDPDrm, 16 },
476
460
{ X86::ADDPSrr, X86::ADDPSrm, 16 },
@@ -665,23 +649,16 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
665
649
666
650
for (unsigned i = 0 , e = array_lengthof (OpTbl2); i != e; ++i) {
667
651
unsigned RegOp = OpTbl2[i][0 ];
668
- unsigned MemOp = OpTbl2[i][1 ] & ~TB_FLAGS ;
652
+ unsigned MemOp = OpTbl2[i][1 ];
669
653
unsigned Align = OpTbl2[i][2 ];
670
-
671
- assert (!RegOp2MemOpTable2.count (RegOp) && " Duplicate entry!" );
672
- RegOp2MemOpTable2[RegOp] = std::make_pair (MemOp, Align);
673
-
674
-
675
- // If this is not a reversable operation (because there is a many->one)
676
- // mapping, don't insert the reverse of the operation into MemOp2RegOpTable.
677
- if (OpTbl2[i][1 ] & TB_NOT_REVERSABLE)
678
- continue ;
679
-
654
+ if (!RegOp2MemOpTable2.insert (std::make_pair (RegOp,
655
+ std::make_pair (MemOp,Align))).second )
656
+ assert (false && " Duplicated entries?" );
680
657
// Index 2, folded load
681
658
unsigned AuxInfo = 2 | (1 << 4 );
682
- assert (!MemOp2RegOpTable.count ( MemOp) &&
683
- " Duplicated entries in unfolding maps? " );
684
- MemOp2RegOpTable[MemOp] = std::make_pair (RegOp, AuxInfo );
659
+ if (!MemOp2RegOpTable.insert ( std::make_pair ( MemOp,
660
+ std::make_pair (RegOp, AuxInfo))). second )
661
+ assert ( false && " Duplicated entries in unfolding maps? " );
685
662
}
686
663
}
687
664
@@ -1156,8 +1133,7 @@ X86InstrInfo::convertToThreeAddressWithLEA(unsigned MIOpc,
1156
1133
case X86::ADD16ri8:
1157
1134
addRegOffset (MIB, leaInReg, true , MI->getOperand (2 ).getImm ());
1158
1135
break ;
1159
- case X86::ADD16rr:
1160
- case X86::ADD16rr_DB: {
1136
+ case X86::ADD16rr: {
1161
1137
unsigned Src2 = MI->getOperand (2 ).getReg ();
1162
1138
bool isKill2 = MI->getOperand (2 ).isKill ();
1163
1139
unsigned leaInReg2 = 0 ;
@@ -1370,27 +1346,18 @@ X86InstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
1370
1346
Src, isKill, -1 );
1371
1347
break ;
1372
1348
case X86::ADD64rr:
1373
- case X86::ADD64rr_DB:
1374
- case X86::ADD32rr:
1375
- case X86::ADD32rr_DB: {
1349
+ case X86::ADD32rr: {
1376
1350
assert (MI->getNumOperands () >= 3 && " Unknown add instruction!" );
1377
- unsigned Opc;
1378
- TargetRegisterClass *RC;
1379
- if (MIOpc == X86::ADD64rr || MIOpc == X86::ADD64rr_DB) {
1380
- Opc = X86::LEA64r;
1381
- RC = X86::GR64_NOSPRegisterClass;
1382
- } else {
1383
- Opc = is64Bit ? X86::LEA64_32r : X86::LEA32r;
1384
- RC = X86::GR32_NOSPRegisterClass;
1385
- }
1386
-
1387
-
1351
+ unsigned Opc = MIOpc == X86::ADD64rr ? X86::LEA64r
1352
+ : (is64Bit ? X86::LEA64_32r : X86::LEA32r);
1388
1353
unsigned Src2 = MI->getOperand (2 ).getReg ();
1389
1354
bool isKill2 = MI->getOperand (2 ).isKill ();
1390
1355
1391
1356
// LEA can't handle RSP.
1392
1357
if (TargetRegisterInfo::isVirtualRegister (Src2) &&
1393
- !MF.getRegInfo ().constrainRegClass (Src2, RC))
1358
+ !MF.getRegInfo ().constrainRegClass (Src2,
1359
+ MIOpc == X86::ADD64rr ? X86::GR64_NOSPRegisterClass :
1360
+ X86::GR32_NOSPRegisterClass))
1394
1361
return 0 ;
1395
1362
1396
1363
NewMI = addRegReg (BuildMI (MF, MI->getDebugLoc (), get (Opc))
@@ -1401,8 +1368,7 @@ X86InstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
1401
1368
LV->replaceKillInstruction (Src2, MI, NewMI);
1402
1369
break ;
1403
1370
}
1404
- case X86::ADD16rr:
1405
- case X86::ADD16rr_DB: {
1371
+ case X86::ADD16rr: {
1406
1372
if (DisableLEA16)
1407
1373
return is64Bit ? convertToThreeAddressWithLEA (MIOpc, MFI, MBBI, LV) : 0 ;
1408
1374
assert (MI->getNumOperands () >= 3 && " Unknown add instruction!" );
@@ -2630,8 +2596,13 @@ bool X86InstrInfo::canFoldMemoryOperand(const MachineInstr *MI,
2630
2596
OpcodeTablePtr = &RegOp2MemOpTable2;
2631
2597
}
2632
2598
2633
- if (OpcodeTablePtr && OpcodeTablePtr->count (Opc))
2634
- return true ;
2599
+ if (OpcodeTablePtr) {
2600
+ // Find the Opcode to fuse
2601
+ DenseMap<unsigned , std::pair<unsigned ,unsigned > >::const_iterator I =
2602
+ OpcodeTablePtr->find (Opc);
2603
+ if (I != OpcodeTablePtr->end ())
2604
+ return true ;
2605
+ }
2635
2606
return TargetInstrInfoImpl::canFoldMemoryOperand (MI, Ops);
2636
2607
}
2637
2608
0 commit comments