Skip to content

Commit 815e048

Browse files
authored
[AMDGPU][MC] Fix printing vcc(_lo) twice for VOPC DPP instrucitons (#81158)
1 parent a3dcc7a commit 815e048

File tree

6 files changed

+116
-79
lines changed

6 files changed

+116
-79
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ bool AMDGPUInstPrinter::needsImpliedVcc(const MCInstrDesc &Desc,
709709
unsigned OpNo) const {
710710
return OpNo == 0 && (Desc.TSFlags & SIInstrFlags::DPP) &&
711711
(Desc.TSFlags & SIInstrFlags::VOPC) &&
712+
!isVOPCAsmOnly(Desc.getOpcode()) &&
712713
(Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
713714
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO));
714715
}
@@ -725,7 +726,7 @@ void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
725726
// printOperandAndIntInputMods will be called instead
726727
if ((OpNo == 0 ||
727728
(OpNo == 1 && (Desc.TSFlags & SIInstrFlags::DPP) && ModIdx != -1)) &&
728-
(Desc.TSFlags & SIInstrFlags::VOPC) &&
729+
(Desc.TSFlags & SIInstrFlags::VOPC) && !isVOPCAsmOnly(Desc.getOpcode()) &&
729730
(Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC) ||
730731
Desc.hasImplicitDefOfPhysReg(AMDGPU::VCC_LO)))
731732
printDefaultVccOperand(true, STI, O);

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ struct VOPC64DPPInfo {
342342
uint16_t Opcode;
343343
};
344344

345+
struct VOPCDPPAsmOnlyInfo {
346+
uint16_t Opcode;
347+
};
348+
349+
struct VOP3CDPPAsmOnlyInfo {
350+
uint16_t Opcode;
351+
};
352+
345353
struct VOPDComponentInfo {
346354
uint16_t BaseVOP;
347355
uint16_t VOPDOp;
@@ -376,6 +384,10 @@ struct VOPTrue16Info {
376384
#define GET_VOPC64DPPTable_IMPL
377385
#define GET_VOPC64DPP8Table_DECL
378386
#define GET_VOPC64DPP8Table_IMPL
387+
#define GET_VOPCAsmOnlyInfoTable_DECL
388+
#define GET_VOPCAsmOnlyInfoTable_IMPL
389+
#define GET_VOP3CAsmOnlyInfoTable_DECL
390+
#define GET_VOP3CAsmOnlyInfoTable_IMPL
379391
#define GET_VOPDComponentTable_DECL
380392
#define GET_VOPDComponentTable_IMPL
381393
#define GET_VOPDPairs_DECL
@@ -477,6 +489,10 @@ bool isVOPC64DPP(unsigned Opc) {
477489
return isVOPC64DPPOpcodeHelper(Opc) || isVOPC64DPP8OpcodeHelper(Opc);
478490
}
479491

492+
bool isVOPCAsmOnly(unsigned Opc) {
493+
return isVOPCAsmOnlyOpcodeHelper(Opc) || isVOP3CAsmOnlyOpcodeHelper(Opc);
494+
}
495+
480496
bool getMAIIsDGEMM(unsigned Opc) {
481497
const MAIInstInfo *Info = getMAIInstInfoHelper(Opc);
482498
return Info ? Info->is_dgemm : false;

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ bool getVOP3IsSingle(unsigned Opc);
500500
LLVM_READONLY
501501
bool isVOPC64DPP(unsigned Opc);
502502

503+
LLVM_READONLY
504+
bool isVOPCAsmOnly(unsigned Opc);
505+
503506
/// Returns true if MAI operation is a double precision GEMM.
504507
LLVM_READONLY
505508
bool getMAIIsDGEMM(unsigned Opc);

llvm/lib/Target/AMDGPU/VOPCInstructions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,8 @@ class VOPC_DPPe_Common<bits<8> op> : Enc64 {
11651165
class VOPC_DPP_Base<bits<8> op, string OpName, VOPProfile P>
11661166
: VOP_DPP_Base<OpName, P, P.InsDPP16, " " #P.AsmDPP16>,
11671167
VOPC_DPPe_Common<op> {
1168+
Instruction Opcode = !cast<Instruction>(NAME);
1169+
11681170
bits<2> src0_modifiers;
11691171
bits<8> src0;
11701172
bits<2> src1_modifiers;
@@ -1194,6 +1196,8 @@ class VOPC_DPP_Base<bits<8> op, string OpName, VOPProfile P>
11941196
class VOPC_DPP8_Base<bits<8> op, string OpName, VOPProfile P>
11951197
: VOP_DPP8_Base<OpName, P, P.InsDPP8, " " #P.AsmDPP8>,
11961198
VOPC_DPPe_Common<op> {
1199+
Instruction Opcode = !cast<Instruction>(NAME);
1200+
11971201
bits<8> src0;
11981202
bits<24> dpp8;
11991203
bits<9> fi;

llvm/lib/Target/AMDGPU/VOPInstructions.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,19 @@ class VOPC64Table <string Format> : GenericTable {
16691669
def VOPC64DPPTable : VOPC64Table<"DPP">;
16701670
def VOPC64DPP8Table : VOPC64Table<"DPP8">;
16711671

1672+
class AsmOnlyInfoTable <string Format, string Class>: GenericTable {
1673+
let FilterClass = Class;
1674+
let FilterClassField = "isAsmParserOnly";
1675+
let CppTypeName = Format # "DPPAsmOnlyInfo";
1676+
let Fields = ["Opcode"];
1677+
1678+
let PrimaryKey = ["Opcode"];
1679+
let PrimaryKeyName = "is" # Format # "AsmOnlyOpcodeHelper";
1680+
}
1681+
1682+
def VOPCAsmOnlyInfoTable : AsmOnlyInfoTable <"VOPC", "VOPC_DPPe_Common">;
1683+
def VOP3CAsmOnlyInfoTable : AsmOnlyInfoTable <"VOP3C", "VOP3_DPPe_Common_Base">;
1684+
16721685
def VOPTrue16Table : GenericTable {
16731686
let FilterClass = "VOP_Pseudo";
16741687
let CppTypeName = "VOPTrue16Info";

0 commit comments

Comments
 (0)