22#define DEBUG_TYPE "r600mergeclause"
27 switch (
MI.getOpcode()) {
29 case R600::CF_ALU_PUSH_BEFORE:
48 void cleanPotentialDisabledCFAlu(
MachineInstr &CFAlu)
const;
68 "R600 Clause Merge",
false,
false)
72char R600ClauseMergePass::
ID = 0;
79 .getOperand(
TII->getOperandIdx(
MI.getOpcode(), R600::OpName::COUNT))
83bool R600ClauseMergePass::isCFAluEnabled(
const MachineInstr &
MI)
const {
86 .getOperand(
TII->getOperandIdx(
MI.getOpcode(), R600::OpName::Enabled))
90void R600ClauseMergePass::cleanPotentialDisabledCFAlu(
92 int CntIdx =
TII->getOperandIdx(R600::CF_ALU, R600::OpName::COUNT);
96 while (
I != E && !isCFAlu(*
I))
101 if (isCFAluEnabled(
MI))
104 MI.eraseFromParent();
108bool R600ClauseMergePass::mergeIfPossible(
MachineInstr &RootCFAlu,
110 assert(isCFAlu(RootCFAlu) && isCFAlu(LatrCFAlu));
111 int CntIdx =
TII->getOperandIdx(R600::CF_ALU, R600::OpName::COUNT);
112 unsigned RootInstCount = getCFAluSize(RootCFAlu),
113 LaterInstCount = getCFAluSize(LatrCFAlu);
114 unsigned CumuledInsts = RootInstCount + LaterInstCount;
115 if (CumuledInsts >=
TII->getMaxAlusPerClause()) {
119 if (RootCFAlu.
getOpcode() == R600::CF_ALU_PUSH_BEFORE)
123 TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_MODE0);
125 TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_BANK0);
127 TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_ADDR0);
139 TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_MODE1);
141 TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_BANK1);
143 TII->getOperandIdx(R600::CF_ALU, R600::OpName::KCACHE_ADDR1);
179 TII =
ST.getInstrInfo();
186 if ((!
TII->canBeConsideredALU(
MI) && !isCFAlu(
MI)) ||
187 TII->mustBeLastInClause(
MI.getOpcode()))
191 cleanPotentialDisabledCFAlu(
MI);
193 if (LatestCFAlu != E && mergeIfPossible(*LatestCFAlu,
MI)) {
194 MI.eraseFromParent();
196 assert(
MI.getOperand(8).getImm() &&
"CF ALU instruction disabled");
204StringRef R600ClauseMergePass::getPassName()
const {
205 return "R600 Merge Clause Markers Pass";
209 return new R600ClauseMergePass();
const HexagonInstrInfo * TII
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Provides R600 specific target descriptions.
AMDGPU R600 specific subclass of TargetSubtarget.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
const MachineOperand & getOperand(unsigned i) const
void setImm(int64_t immVal)
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
char & R600ClauseMergePassID
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createR600ClauseMergePass()