OLD | NEW |
1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===// | 1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- 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 representation of function declarations, | 10 // This file declares the representation of function declarations, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const GlobalDeclarationKind Kind; | 84 const GlobalDeclarationKind Kind; |
85 IceString Name; | 85 IceString Name; |
86 llvm::GlobalValue::LinkageTypes Linkage; | 86 llvm::GlobalValue::LinkageTypes Linkage; |
87 }; | 87 }; |
88 | 88 |
89 // Models a function declaration. This includes the type signature of | 89 // Models a function declaration. This includes the type signature of |
90 // the function, its calling conventions, and its linkage. | 90 // the function, its calling conventions, and its linkage. |
91 class FunctionDeclaration : public GlobalDeclaration { | 91 class FunctionDeclaration : public GlobalDeclaration { |
92 FunctionDeclaration(const FunctionDeclaration &) = delete; | 92 FunctionDeclaration(const FunctionDeclaration &) = delete; |
93 FunctionDeclaration &operator=(const FunctionDeclaration &) = delete; | 93 FunctionDeclaration &operator=(const FunctionDeclaration &) = delete; |
94 friend class GlobalContext; | |
95 | 94 |
96 public: | 95 public: |
97 static FunctionDeclaration *create(GlobalContext *Ctx, | 96 static FunctionDeclaration *create(const FuncSigType &Signature, |
98 const FuncSigType &Signature, | |
99 llvm::CallingConv::ID CallingConv, | 97 llvm::CallingConv::ID CallingConv, |
100 llvm::GlobalValue::LinkageTypes Linkage, | 98 llvm::GlobalValue::LinkageTypes Linkage, |
101 bool IsProto); | 99 bool IsProto); |
102 ~FunctionDeclaration() final {} | 100 ~FunctionDeclaration() final {} |
103 const FuncSigType &getSignature() const { return Signature; } | 101 const FuncSigType &getSignature() const { return Signature; } |
104 llvm::CallingConv::ID getCallingConv() const { return CallingConv; } | 102 llvm::CallingConv::ID getCallingConv() const { return CallingConv; } |
105 // isProto implies that there isn't a (local) definition for the function. | 103 // isProto implies that there isn't a (local) definition for the function. |
106 bool isProto() const { return IsProto; } | 104 bool isProto() const { return IsProto; } |
107 static bool classof(const GlobalDeclaration *Addr) { | 105 static bool classof(const GlobalDeclaration *Addr) { |
108 return Addr->getKind() == FunctionDeclarationKind; | 106 return Addr->getKind() == FunctionDeclarationKind; |
(...skipping 13 matching lines...) Expand all Loading... |
122 llvm::CallingConv::ID CallingConv, | 120 llvm::CallingConv::ID CallingConv, |
123 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) | 121 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) |
124 : GlobalDeclaration(FunctionDeclarationKind, Linkage), | 122 : GlobalDeclaration(FunctionDeclarationKind, Linkage), |
125 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} | 123 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} |
126 }; | 124 }; |
127 | 125 |
128 /// Models a global variable declaration, and its initializers. | 126 /// Models a global variable declaration, and its initializers. |
129 class VariableDeclaration : public GlobalDeclaration { | 127 class VariableDeclaration : public GlobalDeclaration { |
130 VariableDeclaration(const VariableDeclaration &) = delete; | 128 VariableDeclaration(const VariableDeclaration &) = delete; |
131 VariableDeclaration &operator=(const VariableDeclaration &) = delete; | 129 VariableDeclaration &operator=(const VariableDeclaration &) = delete; |
132 friend class GlobalContext; | |
133 // TODO(kschimpf) Factor out allocation of initializers into the | |
134 // global context, so that memory allocation/collection can be | |
135 // optimized. | |
136 public: | 130 public: |
137 /// Base class for a global variable initializer. | 131 /// Base class for a global variable initializer. |
138 class Initializer { | 132 class Initializer { |
139 Initializer(const Initializer &) = delete; | 133 Initializer(const Initializer &) = delete; |
140 Initializer &operator=(const Initializer &) = delete; | 134 Initializer &operator=(const Initializer &) = delete; |
141 | 135 |
142 public: | 136 public: |
143 /// Discriminator for LLVM-style RTTI. | 137 /// Discriminator for LLVM-style RTTI. |
144 enum InitializerKind { | 138 enum InitializerKind { |
145 DataInitializerKind, | 139 DataInitializerKind, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 private: | 235 private: |
242 // The global declaration used in the relocation. | 236 // The global declaration used in the relocation. |
243 const GlobalDeclaration *Declaration; | 237 const GlobalDeclaration *Declaration; |
244 // The offset to add to the relocation. | 238 // The offset to add to the relocation. |
245 const RelocOffsetT Offset; | 239 const RelocOffsetT Offset; |
246 }; | 240 }; |
247 | 241 |
248 /// Models the list of initializers. | 242 /// Models the list of initializers. |
249 typedef std::vector<Initializer *> InitializerListType; | 243 typedef std::vector<Initializer *> InitializerListType; |
250 | 244 |
251 static VariableDeclaration *create(GlobalContext *Ctx); | 245 static VariableDeclaration *create(); |
252 ~VariableDeclaration() final; | 246 ~VariableDeclaration() final; |
253 | 247 |
254 const InitializerListType &getInitializers() const { return Initializers; } | 248 const InitializerListType &getInitializers() const { return Initializers; } |
255 bool getIsConstant() const { return IsConstant; } | 249 bool getIsConstant() const { return IsConstant; } |
256 void setIsConstant(bool NewValue) { IsConstant = NewValue; } | 250 void setIsConstant(bool NewValue) { IsConstant = NewValue; } |
257 uint32_t getAlignment() const { return Alignment; } | 251 uint32_t getAlignment() const { return Alignment; } |
258 void setAlignment(uint32_t NewAlignment) { Alignment = NewAlignment; } | 252 void setAlignment(uint32_t NewAlignment) { Alignment = NewAlignment; } |
259 bool hasInitializer() const { return !Initializers.empty(); } | 253 bool hasInitializer() const { return !Initializers.empty(); } |
260 bool hasNonzeroInitializer() const { | 254 bool hasNonzeroInitializer() const { |
261 return !(Initializers.size() == 1 && | 255 return !(Initializers.size() == 1 && |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 template <class StreamType> | 312 template <class StreamType> |
319 inline StreamType &operator<<(StreamType &Stream, | 313 inline StreamType &operator<<(StreamType &Stream, |
320 const GlobalDeclaration &Addr) { | 314 const GlobalDeclaration &Addr) { |
321 Addr.dump(Stream); | 315 Addr.dump(Stream); |
322 return Stream; | 316 return Stream; |
323 } | 317 } |
324 | 318 |
325 } // end of namespace Ice | 319 } // end of namespace Ice |
326 | 320 |
327 #endif // SUBZERO_SRC_ICEGLOBALINITS_H | 321 #endif // SUBZERO_SRC_ICEGLOBALINITS_H |
OLD | NEW |