LLVM  8.0.1
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 "RDFLiveness.h"
15 #include "RDFRegisters.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 {
29  CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
30  L(dfg.getMF().getRegInfo(), dfg) {}
31 
32  virtual ~CopyPropagation() = default;
33 
34  bool run();
35  void trace(bool On) { Trace = On; }
36  bool trace() const { return Trace; }
37  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
This class represents lattice values for constants.
Definition: AllocatorList.h:24
virtual ~CopyPropagation()=default
bool trace() const
Definition: RDFCopy.h:36
std::map< RegisterRef, RegisterRef > EqualityMap
Definition: RDFCopy.h:39
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
CopyPropagation(DataFlowGraph &dfg)
Definition: RDFCopy.h:29
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM)
Definition: RDFCopy.cpp:41
DataFlowGraph & getDFG()
Definition: RDFCopy.h:37
void trace(bool On)
Definition: RDFCopy.h:35
Representation of each machine instruction.
Definition: MachineInstr.h:64
IRTranslator LLVM IR MI
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...