1 //===- RDFCopy.h ------------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H 11 #define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H 12 13 #include "RDFGraph.h" 14 #include "RDFLiveness.h" 15 #include "RDFRegisters.h" 16 #include "llvm/CodeGen/MachineFunction.h" 17 #include <map> 18 #include <vector> 19 20 namespace llvm { 21 22 class MachineBasicBlock; 23 class MachineDominatorTree; 24 class MachineInstr; 25 26 namespace rdf { 27 28 struct CopyPropagation { CopyPropagationCopyPropagation29 CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg), 30 L(dfg.getMF().getRegInfo(), dfg) {} 31 32 virtual ~CopyPropagation() = default; 33 34 bool run(); traceCopyPropagation35 void trace(bool On) { Trace = On; } traceCopyPropagation36 bool trace() const { return Trace; } getDFGCopyPropagation37 DataFlowGraph &getDFG() { return DFG; } 38 39 using EqualityMap = std::map<RegisterRef, RegisterRef>; 40 41 virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM); 42 43 private: 44 const MachineDominatorTree &MDT; 45 DataFlowGraph &DFG; 46 Liveness L; 47 bool Trace = false; 48 49 // map: statement -> (map: dst reg -> src reg) 50 std::map<NodeId, EqualityMap> CopyMap; 51 std::vector<NodeId> Copies; 52 53 void recordCopy(NodeAddr<StmtNode*> SA, EqualityMap &EM); 54 bool scanBlock(MachineBasicBlock *B); 55 NodeId getLocalReachingDef(RegisterRef RefRR, NodeAddr<InstrNode*> IA); 56 }; 57 58 } // end namespace rdf 59 60 } // end namespace llvm 61 62 #endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H 63