54 case R600::INTERP_PAIR_XY:
55 case R600::INTERP_PAIR_ZW:
56 case R600::INTERP_VEC_LOAD:
74 unsigned NumLiteral = 0;
79 if (MO.
isReg() && MO.
getReg() == R600::ALU_LITERAL_X)
82 return 1 + NumLiteral;
92 case R600::INTERP_PAIR_XY:
93 case R600::INTERP_PAIR_ZW:
94 case R600::INTERP_VEC_LOAD:
107 case R600::IMPLICIT_DEF:
114 std::pair<unsigned, unsigned> getAccessedBankLine(
unsigned Sel)
const {
118 return std::pair<unsigned, unsigned>(
119 ((Sel >> 2) - 512) >> 12,
125 ((((Sel >> 2) - 512) & 4095) >> 5) << 1);
130 std::vector<std::pair<unsigned, unsigned>> &CachedConsts,
131 bool UpdateInstr =
true)
const {
132 std::vector<std::pair<unsigned, unsigned>> UsedKCache;
141 "Can't assign Const");
142 for (
unsigned i = 0, n = Consts.
size(); i < n; ++i) {
143 if (Consts[i].
first->getReg() != R600::ALU_CONST)
145 unsigned Sel = Consts[i].second;
146 unsigned Chan = Sel & 3,
Index = ((Sel >> 2) - 512) & 31;
147 unsigned KCacheIndex = Index * 4 + Chan;
148 const std::pair<unsigned, unsigned> &BankLine = getAccessedBankLine(Sel);
149 if (CachedConsts.empty()) {
150 CachedConsts.push_back(BankLine);
151 UsedKCache.push_back(std::pair<unsigned, unsigned>(0, KCacheIndex));
154 if (CachedConsts[0] == BankLine) {
155 UsedKCache.push_back(std::pair<unsigned, unsigned>(0, KCacheIndex));
158 if (CachedConsts.size() == 1) {
159 CachedConsts.push_back(BankLine);
160 UsedKCache.push_back(std::pair<unsigned, unsigned>(1, KCacheIndex));
163 if (CachedConsts[1] == BankLine) {
164 UsedKCache.push_back(std::pair<unsigned, unsigned>(1, KCacheIndex));
173 for (
unsigned i = 0, j = 0, n = Consts.
size(); i < n; ++i) {
174 if (Consts[i].
first->getReg() != R600::ALU_CONST)
176 switch(UsedKCache[j].
first) {
178 Consts[i].first->setReg(
179 R600::R600_KC0RegClass.getRegister(UsedKCache[j].
second));
182 Consts[i].first->setReg(
183 R600::R600_KC1RegClass.getRegister(UsedKCache[j].second));
193 bool canClauseLocalKillFitInClause(
194 unsigned AluInstCount,
195 std::vector<std::pair<unsigned, unsigned>> KCacheBanks,
201 MOI = Def->operands_begin(),
202 MOE = Def->operands_end(); MOI != MOE; ++MOI) {
203 if (!MOI->isReg() || !MOI->isDef() ||
209 unsigned LastUseCount = 0;
211 AluInstCount += OccupiedDwords(*UseI);
213 if (!SubstituteKCacheBank(*UseI, KCacheBanks,
false))
228 if (UseI->readsRegister(MOI->getReg(), &
TRI))
229 LastUseCount = AluInstCount;
232 if (UseI != Def && UseI->killsRegister(MOI->getReg(), &
TRI))
245 std::vector<std::pair<unsigned, unsigned>> KCacheBanks;
246 bool PushBeforeModifier =
false;
247 unsigned AluInstCount = 0;
249 if (IsTrivialInst(*I))
255 if (I->getOpcode() == R600::PRED_X) {
262 if (AluInstCount > 0)
265 PushBeforeModifier =
true;
283 if (!canClauseLocalKillFitInClause(AluInstCount, KCacheBanks, I,
E))
286 if (!SubstituteKCacheBank(*I, KCacheBanks))
288 AluInstCount += OccupiedDwords(*I);
290 unsigned Opcode = PushBeforeModifier ?
291 R600::CF_ALU_PUSH_BEFORE : R600::CF_ALU;
298 .
addImm(KCacheBanks.empty()?0:KCacheBanks[0].first)
299 .addImm((KCacheBanks.size() < 2)?0:KCacheBanks[1].first)
300 .
addImm(KCacheBanks.empty()?0:2)
301 .addImm((KCacheBanks.size() < 2)?0:2)
302 .
addImm(KCacheBanks.empty()?0:KCacheBanks[0].second)
303 .addImm((KCacheBanks.size() < 2)?0:KCacheBanks[1].
second)
324 if (I != MBB.
end() && I->getOpcode() == R600::CF_ALU)
328 auto next = MakeALUClause(MBB, I);
339 return "R600 Emit Clause Markers Pass";
348 "R600 Emit Clause Markters",
false,
false)
353 return new R600EmitClauseMarkers();
mop_iterator operands_end()
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
Interface definition for R600InstrInfo.
void initializeR600EmitClauseMarkersPass(PassRegistry &)
unsigned const TargetRegisterInfo * TRI
Interface definition for R600RegisterInfo.
R600 Emit Clause Markters
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
INITIALIZE_PASS_BEGIN(R600EmitClauseMarkers, "emitclausemarkers", "R600 Emit Clause Markters", false, false) INITIALIZE_PASS_END(R600EmitClauseMarkers
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
MachineOperand & getFlagOp(MachineInstr &MI, unsigned SrcIdx=0, unsigned Flag=0) const
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
unsigned getMaxAlusPerClause() const
bool mustBeLastInClause(unsigned Opcode) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions...
const R600InstrInfo * getInstrInfo() const override
FunctionPass class - This class is used to implement most global optimizations.
const R600RegisterInfo & getRegisterInfo() const
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isVector(const MachineInstr &MI) const
Vector instructions are instructions that must fill all instruction slots within an instruction group...
Iterator for intrusive lists based on ilist_node.
bool isPhysRegLiveAcrossClauses(unsigned Reg) const
MachineOperand class - Representation of each machine instruction operand.
FunctionPass * createR600EmitClauseMarkers()
bool isALUInstr(unsigned Opcode) const
bool isLDSRetInstr(unsigned Opcode) const
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool isReductionOp(unsigned opcode) const
SmallVector< std::pair< MachineOperand *, int64_t >, 3 > getSrcs(MachineInstr &MI) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
mop_iterator operands_begin()
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Register getReg() const
getReg - Returns the register number.
bool isCubeOp(unsigned opcode) const