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

Side by Side Diff: src/IceGlobalInits.h

Issue 695563006: Subzero: Use a common RelocOffsetType / RelocOffsetT. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 209 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
210 static bool classof(const Initializer *Z) { 210 static bool classof(const Initializer *Z) {
211 return Z->getKind() == ZeroInitializerKind; 211 return Z->getKind() == ZeroInitializerKind;
212 } 212 }
213 213
214 private: 214 private:
215 // The number of bytes to be zero initialized. 215 // The number of bytes to be zero initialized.
216 SizeT Size; 216 SizeT Size;
217 }; 217 };
218 218
219 // Relocation address offsets must be 32 bit values.
220 typedef int32_t RelocOffsetType;
221 static const SizeT RelocAddrSize = 4;
222
223 /// Defines the relocation value of another global declaration. 219 /// Defines the relocation value of another global declaration.
224 class RelocInitializer : public Initializer { 220 class RelocInitializer : public Initializer {
225 RelocInitializer(const RelocInitializer &) = delete; 221 RelocInitializer(const RelocInitializer &) = delete;
226 RelocInitializer &operator=(const RelocInitializer &) = delete; 222 RelocInitializer &operator=(const RelocInitializer &) = delete;
227 223
228 public: 224 public:
229 RelocInitializer(const GlobalDeclaration *Declaration, 225 RelocInitializer(const GlobalDeclaration *Declaration,
230 RelocOffsetType Offset) 226 RelocOffsetT Offset)
231 : Initializer(RelocInitializerKind), Declaration(Declaration), 227 : Initializer(RelocInitializerKind), Declaration(Declaration),
232 Offset(Offset) {} 228 Offset(Offset) {}
233 ~RelocInitializer() override {} 229 ~RelocInitializer() override {}
234 RelocOffsetType getOffset() const { return Offset; } 230 RelocOffsetT getOffset() const { return Offset; }
235 const GlobalDeclaration *getDeclaration() const { return Declaration; } 231 const GlobalDeclaration *getDeclaration() const { return Declaration; }
236 SizeT getNumBytes() const final { return RelocAddrSize; } 232 SizeT getNumBytes() const final { return sizeof(RelocOffsetT); }
jvoung (off chromium) 2014/11/04 19:21:55 or I can keep the constant, and put it alongside R
Karl 2014/11/04 20:15:00 I would prefer the constant, in case we change the
Jim Stichnoth 2014/11/04 20:18:05 But RelocOffsetT (as well as RelocOffsetType) is d
Karl 2014/11/04 23:01:21 I have no problem with this, so long as a comment
237 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 233 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
238 void dumpType(Ostream &Stream) const final; 234 void dumpType(Ostream &Stream) const final;
239 static bool classof(const Initializer *R) { 235 static bool classof(const Initializer *R) {
240 return R->getKind() == RelocInitializerKind; 236 return R->getKind() == RelocInitializerKind;
241 } 237 }
242 238
243 private: 239 private:
244 // The global declaration used in the relocation. 240 // The global declaration used in the relocation.
245 const GlobalDeclaration *Declaration; 241 const GlobalDeclaration *Declaration;
246 // The offset to add to the relocation. 242 // The offset to add to the relocation.
247 const RelocOffsetType Offset; 243 const RelocOffsetT Offset;
248 }; 244 };
249 245
250 /// Models the list of initializers. 246 /// Models the list of initializers.
251 typedef std::vector<Initializer *> InitializerListType; 247 typedef std::vector<Initializer *> InitializerListType;
252 248
253 static VariableDeclaration *create(GlobalContext *Ctx); 249 static VariableDeclaration *create(GlobalContext *Ctx);
254 ~VariableDeclaration() final; 250 ~VariableDeclaration() final;
255 251
256 const InitializerListType &getInitializers() const { return Initializers; } 252 const InitializerListType &getInitializers() const { return Initializers; }
257 bool getIsConstant() const { return IsConstant; } 253 bool getIsConstant() const { return IsConstant; }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 template <class StreamType> 316 template <class StreamType>
321 inline StreamType &operator<<(StreamType &Stream, 317 inline StreamType &operator<<(StreamType &Stream,
322 const GlobalDeclaration &Addr) { 318 const GlobalDeclaration &Addr) {
323 Addr.dump(Stream); 319 Addr.dump(Stream);
324 return Stream; 320 return Stream;
325 } 321 }
326 322
327 } // end of namespace Ice 323 } // end of namespace Ice
328 324
329 #endif // SUBZERO_SRC_ICEGLOBALINITS_H 325 #endif // SUBZERO_SRC_ICEGLOBALINITS_H
OLDNEW
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698