1//===--- RDFCopyBase.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_BASE_H
10#define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_BASE_H
11
12#include "llvm/CodeGen/MachineFunction.h"
13#include "llvm/CodeGen/RDFGraph.h"
14#include "llvm/CodeGen/RDFLiveness.h"
15#include "llvm/CodeGen/RDFRegisters.h"
16#include <map>
17#include <vector>
18
19namespace llvm {
20
21class MachineBasicBlock;
22class MachineDominatorTree;
23class MachineInstr;
24
25namespace rdf {
26
27struct CopyPropagationBase {
28 CopyPropagationBase(DataFlowGraph &dfg)
29 : MDT(dfg.getDT()), DFG(dfg), RDefMap(RegisterRefLess(DFG.getPRI())) {}
30
31 virtual ~CopyPropagationBase() = default;
32
33 void trace(bool On) { Trace = On; }
34 bool trace() const { return Trace; }
35 DataFlowGraph &getDFG() { return DFG; }
36
37 using EqualityMap = std::map<RegisterRef, RegisterRef, RegisterRefLess>;
38
39protected:
40 const MachineDominatorTree &MDT;
41 DataFlowGraph &DFG;
42 DataFlowGraph::DefStackMap DefM;
43 bool Trace = false;
44
45 // map: register -> (map: stmt -> reaching def)
46 std::map<RegisterRef, std::map<NodeId, NodeId>, RegisterRefLess> RDefMap;
47 // map: statement -> (map: dst reg -> src reg)
48 std::map<NodeId, EqualityMap> CopyMap;
49};
50
51} // end namespace rdf
52} // end namespace llvm
53
54#endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_BASE_H
55