comparison lib/Target/Hexagon/RDFCopy.h @ 121:803732b1fca8

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