mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 01:07:04 +08:00
[AMDGPU] SIInsertHardClauses: move more stuff into the class. NFC.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user