Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: src/IceGlobalInits.h

Issue 1216963007: Doxygenize the documentation comments (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void dump(Ostream &Stream) const { 72 void dump(Ostream &Stream) const {
73 if (!BuildDefs::dump()) 73 if (!BuildDefs::dump())
74 return; 74 return;
75 GlobalContext *const Ctx = nullptr; 75 GlobalContext *const Ctx = nullptr;
76 dump(Ctx, Stream); 76 dump(Ctx, Stream);
77 } 77 }
78 78
79 /// Returns true if when emitting names, we should suppress mangling. 79 /// Returns true if when emitting names, we should suppress mangling.
80 virtual bool getSuppressMangling() const = 0; 80 virtual bool getSuppressMangling() const = 0;
81 81
82 // Mangles name for cross tests, unless external and not defined locally 82 /// Mangles name for cross tests, unless external and not defined locally
83 // (so that relocations accross pnacl-sz and pnacl-llc will work). 83 /// (so that relocations accross pnacl-sz and pnacl-llc will work).
84 virtual IceString mangleName(GlobalContext *Ctx) const { 84 virtual IceString mangleName(GlobalContext *Ctx) const {
85 return getSuppressMangling() ? Name : Ctx->mangleName(Name); 85 return getSuppressMangling() ? Name : Ctx->mangleName(Name);
86 } 86 }
87 87
88 protected: 88 protected:
89 GlobalDeclaration(GlobalDeclarationKind Kind, 89 GlobalDeclaration(GlobalDeclarationKind Kind,
90 llvm::GlobalValue::LinkageTypes Linkage) 90 llvm::GlobalValue::LinkageTypes Linkage)
91 : Kind(Kind), Linkage(Linkage) {} 91 : Kind(Kind), Linkage(Linkage) {}
92 92
93 const GlobalDeclarationKind Kind; 93 const GlobalDeclarationKind Kind;
94 IceString Name; 94 IceString Name;
95 llvm::GlobalValue::LinkageTypes Linkage; 95 llvm::GlobalValue::LinkageTypes Linkage;
96 }; 96 };
97 97
98 // Models a function declaration. This includes the type signature of 98 /// Models a function declaration. This includes the type signature of
99 // the function, its calling conventions, and its linkage. 99 /// the function, its calling conventions, and its linkage.
100 class FunctionDeclaration : public GlobalDeclaration { 100 class FunctionDeclaration : public GlobalDeclaration {
101 FunctionDeclaration() = delete; 101 FunctionDeclaration() = delete;
102 FunctionDeclaration(const FunctionDeclaration &) = delete; 102 FunctionDeclaration(const FunctionDeclaration &) = delete;
103 FunctionDeclaration &operator=(const FunctionDeclaration &) = delete; 103 FunctionDeclaration &operator=(const FunctionDeclaration &) = delete;
104 104
105 public: 105 public:
106 static FunctionDeclaration *create(GlobalContext *Context, 106 static FunctionDeclaration *create(GlobalContext *Context,
107 const FuncSigType &Signature, 107 const FuncSigType &Signature,
108 llvm::CallingConv::ID CallingConv, 108 llvm::CallingConv::ID CallingConv,
109 llvm::GlobalValue::LinkageTypes Linkage, 109 llvm::GlobalValue::LinkageTypes Linkage,
110 bool IsProto) { 110 bool IsProto) {
111 return new (Context->allocate<FunctionDeclaration>()) 111 return new (Context->allocate<FunctionDeclaration>())
112 FunctionDeclaration(Signature, CallingConv, Linkage, IsProto); 112 FunctionDeclaration(Signature, CallingConv, Linkage, IsProto);
113 } 113 }
114 const FuncSigType &getSignature() const { return Signature; } 114 const FuncSigType &getSignature() const { return Signature; }
115 llvm::CallingConv::ID getCallingConv() const { return CallingConv; } 115 llvm::CallingConv::ID getCallingConv() const { return CallingConv; }
116 // isProto implies that there isn't a (local) definition for the function. 116 /// isProto implies that there isn't a (local) definition for the function.
117 bool isProto() const { return IsProto; } 117 bool isProto() const { return IsProto; }
118 static bool classof(const GlobalDeclaration *Addr) { 118 static bool classof(const GlobalDeclaration *Addr) {
119 return Addr->getKind() == FunctionDeclarationKind; 119 return Addr->getKind() == FunctionDeclarationKind;
120 } 120 }
121 void dumpType(Ostream &Stream) const final; 121 void dumpType(Ostream &Stream) const final;
122 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 122 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
123 bool getSuppressMangling() const final { return isExternal() && IsProto; } 123 bool getSuppressMangling() const final { return isExternal() && IsProto; }
124 124
125 private: 125 private:
126 const Ice::FuncSigType Signature; 126 const Ice::FuncSigType Signature;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 virtual void dumpType(Ostream &Stream) const; 163 virtual void dumpType(Ostream &Stream) const;
164 164
165 protected: 165 protected:
166 explicit Initializer(InitializerKind Kind) : Kind(Kind) {} 166 explicit Initializer(InitializerKind Kind) : Kind(Kind) {}
167 167
168 private: 168 private:
169 const InitializerKind Kind; 169 const InitializerKind Kind;
170 }; 170 };
171 171
172 // Models the data in a data initializer. 172 /// Models the data in a data initializer.
173 typedef std::vector<char> DataVecType; 173 typedef std::vector<char> DataVecType;
174 174
175 /// Defines a sequence of byte values as a data initializer. 175 /// Defines a sequence of byte values as a data initializer.
176 class DataInitializer : public Initializer { 176 class DataInitializer : public Initializer {
177 DataInitializer(const DataInitializer &) = delete; 177 DataInitializer(const DataInitializer &) = delete;
178 DataInitializer &operator=(const DataInitializer &) = delete; 178 DataInitializer &operator=(const DataInitializer &) = delete;
179 179
180 public: 180 public:
181 template <class... Args> 181 template <class... Args>
182 static std::unique_ptr<DataInitializer> create(Args &&... TheArgs) { 182 static std::unique_ptr<DataInitializer> create(Args &&... TheArgs) {
(...skipping 15 matching lines...) Expand all
198 for (SizeT I = 0; I < Values.size(); ++I) 198 for (SizeT I = 0; I < Values.size(); ++I)
199 Contents[I] = static_cast<int8_t>(Values[I]); 199 Contents[I] = static_cast<int8_t>(Values[I]);
200 } 200 }
201 201
202 DataInitializer(const char *Str, size_t StrLen) 202 DataInitializer(const char *Str, size_t StrLen)
203 : Initializer(DataInitializerKind), Contents(StrLen) { 203 : Initializer(DataInitializerKind), Contents(StrLen) {
204 for (size_t i = 0; i < StrLen; ++i) 204 for (size_t i = 0; i < StrLen; ++i)
205 Contents[i] = Str[i]; 205 Contents[i] = Str[i];
206 } 206 }
207 207
208 // The byte contents of the data initializer. 208 /// The byte contents of the data initializer.
209 DataVecType Contents; 209 DataVecType Contents;
210 }; 210 };
211 211
212 /// Defines a sequence of bytes initialized to zero. 212 /// Defines a sequence of bytes initialized to zero.
213 class ZeroInitializer : public Initializer { 213 class ZeroInitializer : public Initializer {
214 ZeroInitializer(const ZeroInitializer &) = delete; 214 ZeroInitializer(const ZeroInitializer &) = delete;
215 ZeroInitializer &operator=(const ZeroInitializer &) = delete; 215 ZeroInitializer &operator=(const ZeroInitializer &) = delete;
216 216
217 public: 217 public:
218 static std::unique_ptr<ZeroInitializer> create(SizeT Size) { 218 static std::unique_ptr<ZeroInitializer> create(SizeT Size) {
219 return makeUnique<ZeroInitializer>(Size); 219 return makeUnique<ZeroInitializer>(Size);
220 } 220 }
221 SizeT getNumBytes() const final { return Size; } 221 SizeT getNumBytes() const final { return Size; }
222 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 222 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
223 static bool classof(const Initializer *Z) { 223 static bool classof(const Initializer *Z) {
224 return Z->getKind() == ZeroInitializerKind; 224 return Z->getKind() == ZeroInitializerKind;
225 } 225 }
226 226
227 private: 227 private:
228 ENABLE_MAKE_UNIQUE; 228 ENABLE_MAKE_UNIQUE;
229 229
230 explicit ZeroInitializer(SizeT Size) 230 explicit ZeroInitializer(SizeT Size)
231 : Initializer(ZeroInitializerKind), Size(Size) {} 231 : Initializer(ZeroInitializerKind), Size(Size) {}
232 232
233 // The number of bytes to be zero initialized. 233 /// The number of bytes to be zero initialized.
234 SizeT Size; 234 SizeT Size;
235 }; 235 };
236 236
237 /// Defines the relocation value of another global declaration. 237 /// Defines the relocation value of another global declaration.
238 class RelocInitializer : public Initializer { 238 class RelocInitializer : public Initializer {
239 RelocInitializer(const RelocInitializer &) = delete; 239 RelocInitializer(const RelocInitializer &) = delete;
240 RelocInitializer &operator=(const RelocInitializer &) = delete; 240 RelocInitializer &operator=(const RelocInitializer &) = delete;
241 241
242 public: 242 public:
243 static std::unique_ptr<RelocInitializer> 243 static std::unique_ptr<RelocInitializer>
(...skipping 11 matching lines...) Expand all
255 } 255 }
256 256
257 private: 257 private:
258 ENABLE_MAKE_UNIQUE; 258 ENABLE_MAKE_UNIQUE;
259 259
260 RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset) 260 RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset)
261 : Initializer(RelocInitializerKind), Declaration(Declaration), 261 : Initializer(RelocInitializerKind), Declaration(Declaration),
262 Offset(Offset) {} // The global declaration used in the relocation. 262 Offset(Offset) {} // The global declaration used in the relocation.
263 263
264 const GlobalDeclaration *Declaration; 264 const GlobalDeclaration *Declaration;
265 // The offset to add to the relocation. 265 /// The offset to add to the relocation.
266 const RelocOffsetT Offset; 266 const RelocOffsetT Offset;
267 }; 267 };
268 268
269 /// Models the list of initializers. 269 /// Models the list of initializers.
270 typedef std::vector<std::unique_ptr<Initializer>> InitializerListType; 270 typedef std::vector<std::unique_ptr<Initializer>> InitializerListType;
271 271
272 static VariableDeclaration *create(GlobalContext *Context) { 272 static VariableDeclaration *create(GlobalContext *Context) {
273 return new (Context->allocate<VariableDeclaration>()) VariableDeclaration(); 273 return new (Context->allocate<VariableDeclaration>()) VariableDeclaration();
274 } 274 }
275 275
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (ForceSuppressMangling) 317 if (ForceSuppressMangling)
318 return true; 318 return true;
319 return isExternal() && !hasInitializer(); 319 return isExternal() && !hasInitializer();
320 } 320 }
321 321
322 void setSuppressMangling() { ForceSuppressMangling = true; } 322 void setSuppressMangling() { ForceSuppressMangling = true; }
323 323
324 void discardInitializers() { Initializers = nullptr; } 324 void discardInitializers() { Initializers = nullptr; }
325 325
326 private: 326 private:
327 // list of initializers for the declared variable. 327 /// list of initializers for the declared variable.
jvoung (off chromium) 2015/06/30 22:05:48 Capitalized "List of..."
ascull 2015/07/06 19:29:09 Done.
328 std::unique_ptr<InitializerListType> Initializers; 328 std::unique_ptr<InitializerListType> Initializers;
329 bool HasInitializer; 329 bool HasInitializer;
330 // The alignment of the declared variable. 330 /// The alignment of the declared variable.
331 uint32_t Alignment; 331 uint32_t Alignment;
332 // True if a declared (global) constant. 332 /// True if a declared (global) constant.
333 bool IsConstant; 333 bool IsConstant;
334 // If set to true, force getSuppressMangling() to return true. 334 /// If set to true, force getSuppressMangling() to return true.
335 bool ForceSuppressMangling; 335 bool ForceSuppressMangling;
336 336
337 VariableDeclaration() 337 VariableDeclaration()
338 : GlobalDeclaration(VariableDeclarationKind, 338 : GlobalDeclaration(VariableDeclarationKind,
339 llvm::GlobalValue::InternalLinkage), 339 llvm::GlobalValue::InternalLinkage),
340 Initializers(new InitializerListType), HasInitializer(false), 340 Initializers(new InitializerListType), HasInitializer(false),
341 Alignment(0), IsConstant(false), ForceSuppressMangling(false) {} 341 Alignment(0), IsConstant(false), ForceSuppressMangling(false) {}
342 }; 342 };
343 343
344 template <class StreamType> 344 template <class StreamType>
345 inline StreamType &operator<<(StreamType &Stream, 345 inline StreamType &operator<<(StreamType &Stream,
346 const VariableDeclaration::Initializer &Init) { 346 const VariableDeclaration::Initializer &Init) {
347 Init.dump(Stream); 347 Init.dump(Stream);
348 return Stream; 348 return Stream;
349 } 349 }
350 350
351 template <class StreamType> 351 template <class StreamType>
352 inline StreamType &operator<<(StreamType &Stream, 352 inline StreamType &operator<<(StreamType &Stream,
353 const GlobalDeclaration &Addr) { 353 const GlobalDeclaration &Addr) {
354 Addr.dump(Stream); 354 Addr.dump(Stream);
355 return Stream; 355 return Stream;
356 } 356 }
357 357
358 } // end of namespace Ice 358 } // end of namespace Ice
359 359
360 #endif // SUBZERO_SRC_ICEGLOBALINITS_H 360 #endif // SUBZERO_SRC_ICEGLOBALINITS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698