blob: 02531b94c9b04ef4a701fa1525f7cdb69d6facc4 [file] [log] [blame]
Krzysztof Parzyszekc09d6302016-01-12 17:23:48 +00001//===--- RDFCopy.h --------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef RDF_COPY_H
11#define RDF_COPY_H
12
13#include "RDFGraph.h"
14#include <map>
15#include <vector>
16
17namespace llvm {
18 class MachineBasicBlock;
19 class MachineDominatorTree;
20 class MachineInstr;
21}
22
23namespace rdf {
24 struct CopyPropagation {
25 CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg),
26 Trace(false) {}
27
28 bool run();
29 void trace(bool On) { Trace = On; }
30 bool trace() const { return Trace; }
31
32 private:
33 const MachineDominatorTree &MDT;
34 DataFlowGraph &DFG;
35 DataFlowGraph::DefStackMap DefM;
36 bool Trace;
37
38 // map: register -> (map: stmt -> reaching def)
39 std::map<RegisterRef,std::map<NodeId,NodeId>> RDefMap;
40 std::vector<NodeId> Copies;
41
42 void recordCopy(NodeAddr<StmtNode*> SA, MachineInstr *MI);
43 void updateMap(NodeAddr<InstrNode*> IA);
44 bool scanBlock(MachineBasicBlock *B);
45 };
46}
47
48#endif