LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AArch64MCExpr.h
Go to the documentation of this file.
1 //==- AArch64MCExpr.h - AArch64 specific MC expression classes --*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
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 describes AArch64-specific MCExprs, used for modifiers like
11 // ":lo12:" or ":gottprel_g1:".
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_AARCH64MCEXPR_H
16 #define LLVM_AARCH64MCEXPR_H
17 
18 #include "llvm/MC/MCExpr.h"
19 
20 namespace llvm {
21 
22 class AArch64MCExpr : public MCTargetExpr {
23 public:
24  enum VariantKind {
26  VK_AARCH64_GOT, // :got: modifier in assembly
27  VK_AARCH64_GOT_LO12, // :got_lo12:
28  VK_AARCH64_LO12, // :lo12:
29 
30  VK_AARCH64_ABS_G0, // :abs_g0:
31  VK_AARCH64_ABS_G0_NC, // :abs_g0_nc:
37 
38  VK_AARCH64_SABS_G0, // :abs_g0_s:
41 
42  VK_AARCH64_DTPREL_G2, // :dtprel_g2:
50 
51  VK_AARCH64_GOTTPREL_G1, // :gottprel:
55 
56  VK_AARCH64_TPREL_G2, // :tprel:
64 
65  VK_AARCH64_TLSDESC, // :tlsdesc:
67  };
68 
69 private:
70  const VariantKind Kind;
71  const MCExpr *Expr;
72 
73  explicit AArch64MCExpr(VariantKind _Kind, const MCExpr *_Expr)
74  : Kind(_Kind), Expr(_Expr) {}
75 
76 public:
77  /// @name Construction
78  /// @{
79 
80  static const AArch64MCExpr *Create(VariantKind Kind, const MCExpr *Expr,
81  MCContext &Ctx);
82 
83  static const AArch64MCExpr *CreateLo12(const MCExpr *Expr, MCContext &Ctx) {
84  return Create(VK_AARCH64_LO12, Expr, Ctx);
85  }
86 
87  static const AArch64MCExpr *CreateGOT(const MCExpr *Expr, MCContext &Ctx) {
88  return Create(VK_AARCH64_GOT, Expr, Ctx);
89  }
90 
91  static const AArch64MCExpr *CreateGOTLo12(const MCExpr *Expr,
92  MCContext &Ctx) {
93  return Create(VK_AARCH64_GOT_LO12, Expr, Ctx);
94  }
95 
96  static const AArch64MCExpr *CreateDTPREL_G1(const MCExpr *Expr,
97  MCContext &Ctx) {
98  return Create(VK_AARCH64_DTPREL_G1, Expr, Ctx);
99  }
100 
101  static const AArch64MCExpr *CreateDTPREL_G0_NC(const MCExpr *Expr,
102  MCContext &Ctx) {
103  return Create(VK_AARCH64_DTPREL_G0_NC, Expr, Ctx);
104  }
105 
106  static const AArch64MCExpr *CreateGOTTPREL(const MCExpr *Expr,
107  MCContext &Ctx) {
108  return Create(VK_AARCH64_GOTTPREL, Expr, Ctx);
109  }
110 
111  static const AArch64MCExpr *CreateGOTTPRELLo12(const MCExpr *Expr,
112  MCContext &Ctx) {
113  return Create(VK_AARCH64_GOTTPREL_LO12, Expr, Ctx);
114  }
115 
116  static const AArch64MCExpr *CreateTLSDesc(const MCExpr *Expr,
117  MCContext &Ctx) {
118  return Create(VK_AARCH64_TLSDESC, Expr, Ctx);
119  }
120 
121  static const AArch64MCExpr *CreateTLSDescLo12(const MCExpr *Expr,
122  MCContext &Ctx) {
123  return Create(VK_AARCH64_TLSDESC_LO12, Expr, Ctx);
124  }
125 
126  static const AArch64MCExpr *CreateTPREL_G1(const MCExpr *Expr,
127  MCContext &Ctx) {
128  return Create(VK_AARCH64_TPREL_G1, Expr, Ctx);
129  }
130 
131  static const AArch64MCExpr *CreateTPREL_G0_NC(const MCExpr *Expr,
132  MCContext &Ctx) {
133  return Create(VK_AARCH64_TPREL_G0_NC, Expr, Ctx);
134  }
135 
136  static const AArch64MCExpr *CreateABS_G3(const MCExpr *Expr,
137  MCContext &Ctx) {
138  return Create(VK_AARCH64_ABS_G3, Expr, Ctx);
139  }
140 
141  static const AArch64MCExpr *CreateABS_G2_NC(const MCExpr *Expr,
142  MCContext &Ctx) {
143  return Create(VK_AARCH64_ABS_G2_NC, Expr, Ctx);
144  }
145 
146  static const AArch64MCExpr *CreateABS_G1_NC(const MCExpr *Expr,
147  MCContext &Ctx) {
148  return Create(VK_AARCH64_ABS_G1_NC, Expr, Ctx);
149  }
150 
151  static const AArch64MCExpr *CreateABS_G0_NC(const MCExpr *Expr,
152  MCContext &Ctx) {
153  return Create(VK_AARCH64_ABS_G0_NC, Expr, Ctx);
154  }
155 
156  /// @}
157  /// @name Accessors
158  /// @{
159 
160  /// getOpcode - Get the kind of this expression.
161  VariantKind getKind() const { return Kind; }
162 
163  /// getSubExpr - Get the child of this expression.
164  const MCExpr *getSubExpr() const { return Expr; }
165 
166  /// @}
167 
168  void PrintImpl(raw_ostream &OS) const;
170  const MCAsmLayout *Layout) const;
171  void AddValueSymbols(MCAssembler *) const;
173  return getSubExpr()->FindAssociatedSection();
174  }
175 
177 
178  static bool classof(const MCExpr *E) {
179  return E->getKind() == MCExpr::Target;
180  }
181 
182  static bool classof(const AArch64MCExpr *) { return true; }
183 
184 };
185 } // end namespace llvm
186 
187 #endif
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const
ExprKind getKind() const
Definition: MCExpr.h:61
static bool classof(const AArch64MCExpr *)
static const AArch64MCExpr * CreateTLSDesc(const MCExpr *Expr, MCContext &Ctx)
void AddValueSymbols(MCAssembler *) const
static const AArch64MCExpr * CreateDTPREL_G1(const MCExpr *Expr, MCContext &Ctx)
Definition: AArch64MCExpr.h:96
static const AArch64MCExpr * CreateABS_G2_NC(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateGOTTPRELLo12(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateDTPREL_G0_NC(const MCExpr *Expr, MCContext &Ctx)
VariantKind getKind() const
getOpcode - Get the kind of this expression.
static const AArch64MCExpr * CreateTPREL_G1(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateABS_G1_NC(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateLo12(const MCExpr *Expr, MCContext &Ctx)
Definition: AArch64MCExpr.h:83
const MCSection * FindAssociatedSection() const
static const AArch64MCExpr * CreateGOTLo12(const MCExpr *Expr, MCContext &Ctx)
Definition: AArch64MCExpr.h:91
const MCSection * FindAssociatedSection() const
Definition: MCExpr.cpp:743
static const AArch64MCExpr * CreateTLSDescLo12(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * Create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateTPREL_G0_NC(const MCExpr *Expr, MCContext &Ctx)
void PrintImpl(raw_ostream &OS) const
static bool classof(const MCExpr *E)
static const AArch64MCExpr * CreateGOTTPREL(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateABS_G0_NC(const MCExpr *Expr, MCContext &Ctx)
static const AArch64MCExpr * CreateABS_G3(const MCExpr *Expr, MCContext &Ctx)
Target specific expression.
Definition: MCExpr.h:38
bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const
static const AArch64MCExpr * CreateGOT(const MCExpr *Expr, MCContext &Ctx)
Definition: AArch64MCExpr.h:87
const MCExpr * getSubExpr() const
getSubExpr - Get the child of this expression.