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; | |
|
Jim Stichnoth
2015/07/30 15:20:23
There are already a bunch of forward class declara
ascull
2015/07/30 17:29:59
Done.
Jim Stichnoth
2015/07/30 19:21:23
But remove it here?
ascull
2015/07/30 20:39:38
Done.
| |
| 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 23 matching lines...) Expand all Loading... | |
| 176 void doAddressOpt(); | 185 void doAddressOpt(); |
| 177 void doArgLowering(); | 186 void doArgLowering(); |
| 178 void doNopInsertion(); | 187 void doNopInsertion(); |
| 179 void genCode(); | 188 void genCode(); |
| 180 void genFrame(); | 189 void genFrame(); |
| 181 void livenessLightweight(); | 190 void livenessLightweight(); |
| 182 void liveness(LivenessMode Mode); | 191 void liveness(LivenessMode Mode); |
| 183 bool validateLiveness() const; | 192 bool validateLiveness() const; |
| 184 void contractEmptyNodes(); | 193 void contractEmptyNodes(); |
| 185 void doBranchOpt(); | 194 void doBranchOpt(); |
| 195 void markNodesForSandboxing(); | |
| 186 | 196 |
| 187 /// \name Manage the CurrentNode field. | 197 /// \name Manage the CurrentNode field. |
| 188 /// CurrentNode is used for validating the Variable::DefNode field during | 198 /// CurrentNode is used for validating the Variable::DefNode field during |
| 189 /// dumping/emitting. | 199 /// dumping/emitting. |
| 190 /// @{ | 200 /// @{ |
| 191 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; } | 201 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; } |
| 192 void resetCurrentNode() { setCurrentNode(nullptr); } | 202 void resetCurrentNode() { setCurrentNode(nullptr); } |
| 193 const CfgNode *getCurrentNode() const { return CurrentNode; } | 203 const CfgNode *getCurrentNode() const { return CurrentNode; } |
| 194 /// @} | 204 /// @} |
| 195 | 205 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 222 | 232 |
| 223 /// Adds a call to the ProfileSummary runtime function as the first | 233 /// Adds a call to the ProfileSummary runtime function as the first |
| 224 /// instruction in this CFG's entry block. | 234 /// instruction in this CFG's entry block. |
| 225 void addCallToProfileSummary(); | 235 void addCallToProfileSummary(); |
| 226 | 236 |
| 227 /// Iterates over the basic blocks in this CFG, adding profiling code to each | 237 /// 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 | 238 /// one of them. It returns a list with all the globals that the profiling |
| 229 /// code needs to be defined. | 239 /// code needs to be defined. |
| 230 void profileBlocks(); | 240 void profileBlocks(); |
| 231 | 241 |
| 242 /// Delete registered jump table placeholder instructions. This should only be | |
| 243 /// called once all repointing has taken place. | |
| 244 void deleteJumpTableInsts(); | |
| 245 /// Iterate through the registered jump tables and emit them. | |
| 246 void emitJumpTables(); | |
| 247 | |
| 232 GlobalContext *Ctx; | 248 GlobalContext *Ctx; |
| 233 uint32_t SequenceNumber; /// output order for emission | 249 uint32_t SequenceNumber; /// output order for emission |
| 234 VerboseMask VMask; | 250 VerboseMask VMask; |
| 235 IceString FunctionName = ""; | 251 IceString FunctionName = ""; |
| 236 Type ReturnType = IceType_void; | 252 Type ReturnType = IceType_void; |
| 237 bool IsInternalLinkage = false; | 253 bool IsInternalLinkage = false; |
| 238 bool HasError = false; | 254 bool HasError = false; |
| 239 bool FocusedTiming = false; | 255 bool FocusedTiming = false; |
| 240 IceString ErrorMessage = ""; | 256 IceString ErrorMessage = ""; |
| 241 CfgNode *Entry = nullptr; /// entry basic block | 257 CfgNode *Entry = nullptr; /// entry basic block |
| 242 NodeList Nodes; /// linearized node list; Entry should be first | 258 NodeList Nodes; /// linearized node list; Entry should be first |
| 243 std::vector<IceString> IdentifierNames; | 259 std::vector<IceString> IdentifierNames; |
| 244 InstNumberT NextInstNumber; | 260 InstNumberT NextInstNumber; |
| 245 VarList Variables; | 261 VarList Variables; |
| 246 VarList Args; /// subset of Variables, in argument order | 262 VarList Args; /// subset of Variables, in argument order |
| 247 VarList ImplicitArgs; /// subset of Variables | 263 VarList ImplicitArgs; /// subset of Variables |
| 248 std::unique_ptr<ArenaAllocator<>> Allocator; | 264 std::unique_ptr<ArenaAllocator<>> Allocator; |
| 249 std::unique_ptr<Liveness> Live; | 265 std::unique_ptr<Liveness> Live; |
| 250 std::unique_ptr<TargetLowering> Target; | 266 std::unique_ptr<TargetLowering> Target; |
| 251 std::unique_ptr<VariablesMetadata> VMetadata; | 267 std::unique_ptr<VariablesMetadata> VMetadata; |
| 252 std::unique_ptr<Assembler> TargetAssembler; | 268 std::unique_ptr<Assembler> TargetAssembler; |
| 253 /// Globals required by this CFG. Mostly used for the profiler's globals. | 269 /// Globals required by this CFG. Mostly used for the profiler's globals. |
| 254 std::unique_ptr<VariableDeclarationList> GlobalInits; | 270 std::unique_ptr<VariableDeclarationList> GlobalInits; |
| 271 std::vector<InstJumpTable *> JumpTables; | |
| 255 | 272 |
| 256 /// CurrentNode is maintained during dumping/emitting just for | 273 /// CurrentNode is maintained during dumping/emitting just for |
| 257 /// validating Variable::DefNode. Normally, a traversal over | 274 /// validating Variable::DefNode. Normally, a traversal over |
| 258 /// CfgNodes maintains this, but before global operations like | 275 /// CfgNodes maintains this, but before global operations like |
| 259 /// register allocation, resetCurrentNode() should be called to avoid | 276 /// register allocation, resetCurrentNode() should be called to avoid |
| 260 /// spurious validation failures. | 277 /// spurious validation failures. |
| 261 const CfgNode *CurrentNode = nullptr; | 278 const CfgNode *CurrentNode = nullptr; |
| 262 | 279 |
| 263 /// Maintain a pointer in TLS to the current Cfg being translated. | 280 /// Maintain a pointer in TLS to the current Cfg being translated. |
| 264 /// This is primarily for accessing its allocator statelessly, but | 281 /// This is primarily for accessing its allocator statelessly, but |
| 265 /// other uses are possible. | 282 /// other uses are possible. |
| 266 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); | 283 ICE_TLS_DECLARE_FIELD(const Cfg *, CurrentCfg); |
| 267 | 284 |
| 268 public: | 285 public: |
| 269 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } | 286 static void TlsInit() { ICE_TLS_INIT_FIELD(CurrentCfg); } |
| 270 }; | 287 }; |
| 271 | 288 |
| 272 } // end of namespace Ice | 289 } // end of namespace Ice |
| 273 | 290 |
| 274 #endif // SUBZERO_SRC_ICECFG_H | 291 #endif // SUBZERO_SRC_ICECFG_H |
| OLD | NEW |