2017-08-01 23:20:10 +02:00
|
|
|
//===- RDFCopy.h ------------------------------------------------*- C++ -*-===//
|
2016-01-12 18:23:48 +01:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-01-12 18:23:48 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-01-04 03:02:05 +01:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
|
2016-01-12 18:23:48 +01:00
|
|
|
|
2020-03-17 19:45:11 +01:00
|
|
|
#include "llvm/CodeGen/RDFGraph.h"
|
|
|
|
#include "llvm/CodeGen/RDFLiveness.h"
|
|
|
|
#include "llvm/CodeGen/RDFRegisters.h"
|
2017-03-10 23:44:24 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2016-01-12 18:23:48 +01:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
2017-01-04 03:02:05 +01:00
|
|
|
|
2017-08-01 23:20:10 +02:00
|
|
|
class MachineBasicBlock;
|
|
|
|
class MachineDominatorTree;
|
|
|
|
class MachineInstr;
|
2016-01-12 18:23:48 +01:00
|
|
|
|
|
|
|
namespace rdf {
|
2017-01-04 03:02:05 +01:00
|
|
|
|
2016-01-12 18:23:48 +01:00
|
|
|
struct CopyPropagation {
|
|
|
|
CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
|
2017-08-01 23:20:10 +02:00
|
|
|
L(dfg.getMF().getRegInfo(), dfg) {}
|
2017-01-04 03:02:05 +01:00
|
|
|
|
|
|
|
virtual ~CopyPropagation() = default;
|
2016-01-12 18:23:48 +01:00
|
|
|
|
|
|
|
bool run();
|
|
|
|
void trace(bool On) { Trace = On; }
|
|
|
|
bool trace() const { return Trace; }
|
2016-10-14 19:57:55 +02:00
|
|
|
DataFlowGraph &getDFG() { return DFG; }
|
2016-01-12 18:23:48 +01:00
|
|
|
|
2017-08-01 23:20:10 +02:00
|
|
|
using EqualityMap = std::map<RegisterRef, RegisterRef>;
|
|
|
|
|
2016-01-18 21:43:57 +01:00
|
|
|
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
|
|
|
|
|
2016-01-12 18:23:48 +01:00
|
|
|
private:
|
|
|
|
const MachineDominatorTree &MDT;
|
|
|
|
DataFlowGraph &DFG;
|
2017-03-10 23:44:24 +01:00
|
|
|
Liveness L;
|
2017-08-01 23:20:10 +02:00
|
|
|
bool Trace = false;
|
2016-01-12 18:23:48 +01:00
|
|
|
|
2016-01-18 21:43:57 +01:00
|
|
|
// map: statement -> (map: dst reg -> src reg)
|
|
|
|
std::map<NodeId, EqualityMap> CopyMap;
|
2016-01-12 18:23:48 +01:00
|
|
|
std::vector<NodeId> Copies;
|
|
|
|
|
2016-01-18 21:43:57 +01:00
|
|
|
void recordCopy(NodeAddr<StmtNode*> SA, EqualityMap &EM);
|
2016-01-12 18:23:48 +01:00
|
|
|
bool scanBlock(MachineBasicBlock *B);
|
2017-03-10 23:44:24 +01:00
|
|
|
NodeId getLocalReachingDef(RegisterRef RefRR, NodeAddr<InstrNode*> IA);
|
2016-01-12 18:23:48 +01:00
|
|
|
};
|
|
|
|
|
2017-01-04 03:02:05 +01:00
|
|
|
} // end namespace rdf
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
|