diff options
author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2016-07-15 17:48:09 +0000 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2016-07-15 17:48:09 +0000 |
commit | 9be66737c134f655a585961671c4b3ff801190bf (patch) | |
tree | 2430e688462f32e0bf1dce007fb870cb62d3a0b2 /llvm/lib | |
parent | 9da82d6aca371de0703236db374ab509d5487bf4 (diff) | |
download | bcm5719-llvm-9be66737c134f655a585961671c4b3ff801190bf.tar.gz bcm5719-llvm-9be66737c134f655a585961671c4b3ff801190bf.zip |
[Hexagon] Add a scheduling DAG mutation
- Remove output dependencies on USR_OVF register.
- Update chain edge latencies between v60 vector loads/stores.
llvm-svn: 275586
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonSubtarget.cpp | 53 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonSubtarget.h | 10 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp | 2 |
4 files changed, 68 insertions, 1 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp index 035cea3ba4d..c3fca85dab9 100644 --- a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp +++ b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp @@ -13,7 +13,9 @@ //===----------------------------------------------------------------------===// #include "HexagonMachineScheduler.h" +#include "HexagonSubtarget.h" #include "llvm/CodeGen/MachineLoopInfo.h" +#include "llvm/CodeGen/ScheduleDAGMutation.h" #include "llvm/IR/Function.h" using namespace llvm; @@ -223,6 +225,8 @@ void ConvergingVLIWScheduler::initialize(ScheduleDAGMI *dag) { assert((!llvm::ForceTopDown || !llvm::ForceBottomUp) && "-misched-topdown incompatible with -misched-bottomup"); + + DAG->addMutation(make_unique<HexagonSubtarget::HexagonDAGMutation>()); } void ConvergingVLIWScheduler::releaseTopNode(SUnit *SU) { diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp index 842b715b6f7..0771cbebbea 100644 --- a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp +++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -14,6 +14,8 @@ #include "HexagonSubtarget.h" #include "Hexagon.h" #include "HexagonRegisterInfo.h" +#include "llvm/CodeGen/ScheduleDAG.h" +#include "llvm/CodeGen/ScheduleDAGInstrs.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include <map> @@ -119,6 +121,57 @@ HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU, UseBSBScheduling = hasV60TOps() && EnableBSBSched; } + +void HexagonSubtarget::HexagonDAGMutation::apply(ScheduleDAGInstrs *DAG) { + for (auto &SU : DAG->SUnits) { + if (!SU.isInstr()) + continue; + SmallVector<SDep, 4> Erase; + for (auto &D : SU.Preds) + if (D.getKind() == SDep::Output && D.getReg() == Hexagon::USR_OVF) + Erase.push_back(D); + for (auto &E : Erase) + SU.removePred(E); + } + + for (auto &SU : DAG->SUnits) { + // Update the latency of chain edges between v60 vector load or store + // instructions to be 1. These instructions cannot be scheduled in the + // same packet. + MachineInstr *MI1 = SU.getInstr(); + auto *QII = static_cast<const HexagonInstrInfo*>(DAG->TII); + bool IsStoreMI1 = MI1->mayStore(); + bool IsLoadMI1 = MI1->mayLoad(); + if (!QII->isV60VectorInstruction(MI1) || !(IsStoreMI1 || IsLoadMI1)) + continue; + for (auto &SI : SU.Succs) { + if (SI.getKind() != SDep::Order || SI.getLatency() != 0) + continue; + MachineInstr *MI2 = SI.getSUnit()->getInstr(); + if (!QII->isV60VectorInstruction(MI2)) + continue; + if ((IsStoreMI1 && MI2->mayStore()) || (IsLoadMI1 && MI2->mayLoad())) { + SI.setLatency(1); + SU.setHeightDirty(); + // Change the dependence in the opposite direction too. + for (auto &PI : SI.getSUnit()->Preds) { + if (PI.getSUnit() != &SU || PI.getKind() != SDep::Order) + continue; + PI.setLatency(1); + SI.getSUnit()->setDepthDirty(); + } + } + } + } +} + + +void HexagonSubtarget::getPostRAMutations( + std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const { + Mutations.push_back(make_unique<HexagonSubtarget::HexagonDAGMutation>()); +} + + // Pin the vtable to this file. void HexagonSubtarget::anchor() {} diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.h b/llvm/lib/Target/Hexagon/HexagonSubtarget.h index 134b8237e5b..1922df1d3d7 100644 --- a/llvm/lib/Target/Hexagon/HexagonSubtarget.h +++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.h @@ -18,7 +18,6 @@ #include "HexagonISelLowering.h" #include "HexagonInstrInfo.h" #include "HexagonSelectionDAGInfo.h" -#include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSubtargetInfo.h" #include <string> @@ -47,6 +46,11 @@ public: /// default for V60. bool UseBSBScheduling; + class HexagonDAGMutation : public ScheduleDAGMutation { + public: + void apply(ScheduleDAGInstrs *DAG) override; + }; + private: std::string CPUString; HexagonInstrInfo InstrInfo; @@ -119,6 +123,10 @@ public: const HexagonArchEnum &getHexagonArchVersion() const { return HexagonArchVersion; } + + void getPostRAMutations( + std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) + const override; }; } // end namespace llvm diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index 0b3aea1bdbe..d326b947131 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -108,6 +108,8 @@ HexagonPacketizerList::HexagonPacketizerList(MachineFunction &MF, : VLIWPacketizerList(MF, MLI, AA), MBPI(MBPI), MLI(&MLI) { HII = MF.getSubtarget<HexagonSubtarget>().getInstrInfo(); HRI = MF.getSubtarget<HexagonSubtarget>().getRegisterInfo(); + + addMutation(make_unique<HexagonSubtarget::HexagonDAGMutation>()); } // Check if FirstI modifies a register that SecondI reads. |