Add callback to allow target to adjust latency of schedule dependency edge.
llvm-svn: 78910
This commit is contained in:
parent
54401d4174
commit
90e6b8b708
|
@ -145,6 +145,11 @@ namespace llvm {
|
||||||
return Latency;
|
return Latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// setLatency - Set the latency for this edge.
|
||||||
|
void setLatency(unsigned Lat) {
|
||||||
|
Latency = Lat;
|
||||||
|
}
|
||||||
|
|
||||||
//// getSUnit - Return the SUnit to which this edge points.
|
//// getSUnit - Return the SUnit to which this edge points.
|
||||||
SUnit *getSUnit() const {
|
SUnit *getSUnit() const {
|
||||||
return Dep.getPointer();
|
return Dep.getPointer();
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
class SDep;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
///
|
///
|
||||||
/// TargetSubtarget - Generic base class for all target subtargets. All
|
/// TargetSubtarget - Generic base class for all target subtargets. All
|
||||||
|
@ -35,6 +37,10 @@ public:
|
||||||
/// indicating the number of scheduling cycles of backscheduling that
|
/// indicating the number of scheduling cycles of backscheduling that
|
||||||
/// should be attempted.
|
/// should be attempted.
|
||||||
virtual unsigned getSpecialAddressLatency() const { return 0; }
|
virtual unsigned getSpecialAddressLatency() const { return 0; }
|
||||||
|
|
||||||
|
// adjustSchedDependency - Perform target specific adjustments to
|
||||||
|
// the latency of a schedule dependency.
|
||||||
|
virtual void adjustSchedDependency(SDep&) const { };
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
|
@ -145,8 +145,8 @@ void ScheduleDAGInstrs::BuildSchedGraph() {
|
||||||
bool UnitLatencies = ForceUnitLatencies();
|
bool UnitLatencies = ForceUnitLatencies();
|
||||||
|
|
||||||
// Ask the target if address-backscheduling is desirable, and if so how much.
|
// Ask the target if address-backscheduling is desirable, and if so how much.
|
||||||
unsigned SpecialAddressLatency =
|
const TargetSubtarget &ST = TM.getSubtarget<TargetSubtarget>();
|
||||||
TM.getSubtarget<TargetSubtarget>().getSpecialAddressLatency();
|
unsigned SpecialAddressLatency = ST.getSpecialAddressLatency();
|
||||||
|
|
||||||
// Walk the list of instructions, from bottom moving up.
|
// Walk the list of instructions, from bottom moving up.
|
||||||
for (MachineBasicBlock::iterator MII = InsertPos, MIE = Begin;
|
for (MachineBasicBlock::iterator MII = InsertPos, MIE = Begin;
|
||||||
|
@ -220,15 +220,20 @@ void ScheduleDAGInstrs::BuildSchedGraph() {
|
||||||
UseTID.OpInfo[RegUseIndex].isLookupPtrRegClass())
|
UseTID.OpInfo[RegUseIndex].isLookupPtrRegClass())
|
||||||
LDataLatency += SpecialAddressLatency;
|
LDataLatency += SpecialAddressLatency;
|
||||||
}
|
}
|
||||||
UseSU->addPred(SDep(SU, SDep::Data, LDataLatency, Reg));
|
const SDep& dep = SDep(SU, SDep::Data, LDataLatency, Reg);
|
||||||
|
ST.adjustSchedDependency((SDep &)dep);
|
||||||
|
UseSU->addPred(dep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
|
for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
|
||||||
std::vector<SUnit *> &UseList = Uses[*Alias];
|
std::vector<SUnit *> &UseList = Uses[*Alias];
|
||||||
for (unsigned i = 0, e = UseList.size(); i != e; ++i) {
|
for (unsigned i = 0, e = UseList.size(); i != e; ++i) {
|
||||||
SUnit *UseSU = UseList[i];
|
SUnit *UseSU = UseList[i];
|
||||||
if (UseSU != SU)
|
if (UseSU != SU) {
|
||||||
UseSU->addPred(SDep(SU, SDep::Data, DataLatency, *Alias));
|
const SDep& dep = SDep(SU, SDep::Data, DataLatency, *Alias);
|
||||||
|
ST.adjustSchedDependency((SDep &)dep);
|
||||||
|
UseSU->addPred(dep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
|
#include "llvm/Target/TargetSubtarget.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -152,6 +153,8 @@ void ScheduleDAGSDNodes::BuildSchedUnits() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleDAGSDNodes::AddSchedEdges() {
|
void ScheduleDAGSDNodes::AddSchedEdges() {
|
||||||
|
const TargetSubtarget &ST = TM.getSubtarget<TargetSubtarget>();
|
||||||
|
|
||||||
// Pass 2: add the preds, succs, etc.
|
// Pass 2: add the preds, succs, etc.
|
||||||
for (unsigned su = 0, e = SUnits.size(); su != e; ++su) {
|
for (unsigned su = 0, e = SUnits.size(); su != e; ++su) {
|
||||||
SUnit *SU = &SUnits[su];
|
SUnit *SU = &SUnits[su];
|
||||||
|
@ -206,8 +209,13 @@ void ScheduleDAGSDNodes::AddSchedEdges() {
|
||||||
// dependency. This may change in the future though.
|
// dependency. This may change in the future though.
|
||||||
if (Cost >= 0)
|
if (Cost >= 0)
|
||||||
PhysReg = 0;
|
PhysReg = 0;
|
||||||
SU->addPred(SDep(OpSU, isChain ? SDep::Order : SDep::Data,
|
|
||||||
OpSU->Latency, PhysReg));
|
const SDep& dep = SDep(OpSU, isChain ? SDep::Order : SDep::Data,
|
||||||
|
OpSU->Latency, PhysReg);
|
||||||
|
if (!isChain)
|
||||||
|
ST.adjustSchedDependency((SDep &)dep);
|
||||||
|
|
||||||
|
SU->addPred(dep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue