24 #define DEBUG_TYPE "pre-RA-sched" 26 bool PPCDispatchGroupSBHazardRecognizer::isLoadAfterStore(
SUnit *SU) {
28 if (isBCTRAfterSet(SU))
40 for (
unsigned i = 0, ie = (
unsigned) SU->
Preds.size(); i != ie; ++i) {
42 if (!PredMCID || !PredMCID->
mayStore())
45 if (!SU->
Preds[i].isNormalMemory() && !SU->
Preds[i].isBarrier())
48 for (
unsigned j = 0, je = CurGroup.size(); j != je; ++j)
49 if (SU->
Preds[i].getSUnit() == CurGroup[j])
56 bool PPCDispatchGroupSBHazardRecognizer::isBCTRAfterSet(
SUnit *SU) {
66 for (
unsigned i = 0, ie = (
unsigned) SU->
Preds.size(); i != ie; ++i) {
68 if (!PredMCID || PredMCID->
getSchedClass() != PPC::Sched::IIC_SprMTSPR)
71 if (SU->
Preds[i].isCtrl())
74 for (
unsigned j = 0, je = CurGroup.size(); j != je; ++j)
75 if (SU->
Preds[i].getSUnit() == CurGroup[j])
87 bool PPCDispatchGroupSBHazardRecognizer::mustComeFirst(
const MCInstrDesc *MCID,
97 case PPC::Sched::IIC_IntDivW:
98 case PPC::Sched::IIC_IntDivD:
99 case PPC::Sched::IIC_LdStLoadUpd:
100 case PPC::Sched::IIC_LdStLDU:
101 case PPC::Sched::IIC_LdStLFDU:
102 case PPC::Sched::IIC_LdStLFDUX:
103 case PPC::Sched::IIC_LdStLHA:
104 case PPC::Sched::IIC_LdStLHAU:
105 case PPC::Sched::IIC_LdStLWA:
106 case PPC::Sched::IIC_LdStSTU:
107 case PPC::Sched::IIC_LdStSTFDU:
110 case PPC::Sched::IIC_LdStLoadUpdX:
111 case PPC::Sched::IIC_LdStLDUX:
112 case PPC::Sched::IIC_LdStLHAUX:
113 case PPC::Sched::IIC_LdStLWARX:
114 case PPC::Sched::IIC_LdStLDARX:
115 case PPC::Sched::IIC_LdStSTUX:
116 case PPC::Sched::IIC_LdStSTDCX:
117 case PPC::Sched::IIC_LdStSTWCX:
118 case PPC::Sched::IIC_BrMCRX:
132 case PPC::Sched::IIC_BrCR:
133 case PPC::Sched::IIC_SprMFCR:
134 case PPC::Sched::IIC_SprMFCRF:
135 case PPC::Sched::IIC_SprMTSPR:
142 if (Stalls == 0 && isLoadAfterStore(SU))
151 if (MCID && mustComeFirst(MCID, NSlots) && CurSlots)
161 if (isLoadAfterStore(SU) && CurSlots < 6) {
163 DAG->MF.getSubtarget<
PPCSubtarget>().getDarwinDirective();
179 if (CurSlots == 5 || (MCID->
isBranch() && CurBranches == 1)) {
181 CurSlots = CurBranches = 0;
187 bool MustBeFirst = mustComeFirst(MCID, NSlots);
191 if (MustBeFirst && CurSlots) {
192 CurSlots = CurBranches = 0;
197 CurGroup.push_back(SU);
217 CurSlots = CurBranches = 0;
223 DAG->MF.getSubtarget<
PPCSubtarget>().getDarwinDirective();
231 CurSlots = CurBranches = 0;
233 CurGroup.push_back(
nullptr);
269 void PPCHazardRecognizer970::EndDispatchGroup() {
280 PPCHazardRecognizer970::GetInstrType(
unsigned Opcode,
281 bool &isFirst,
bool &isSingle,
289 uint64_t TSFlags = MCID.
TSFlags;
299 bool PPCHazardRecognizer970::
300 isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset,
301 const Value *LoadValue)
const {
302 for (
unsigned i = 0, e = NumStores; i != e; ++i) {
304 if (LoadValue == StoreValue[i] && LoadOffset == StoreOffset[i])
309 if (StoreValue[i] == LoadValue) {
312 if (StoreOffset[i] < LoadOffset) {
313 if (int64_t(StoreOffset[i]+StoreSize[i]) > LoadOffset)
return true;
315 if (int64_t(LoadOffset+LoadSize) > StoreOffset[i])
return true;
328 assert(Stalls == 0 &&
"PPC hazards don't support scoreboard lookahead");
338 GetInstrType(Opcode, isFirst, isSingle, isCracked,
344 if (NumIssued != 0 && (isFirst || isSingle))
350 if (isCracked && NumIssued > 2)
361 if (NumIssued == 4)
return Hazard;
365 if (NumIssued >= 2)
return Hazard;
379 if (isLoadOfStoredAddress(MO->
getSize(),
396 GetInstrType(Opcode, isFirst, isSingle, isCracked,
401 if (Opcode ==
PPC::MTCTR || Opcode == PPC::MTCTR8) HasCTRSet =
true;
404 if (isStore && NumStores < 4 && !MI->memoperands_empty()) {
406 StoreSize[NumStores] = MO->
getSize();
407 StoreOffset[NumStores] = MO->
getOffset();
408 StoreValue[NumStores] = MO->
getValue();
426 assert(NumIssued < 5 &&
"Illegal dispatch group!");
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
int getNonRecordFormOpcode(uint16_t)
PPCHazardRecognizer970(const ScheduleDAG &DAG)
This class represents lattice values for constants.
Describe properties that are true of each instruction in the target description file.
PPC970_Single - This instruction starts a new dispatch group and terminates it, so it will be the sol...
void RecedeCycle() override
RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot...
unsigned PreEmitNoops(SUnit *SU) override
PreEmitNoops - This callback is invoked prior to emitting an instruction.
uint64_t getSize() const
Return the size in bytes of the memory reference.
These are the various PPC970 execution unit pipelines.
CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a BCTRL instruction.
bool mayLoad() const
Return true if this instruction could possibly read memory.
SmallVector< SDep, 4 > Preds
All sunit predecessors.
bool isBranch() const
Returns true if this is a conditional, unconditional, or indirect branch.
A description of a memory reference used in the backend.
static bool isLoad(int Opcode)
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - We return hazard for any non-branch instruction that would terminate the dispatch gro...
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
Returns the MCInstrDesc of this SUnit.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
static bool isStore(int Opcode)
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
void EmitNoop() override
EmitNoop - This callback is invoked when a noop was added to the instruction stream.
const Value * getValue() const
Return the base address of the memory access.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
void Reset() override
Reset - This callback is invoked when a new block of instructions is about to be schedule.
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - Return the hazard type of emitting this node.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
InstrType
Represents how an instruction should be mapped by the outliner.
CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a MTCTR instruction.
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
PPC970_First - This instruction starts a new dispatch group, so it will always be the first one in th...
virtual bool ShouldPreferAnother(SUnit *)
ShouldPreferAnother - This callback may be invoked if getHazardType returns NoHazard.
bool isDebugInstr() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void Reset() override
Reset - This callback is invoked when a new block of instructions is about to be schedule.
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
void Reset() override
Reset - This callback is invoked when a new block of instructions is about to be schedule.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
virtual unsigned PreEmitNoops(SUnit *)
PreEmitNoops - This callback is invoked prior to emitting an instruction.
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool ShouldPreferAnother(SUnit *SU) override
ShouldPreferAnother - This callback may be invoked if getHazardType returns NoHazard.
Representation of each machine instruction.
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
const TargetInstrInfo * TII
Target instruction information.
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
LLVM Value Representation.
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
unsigned getOpcode() const
Return the opcode number for this descriptor.
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - Return the hazard type of emitting this node.
PPC970_Cracked - This instruction is cracked into two pieces, requiring two dispatch pipes to be avai...
Scheduling unit. This is a node in the scheduling DAG.