@@ -1412,51 +1412,33 @@ static unsigned getSrcIdx(const MachineInstr* MI, unsigned SrcIdx) {
1412
1412
return SrcIdx;
1413
1413
}
1414
1414
1415
- static std::string getShuffleComment (const MachineInstr *MI, unsigned SrcOp1Idx,
1416
- unsigned SrcOp2Idx, ArrayRef<int > Mask) {
1417
- std::string Comment;
1418
-
1419
- // Compute the name for a register. This is really goofy because we have
1420
- // multiple instruction printers that could (in theory) use different
1421
- // names. Fortunately most people use the ATT style (outside of Windows)
1422
- // and they actually agree on register naming here. Ultimately, this is
1423
- // a comment, and so its OK if it isn't perfect.
1424
- auto GetRegisterName = [](MCRegister Reg) -> StringRef {
1425
- return X86ATTInstPrinter::getRegisterName (Reg);
1426
- };
1427
-
1415
+ static void printDstRegisterName (raw_ostream &CS, const MachineInstr *MI,
1416
+ unsigned SrcOpIdx) {
1428
1417
const MachineOperand &DstOp = MI->getOperand (0 );
1429
- const MachineOperand &SrcOp1 = MI->getOperand (SrcOp1Idx);
1430
- const MachineOperand &SrcOp2 = MI->getOperand (SrcOp2Idx);
1431
-
1432
- StringRef DstName = DstOp.isReg () ? GetRegisterName (DstOp.getReg ()) : " mem" ;
1433
- StringRef Src1Name =
1434
- SrcOp1.isReg () ? GetRegisterName (SrcOp1.getReg ()) : " mem" ;
1435
- StringRef Src2Name =
1436
- SrcOp2.isReg () ? GetRegisterName (SrcOp2.getReg ()) : " mem" ;
1437
-
1438
- // One source operand, fix the mask to print all elements in one span.
1439
- SmallVector<int , 8 > ShuffleMask (Mask);
1440
- if (Src1Name == Src2Name)
1441
- for (int i = 0 , e = ShuffleMask.size (); i != e; ++i)
1442
- if (ShuffleMask[i] >= e)
1443
- ShuffleMask[i] -= e;
1444
-
1445
- raw_string_ostream CS (Comment);
1446
- CS << DstName;
1418
+ CS << X86ATTInstPrinter::getRegisterName (DstOp.getReg ());
1447
1419
1448
1420
// Handle AVX512 MASK/MASXZ write mask comments.
1449
1421
// MASK: zmmX {%kY}
1450
1422
// MASKZ: zmmX {%kY} {z}
1451
1423
if (X86II::isKMasked (MI->getDesc ().TSFlags )) {
1452
- const MachineOperand &WriteMaskOp = MI->getOperand (SrcOp1Idx - 1 );
1453
- CS << " {%" << GetRegisterName (WriteMaskOp.getReg ()) << " }" ;
1424
+ const MachineOperand &WriteMaskOp = MI->getOperand (SrcOpIdx - 1 );
1425
+ CS << " {%" ;
1426
+ CS << X86ATTInstPrinter::getRegisterName (WriteMaskOp.getReg ());
1427
+ CS << " }" ;
1454
1428
if (!X86II::isKMergeMasked (MI->getDesc ().TSFlags )) {
1455
1429
CS << " {z}" ;
1456
1430
}
1457
1431
}
1432
+ }
1458
1433
1459
- CS << " = " ;
1434
+ static void printShuffleMask (raw_ostream &CS, StringRef Src1Name,
1435
+ StringRef Src2Name, ArrayRef<int > Mask) {
1436
+ // One source operand, fix the mask to print all elements in one span.
1437
+ SmallVector<int , 8 > ShuffleMask (Mask);
1438
+ if (Src1Name == Src2Name)
1439
+ for (int i = 0 , e = ShuffleMask.size (); i != e; ++i)
1440
+ if (ShuffleMask[i] >= e)
1441
+ ShuffleMask[i] -= e;
1460
1442
1461
1443
for (int i = 0 , e = ShuffleMask.size (); i != e; ++i) {
1462
1444
if (i != 0 )
@@ -1487,6 +1469,25 @@ static std::string getShuffleComment(const MachineInstr *MI, unsigned SrcOp1Idx,
1487
1469
CS << ' ]' ;
1488
1470
--i; // For loop increments element #.
1489
1471
}
1472
+ }
1473
+
1474
+ static std::string getShuffleComment (const MachineInstr *MI, unsigned SrcOp1Idx,
1475
+ unsigned SrcOp2Idx, ArrayRef<int > Mask) {
1476
+ std::string Comment;
1477
+
1478
+ const MachineOperand &SrcOp1 = MI->getOperand (SrcOp1Idx);
1479
+ const MachineOperand &SrcOp2 = MI->getOperand (SrcOp2Idx);
1480
+ StringRef Src1Name = SrcOp1.isReg ()
1481
+ ? X86ATTInstPrinter::getRegisterName (SrcOp1.getReg ())
1482
+ : " mem" ;
1483
+ StringRef Src2Name = SrcOp2.isReg ()
1484
+ ? X86ATTInstPrinter::getRegisterName (SrcOp2.getReg ())
1485
+ : " mem" ;
1486
+
1487
+ raw_string_ostream CS (Comment);
1488
+ printDstRegisterName (CS, MI, SrcOp1Idx);
1489
+ CS << " = " ;
1490
+ printShuffleMask (CS, Src1Name, Src2Name, Mask);
1490
1491
CS.flush ();
1491
1492
1492
1493
return Comment;
0 commit comments