Skip to content

Commit 7a3bc44

Browse files
authored
[AMDGPU][MC][NFCI] Eliminate printU4ImmDecOperand(). (#100589)
This is hoped to make things a bit safer not masking the value to print and to make the logic in printDPPCtrl() a bit more explicit. Part of <#62629>.
1 parent 63e1647 commit 7a3bc44

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ void AMDGPUInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
6565
printU32ImmOperand(MI, OpNo, STI, O);
6666
}
6767

68-
void AMDGPUInstPrinter::printU4ImmDecOperand(const MCInst *MI, unsigned OpNo,
69-
raw_ostream &O) {
70-
O << formatDec(MI->getOperand(OpNo).getImm() & 0xf);
71-
}
72-
7368
void AMDGPUInstPrinter::printU16ImmDecOperand(const MCInst *MI, unsigned OpNo,
7469
raw_ostream &O) {
7570
O << formatDec(MI->getOperand(OpNo).getImm() & 0xffff);
@@ -719,29 +714,25 @@ void AMDGPUInstPrinter::printDefaultVccOperand(bool FirstOperand,
719714
void AMDGPUInstPrinter::printWaitVDST(const MCInst *MI, unsigned OpNo,
720715
const MCSubtargetInfo &STI,
721716
raw_ostream &O) {
722-
O << " wait_vdst:";
723-
printU4ImmDecOperand(MI, OpNo, O);
717+
O << " wait_vdst:" << formatDec(MI->getOperand(OpNo).getImm());
724718
}
725719

726720
void AMDGPUInstPrinter::printWaitVAVDst(const MCInst *MI, unsigned OpNo,
727721
const MCSubtargetInfo &STI,
728722
raw_ostream &O) {
729-
O << " wait_va_vdst:";
730-
printU4ImmDecOperand(MI, OpNo, O);
723+
O << " wait_va_vdst:" << formatDec(MI->getOperand(OpNo).getImm());
731724
}
732725

733726
void AMDGPUInstPrinter::printWaitVMVSrc(const MCInst *MI, unsigned OpNo,
734727
const MCSubtargetInfo &STI,
735728
raw_ostream &O) {
736-
O << " wait_vm_vsrc:";
737-
printU4ImmDecOperand(MI, OpNo, O);
729+
O << " wait_vm_vsrc:" << formatDec(MI->getOperand(OpNo).getImm());
738730
}
739731

740732
void AMDGPUInstPrinter::printWaitEXP(const MCInst *MI, unsigned OpNo,
741733
const MCSubtargetInfo &STI,
742734
raw_ostream &O) {
743-
O << " wait_exp:";
744-
printU4ImmDecOperand(MI, OpNo, O);
735+
O << " wait_exp:" << formatDec(MI->getOperand(OpNo).getImm());
745736
}
746737

747738
bool AMDGPUInstPrinter::needsImpliedVcc(const MCInstrDesc &Desc,
@@ -1065,16 +1056,13 @@ void AMDGPUInstPrinter::printDPPCtrl(const MCInst *MI, unsigned OpNo,
10651056
O << formatDec((Imm & 0xc0) >> 6) << ']';
10661057
} else if ((Imm >= DppCtrl::ROW_SHL_FIRST) &&
10671058
(Imm <= DppCtrl::ROW_SHL_LAST)) {
1068-
O << "row_shl:";
1069-
printU4ImmDecOperand(MI, OpNo, O);
1059+
O << "row_shl:" << formatDec(Imm - DppCtrl::ROW_SHL0);
10701060
} else if ((Imm >= DppCtrl::ROW_SHR_FIRST) &&
10711061
(Imm <= DppCtrl::ROW_SHR_LAST)) {
1072-
O << "row_shr:";
1073-
printU4ImmDecOperand(MI, OpNo, O);
1062+
O << "row_shr:" << formatDec(Imm - DppCtrl::ROW_SHR0);
10741063
} else if ((Imm >= DppCtrl::ROW_ROR_FIRST) &&
10751064
(Imm <= DppCtrl::ROW_ROR_LAST)) {
1076-
O << "row_ror:";
1077-
printU4ImmDecOperand(MI, OpNo, O);
1065+
O << "row_ror:" << formatDec(Imm - DppCtrl::ROW_ROR0);
10781066
} else if (Imm == DppCtrl::WAVE_SHL1) {
10791067
if (AMDGPU::isGFX10Plus(STI)) {
10801068
O << "/* wave_shl is not supported starting from GFX10 */";
@@ -1126,15 +1114,14 @@ void AMDGPUInstPrinter::printDPPCtrl(const MCInst *MI, unsigned OpNo,
11261114
"than GFX90A/GFX10 */";
11271115
return;
11281116
}
1129-
printU4ImmDecOperand(MI, OpNo, O);
1117+
O << formatDec(Imm - DppCtrl::ROW_SHARE_FIRST);
11301118
} else if ((Imm >= DppCtrl::ROW_XMASK_FIRST) &&
11311119
(Imm <= DppCtrl::ROW_XMASK_LAST)) {
11321120
if (!AMDGPU::isGFX10Plus(STI)) {
11331121
O << "/* row_xmask is not supported on ASICs earlier than GFX10 */";
11341122
return;
11351123
}
1136-
O << "row_xmask:";
1137-
printU4ImmDecOperand(MI, OpNo, O);
1124+
O << "row_xmask:" << formatDec(Imm - DppCtrl::ROW_XMASK_FIRST);
11381125
} else {
11391126
O << "/* Invalid dpp_ctrl value */";
11401127
}

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class AMDGPUInstPrinter : public MCInstPrinter {
3838
private:
3939
void printU16ImmOperand(const MCInst *MI, unsigned OpNo,
4040
const MCSubtargetInfo &STI, raw_ostream &O);
41-
void printU4ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
4241
void printU16ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
4342
void printU32ImmOperand(const MCInst *MI, unsigned OpNo,
4443
const MCSubtargetInfo &STI, raw_ostream &O);

0 commit comments

Comments
 (0)