1 //===- RDFCopy.h ------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
10 #define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
13 #include "RDFLiveness.h"
14 #include "RDFRegisters.h"
15 #include "llvm/CodeGen/MachineFunction.h"
21 class MachineBasicBlock
;
22 class MachineDominatorTree
;
27 struct CopyPropagation
{
28 CopyPropagation(DataFlowGraph
&dfg
) : MDT(dfg
.getDT()), DFG(dfg
),
29 L(dfg
.getMF().getRegInfo(), dfg
) {}
31 virtual ~CopyPropagation() = default;
34 void trace(bool On
) { Trace
= On
; }
35 bool trace() const { return Trace
; }
36 DataFlowGraph
&getDFG() { return DFG
; }
38 using EqualityMap
= std::map
<RegisterRef
, RegisterRef
>;
40 virtual bool interpretAsCopy(const MachineInstr
*MI
, EqualityMap
&EM
);
43 const MachineDominatorTree
&MDT
;
48 // map: statement -> (map: dst reg -> src reg)
49 std::map
<NodeId
, EqualityMap
> CopyMap
;
50 std::vector
<NodeId
> Copies
;
52 void recordCopy(NodeAddr
<StmtNode
*> SA
, EqualityMap
&EM
);
53 bool scanBlock(MachineBasicBlock
*B
);
54 NodeId
getLocalReachingDef(RegisterRef RefRR
, NodeAddr
<InstrNode
*> IA
);
57 } // end namespace rdf
59 } // end namespace llvm
61 #endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H