LLVM  4.0.0
RDFCopy.h
Go to the documentation of this file.
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;
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
std::map< RegisterRef, RegisterRef > EqualityMap
Definition: RDFCopy.h:36
virtual ~CopyPropagation()=default
Function Alias Analysis false
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
bool trace() const
Definition: RDFCopy.h:33
CopyPropagation(DataFlowGraph &dfg)
Definition: RDFCopy.h:26
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM)
Definition: RDFCopy.cpp:29
DataFlowGraph & getDFG()
Definition: RDFCopy.h:34
std::unordered_map< RegisterId, DefStack > DefStackMap
Definition: RDFGraph.h:828
void trace(bool On)
Definition: RDFCopy.h:32
Representation of each machine instruction.
Definition: MachineInstr.h:52
IRTranslator LLVM IR MI
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...