[AMDGPU] SIInsertHardClauses: move more stuff into the class. NFC.

This commit is contained in:
Jay Foad
2021-05-06 14:47:43 +01:00
parent ed87f512bb
commit 9e026273b0

View File

@@ -63,30 +63,10 @@ enum HardClauseType {
HARDCLAUSE_ILLEGAL,
};
HardClauseType getHardClauseType(const MachineInstr &MI) {
// On current architectures we only get a benefit from clausing loads.
if (MI.mayLoad()) {
if (SIInstrInfo::isVMEM(MI) || SIInstrInfo::isSegmentSpecificFLAT(MI))
return HARDCLAUSE_VMEM;
if (SIInstrInfo::isFLAT(MI))
return HARDCLAUSE_FLAT;
// TODO: LDS
if (SIInstrInfo::isSMRD(MI))
return HARDCLAUSE_SMEM;
}
// Don't form VALU clauses. It's not clear what benefit they give, if any.
// In practice s_nop is the only internal instruction we're likely to see.
// It's safe to treat the rest as illegal.
if (MI.getOpcode() == AMDGPU::S_NOP)
return HARDCLAUSE_INTERNAL;
return HARDCLAUSE_ILLEGAL;
}
class SIInsertHardClauses : public MachineFunctionPass {
public:
static char ID;
const GCNSubtarget *ST = nullptr;
SIInsertHardClauses() : MachineFunctionPass(ID) {}
@@ -95,6 +75,27 @@ public:
MachineFunctionPass::getAnalysisUsage(AU);
}
HardClauseType getHardClauseType(const MachineInstr &MI) {
// On current architectures we only get a benefit from clausing loads.
if (MI.mayLoad()) {
if (SIInstrInfo::isVMEM(MI) || SIInstrInfo::isSegmentSpecificFLAT(MI))
return HARDCLAUSE_VMEM;
if (SIInstrInfo::isFLAT(MI))
return HARDCLAUSE_FLAT;
// TODO: LDS
if (SIInstrInfo::isSMRD(MI))
return HARDCLAUSE_SMEM;
}
// Don't form VALU clauses. It's not clear what benefit they give, if any.
// In practice s_nop is the only internal instruction we're likely to see.
// It's safe to treat the rest as illegal.
if (MI.getOpcode() == AMDGPU::S_NOP)
return HARDCLAUSE_INTERNAL;
return HARDCLAUSE_ILLEGAL;
}
// Track information about a clause as we discover it.
struct ClauseInfo {
// The type of all (non-internal) instructions in the clause.
@@ -132,12 +133,12 @@ public:
if (skipFunction(MF.getFunction()))
return false;
const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
if (!ST.hasHardClauses())
ST = &MF.getSubtarget<GCNSubtarget>();
if (!ST->hasHardClauses())
return false;
const SIInstrInfo *SII = ST.getInstrInfo();
const TargetRegisterInfo *TRI = ST.getRegisterInfo();
const SIInstrInfo *SII = ST->getInstrInfo();
const TargetRegisterInfo *TRI = ST->getRegisterInfo();
bool Changed = false;
for (auto &MBB : MF) {