diff options
author | Dan Gohman <gohman@apple.com> | 2008-11-21 00:12:10 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-11-21 00:12:10 +0000 |
commit | 7b7ca502facc44ee64131f0ec8ea3f22bc684111 (patch) | |
tree | a4a5d7acfc91c5de4300b4c35d95b05cac63869b /llvm/lib/CodeGen | |
parent | 39acb29ff8c7ea5f4852c471b3b1d0387f138898 (diff) | |
download | bcm5719-llvm-7b7ca502facc44ee64131f0ec8ea3f22bc684111.tar.gz bcm5719-llvm-7b7ca502facc44ee64131f0ec8ea3f22bc684111.zip |
Implement ComputeLatency for MachineInstr ScheduleDAGs. Factor
some of the latency computation logic out of the SDNode
ScheduleDAG code into a TargetInstrItineraries helper method
to help with this.
llvm-svn: 59761
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/ScheduleDAGInstrs.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp | 16 |
2 files changed, 19 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp index b6bc44e849e..06d8ed9b25d 100644 --- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp +++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp @@ -50,7 +50,7 @@ void ScheduleDAGInstrs::BuildSchedUnits() { assert(TRI->isPhysicalRegister(Reg) && "Virtual register encountered!"); std::vector<SUnit *> &UseList = Uses[Reg]; SUnit *&Def = Defs[Reg]; - // Optionally add output and anti dependences + // Optionally add output and anti dependences. if (Def && Def != SU) Def->addPred(SU, /*isCtrl=*/true, /*isSpecial=*/false, /*PhyReg=*/Reg, Cost); @@ -102,6 +102,15 @@ void ScheduleDAGInstrs::BuildSchedUnits() { } } +void ScheduleDAGInstrs::ComputeLatency(SUnit *SU) { + const InstrItineraryData &InstrItins = TM.getInstrItineraryData(); + + // Compute the latency for the node. We use the sum of the latencies for + // all nodes flagged together into this SUnit. + SU->Latency = + InstrItins.getLatency(SU->getInstr()->getDesc().getSchedClass()); +} + void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const { SU->getInstr()->dump(); } diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index 9d32d9afac5..91a8294e1d4 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -193,15 +193,17 @@ void ScheduleDAGSDNodes::ComputeLatency(SUnit *SU) { } SU->Latency = 0; - for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode()) { + bool SawMachineOpcode = false; + for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode()) if (N->isMachineOpcode()) { - unsigned SchedClass = TII->get(N->getMachineOpcode()).getSchedClass(); - const InstrStage *S = InstrItins.begin(SchedClass); - const InstrStage *E = InstrItins.end(SchedClass); - for (; S != E; ++S) - SU->Latency += S->Cycles; + SawMachineOpcode = true; + SU->Latency += + InstrItins.getLatency(TII->get(N->getMachineOpcode()).getSchedClass()); } - } + + // Ensure that CopyToReg and similar nodes have a non-zero latency. + if (!SawMachineOpcode) + SU->Latency = 1; } /// CountResults - The results of target nodes have register or immediate |