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 /// \file | 10 /// \file |
11 /// \brief Declares the representation of function declarations, global variable | 11 /// \brief Declares the representation of function declarations, global variable |
12 /// declarations, and the corresponding variable initializers in Subzero. | 12 /// declarations, and the corresponding variable initializers in Subzero. |
13 /// | 13 /// |
14 /// Global variable initializers are represented as a sequence of simple | 14 /// Global variable initializers are represented as a sequence of simple |
15 /// initializers. | 15 /// initializers. |
16 /// | 16 /// |
17 //===----------------------------------------------------------------------===// | 17 //===----------------------------------------------------------------------===// |
18 | 18 |
19 #ifndef SUBZERO_SRC_ICEGLOBALINITS_H | 19 #ifndef SUBZERO_SRC_ICEGLOBALINITS_H |
20 #define SUBZERO_SRC_ICEGLOBALINITS_H | 20 #define SUBZERO_SRC_ICEGLOBALINITS_H |
21 | 21 |
22 #include "IceDefs.h" | 22 #include "IceDefs.h" |
| 23 #include "IceFixups.h" |
23 #include "IceGlobalContext.h" | 24 #include "IceGlobalContext.h" |
24 #include "IceIntrinsics.h" | 25 #include "IceIntrinsics.h" |
25 #include "IceOperand.h" | 26 #include "IceOperand.h" |
26 #include "IceTypes.h" | 27 #include "IceTypes.h" |
27 | 28 |
28 #ifdef __clang__ | 29 #ifdef __clang__ |
29 #pragma clang diagnostic push | 30 #pragma clang diagnostic push |
30 #pragma clang diagnostic ignored "-Wunused-parameter" | 31 #pragma clang diagnostic ignored "-Wunused-parameter" |
31 #pragma clang diagnostic ignored "-Wredundant-move" | 32 #pragma clang diagnostic ignored "-Wredundant-move" |
32 #endif // __clang__ | 33 #endif // __clang__ |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 315 |
315 /// Defines the relocation value of another global declaration. | 316 /// Defines the relocation value of another global declaration. |
316 class RelocInitializer : public Initializer { | 317 class RelocInitializer : public Initializer { |
317 RelocInitializer(const RelocInitializer &) = delete; | 318 RelocInitializer(const RelocInitializer &) = delete; |
318 RelocInitializer &operator=(const RelocInitializer &) = delete; | 319 RelocInitializer &operator=(const RelocInitializer &) = delete; |
319 | 320 |
320 public: | 321 public: |
321 static std::unique_ptr<RelocInitializer> | 322 static std::unique_ptr<RelocInitializer> |
322 create(const GlobalDeclaration *Declaration, | 323 create(const GlobalDeclaration *Declaration, |
323 const RelocOffsetArray &OffsetExpr) { | 324 const RelocOffsetArray &OffsetExpr) { |
324 return makeUnique<RelocInitializer>(Declaration, OffsetExpr); | 325 constexpr bool NoFixup = false; |
| 326 return makeUnique<RelocInitializer>(Declaration, OffsetExpr, NoFixup); |
| 327 } |
| 328 |
| 329 static std::unique_ptr<RelocInitializer> |
| 330 create(const GlobalDeclaration *Declaration, |
| 331 const RelocOffsetArray &OffsetExpr, FixupKind Fixup) { |
| 332 constexpr bool HasFixup = true; |
| 333 return makeUnique<RelocInitializer>(Declaration, OffsetExpr, HasFixup, |
| 334 Fixup); |
325 } | 335 } |
326 | 336 |
327 RelocOffsetT getOffset() const { | 337 RelocOffsetT getOffset() const { |
328 RelocOffsetT Offset = 0; | 338 RelocOffsetT Offset = 0; |
329 for (const auto *RelocOffset : OffsetExpr) { | 339 for (const auto *RelocOffset : OffsetExpr) { |
330 Offset += RelocOffset->getOffset(); | 340 Offset += RelocOffset->getOffset(); |
331 } | 341 } |
332 return Offset; | 342 return Offset; |
333 } | 343 } |
334 | 344 |
| 345 bool hasFixup() const { return HasFixup; } |
| 346 FixupKind getFixup() const { |
| 347 assert(HasFixup); |
| 348 return Fixup; |
| 349 } |
| 350 |
335 const GlobalDeclaration *getDeclaration() const { return Declaration; } | 351 const GlobalDeclaration *getDeclaration() const { return Declaration; } |
336 SizeT getNumBytes() const final { return RelocAddrSize; } | 352 SizeT getNumBytes() const final { return RelocAddrSize; } |
337 void dump(GlobalContext *Ctx, Ostream &Stream) const final; | 353 void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
338 void dumpType(Ostream &Stream) const final; | 354 void dumpType(Ostream &Stream) const final; |
339 static bool classof(const Initializer *R) { | 355 static bool classof(const Initializer *R) { |
340 return R->getKind() == RelocInitializerKind; | 356 return R->getKind() == RelocInitializerKind; |
341 } | 357 } |
342 | 358 |
343 private: | 359 private: |
344 ENABLE_MAKE_UNIQUE; | 360 ENABLE_MAKE_UNIQUE; |
345 | 361 |
346 RelocInitializer(const GlobalDeclaration *Declaration, | 362 RelocInitializer(const GlobalDeclaration *Declaration, |
347 const RelocOffsetArray &OffsetExpr) | 363 const RelocOffsetArray &OffsetExpr, bool HasFixup, |
| 364 FixupKind Fixup = 0) |
348 : Initializer(RelocInitializerKind), | 365 : Initializer(RelocInitializerKind), |
349 Declaration(Declaration), // The global declaration used in the reloc. | 366 Declaration(Declaration), // The global declaration used in the reloc. |
350 OffsetExpr(OffsetExpr) {} | 367 OffsetExpr(OffsetExpr), HasFixup(HasFixup), Fixup(Fixup) {} |
351 | 368 |
352 const GlobalDeclaration *Declaration; | 369 const GlobalDeclaration *Declaration; |
353 /// The offset to add to the relocation. | 370 /// The offset to add to the relocation. |
354 const RelocOffsetArray OffsetExpr; | 371 const RelocOffsetArray OffsetExpr; |
| 372 const bool HasFixup = false; |
| 373 const FixupKind Fixup = 0; |
355 }; | 374 }; |
356 | 375 |
357 /// Models the list of initializers. | 376 /// Models the list of initializers. |
358 using InitializerListType = std::vector<std::unique_ptr<Initializer>>; | 377 using InitializerListType = std::vector<std::unique_ptr<Initializer>>; |
359 | 378 |
360 static VariableDeclaration *create(GlobalContext *Context) { | 379 static VariableDeclaration *create(GlobalContext *Context) { |
361 return new (Context->allocate<VariableDeclaration>()) VariableDeclaration(); | 380 return new (Context->allocate<VariableDeclaration>()) VariableDeclaration(); |
362 } | 381 } |
363 | 382 |
364 const InitializerListType &getInitializers() const { return *Initializers; } | 383 const InitializerListType &getInitializers() const { return *Initializers; } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 template <class StreamType> | 461 template <class StreamType> |
443 inline StreamType &operator<<(StreamType &Stream, | 462 inline StreamType &operator<<(StreamType &Stream, |
444 const GlobalDeclaration &Addr) { | 463 const GlobalDeclaration &Addr) { |
445 Addr.dump(Stream); | 464 Addr.dump(Stream); |
446 return Stream; | 465 return Stream; |
447 } | 466 } |
448 | 467 |
449 } // end of namespace Ice | 468 } // end of namespace Ice |
450 | 469 |
451 #endif // SUBZERO_SRC_ICEGLOBALINITS_H | 470 #endif // SUBZERO_SRC_ICEGLOBALINITS_H |
OLD | NEW |