2017-08-02 05:20:10 +08:00
|
|
|
//===- RDFCopy.h ------------------------------------------------*- C++ -*-===//
|
2016-01-13 01:23:48 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-01-04 10:02:05 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
|
2016-01-13 01:23:48 +08:00
|
|
|
|
|
|
|
#include "RDFGraph.h"
|
2017-03-11 06:44:24 +08:00
|
|
|
#include "RDFLiveness.h"
|
2017-08-02 05:20:10 +08:00
|
|
|
#include "RDFRegisters.h"
|
2017-03-11 06:44:24 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2016-01-13 01:23:48 +08:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
2017-01-04 10:02:05 +08:00
|
|
|
|
2017-08-02 05:20:10 +08:00
|
|
|
class MachineBasicBlock;
|
|
|
|
class MachineDominatorTree;
|
|
|
|
class MachineInstr;
|
2016-01-13 01:23:48 +08:00
|
|
|
|
|
|
|
namespace rdf {
|
2017-01-04 10:02:05 +08:00
|
|
|
|
2016-01-13 01:23:48 +08:00
|
|
|
struct CopyPropagation {
|
|
|
|
CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
|
2017-08-02 05:20:10 +08:00
|
|
|
L(dfg.getMF().getRegInfo(), dfg) {}
|
2017-01-04 10:02:05 +08:00
|
|
|
|
|
|
|
virtual ~CopyPropagation() = default;
|
2016-01-13 01:23:48 +08:00
|
|
|
|
|
|
|
bool run();
|
|
|
|
void trace(bool On) { Trace = On; }
|
|
|
|
bool trace() const { return Trace; }
|
2016-10-15 01:57:55 +08:00
|
|
|
DataFlowGraph &getDFG() { return DFG; }
|
2016-01-13 01:23:48 +08:00
|
|
|
|
2017-08-02 05:20:10 +08:00
|
|
|
using EqualityMap = std::map<RegisterRef, RegisterRef>;
|
|
|
|
|
2016-01-19 04:43:57 +08:00
|
|
|
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
|
|
|
|
|
2016-01-13 01:23:48 +08:00
|
|
|
private:
|
|
|
|
const MachineDominatorTree &MDT;
|
|
|
|
DataFlowGraph &DFG;
|
2017-03-11 06:44:24 +08:00
|
|
|
Liveness L;
|
2017-08-02 05:20:10 +08:00
|
|
|
bool Trace = false;
|
2016-01-13 01:23:48 +08:00
|
|
|
|
2016-01-19 04:43:57 +08:00
|
|
|
// map: statement -> (map: dst reg -> src reg)
|
|
|
|
std::map<NodeId, EqualityMap> CopyMap;
|
2016-01-13 01:23:48 +08:00
|
|
|
std::vector<NodeId> Copies;
|
|
|
|
|
2016-01-19 04:43:57 +08:00
|
|
|
void recordCopy(NodeAddr<StmtNode*> SA, EqualityMap &EM);
|
2016-01-13 01:23:48 +08:00
|
|
|
bool scanBlock(MachineBasicBlock *B);
|
2017-03-11 06:44:24 +08:00
|
|
|
NodeId getLocalReachingDef(RegisterRef RefRR, NodeAddr<InstrNode*> IA);
|
2016-01-13 01:23:48 +08:00
|
|
|
};
|
|
|
|
|
2017-01-04 10:02:05 +08:00
|
|
|
} // end namespace rdf
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_HEXAGON_RDFCOPY_H
|