From 12dfdb424ddcfabb347f168f9332795ba443ccd3 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 14 Dec 2011 02:28:53 +0000 Subject: [PATCH] Allow target to specify register output dependency. Still default to one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146547 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetInstrInfo.h | 10 ++++++++++ lib/CodeGen/ScheduleDAGInstrs.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index 1903da73e6a..957a89af820 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -648,6 +648,16 @@ public: SDNode *DefNode, unsigned DefIdx, SDNode *UseNode, unsigned UseIdx) const; + /// getOutputLatency - Compute and return the output dependency latency of a + /// a given pair of defs which both target the same register. This is usually + /// one. + virtual unsigned getOutputLatency(const InstrItineraryData *ItinData, + const MachineInstr *DefMI1, + const MachineInstr *DefMI2, + unsigned Reg) const { + return 1; + } + /// getInstrLatency - Compute the instruction latency of a given instruction. /// If the instruction has higher cost when predicated, it's returned via /// PredCost. diff --git a/lib/CodeGen/ScheduleDAGInstrs.cpp b/lib/CodeGen/ScheduleDAGInstrs.cpp index aedc2a13faf..47c533932d6 100644 --- a/lib/CodeGen/ScheduleDAGInstrs.cpp +++ b/lib/CodeGen/ScheduleDAGInstrs.cpp @@ -278,7 +278,13 @@ void ScheduleDAGInstrs::BuildSchedGraph(AliasAnalysis *AA) { if (DefSU != SU && (Kind != SDep::Output || !MO.isDead() || !DefSU->getInstr()->registerDefIsDead(Reg))) { - DefSU->addPred(SDep(SU, Kind, AOLatency, /*Reg=*/Reg)); + if (Kind == SDep::Anti) + DefSU->addPred(SDep(SU, Kind, 0, /*Reg=*/Reg)); + else { + unsigned AOLat = TII->getOutputLatency(InstrItins, MI, + DefSU->getInstr(), Reg); + DefSU->addPred(SDep(SU, Kind, AOLat, /*Reg=*/Reg)); + } } } for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) { -- 2.34.1