Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / Target / Hexagon / RDFCopy.h
blobe4fb89892831de5511a71f3325fa694289ee1fd3
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
10 #define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
12 #include "llvm/CodeGen/RDFGraph.h"
13 #include "llvm/CodeGen/RDFLiveness.h"
14 #include "llvm/CodeGen/RDFRegisters.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include <map>
17 #include <vector>
19 namespace llvm {
21 class MachineBasicBlock;
22 class MachineDominatorTree;
23 class MachineInstr;
25 namespace rdf {
27 struct CopyPropagation {
28 CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
29 RDefMap(std::less<RegisterRef>(DFG.getPRI())) {}
31 virtual ~CopyPropagation() = default;
33 bool run();
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>;
39 virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
41 private:
42 const MachineDominatorTree &MDT;
43 DataFlowGraph &DFG;
44 DataFlowGraph::DefStackMap DefM;
45 bool Trace = false;
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;
53 void recordCopy(NodeAddr<StmtNode*> SA, EqualityMap &EM);
54 void updateMap(NodeAddr<InstrNode*> IA);
55 bool scanBlock(MachineBasicBlock *B);
58 } // end namespace rdf
60 } // end namespace llvm
62 #endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H