LLVM  13.0.0git
RDFCopy.h
Go to the documentation of this file.
1 //===- RDFCopy.h ------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
10 #define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
11 
12 #include "llvm/CodeGen/RDFGraph.h"
16 #include <map>
17 #include <vector>
18 
19 namespace llvm {
20 
21 class MachineBasicBlock;
22 class MachineDominatorTree;
23 class MachineInstr;
24 
25 namespace rdf {
26 
27  struct CopyPropagation {
28  CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
29  L(dfg.getMF().getRegInfo(), dfg) {}
30 
31  virtual ~CopyPropagation() = default;
32 
33  bool run();
34  void trace(bool On) { Trace = On; }
35  bool trace() const { return Trace; }
36  DataFlowGraph &getDFG() { return DFG; }
37 
38  using EqualityMap = std::map<RegisterRef, RegisterRef>;
39 
40  virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
41 
42  private:
43  const MachineDominatorTree &MDT;
44  DataFlowGraph &DFG;
45  Liveness L;
46  bool Trace = false;
47 
48  // map: statement -> (map: dst reg -> src reg)
49  std::map<NodeId, EqualityMap> CopyMap;
50  std::vector<NodeId> Copies;
51 
52  void recordCopy(NodeAddr<StmtNode*> SA, EqualityMap &EM);
53  bool scanBlock(MachineBasicBlock *B);
54  NodeId getLocalReachingDef(RegisterRef RefRR, NodeAddr<InstrNode*> IA);
55  };
56 
57 } // end namespace rdf
58 
59 } // end namespace llvm
60 
61 #endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:100
llvm
Definition: AllocatorList.h:23
llvm::rdf::CopyPropagation::trace
void trace(bool On)
Definition: RDFCopy.h:34
llvm::rdf::CopyPropagation::CopyPropagation
CopyPropagation(DataFlowGraph &dfg)
Definition: RDFCopy.h:28
llvm::rdf::CopyPropagation::interpretAsCopy
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM)
Definition: RDFCopy.cpp:40
llvm::rdf::CopyPropagation::getDFG
DataFlowGraph & getDFG()
Definition: RDFCopy.h:36
RDFRegisters.h
llvm::rdf::RegisterRef
Definition: RDFRegisters.h:71
RDFLiveness.h
llvm::rdf::NodeAddr
Definition: RDFGraph.h:334
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::rdf::DataFlowGraph
Definition: RDFGraph.h:644
RDFGraph.h
uint32_t
llvm::Trace
Definition: Trace.h:30
llvm::rdf::CopyPropagation::~CopyPropagation
virtual ~CopyPropagation()=default
llvm::rdf::CopyPropagation::trace
bool trace() const
Definition: RDFCopy.h:35
llvm::rdf::CopyPropagation::run
bool run()
Definition: RDFCopy.cpp:101
llvm::rdf::CopyPropagation
Definition: RDFCopy.h:27
llvm::rdf::Liveness
Definition: RDFLiveness.h:59
llvm::rdf::CopyPropagation::EqualityMap
std::map< RegisterRef, RegisterRef > EqualityMap
Definition: RDFCopy.h:38
llvm::MachineDominatorTree
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Definition: MachineDominators.h:45
MachineFunction.h