| 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 "IceGlobalContext.h" | 23 #include "IceGlobalContext.h" |
| 24 #include "IceIntrinsics.h" | 24 #include "IceIntrinsics.h" |
| 25 #include "IceOperand.h" |
| 25 #include "IceTypes.h" | 26 #include "IceTypes.h" |
| 26 | 27 |
| 27 #ifdef __clang__ | 28 #ifdef __clang__ |
| 28 #pragma clang diagnostic push | 29 #pragma clang diagnostic push |
| 29 #pragma clang diagnostic ignored "-Wunused-parameter" | 30 #pragma clang diagnostic ignored "-Wunused-parameter" |
| 30 #pragma clang diagnostic ignored "-Wredundant-move" | 31 #pragma clang diagnostic ignored "-Wredundant-move" |
| 31 #endif // __clang__ | 32 #endif // __clang__ |
| 32 | 33 |
| 33 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" // for NaClBitcodeRecord. | 34 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" // for NaClBitcodeRecord. |
| 34 #include "llvm/IR/CallingConv.h" | 35 #include "llvm/IR/CallingConv.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 SizeT Size; | 312 SizeT Size; |
| 312 }; | 313 }; |
| 313 | 314 |
| 314 /// Defines the relocation value of another global declaration. | 315 /// Defines the relocation value of another global declaration. |
| 315 class RelocInitializer : public Initializer { | 316 class RelocInitializer : public Initializer { |
| 316 RelocInitializer(const RelocInitializer &) = delete; | 317 RelocInitializer(const RelocInitializer &) = delete; |
| 317 RelocInitializer &operator=(const RelocInitializer &) = delete; | 318 RelocInitializer &operator=(const RelocInitializer &) = delete; |
| 318 | 319 |
| 319 public: | 320 public: |
| 320 static std::unique_ptr<RelocInitializer> | 321 static std::unique_ptr<RelocInitializer> |
| 321 create(const GlobalDeclaration *Declaration, RelocOffsetT Offset) { | 322 create(const GlobalDeclaration *Declaration, |
| 322 return makeUnique<RelocInitializer>(Declaration, Offset); | 323 const RelocOffsetArray &OffsetExpr) { |
| 324 return makeUnique<RelocInitializer>(Declaration, OffsetExpr); |
| 323 } | 325 } |
| 324 | 326 |
| 325 RelocOffsetT getOffset() const { return Offset; } | 327 RelocOffsetT getOffset() const { |
| 328 RelocOffsetT Offset = 0; |
| 329 for (const auto *RelocOffset : OffsetExpr) { |
| 330 Offset += RelocOffset->getOffset(); |
| 331 } |
| 332 return Offset; |
| 333 } |
| 334 |
| 326 const GlobalDeclaration *getDeclaration() const { return Declaration; } | 335 const GlobalDeclaration *getDeclaration() const { return Declaration; } |
| 327 SizeT getNumBytes() const final { return RelocAddrSize; } | 336 SizeT getNumBytes() const final { return RelocAddrSize; } |
| 328 void dump(GlobalContext *Ctx, Ostream &Stream) const final; | 337 void dump(GlobalContext *Ctx, Ostream &Stream) const final; |
| 329 void dumpType(Ostream &Stream) const final; | 338 void dumpType(Ostream &Stream) const final; |
| 330 static bool classof(const Initializer *R) { | 339 static bool classof(const Initializer *R) { |
| 331 return R->getKind() == RelocInitializerKind; | 340 return R->getKind() == RelocInitializerKind; |
| 332 } | 341 } |
| 333 | 342 |
| 334 private: | 343 private: |
| 335 ENABLE_MAKE_UNIQUE; | 344 ENABLE_MAKE_UNIQUE; |
| 336 | 345 |
| 337 RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset) | 346 RelocInitializer(const GlobalDeclaration *Declaration, |
| 338 : Initializer(RelocInitializerKind), Declaration(Declaration), | 347 const RelocOffsetArray &OffsetExpr) |
| 339 Offset(Offset) {} // The global declaration used in the relocation. | 348 : Initializer(RelocInitializerKind), |
| 349 Declaration(Declaration), // The global declaration used in the reloc. |
| 350 OffsetExpr(OffsetExpr) {} |
| 340 | 351 |
| 341 const GlobalDeclaration *Declaration; | 352 const GlobalDeclaration *Declaration; |
| 342 /// The offset to add to the relocation. | 353 /// The offset to add to the relocation. |
| 343 const RelocOffsetT Offset; | 354 const RelocOffsetArray OffsetExpr; |
| 344 }; | 355 }; |
| 345 | 356 |
| 346 /// Models the list of initializers. | 357 /// Models the list of initializers. |
| 347 using InitializerListType = std::vector<std::unique_ptr<Initializer>>; | 358 using InitializerListType = std::vector<std::unique_ptr<Initializer>>; |
| 348 | 359 |
| 349 static VariableDeclaration *create(GlobalContext *Context) { | 360 static VariableDeclaration *create(GlobalContext *Context) { |
| 350 return new (Context->allocate<VariableDeclaration>()) VariableDeclaration(); | 361 return new (Context->allocate<VariableDeclaration>()) VariableDeclaration(); |
| 351 } | 362 } |
| 352 | 363 |
| 353 const InitializerListType &getInitializers() const { return *Initializers; } | 364 const InitializerListType &getInitializers() const { return *Initializers; } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 template <class StreamType> | 442 template <class StreamType> |
| 432 inline StreamType &operator<<(StreamType &Stream, | 443 inline StreamType &operator<<(StreamType &Stream, |
| 433 const GlobalDeclaration &Addr) { | 444 const GlobalDeclaration &Addr) { |
| 434 Addr.dump(Stream); | 445 Addr.dump(Stream); |
| 435 return Stream; | 446 return Stream; |
| 436 } | 447 } |
| 437 | 448 |
| 438 } // end of namespace Ice | 449 } // end of namespace Ice |
| 439 | 450 |
| 440 #endif // SUBZERO_SRC_ICEGLOBALINITS_H | 451 #endif // SUBZERO_SRC_ICEGLOBALINITS_H |
| OLD | NEW |