OLD | NEW |
1 //===- subzero/src/IceCfg.h - Control flow graph ----------------*- C++ -*-===// | 1 //===- subzero/src/IceCfg.h - Control flow graph ----------------*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file declares the Cfg class, which represents the control flow | 10 // This file declares the Cfg class, which represents the control flow |
(...skipping 40 matching lines...) Loading... |
51 | 51 |
52 // Manage nodes (a.k.a. basic blocks, CfgNodes). | 52 // Manage nodes (a.k.a. basic blocks, CfgNodes). |
53 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; } | 53 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; } |
54 CfgNode *getEntryNode() const { return Entry; } | 54 CfgNode *getEntryNode() const { return Entry; } |
55 // Create a node and append it to the end of the linearized list. | 55 // Create a node and append it to the end of the linearized list. |
56 CfgNode *makeNode(const IceString &Name = ""); | 56 CfgNode *makeNode(const IceString &Name = ""); |
57 SizeT getNumNodes() const { return Nodes.size(); } | 57 SizeT getNumNodes() const { return Nodes.size(); } |
58 const NodeList &getNodes() const { return Nodes; } | 58 const NodeList &getNodes() const { return Nodes; } |
59 | 59 |
60 // Manage instruction numbering. | 60 // Manage instruction numbering. |
61 int newInstNumber() { return NextInstNumber++; } | 61 int32_t newInstNumber() { return NextInstNumber++; } |
62 | 62 |
63 // Manage Variables. | 63 // Manage Variables. |
64 Variable *makeVariable(Type Ty, const CfgNode *Node, | 64 Variable *makeVariable(Type Ty, const CfgNode *Node, |
65 const IceString &Name = ""); | 65 const IceString &Name = ""); |
66 SizeT getNumVariables() const { return Variables.size(); } | 66 SizeT getNumVariables() const { return Variables.size(); } |
67 const VarList &getVariables() const { return Variables; } | 67 const VarList &getVariables() const { return Variables; } |
68 | 68 |
69 // Manage arguments to the function. | 69 // Manage arguments to the function. |
70 void addArg(Variable *Arg); | 70 void addArg(Variable *Arg); |
71 const VarList &getArgs() const { return Args; } | 71 const VarList &getArgs() const { return Args; } |
72 | 72 |
| 73 // Miscellaneous accessors. |
| 74 TargetLowering *getTarget() const { return Target.get(); } |
| 75 bool hasComputedFrame() const; |
| 76 |
| 77 // Passes over the CFG. |
| 78 void translate(); |
73 // After the CFG is fully constructed, iterate over the nodes and | 79 // After the CFG is fully constructed, iterate over the nodes and |
74 // compute the predecessor edges, in the form of | 80 // compute the predecessor edges, in the form of |
75 // CfgNode::InEdges[]. | 81 // CfgNode::InEdges[]. |
76 void computePredecessors(); | 82 void computePredecessors(); |
| 83 void placePhiLoads(); |
| 84 void placePhiStores(); |
| 85 void deletePhis(); |
| 86 void genCode(); |
| 87 void genFrame(); |
77 | 88 |
78 // Manage the CurrentNode field, which is used for validating the | 89 // Manage the CurrentNode field, which is used for validating the |
79 // Variable::DefNode field during dumping/emitting. | 90 // Variable::DefNode field during dumping/emitting. |
80 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; } | 91 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; } |
81 const CfgNode *getCurrentNode() const { return CurrentNode; } | 92 const CfgNode *getCurrentNode() const { return CurrentNode; } |
82 | 93 |
| 94 void emit(); |
83 void dump(); | 95 void dump(); |
84 | 96 |
85 // Allocate data of type T using the per-Cfg allocator. | 97 // Allocate data of type T using the per-Cfg allocator. |
86 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } | 98 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } |
87 | 99 |
88 // Allocate an instruction of type T using the per-Cfg instruction allocator. | 100 // Allocate an instruction of type T using the per-Cfg instruction allocator. |
89 template <typename T> T *allocateInst() { return Allocator.Allocate<T>(); } | 101 template <typename T> T *allocateInst() { return Allocator.Allocate<T>(); } |
90 | 102 |
91 // Allocate an array of data of type T using the per-Cfg allocator. | 103 // Allocate an array of data of type T using the per-Cfg allocator. |
92 template <typename T> T *allocateArrayOf(size_t NumElems) { | 104 template <typename T> T *allocateArrayOf(size_t NumElems) { |
(...skipping 24 matching lines...) Loading... |
117 llvm::BumpPtrAllocator Allocator; | 129 llvm::BumpPtrAllocator Allocator; |
118 | 130 |
119 GlobalContext *Ctx; | 131 GlobalContext *Ctx; |
120 IceString FunctionName; | 132 IceString FunctionName; |
121 Type ReturnType; | 133 Type ReturnType; |
122 bool IsInternalLinkage; | 134 bool IsInternalLinkage; |
123 bool HasError; | 135 bool HasError; |
124 IceString ErrorMessage; | 136 IceString ErrorMessage; |
125 CfgNode *Entry; // entry basic block | 137 CfgNode *Entry; // entry basic block |
126 NodeList Nodes; // linearized node list; Entry should be first | 138 NodeList Nodes; // linearized node list; Entry should be first |
127 int NextInstNumber; | 139 int32_t NextInstNumber; |
128 VarList Variables; | 140 VarList Variables; |
129 VarList Args; // subset of Variables, in argument order | 141 VarList Args; // subset of Variables, in argument order |
| 142 llvm::OwningPtr<TargetLowering> Target; |
130 | 143 |
131 // CurrentNode is maintained during dumping/emitting just for | 144 // CurrentNode is maintained during dumping/emitting just for |
132 // validating Variable::DefNode. Normally, a traversal over | 145 // validating Variable::DefNode. Normally, a traversal over |
133 // CfgNodes maintains this, but before global operations like | 146 // CfgNodes maintains this, but before global operations like |
134 // register allocation, setCurrentNode(NULL) should be called to | 147 // register allocation, setCurrentNode(NULL) should be called to |
135 // avoid spurious validation failures. | 148 // avoid spurious validation failures. |
136 const CfgNode *CurrentNode; | 149 const CfgNode *CurrentNode; |
137 | 150 |
138 Cfg(const Cfg &) LLVM_DELETED_FUNCTION; | 151 Cfg(const Cfg &) LLVM_DELETED_FUNCTION; |
139 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION; | 152 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION; |
140 }; | 153 }; |
141 | 154 |
142 } // end of namespace Ice | 155 } // end of namespace Ice |
143 | 156 |
144 #endif // SUBZERO_SRC_ICECFG_H | 157 #endif // SUBZERO_SRC_ICECFG_H |
OLD | NEW |