[AMDGPU] Define and use names for export targets. NFC.

Differential Revision: https://reviews.llvm.org/D91289
This commit is contained in:
Jay Foad 2020-11-11 19:21:02 +00:00
parent 2d96859ea6
commit d7d6ac5624
6 changed files with 38 additions and 20 deletions

View File

@ -33,7 +33,7 @@ static bool isExport(const SUnit &SU) {
static bool isPositionExport(const SIInstrInfo *TII, SUnit *SU) {
const MachineInstr *MI = SU->getInstr();
int Imm = TII->getNamedOperand(*MI, AMDGPU::OpName::tgt)->getImm();
return Imm >= 12 && Imm <= 15;
return Imm >= AMDGPU::Exp::ET_POS0 && Imm <= AMDGPU::Exp::ET_POS3;
}
static void sortChain(const SIInstrInfo *TII, SmallVector<SUnit *, 8> &Chain,

View File

@ -5840,21 +5840,21 @@ OperandMatchResultTy AMDGPUAsmParser::parseInterpAttr(OperandVector &Operands) {
OperandMatchResultTy AMDGPUAsmParser::parseExpTgtImpl(StringRef Str,
uint8_t &Val) {
if (Str == "null") {
Val = 9;
Val = Exp::ET_NULL;
return MatchOperand_Success;
}
if (Str.startswith("mrt")) {
Str = Str.drop_front(3);
if (Str == "z") { // == mrtz
Val = 8;
Val = Exp::ET_MRTZ;
return MatchOperand_Success;
}
if (Str.getAsInteger(10, Val))
return MatchOperand_ParseFail;
if (Val > 7)
if (Val > Exp::ET_MRT7)
return MatchOperand_ParseFail;
return MatchOperand_Success;
@ -5865,15 +5865,15 @@ OperandMatchResultTy AMDGPUAsmParser::parseExpTgtImpl(StringRef Str,
if (Str.getAsInteger(10, Val))
return MatchOperand_ParseFail;
if (Val > 4 || (Val == 4 && !isGFX10()))
if (Val > (isGFX10() ? 4 : 3))
return MatchOperand_ParseFail;
Val += 12;
Val += Exp::ET_POS0;
return MatchOperand_Success;
}
if (isGFX10() && Str == "prim") {
Val = 20;
Val = Exp::ET_PRIM;
return MatchOperand_Success;
}
@ -5885,7 +5885,7 @@ OperandMatchResultTy AMDGPUAsmParser::parseExpTgtImpl(StringRef Str,
if (Val >= 32)
return MatchOperand_ParseFail;
Val += 32;
Val += Exp::ET_PARAM0;
return MatchOperand_Success;
}

View File

@ -1016,18 +1016,19 @@ void AMDGPUInstPrinter::printExpTgt(const MCInst *MI, unsigned OpNo,
// This is really a 6 bit field.
uint32_t Tgt = MI->getOperand(OpNo).getImm() & ((1 << 6) - 1);
if (Tgt <= 7)
O << " mrt" << Tgt;
else if (Tgt == 8)
if (Tgt <= Exp::ET_MRT7)
O << " mrt" << Tgt - Exp::ET_MRT0;
else if (Tgt == Exp::ET_MRTZ)
O << " mrtz";
else if (Tgt == 9)
else if (Tgt == Exp::ET_NULL)
O << " null";
else if ((Tgt >= 12 && Tgt <= 15) || (Tgt == 16 && AMDGPU::isGFX10(STI)))
O << " pos" << Tgt - 12;
else if (AMDGPU::isGFX10(STI) && Tgt == 20)
else if (Tgt >= Exp::ET_POS0 &&
Tgt <= (isGFX10(STI) ? Exp::ET_POS4 : Exp::ET_POS3))
O << " pos" << Tgt - Exp::ET_POS0;
else if (isGFX10(STI) && Tgt == Exp::ET_PRIM)
O << " prim";
else if (Tgt >= 32 && Tgt <= 63)
O << " param" << Tgt - 32;
else if (Tgt >= Exp::ET_PARAM0 && Tgt <= Exp::ET_PARAM31)
O << " param" << Tgt - Exp::ET_PARAM0;
else {
// Reserved values 10, 11
O << " invalid_target_" << Tgt;

View File

@ -688,6 +688,23 @@ enum DppFiMode {
};
} // namespace DPP
namespace Exp {
enum Target {
ET_MRT0 = 0,
ET_MRT7 = 7,
ET_MRTZ = 8,
ET_NULL = 9,
ET_POS0 = 12,
ET_POS3 = 15,
ET_POS4 = 16, // GFX10+
ET_PRIM = 20, // GFX10+
ET_PARAM0 = 32,
ET_PARAM31 = 63,
};
} // namespace Exp
} // namespace AMDGPU
#define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028

View File

@ -170,7 +170,7 @@ static void generatePsEndPgm(MachineBasicBlock &MBB,
const SIInstrInfo *TII) {
// Generate "null export; s_endpgm".
BuildMI(MBB, I, DL, TII->get(AMDGPU::EXP_DONE))
.addImm(0x09) // V_008DFC_SQ_EXP_NULL
.addImm(AMDGPU::Exp::ET_NULL)
.addReg(AMDGPU::VGPR0, RegState::Undef)
.addReg(AMDGPU::VGPR0, RegState::Undef)
.addReg(AMDGPU::VGPR0, RegState::Undef)

View File

@ -1325,9 +1325,9 @@ void SIInsertWaitcnts::updateEventWaitcntAfter(MachineInstr &Inst,
}
} else if (SIInstrInfo::isEXP(Inst)) {
int Imm = TII->getNamedOperand(Inst, AMDGPU::OpName::tgt)->getImm();
if (Imm >= 32 && Imm <= 63)
if (Imm >= AMDGPU::Exp::ET_PARAM0 && Imm <= AMDGPU::Exp::ET_PARAM31)
ScoreBrackets->updateByEvent(TII, TRI, MRI, EXP_PARAM_ACCESS, Inst);
else if (Imm >= 12 && Imm <= 15)
else if (Imm >= AMDGPU::Exp::ET_POS0 && Imm <= AMDGPU::Exp::ET_POS3)
ScoreBrackets->updateByEvent(TII, TRI, MRI, EXP_POS_ACCESS, Inst);
else
ScoreBrackets->updateByEvent(TII, TRI, MRI, EXP_GPR_LOCK, Inst);