diff options
Diffstat (limited to 'lib/Target/Hexagon/RDFLiveness.cpp')
| -rw-r--r-- | lib/Target/Hexagon/RDFLiveness.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/lib/Target/Hexagon/RDFLiveness.cpp b/lib/Target/Hexagon/RDFLiveness.cpp index 83e8968086d8..13d9a1741978 100644 --- a/lib/Target/Hexagon/RDFLiveness.cpp +++ b/lib/Target/Hexagon/RDFLiveness.cpp @@ -1,4 +1,4 @@ -//===--- RDFLiveness.cpp --------------------------------------------------===// +//===- RDFLiveness.cpp ----------------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -25,14 +25,29 @@ // #include "RDFLiveness.h" #include "RDFGraph.h" +#include "RDFRegisters.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetVector.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineDominanceFrontier.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/TargetRegisterInfo.h" +#include "llvm/MC/LaneBitmask.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" +#include <algorithm> +#include <cassert> +#include <cstdint> +#include <iterator> +#include <map> +#include <utility> +#include <vector> using namespace llvm; using namespace rdf; @@ -42,11 +57,12 @@ static cl::opt<unsigned> MaxRecNest("rdf-liveness-max-rec", cl::init(25), namespace llvm { namespace rdf { + template<> raw_ostream &operator<< (raw_ostream &OS, const Print<Liveness::RefMap> &P) { OS << '{'; for (auto &I : P.Obj) { - OS << ' ' << PrintReg(I.first, &P.G.getTRI()) << '{'; + OS << ' ' << printReg(I.first, &P.G.getTRI()) << '{'; for (auto J = I.second.begin(), E = I.second.end(); J != E; ) { OS << Print<NodeId>(J->first, P.G) << PrintLaneMaskOpt(J->second); if (++J != E) @@ -57,8 +73,9 @@ namespace rdf { OS << " }"; return OS; } -} // namespace rdf -} // namespace llvm + +} // end namespace rdf +} // end namespace llvm // The order in the returned sequence is the order of reaching defs in the // upward traversal: the first def is the closest to the given reference RefA, @@ -245,19 +262,17 @@ NodeList Liveness::getAllReachingDefs(RegisterRef RefRR, auto DeadP = [](const NodeAddr<DefNode*> DA) -> bool { return DA.Addr->getFlags() & NodeAttrs::Dead; }; - RDefs.resize(std::distance(RDefs.begin(), remove_if(RDefs, DeadP))); + RDefs.resize(std::distance(RDefs.begin(), llvm::remove_if(RDefs, DeadP))); return RDefs; } - std::pair<NodeSet,bool> Liveness::getAllReachingDefsRec(RegisterRef RefRR, NodeAddr<RefNode*> RefA, NodeSet &Visited, const NodeSet &Defs) { return getAllReachingDefsRecImpl(RefRR, RefA, Visited, Defs, 0, MaxRecNest); } - std::pair<NodeSet,bool> Liveness::getAllReachingDefsRecImpl(RegisterRef RefRR, NodeAddr<RefNode*> RefA, NodeSet &Visited, const NodeSet &Defs, unsigned Nest, unsigned MaxNest) { @@ -363,7 +378,6 @@ NodeAddr<RefNode*> Liveness::getNearestAliasedRef(RegisterRef RefRR, return NodeAddr<RefNode*>(); } - NodeSet Liveness::getAllReachedUses(RegisterRef RefRR, NodeAddr<DefNode*> DefA, const RegisterAggr &DefRRs) { NodeSet Uses; @@ -410,7 +424,6 @@ NodeSet Liveness::getAllReachedUses(RegisterRef RefRR, return Uses; } - void Liveness::computePhiInfo() { RealUseMap.clear(); @@ -668,7 +681,6 @@ void Liveness::computePhiInfo() { } } - void Liveness::computeLiveIns() { // Populate the node-to-block map. This speeds up the calculations // significantly. @@ -802,7 +814,7 @@ void Liveness::computeLiveIns() { for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I) LV.push_back(RegisterRef(I->PhysReg, I->LaneMask)); std::sort(LV.begin(), LV.end()); - dbgs() << "BB#" << B.getNumber() << "\t rec = {"; + dbgs() << printMBBReference(B) << "\t rec = {"; for (auto I : LV) dbgs() << ' ' << Print<RegisterRef>(I, DFG); dbgs() << " }\n"; @@ -822,7 +834,6 @@ void Liveness::computeLiveIns() { } } - void Liveness::resetLiveIns() { for (auto &B : DFG.getMF()) { // Remove all live-ins. @@ -840,13 +851,11 @@ void Liveness::resetLiveIns() { } } - void Liveness::resetKills() { for (auto &B : DFG.getMF()) resetKills(&B); } - void Liveness::resetKills(MachineBasicBlock *B) { auto CopyLiveIns = [this] (MachineBasicBlock *B, BitVector &LV) -> void { for (auto I : B->liveins()) { @@ -909,7 +918,6 @@ void Liveness::resetKills(MachineBasicBlock *B) { } } - // Helper function to obtain the basic block containing the reaching def // of the given use. MachineBasicBlock *Liveness::getBlockWithRef(NodeId RN) const { @@ -919,7 +927,6 @@ MachineBasicBlock *Liveness::getBlockWithRef(NodeId RN) const { llvm_unreachable("Node id not in map"); } - void Liveness::traverse(MachineBasicBlock *B, RefMap &LiveIn) { // The LiveIn map, for each (physical) register, contains the set of live // reaching defs of that register that are live on entry to the associated @@ -956,7 +963,7 @@ void Liveness::traverse(MachineBasicBlock *B, RefMap &LiveIn) { } if (Trace) { - dbgs() << "\n-- BB#" << B->getNumber() << ": " << __func__ + dbgs() << "\n-- " << printMBBReference(*B) << ": " << __func__ << " after recursion into: {"; for (auto I : *N) dbgs() << ' ' << I->getBlock()->getNumber(); @@ -1107,9 +1114,7 @@ void Liveness::traverse(MachineBasicBlock *B, RefMap &LiveIn) { } } - void Liveness::emptify(RefMap &M) { for (auto I = M.begin(), E = M.end(); I != E; ) I = I->second.empty() ? M.erase(I) : std::next(I); } - |
