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 10 matching lines...) Expand all Loading... |
21 | 21 |
22 #include "assembler.h" | 22 #include "assembler.h" |
23 #include "IceClFlags.h" | 23 #include "IceClFlags.h" |
24 #include "IceDefs.h" | 24 #include "IceDefs.h" |
25 #include "IceGlobalContext.h" | 25 #include "IceGlobalContext.h" |
26 #include "IceTypes.h" | 26 #include "IceTypes.h" |
27 | 27 |
28 namespace Ice { | 28 namespace Ice { |
29 | 29 |
30 class Cfg { | 30 class Cfg { |
| 31 Cfg(const Cfg &) = delete; |
| 32 Cfg &operator=(const Cfg &) = delete; |
| 33 |
31 public: | 34 public: |
32 Cfg(GlobalContext *Ctx); | 35 Cfg(GlobalContext *Ctx); |
33 ~Cfg(); | 36 ~Cfg(); |
34 | 37 |
35 GlobalContext *getContext() const { return Ctx; } | 38 GlobalContext *getContext() const { return Ctx; } |
36 | 39 |
37 // Manage the name and return type of the function being translated. | 40 // Manage the name and return type of the function being translated. |
38 void setFunctionName(const IceString &Name) { FunctionName = Name; } | 41 void setFunctionName(const IceString &Name) { FunctionName = Name; } |
39 IceString getFunctionName() const { return FunctionName; } | 42 IceString getFunctionName() const { return FunctionName; } |
40 void setReturnType(Type Ty) { ReturnType = Ty; } | 43 void setReturnType(Type Ty) { ReturnType = Ty; } |
(...skipping 19 matching lines...) Expand all Loading... |
60 SizeT getNumNodes() const { return Nodes.size(); } | 63 SizeT getNumNodes() const { return Nodes.size(); } |
61 const NodeList &getNodes() const { return Nodes; } | 64 const NodeList &getNodes() const { return Nodes; } |
62 | 65 |
63 // Manage instruction numbering. | 66 // Manage instruction numbering. |
64 InstNumberT newInstNumber() { return NextInstNumber++; } | 67 InstNumberT newInstNumber() { return NextInstNumber++; } |
65 InstNumberT getNextInstNumber() const { return NextInstNumber; } | 68 InstNumberT getNextInstNumber() const { return NextInstNumber; } |
66 | 69 |
67 // Manage Variables. | 70 // Manage Variables. |
68 // Create a new Variable with a particular type and an optional | 71 // Create a new Variable with a particular type and an optional |
69 // name. The Node argument is the node where the variable is defined. | 72 // name. The Node argument is the node where the variable is defined. |
70 template <typename T> T *makeVariable(Type Ty, const IceString &Name = "") { | 73 template <typename T = Variable> |
| 74 T *makeVariable(Type Ty, const IceString &Name = "") { |
71 SizeT Index = Variables.size(); | 75 SizeT Index = Variables.size(); |
72 T *Var = T::create(this, Ty, Index, Name); | 76 T *Var = T::create(this, Ty, Index, Name); |
73 Variables.push_back(Var); | 77 Variables.push_back(Var); |
74 return Var; | 78 return Var; |
75 } | 79 } |
76 // TODO(stichnot): Remove this function with C++11, and use default | |
77 // argument <typename T=Variable> above. | |
78 Variable *makeVariable(Type Ty, const IceString &Name = ""); | |
79 SizeT getNumVariables() const { return Variables.size(); } | 80 SizeT getNumVariables() const { return Variables.size(); } |
80 const VarList &getVariables() const { return Variables; } | 81 const VarList &getVariables() const { return Variables; } |
81 | 82 |
82 // Manage arguments to the function. | 83 // Manage arguments to the function. |
83 void addArg(Variable *Arg); | 84 void addArg(Variable *Arg); |
84 const VarList &getArgs() const { return Args; } | 85 const VarList &getArgs() const { return Args; } |
85 VarList &getArgs() { return Args; } | 86 VarList &getArgs() { return Args; } |
86 void addImplicitArg(Variable *Arg); | 87 void addImplicitArg(Variable *Arg); |
87 const VarList &getImplicitArgs() const { return ImplicitArgs; } | 88 const VarList &getImplicitArgs() const { return ImplicitArgs; } |
88 | 89 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 std::unique_ptr<TargetLowering> Target; | 181 std::unique_ptr<TargetLowering> Target; |
181 std::unique_ptr<VariablesMetadata> VMetadata; | 182 std::unique_ptr<VariablesMetadata> VMetadata; |
182 std::unique_ptr<Assembler> TargetAssembler; | 183 std::unique_ptr<Assembler> TargetAssembler; |
183 | 184 |
184 // CurrentNode is maintained during dumping/emitting just for | 185 // CurrentNode is maintained during dumping/emitting just for |
185 // validating Variable::DefNode. Normally, a traversal over | 186 // validating Variable::DefNode. Normally, a traversal over |
186 // CfgNodes maintains this, but before global operations like | 187 // CfgNodes maintains this, but before global operations like |
187 // register allocation, resetCurrentNode() should be called to avoid | 188 // register allocation, resetCurrentNode() should be called to avoid |
188 // spurious validation failures. | 189 // spurious validation failures. |
189 const CfgNode *CurrentNode; | 190 const CfgNode *CurrentNode; |
190 | |
191 Cfg(const Cfg &) = delete; | |
192 Cfg &operator=(const Cfg &) = delete; | |
193 }; | 191 }; |
194 | 192 |
195 } // end of namespace Ice | 193 } // end of namespace Ice |
196 | 194 |
197 #endif // SUBZERO_SRC_ICECFG_H | 195 #endif // SUBZERO_SRC_ICECFG_H |
OLD | NEW |