31 #define DEBUG_TYPE "packets" 50 StringRef getPassName()
const override {
return "R600 Packetizer"; }
60 bool ConsideredInstUsesAlreadyWrittenVectorElement;
72 if (!TII->
isALUInstr(I->getOpcode()) && !I->isBundle())
80 int BISlot = getSlot(*BI);
81 if (LastDstChan >= BISlot)
87 if (OperandIdx > -1 && BI->getOperand(OperandIdx).getImm() == 0)
89 int DstIdx = TII->
getOperandIdx(BI->getOpcode(), R600::OpName::dst);
93 Register Dst = BI->getOperand(DstIdx).getReg();
95 Result[Dst] = R600::PS;
98 if (BI->getOpcode() == R600::DOT4_r600 ||
99 BI->getOpcode() == R600::DOT4_eg) {
100 Result[Dst] = R600::PV_X;
103 if (Dst == R600::OQAP) {
124 }
while ((++BI)->isBundledWithPred());
135 for (
unsigned i = 0; i < 3; i++) {
156 void initPacketizerState()
override {
157 ConsideredInstUsesAlreadyWrittenVectorElement =
false;
168 bool isSoloInstruction(
const MachineInstr &MI)
override {
173 if (MI.
getOpcode() == R600::GROUP_BARRIER)
182 bool isLegalToPacketizeTogether(
SUnit *SUI,
SUnit *SUJ)
override {
184 if (getSlot(*MII) == getSlot(*MIJ))
185 ConsideredInstUsesAlreadyWrittenVectorElement =
true;
188 OpJ = TII->
getOperandIdx(MIJ->getOpcode(), R600::OpName::pred_sel);
190 PredJ = (OpJ > -1)?MIJ->getOperand(OpJ).getReg() :
Register();
194 for (
unsigned i = 0,
e = SUJ->
Succs.size(); i <
e; ++i) {
212 return !ARDef || !ARUse;
217 bool isLegalToPruneDependencies(
SUnit *SUI,
SUnit *SUJ)
override {
228 std::vector<R600InstrInfo::BankSwizzle> &BS,
231 assert (!isTransSlot || VLIW5);
234 if (!isTransSlot && !CurrentPacketMIs.empty()) {
235 if (getSlot(MI) <= getSlot(*CurrentPacketMIs.back())) {
236 if (ConsideredInstUsesAlreadyWrittenVectorElement &&
240 dbgs() <<
"Considering as Trans Inst :";
250 CurrentPacketMIs.push_back(&MI);
253 dbgs() <<
"Couldn't pack :\n";
255 dbgs() <<
"with the following packets :\n";
256 for (
unsigned i = 0,
e = CurrentPacketMIs.size() - 1; i <
e; i++) {
257 CurrentPacketMIs[i]->dump();
260 dbgs() <<
"because of Consts read limitations\n";
262 CurrentPacketMIs.pop_back();
268 PV, BS, isTransSlot)) {
270 dbgs() <<
"Couldn't pack :\n";
272 dbgs() <<
"with the following packets :\n";
273 for (
unsigned i = 0,
e = CurrentPacketMIs.size() - 1; i <
e; i++) {
274 CurrentPacketMIs[i]->dump();
277 dbgs() <<
"because of Read port limitations\n";
279 CurrentPacketMIs.pop_back();
287 CurrentPacketMIs.pop_back();
293 CurrentPacketMIs.empty() ? &
MI : CurrentPacketMIs.front();
295 getPreviousVector(FirstInBundle);
296 std::vector<R600InstrInfo::BankSwizzle> BS;
299 if (isBundlableWithCurrentPMI(MI, PV, BS, isTransSlot)) {
300 for (
unsigned i = 0,
e = CurrentPacketMIs.size(); i <
e; i++) {
303 R600::OpName::bank_swizzle);
309 if (!CurrentPacketMIs.empty())
310 setIsLastBit(CurrentPacketMIs.back(), 0);
311 substitutePV(MI, PV);
314 endPacket(std::next(It)->
getParent(), std::next(It));
335 assert(Packetizer.getResourceTracker() &&
"Empty DFA table!");
336 assert(Packetizer.getResourceTracker()->getInstrItins());
338 if (Packetizer.getResourceTracker()->getInstrItins()->isEmpty())
352 MBB != MBBe; ++MBB) {
356 if (MI->isKill() || MI->getOpcode() == R600::IMPLICIT_DEF ||
357 (MI->getOpcode() == R600::CF_ALU && !MI->getOperand(8).getImm())) {
360 MBB->erase(DeleteMI);
370 MBB != MBBe; ++MBB) {
372 unsigned RemainingCount = MBB->size();
374 RegionEnd != MBB->begin();) {
378 for(;I != MBB->begin(); --
I, --RemainingCount) {
379 if (TII->isSchedulingBoundary(*std::prev(I), &*MBB, Fn))
385 if (I == RegionEnd) {
386 RegionEnd = std::prev(RegionEnd);
391 if (I == std::prev(RegionEnd)) {
392 RegionEnd = std::prev(RegionEnd);
396 Packetizer.PacketizeMIs(&*MBB, &*I, RegionEnd);
408 "R600 Packetizer",
false,
false)
412 char R600Packetizer::
ID = 0;
417 return new R600Packetizer();
bool usesAddressRegister(MachineInstr &MI) const
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
Interface definition for R600InstrInfo.
bool isPredicated(const MachineInstr &MI) const override
unsigned const TargetRegisterInfo * TRI
A register anti-dependence (aka WAR).
AnalysisUsage & addRequired()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
A register output-dependence (aka WAW).
virtual MachineBasicBlock::iterator addToPacket(MachineInstr &MI)
instr_iterator getInstrIterator() const
void setReg(Register Reg)
Change the register this operand corresponds to.
iterator find(const_arg_type_t< KeyT > Val)
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
const R600InstrInfo * getInstrInfo() const override
bool isLDSInstr(unsigned Opcode) const
void setImm(int64_t immVal)
FunctionPass class - This class is used to implement most global optimizations.
int getOperandIdx(const MachineInstr &MI, unsigned Op) const
Get the index of Op in the MachineInstr.
const R600RegisterInfo & getRegisterInfo() const
bool isVectorOnly(unsigned Opcode) const
static void write(bool isBE, void *P, T V)
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 fitsConstReadLimitations(const std::vector< MachineInstr *> &) const
An instruction group can only access 2 channel pair (either [XY] or [ZW]) from KCache bank on R700+...
bool isTransOnly(unsigned Opcode) const
INITIALIZE_PASS_BEGIN(R600Packetizer, DEBUG_TYPE, "R600 Packetizer", false, false) INITIALIZE_PASS_END(R600Packetizer
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.
Promote Memory to Register
bool hasCaymanISA() const
void setPreservesCFG()
This function should be called by the pass, iff they do not:
unsigned getHWRegChan(unsigned reg) const
get the HW encoding for a register's channel.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isALUInstr(unsigned Opcode) const
bool readsLDSSrcReg(const MachineInstr &MI) const
FunctionPass * createR600Packetizer()
const MachineBasicBlock * getParent() const
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
bool fitsReadPortLimitations(const std::vector< MachineInstr *> &MIs, const DenseMap< unsigned, unsigned > &PV, std::vector< BankSwizzle > &BS, bool isLastAluTrans) const
Given the order VEC_012 < VEC_021 < VEC_120 < VEC_102 < VEC_201 < VEC_210 returns true and the first ...
Kind getKind() const
Returns an enum value representing the kind of the dependence.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallVector< SDep, 4 > Succs
All sunit successors.
static const Function * getParent(const Value *V)
StringRef - Represent a constant reference to a string, i.e.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
bool isSucc(const SUnit *N) const
Tests if node N is a successor of this node.
bool definesAddressRegister(MachineInstr &MI) const
Scheduling unit. This is a node in the scheduling DAG.
Wrapper class representing virtual and physical registers.