Chromium Code Reviews| 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 /// \file | 10 /// \file |
| 11 /// This file declares the Cfg class, which represents the control flow | 11 /// This file declares the Cfg class, which represents the control flow |
| 12 /// graph and the overall per-function compilation context. | 12 /// graph and the overall per-function compilation context. |
| 13 /// | 13 /// |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICECFG_H | 16 #ifndef SUBZERO_SRC_ICECFG_H |
| 17 #define SUBZERO_SRC_ICECFG_H | 17 #define SUBZERO_SRC_ICECFG_H |
| 18 | 18 |
| 19 #include "IceAssembler.h" | 19 #include "IceAssembler.h" |
| 20 #include "IceClFlags.h" | 20 #include "IceClFlags.h" |
| 21 #include "IceDefs.h" | 21 #include "IceDefs.h" |
| 22 #include "IceGlobalContext.h" | 22 #include "IceGlobalContext.h" |
| 23 #include "IceTypes.h" | 23 #include "IceTypes.h" |
| 24 | 24 |
| 25 namespace Ice { | 25 namespace Ice { |
| 26 | 26 |
| 27 class InstJumpTable; | |
| 28 | |
| 27 class Cfg { | 29 class Cfg { |
| 28 Cfg() = delete; | 30 Cfg() = delete; |
| 29 Cfg(const Cfg &) = delete; | 31 Cfg(const Cfg &) = delete; |
| 30 Cfg &operator=(const Cfg &) = delete; | 32 Cfg &operator=(const Cfg &) = delete; |
| 31 | 33 |
| 32 public: | 34 public: |
| 33 ~Cfg(); | 35 ~Cfg(); |
| 34 | 36 |
| 35 static std::unique_ptr<Cfg> create(GlobalContext *Ctx, | 37 static std::unique_ptr<Cfg> create(GlobalContext *Ctx, |
| 36 uint32_t SequenceNumber) { | 38 uint32_t SequenceNumber) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 | 135 |
| 134 /// \name Manage arguments to the function. | 136 /// \name Manage arguments to the function. |
| 135 /// @{ | 137 /// @{ |
| 136 void addArg(Variable *Arg); | 138 void addArg(Variable *Arg); |
| 137 const VarList &getArgs() const { return Args; } | 139 const VarList &getArgs() const { return Args; } |
| 138 VarList &getArgs() { return Args; } | 140 VarList &getArgs() { return Args; } |
| 139 void addImplicitArg(Variable *Arg); | 141 void addImplicitArg(Variable *Arg); |
| 140 const VarList &getImplicitArgs() const { return ImplicitArgs; } | 142 const VarList &getImplicitArgs() const { return ImplicitArgs; } |
| 141 /// @} | 143 /// @} |
| 142 | 144 |
| 145 /// \name Manage the jump tables. | |
| 146 /// @{ | |
| 147 void addJumpTable(InstJumpTable *JumpTable) { | |
| 148 JumpTables.emplace_back(JumpTable); | |
| 149 } | |
| 150 /// @} | |
| 151 | |
| 143 /// \name Miscellaneous accessors. | 152 /// \name Miscellaneous accessors. |
| 144 /// @{ | 153 /// @{ |
| 145 TargetLowering *getTarget() const { return Target.get(); } | 154 TargetLowering *getTarget() const { return Target.get(); } |
| 146 VariablesMetadata *getVMetadata() const { return VMetadata.get(); } | 155 VariablesMetadata *getVMetadata() const { return VMetadata.get(); } |
| 147 Liveness *getLiveness() const { return Live.get(); } | 156 Liveness *getLiveness() const { return Live.get(); } |
| 148 template <typename T = Assembler> T *getAssembler() const { | 157 template <typename T = Assembler> T *getAssembler() const { |
| 149 return llvm::dyn_cast<T>(TargetAssembler.get()); | 158 return llvm::dyn_cast<T>(TargetAssembler.get()); |
| 150 } | 159 } |
| 151 Assembler *releaseAssembler() { return TargetAssembler.release(); } | 160 Assembler *releaseAssembler() { return TargetAssembler.release(); } |
| 152 std::unique_ptr<VariableDeclarationList> getGlobalInits() { | 161 std::unique_ptr<VariableDeclarationList> getGlobalInits() { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 231 |
| 223 /// Adds a call to the ProfileSummary runtime function as the first | 232 /// Adds a call to the ProfileSummary runtime function as the first |
| 224 /// instruction in this CFG's entry block. | 233 /// instruction in this CFG's entry block. |
| 225 void addCallToProfileSummary(); | 234 void addCallToProfileSummary(); |
| 226 | 235 |
| 227 /// Iterates over the basic blocks in this CFG, adding profiling code to each | 236 /// Iterates over the basic blocks in this CFG, adding profiling code to each |
| 228 /// one of them. It returns a list with all the globals that the profiling | 237 /// one of them. It returns a list with all the globals that the profiling |
| 229 /// code needs to be defined. | 238 /// code needs to be defined. |
| 230 void profileBlocks(); | 239 void profileBlocks(); |
| 231 | 240 |
| 241 /// Delete registered jump table placeholder instructions. This should only be | |
| 242 /// called once all repointing has taken palce. | |
|
jvoung (off chromium)
2015/07/29 21:31:16
palce -> place
ascull
2015/07/29 22:43:04
Done.
| |
| 243 void deleteJumpTableInsts(); | |
| 244 /// Iterate through the registered jump tables and emit them. | |
| 245 void emitJumpTables(); | |
| 246 | |
| 232 GlobalContext *Ctx; | 247 GlobalContext *Ctx; |
| 233 uint32_t SequenceNumber; /// output order for emission | 248 uint32_t SequenceNumber; /// output order for emission |
| 234 VerboseMask VMask; | 249 VerboseMask VMask; |
| 235 IceString FunctionName = ""; | 250 IceString FunctionName = ""; |
| 236 Type ReturnType = IceType_void; | 251 Type ReturnType = IceType_void; |
| 237 bool IsInternalLinkage = false; | 252 bool IsInternalLinkage = false; |
| 238 bool HasError = false; | 253 bool HasError = false; |
| 239 bool FocusedTiming = false; | 254 bool FocusedTiming = false; |
| 240 IceString ErrorMessage = ""; | 255 IceString ErrorMessage = ""; |
| 241 CfgNode *Entry = nullptr; /// entry basic block | 256 CfgNode *Entry = nullptr; /// entry basic block |
| 242 NodeList Nodes; /// linearized node list; Entry should be first | 257 NodeList Nodes; /// linearized node list; Entry should be first |
| 243 std::vector<IceString> IdentifierNames; | 258 std::vector<IceString> IdentifierNames; |
| 244 InstNumberT NextInstNumber; | 259 InstNumberT NextInstNumber; |
| 245 VarList Variables; | 260 VarList Variables; |
| 246 VarList Args; /// subset of Variables, in argument order | 261 VarList Args; /// subset of Variables, in argument order |
| 247 VarList ImplicitArgs; /// subset of Variables | 262 VarList ImplicitArgs; /// subset of Variables |
| 248 std::unique_ptr<ArenaAllocator<>> Allocator; | 263 std::unique_ptr<ArenaAllocator<>> Allocator; |
| 249 std::unique_ptr<Liveness> Live; | 264 std::unique_ptr<Liveness> Live; |
| 250 std::unique_ptr<TargetLowering> Target; | 265 std::unique_ptr<TargetLowering> Target; |
| 251 std::unique_ptr<VariablesMetadata> VMetadata; | 266 std::unique_ptr<VariablesMetadata> VMetadata; |
| 252 std::unique_ptr<Assembler> TargetAssembler; | 267 std::unique_ptr<Assembler> TargetAssembler; |
| 253 /// Globals required by this CFG. Mostly used for the profiler's globals. | 268 /// Globals required by this CFG. Mostly used for the profiler's globals. |
| 254 std::unique_ptr<VariableDeclarationList> GlobalInits; | 269 std::unique_ptr<VariableDeclarationList> GlobalInits; |
| 270 std::vector<InstJumpTable *> JumpTables; | |
| 255 | 271 |
| 256 /// CurrentNode is maintained during dumping/emitting just for | 272 /// CurrentNode is maintained during dumping/emitting just for |
| 257 /// validating Variable::DefNode. Normally, a traversal over | 273 /// validating Variable::DefNode. Normally, a traversal over |
| 258 /// CfgNodes maintains this, but before global operations like | 274 /// CfgNodes maintains this, but before global operations like |
| 259 /// register allocation, resetCurrentNode() should be called to avoid | 275 /// register allocation, resetCurrentNode() should be called to avoid |
| 260 /// spurious validation failures. | 276 /// spurious validation failures. |
| 261 const CfgNode *CurrentNode = nullptr; | 277 const CfgNode *CurrentNode = nullptr; |
| 262 | 278 |
| 263 /// Maintain a pointer in TLS to the current Cfg being translated. | 279 /// Maintain a pointer in TLS to the current Cfg being translated. |
| 264 /// This is primarily for accessing its allocator statelessly, but | 280 /// This is primarily for accessing its allocator statelessly, but |
| 265 /// other uses are possible. | 281 /// other uses are possible. |
| 266 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); | 282 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); |
| 267 | 283 |
| 268 public: | 284 public: |
| 269 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } | 285 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } |
| 270 }; | 286 }; |
| 271 | 287 |
| 272 } // end of namespace Ice | 288 } // end of namespace Ice |
| 273 | 289 |
| 274 #endif // SUBZERO_SRC_ICECFG_H | 290 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |