blob: 9ec72c36bd331dddf540120e8f427f7465189c03 [file] [log] [blame]
Jan Voung8acded02014-09-22 18:02:25 -07001//===- 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//===----------------------------------------------------------------------===//
9//
10// This file declares generic fixup types.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef SUBZERO_SRC_ICEFIXUPS_H
15#define SUBZERO_SRC_ICEFIXUPS_H
16
Jan Voungec270732015-01-12 17:00:22 -080017#include "IceDefs.h"
Jan Voung8acded02014-09-22 18:02:25 -070018
19namespace Ice {
20
Jan Voungec270732015-01-12 17:00:22 -080021// Each target and container format has a different namespace of relocations.
22// This holds the specific target+container format's relocation number.
23typedef uint32_t FixupKind;
Jan Voung8acded02014-09-22 18:02:25 -070024
Jan Voungec270732015-01-12 17:00:22 -080025// Assembler fixups are positions in generated code/data that hold relocation
26// information that needs to be processed before finalizing the code/data.
27struct AssemblerFixup {
Jim Stichnothc6ead202015-02-24 09:30:30 -080028 AssemblerFixup &operator=(const AssemblerFixup &) = delete;
29
Jan Voungec270732015-01-12 17:00:22 -080030public:
Jim Stichnotheafb56c2015-06-22 10:35:22 -070031 AssemblerFixup() = default;
Jim Stichnothc6ead202015-02-24 09:30:30 -080032 AssemblerFixup(const AssemblerFixup &) = default;
Jan Voungec270732015-01-12 17:00:22 -080033 intptr_t position() const { return position_; }
34 void set_position(intptr_t Position) { position_ = Position; }
35
36 FixupKind kind() const { return kind_; }
37 void set_kind(FixupKind Kind) { kind_ = Kind; }
38
39 RelocOffsetT offset() const;
40 IceString symbol(const GlobalContext *Ctx) const;
Jan Voungf644a4b2015-03-19 11:57:52 -070041
42 static const Constant *NullSymbol;
43 bool isNullSymbol() const { return value_ == NullSymbol; }
44
Jan Voungec270732015-01-12 17:00:22 -080045 void set_value(const Constant *Value) { value_ = Value; }
46
Jim Stichnoth927f7cc2015-03-19 23:23:00 -070047 void emit(GlobalContext *Ctx, RelocOffsetT BaseOffset) const;
Jan Voungec270732015-01-12 17:00:22 -080048
49private:
Jim Stichnotheafb56c2015-06-22 10:35:22 -070050 intptr_t position_ = 0;
51 FixupKind kind_ = 0;
52 const Constant *value_ = nullptr;
Jan Voung8acded02014-09-22 18:02:25 -070053};
54
Jan Voungec270732015-01-12 17:00:22 -080055typedef std::vector<AssemblerFixup> FixupList;
56typedef std::vector<AssemblerFixup *> FixupRefList;
57
Jan Voung8acded02014-09-22 18:02:25 -070058} // end of namespace Ice
59
60#endif // SUBZERO_SRC_ICEFIXUPS_H