Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceFixups.h - Assembler fixup kinds ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
| 11 | /// This file declares generic fixup types. |
| 12 | /// |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef SUBZERO_SRC_ICEFIXUPS_H |
| 16 | #define SUBZERO_SRC_ICEFIXUPS_H |
| 17 | |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 18 | #include "IceDefs.h" |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 19 | |
| 20 | namespace Ice { |
| 21 | |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 22 | /// Each target and container format has a different namespace of relocations. |
| 23 | /// This holds the specific target+container format's relocation number. |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 24 | typedef uint32_t FixupKind; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 25 | |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 26 | /// Assembler fixups are positions in generated code/data that hold relocation |
| 27 | /// information that needs to be processed before finalizing the code/data. |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 28 | struct AssemblerFixup { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 29 | AssemblerFixup &operator=(const AssemblerFixup &) = delete; |
| 30 | |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 31 | public: |
Jim Stichnoth | eafb56c | 2015-06-22 10:35:22 -0700 | [diff] [blame] | 32 | AssemblerFixup() = default; |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 33 | AssemblerFixup(const AssemblerFixup &) = default; |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 34 | intptr_t position() const { return position_; } |
| 35 | void set_position(intptr_t Position) { position_ = Position; } |
| 36 | |
| 37 | FixupKind kind() const { return kind_; } |
| 38 | void set_kind(FixupKind Kind) { kind_ = Kind; } |
| 39 | |
| 40 | RelocOffsetT offset() const; |
| 41 | IceString symbol(const GlobalContext *Ctx) const; |
Jan Voung | f644a4b | 2015-03-19 11:57:52 -0700 | [diff] [blame] | 42 | |
| 43 | static const Constant *NullSymbol; |
| 44 | bool isNullSymbol() const { return value_ == NullSymbol; } |
| 45 | |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 46 | void set_value(const Constant *Value) { value_ = Value; } |
| 47 | |
Jan Voung | b7db1a5 | 2015-07-21 09:39:01 -0700 | [diff] [blame] | 48 | void emit(GlobalContext *Ctx, RelocOffsetT OverrideOffset) const; |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 49 | |
| 50 | private: |
Jim Stichnoth | eafb56c | 2015-06-22 10:35:22 -0700 | [diff] [blame] | 51 | intptr_t position_ = 0; |
| 52 | FixupKind kind_ = 0; |
| 53 | const Constant *value_ = nullptr; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 56 | typedef std::vector<AssemblerFixup> FixupList; |
| 57 | typedef std::vector<AssemblerFixup *> FixupRefList; |
| 58 | |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 59 | } // end of namespace Ice |
| 60 | |
| 61 | #endif // SUBZERO_SRC_ICEFIXUPS_H |