@@ -1107,19 +1107,23 @@ MipsTargetLowering::emitAtomicBinary(MachineInstr *MI, MachineBasicBlock *BB,
1107
1107
MachineRegisterInfo &RegInfo = MF->getRegInfo ();
1108
1108
const TargetRegisterClass *RC = getRegClassFor (MVT::getIntegerVT (Size * 8 ));
1109
1109
const TargetInstrInfo *TII = Subtarget.getInstrInfo ();
1110
+ const bool ArePtrs64bit = ABI.ArePtrs64bit ();
1110
1111
DebugLoc DL = MI->getDebugLoc ();
1111
1112
unsigned LL, SC, AND, NOR, ZERO, BEQ;
1112
1113
1113
- // FIXME: The below code should check for the ISA to emit the correct 64bit
1114
- // operations when the size is 4.
1115
1114
if (Size == 4 ) {
1116
1115
if (isMicroMips) {
1117
1116
LL = Mips::LL_MM;
1118
1117
SC = Mips::SC_MM;
1119
1118
} else {
1120
- LL = Subtarget.hasMips32r6 () ? Mips::LL_R6 : Mips::LL;
1121
- SC = Subtarget.hasMips32r6 () ? Mips::SC_R6 : Mips::SC;
1119
+ LL = Subtarget.hasMips32r6 ()
1120
+ ? (ArePtrs64bit ? Mips::LL64_R6 : Mips::LL_R6)
1121
+ : (ArePtrs64bit ? Mips::LL64 : Mips::LL);
1122
+ SC = Subtarget.hasMips32r6 ()
1123
+ ? (ArePtrs64bit ? Mips::SC64_R6 : Mips::SC_R6)
1124
+ : (ArePtrs64bit ? Mips::SC64 : Mips::SC);
1122
1125
}
1126
+
1123
1127
AND = Mips::AND;
1124
1128
NOR = Mips::NOR;
1125
1129
ZERO = Mips::ZERO;
@@ -1226,7 +1230,7 @@ MachineBasicBlock *MipsTargetLowering::emitAtomicBinaryPartword(
1226
1230
MachineFunction *MF = BB->getParent ();
1227
1231
MachineRegisterInfo &RegInfo = MF->getRegInfo ();
1228
1232
const TargetRegisterClass *RC = getRegClassFor (MVT::i32);
1229
- bool ArePtrs64bit = ABI.ArePtrs64bit ();
1233
+ const bool ArePtrs64bit = ABI.ArePtrs64bit ();
1230
1234
const TargetRegisterClass *RCp =
1231
1235
getRegClassFor (ArePtrs64bit ? MVT::i64 : MVT::i32);
1232
1236
const TargetInstrInfo *TII = Subtarget.getInstrInfo ();
@@ -1254,6 +1258,17 @@ MachineBasicBlock *MipsTargetLowering::emitAtomicBinaryPartword(
1254
1258
unsigned SrlRes = RegInfo.createVirtualRegister (RC);
1255
1259
unsigned Success = RegInfo.createVirtualRegister (RC);
1256
1260
1261
+ unsigned LL, SC;
1262
+ if (isMicroMips) {
1263
+ LL = Mips::LL_MM;
1264
+ SC = Mips::SC_MM;
1265
+ } else {
1266
+ LL = Subtarget.hasMips32r6 () ? (ArePtrs64bit ? Mips::LL64_R6 : Mips::LL_R6)
1267
+ : (ArePtrs64bit ? Mips::LL64 : Mips::LL);
1268
+ SC = Subtarget.hasMips32r6 () ? (ArePtrs64bit ? Mips::SC64_R6 : Mips::SC_R6)
1269
+ : (ArePtrs64bit ? Mips::SC64 : Mips::SC);
1270
+ }
1271
+
1257
1272
// insert new blocks after the current block
1258
1273
const BasicBlock *LLVM_BB = BB->getBasicBlock ();
1259
1274
MachineBasicBlock *loopMBB = MF->CreateMachineBasicBlock (LLVM_BB);
@@ -1326,7 +1341,6 @@ MachineBasicBlock *MipsTargetLowering::emitAtomicBinaryPartword(
1326
1341
// beq success,$0,loopMBB
1327
1342
1328
1343
BB = loopMBB;
1329
- unsigned LL = isMicroMips ? Mips::LL_MM : Mips::LL;
1330
1344
BuildMI (BB, DL, TII->get (LL), OldVal).addReg (AlignedAddr).addImm (0 );
1331
1345
if (Nand) {
1332
1346
// and andres, oldval, incr2
@@ -1350,7 +1364,6 @@ MachineBasicBlock *MipsTargetLowering::emitAtomicBinaryPartword(
1350
1364
.addReg (OldVal).addReg (Mask2);
1351
1365
BuildMI (BB, DL, TII->get (Mips::OR), StoreVal)
1352
1366
.addReg (MaskedOldVal0).addReg (NewVal);
1353
- unsigned SC = isMicroMips ? Mips::SC_MM : Mips::SC;
1354
1367
BuildMI (BB, DL, TII->get (SC), Success)
1355
1368
.addReg (StoreVal).addReg (AlignedAddr).addImm (0 );
1356
1369
BuildMI (BB, DL, TII->get (Mips::BEQ))
@@ -1382,17 +1395,23 @@ MachineBasicBlock * MipsTargetLowering::emitAtomicCmpSwap(MachineInstr *MI,
1382
1395
MachineRegisterInfo &RegInfo = MF->getRegInfo ();
1383
1396
const TargetRegisterClass *RC = getRegClassFor (MVT::getIntegerVT (Size * 8 ));
1384
1397
const TargetInstrInfo *TII = Subtarget.getInstrInfo ();
1398
+ const bool ArePtrs64bit = ABI.ArePtrs64bit ();
1385
1399
DebugLoc DL = MI->getDebugLoc ();
1386
1400
unsigned LL, SC, ZERO, BNE, BEQ;
1387
1401
1388
- if (Size == 4 ) {
1389
- if (isMicroMips) {
1390
- LL = Mips::LL_MM;
1391
- SC = Mips::SC_MM;
1392
- } else {
1393
- LL = Subtarget.hasMips32r6 () ? Mips::LL_R6 : Mips::LL;
1394
- SC = Subtarget.hasMips32r6 () ? Mips::SC_R6 : Mips::SC;
1395
- }
1402
+ if (Size == 4 ) {
1403
+ if (isMicroMips) {
1404
+ LL = Mips::LL_MM;
1405
+ SC = Mips::SC_MM;
1406
+ } else {
1407
+ LL = Subtarget.hasMips32r6 ()
1408
+ ? (ArePtrs64bit ? Mips::LL64_R6 : Mips::LL_R6)
1409
+ : (ArePtrs64bit ? Mips::LL64 : Mips::LL);
1410
+ SC = Subtarget.hasMips32r6 ()
1411
+ ? (ArePtrs64bit ? Mips::SC64_R6 : Mips::SC_R6)
1412
+ : (ArePtrs64bit ? Mips::SC64 : Mips::SC);
1413
+ }
1414
+
1396
1415
ZERO = Mips::ZERO;
1397
1416
BNE = Mips::BNE;
1398
1417
BEQ = Mips::BEQ;
@@ -1467,7 +1486,7 @@ MipsTargetLowering::emitAtomicCmpSwapPartword(MachineInstr *MI,
1467
1486
MachineFunction *MF = BB->getParent ();
1468
1487
MachineRegisterInfo &RegInfo = MF->getRegInfo ();
1469
1488
const TargetRegisterClass *RC = getRegClassFor (MVT::i32);
1470
- bool ArePtrs64bit = ABI.ArePtrs64bit ();
1489
+ const bool ArePtrs64bit = ABI.ArePtrs64bit ();
1471
1490
const TargetRegisterClass *RCp =
1472
1491
getRegClassFor (ArePtrs64bit ? MVT::i64 : MVT::i32);
1473
1492
const TargetInstrInfo *TII = Subtarget.getInstrInfo ();
@@ -1495,6 +1514,17 @@ MipsTargetLowering::emitAtomicCmpSwapPartword(MachineInstr *MI,
1495
1514
unsigned StoreVal = RegInfo.createVirtualRegister (RC);
1496
1515
unsigned SrlRes = RegInfo.createVirtualRegister (RC);
1497
1516
unsigned Success = RegInfo.createVirtualRegister (RC);
1517
+ unsigned LL, SC;
1518
+
1519
+ if (isMicroMips) {
1520
+ LL = Mips::LL_MM;
1521
+ SC = Mips::SC_MM;
1522
+ } else {
1523
+ LL = Subtarget.hasMips32r6 () ? (ArePtrs64bit ? Mips::LL64_R6 : Mips::LL_R6)
1524
+ : (ArePtrs64bit ? Mips::LL64 : Mips::LL);
1525
+ SC = Subtarget.hasMips32r6 () ? (ArePtrs64bit ? Mips::SC64_R6 : Mips::SC_R6)
1526
+ : (ArePtrs64bit ? Mips::SC64 : Mips::SC);
1527
+ }
1498
1528
1499
1529
// insert new blocks after the current block
1500
1530
const BasicBlock *LLVM_BB = BB->getBasicBlock ();
@@ -1568,7 +1598,6 @@ MipsTargetLowering::emitAtomicCmpSwapPartword(MachineInstr *MI,
1568
1598
// and maskedoldval0,oldval,mask
1569
1599
// bne maskedoldval0,shiftedcmpval,sinkMBB
1570
1600
BB = loop1MBB;
1571
- unsigned LL = isMicroMips ? Mips::LL_MM : Mips::LL;
1572
1601
BuildMI (BB, DL, TII->get (LL), OldVal).addReg (AlignedAddr).addImm (0 );
1573
1602
BuildMI (BB, DL, TII->get (Mips::AND), MaskedOldVal0)
1574
1603
.addReg (OldVal).addReg (Mask);
@@ -1585,7 +1614,6 @@ MipsTargetLowering::emitAtomicCmpSwapPartword(MachineInstr *MI,
1585
1614
.addReg (OldVal).addReg (Mask2);
1586
1615
BuildMI (BB, DL, TII->get (Mips::OR), StoreVal)
1587
1616
.addReg (MaskedOldVal1).addReg (ShiftedNewVal);
1588
- unsigned SC = isMicroMips ? Mips::SC_MM : Mips::SC;
1589
1617
BuildMI (BB, DL, TII->get (SC), Success)
1590
1618
.addReg (StoreVal).addReg (AlignedAddr).addImm (0 );
1591
1619
BuildMI (BB, DL, TII->get (Mips::BEQ))
0 commit comments