2016-01-13 01:23:48 +08:00
|
|
|
//===--- RDFCopy.h --------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef RDF_COPY_H
|
|
|
|
#define RDF_COPY_H
|
|
|
|
|
|
|
|
#include "RDFGraph.h"
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MachineBasicBlock;
|
|
|
|
class MachineDominatorTree;
|
|
|
|
class MachineInstr;
|
|
|
|
|
|
|
|
namespace rdf {
|
|
|
|
struct CopyPropagation {
|
|
|
|
CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
|
|
|
|
Trace(false) {}
|
2016-01-19 04:43:57 +08:00
|
|
|
virtual ~CopyPropagation() {}
|
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
|
|
|
|
2016-01-19 04:43:57 +08:00
|
|
|
typedef std::map<RegisterRef, RegisterRef> EqualityMap;
|
|
|
|
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM);
|
|
|
|
|
2016-01-13 01:23:48 +08:00
|
|
|
private:
|
|
|
|
const MachineDominatorTree &MDT;
|
|
|
|
DataFlowGraph &DFG;
|
|
|
|
DataFlowGraph::DefStackMap DefM;
|
|
|
|
bool Trace;
|
|
|
|
|
|
|
|
// map: register -> (map: stmt -> reaching def)
|
|
|
|
std::map<RegisterRef,std::map<NodeId,NodeId>> RDefMap;
|
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
|
|
|
void updateMap(NodeAddr<InstrNode*> IA);
|
|
|
|
bool scanBlock(MachineBasicBlock *B);
|
|
|
|
};
|
2016-05-27 18:06:40 +08:00
|
|
|
} // namespace rdf
|
|
|
|
} // namespace llvm
|
2016-01-13 01:23:48 +08:00
|
|
|
|
|
|
|
#endif
|