]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Hexagon/RDFCopy.h
Merge llvm, clang, lld and lldb trunk r291012, and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Hexagon / RDFCopy.h
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 <map>
15 #include <vector>
16
17 namespace llvm {
18
19   class MachineBasicBlock;
20   class MachineDominatorTree;
21   class MachineInstr;
22
23 namespace rdf {
24
25   struct CopyPropagation {
26     CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
27         Trace(false) {}
28
29     virtual ~CopyPropagation() = default;
30
31     bool run();
32     void trace(bool On) { Trace = On; }
33     bool trace() const { return Trace; }
34     DataFlowGraph &getDFG() { return DFG; }
35
36     typedef std::map<RegisterRef, RegisterRef> EqualityMap;
37     virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
38
39   private:
40     const MachineDominatorTree &MDT;
41     DataFlowGraph &DFG;
42     DataFlowGraph::DefStackMap DefM;
43     bool Trace;
44
45     // map: register -> (map: stmt -> reaching def)
46     std::map<RegisterRef,std::map<NodeId,NodeId>> RDefMap;
47     // map: statement -> (map: dst reg -> src reg)
48     std::map<NodeId, EqualityMap> CopyMap;
49     std::vector<NodeId> Copies;
50
51     void recordCopy(NodeAddr<StmtNode*> SA, EqualityMap &EM);
52     void updateMap(NodeAddr<InstrNode*> IA);
53     bool scanBlock(MachineBasicBlock *B);
54   };
55
56 } // end namespace rdf
57
58 } // end namespace llvm
59
60 #endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H