| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const VarList &getImplicitArgs() const { return ImplicitArgs; } | 121 const VarList &getImplicitArgs() const { return ImplicitArgs; } |
| 122 | 122 |
| 123 // Miscellaneous accessors. | 123 // Miscellaneous accessors. |
| 124 TargetLowering *getTarget() const { return Target.get(); } | 124 TargetLowering *getTarget() const { return Target.get(); } |
| 125 VariablesMetadata *getVMetadata() const { return VMetadata.get(); } | 125 VariablesMetadata *getVMetadata() const { return VMetadata.get(); } |
| 126 Liveness *getLiveness() const { return Live.get(); } | 126 Liveness *getLiveness() const { return Live.get(); } |
| 127 template <typename T = Assembler> T *getAssembler() const { | 127 template <typename T = Assembler> T *getAssembler() const { |
| 128 return static_cast<T *>(TargetAssembler.get()); | 128 return static_cast<T *>(TargetAssembler.get()); |
| 129 } | 129 } |
| 130 Assembler *releaseAssembler() { return TargetAssembler.release(); } | 130 Assembler *releaseAssembler() { return TargetAssembler.release(); } |
| 131 std::unique_ptr<VariableDeclarationList> getGlobalInits() { |
| 132 return std::move(GlobalInits); |
| 133 } |
| 131 bool hasComputedFrame() const; | 134 bool hasComputedFrame() const; |
| 132 bool getFocusedTiming() const { return FocusedTiming; } | 135 bool getFocusedTiming() const { return FocusedTiming; } |
| 133 void setFocusedTiming() { FocusedTiming = true; } | 136 void setFocusedTiming() { FocusedTiming = true; } |
| 134 | 137 |
| 138 // Returns true if Var is a global variable that is used by the profiling |
| 139 // code. |
| 140 static bool isProfileGlobal(const VariableDeclaration &Var); |
| 141 |
| 135 // Passes over the CFG. | 142 // Passes over the CFG. |
| 136 void translate(); | 143 void translate(); |
| 137 // After the CFG is fully constructed, iterate over the nodes and | 144 // After the CFG is fully constructed, iterate over the nodes and |
| 138 // compute the predecessor and successor edges, in the form of | 145 // compute the predecessor and successor edges, in the form of |
| 139 // CfgNode::InEdges[] and CfgNode::OutEdges[]. | 146 // CfgNode::InEdges[] and CfgNode::OutEdges[]. |
| 140 void computeInOutEdges(); | 147 void computeInOutEdges(); |
| 141 void renumberInstructions(); | 148 void renumberInstructions(); |
| 142 void placePhiLoads(); | 149 void placePhiLoads(); |
| 143 void placePhiStores(); | 150 void placePhiStores(); |
| 144 void deletePhis(); | 151 void deletePhis(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 188 } |
| 182 | 189 |
| 183 // Deallocate data that was allocated via allocateArrayOf<T>(). | 190 // Deallocate data that was allocated via allocateArrayOf<T>(). |
| 184 template <typename T> void deallocateArrayOf(T *Array) { | 191 template <typename T> void deallocateArrayOf(T *Array) { |
| 185 Allocator->Deallocate(Array); | 192 Allocator->Deallocate(Array); |
| 186 } | 193 } |
| 187 | 194 |
| 188 private: | 195 private: |
| 189 Cfg(GlobalContext *Ctx, uint32_t SequenceNumber); | 196 Cfg(GlobalContext *Ctx, uint32_t SequenceNumber); |
| 190 | 197 |
| 198 // Adds a call to the ProfileSummary runtime function as the first instruction |
| 199 // in this CFG's entry block. |
| 200 void addCallToProfileSummary(); |
| 201 |
| 202 // Iterates over the basic blocks in this CFG, adding profiling code to each |
| 203 // one of them. It returns a list with all the globals that the profiling code |
| 204 // needs to be defined. |
| 205 void profileBlocks(); |
| 206 |
| 191 GlobalContext *Ctx; | 207 GlobalContext *Ctx; |
| 192 uint32_t SequenceNumber; // output order for emission | 208 uint32_t SequenceNumber; // output order for emission |
| 193 VerboseMask VMask; | 209 VerboseMask VMask; |
| 194 IceString FunctionName; | 210 IceString FunctionName; |
| 195 Type ReturnType; | 211 Type ReturnType; |
| 196 bool IsInternalLinkage; | 212 bool IsInternalLinkage; |
| 197 bool HasError; | 213 bool HasError; |
| 198 bool FocusedTiming; | 214 bool FocusedTiming; |
| 199 IceString ErrorMessage; | 215 IceString ErrorMessage; |
| 200 CfgNode *Entry; // entry basic block | 216 CfgNode *Entry; // entry basic block |
| 201 NodeList Nodes; // linearized node list; Entry should be first | 217 NodeList Nodes; // linearized node list; Entry should be first |
| 202 std::vector<IceString> IdentifierNames; | 218 std::vector<IceString> IdentifierNames; |
| 203 InstNumberT NextInstNumber; | 219 InstNumberT NextInstNumber; |
| 204 VarList Variables; | 220 VarList Variables; |
| 205 VarList Args; // subset of Variables, in argument order | 221 VarList Args; // subset of Variables, in argument order |
| 206 VarList ImplicitArgs; // subset of Variables | 222 VarList ImplicitArgs; // subset of Variables |
| 207 std::unique_ptr<ArenaAllocator<>> Allocator; | 223 std::unique_ptr<ArenaAllocator<>> Allocator; |
| 208 std::unique_ptr<Liveness> Live; | 224 std::unique_ptr<Liveness> Live; |
| 209 std::unique_ptr<TargetLowering> Target; | 225 std::unique_ptr<TargetLowering> Target; |
| 210 std::unique_ptr<VariablesMetadata> VMetadata; | 226 std::unique_ptr<VariablesMetadata> VMetadata; |
| 211 std::unique_ptr<Assembler> TargetAssembler; | 227 std::unique_ptr<Assembler> TargetAssembler; |
| 228 // Globals required by this CFG. Mostly used for the profiler's globals. |
| 229 std::unique_ptr<VariableDeclarationList> GlobalInits; |
| 212 | 230 |
| 213 // CurrentNode is maintained during dumping/emitting just for | 231 // CurrentNode is maintained during dumping/emitting just for |
| 214 // validating Variable::DefNode. Normally, a traversal over | 232 // validating Variable::DefNode. Normally, a traversal over |
| 215 // CfgNodes maintains this, but before global operations like | 233 // CfgNodes maintains this, but before global operations like |
| 216 // register allocation, resetCurrentNode() should be called to avoid | 234 // register allocation, resetCurrentNode() should be called to avoid |
| 217 // spurious validation failures. | 235 // spurious validation failures. |
| 218 const CfgNode *CurrentNode; | 236 const CfgNode *CurrentNode; |
| 219 | 237 |
| 220 // Maintain a pointer in TLS to the current Cfg being translated. | 238 // Maintain a pointer in TLS to the current Cfg being translated. |
| 221 // This is primarily for accessing its allocator statelessly, but | 239 // This is primarily for accessing its allocator statelessly, but |
| 222 // other uses are possible. | 240 // other uses are possible. |
| 223 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); | 241 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); |
| 224 | 242 |
| 225 public: | 243 public: |
| 226 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } | 244 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } |
| 227 }; | 245 }; |
| 228 | 246 |
| 229 } // end of namespace Ice | 247 } // end of namespace Ice |
| 230 | 248 |
| 231 #endif // SUBZERO_SRC_ICECFG_H | 249 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |