LLVM 20.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
16#include <map>
17#include <vector>
18
19namespace llvm {
20
21class MachineBasicBlock;
22class MachineDominatorTree;
23class MachineInstr;
24
25namespace rdf {
26
28 CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
29 RDefMap(std::less<RegisterRef>(DFG.getPRI())) {}
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 virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
40
41 private:
42 const MachineDominatorTree &MDT;
43 DataFlowGraph &DFG;
45 bool Trace = false;
46
47 // map: register -> (map: stmt -> reaching def)
48 std::map<RegisterRef,std::map<NodeId,NodeId>> RDefMap;
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 void updateMap(NodeAddr<InstrNode*> IA);
55 bool scanBlock(MachineBasicBlock *B);
56 };
57
58} // end namespace rdf
59
60} // end namespace llvm
61
62#endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
IRTranslator LLVM IR MI
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
Definition: MachineInstr.h:69
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
bool trace() const
Definition: RDFCopy.h:35
CopyPropagation(DataFlowGraph &dfg)
Definition: RDFCopy.h:28
std::map< RegisterRef, RegisterRef > EqualityMap
Definition: RDFCopy.h:38
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM)
Definition: RDFCopy.cpp:40
DataFlowGraph & getDFG()
Definition: RDFCopy.h:36
virtual ~CopyPropagation()=default
void trace(bool On)
Definition: RDFCopy.h:34
std::unordered_map< RegisterId, DefStack > DefStackMap
Definition: RDFGraph.h:772