1 //==- AArch64MCExpr.h - AArch64 specific MC expression classes --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_AARCH64MCEXPR_H
11 #define LLVM_AARCH64MCEXPR_H
13 #include "llvm/MC/MCExpr.h"
17 class AArch64MCExpr : public MCTargetExpr {
21 VK_AARCH64_GOT, // :got: modifier in assembly
22 VK_AARCH64_GOT_LO12, // :got_lo12:
23 VK_AARCH64_LO12, // :lo12:
25 VK_AARCH64_ABS_G0, // :abs_g0:
26 VK_AARCH64_ABS_G0_NC, // :abs_g0_nc:
33 VK_AARCH64_SABS_G0, // :abs_g0_s:
37 VK_AARCH64_DTPREL_G2, // :dtprel_g2:
39 VK_AARCH64_DTPREL_G1_NC,
41 VK_AARCH64_DTPREL_G0_NC,
42 VK_AARCH64_DTPREL_HI12,
43 VK_AARCH64_DTPREL_LO12,
44 VK_AARCH64_DTPREL_LO12_NC,
46 VK_AARCH64_GOTTPREL_G1, // :gottprel:
47 VK_AARCH64_GOTTPREL_G0_NC,
49 VK_AARCH64_GOTTPREL_LO12,
51 VK_AARCH64_TPREL_G2, // :tprel:
53 VK_AARCH64_TPREL_G1_NC,
55 VK_AARCH64_TPREL_G0_NC,
56 VK_AARCH64_TPREL_HI12,
57 VK_AARCH64_TPREL_LO12,
58 VK_AARCH64_TPREL_LO12_NC,
60 VK_AARCH64_TLSDESC, // :tlsdesc:
61 VK_AARCH64_TLSDESC_LO12
65 const VariantKind Kind;
68 explicit AArch64MCExpr(VariantKind _Kind, const MCExpr *_Expr)
69 : Kind(_Kind), Expr(_Expr) {}
72 /// @name Construction
75 static const AArch64MCExpr *Create(VariantKind Kind, const MCExpr *Expr,
78 static const AArch64MCExpr *CreateLo12(const MCExpr *Expr, MCContext &Ctx) {
79 return Create(VK_AARCH64_LO12, Expr, Ctx);
82 static const AArch64MCExpr *CreateGOT(const MCExpr *Expr, MCContext &Ctx) {
83 return Create(VK_AARCH64_GOT, Expr, Ctx);
86 static const AArch64MCExpr *CreateGOTLo12(const MCExpr *Expr, MCContext &Ctx) {
87 return Create(VK_AARCH64_GOT_LO12, Expr, Ctx);
90 static const AArch64MCExpr *CreateDTPREL_G1(const MCExpr *Expr,
92 return Create(VK_AARCH64_DTPREL_G1, Expr, Ctx);
95 static const AArch64MCExpr *CreateDTPREL_G0_NC(const MCExpr *Expr,
97 return Create(VK_AARCH64_DTPREL_G0_NC, Expr, Ctx);
100 static const AArch64MCExpr *CreateGOTTPREL(const MCExpr *Expr,
102 return Create(VK_AARCH64_GOTTPREL, Expr, Ctx);
105 static const AArch64MCExpr *CreateGOTTPRELLo12(const MCExpr *Expr,
107 return Create(VK_AARCH64_GOTTPREL_LO12, Expr, Ctx);
110 static const AArch64MCExpr *CreateTLSDesc(const MCExpr *Expr,
112 return Create(VK_AARCH64_TLSDESC, Expr, Ctx);
115 static const AArch64MCExpr *CreateTLSDescLo12(const MCExpr *Expr,
117 return Create(VK_AARCH64_TLSDESC_LO12, Expr, Ctx);
120 static const AArch64MCExpr *CreateTPREL_G1(const MCExpr *Expr,
122 return Create(VK_AARCH64_TPREL_G1, Expr, Ctx);
125 static const AArch64MCExpr *CreateTPREL_G0_NC(const MCExpr *Expr,
127 return Create(VK_AARCH64_TPREL_G0_NC, Expr, Ctx);
134 /// getOpcode - Get the kind of this expression.
135 VariantKind getKind() const { return Kind; }
137 /// getSubExpr - Get the child of this expression.
138 const MCExpr *getSubExpr() const { return Expr; }
142 void PrintImpl(raw_ostream &OS) const;
143 bool EvaluateAsRelocatableImpl(MCValue &Res,
144 const MCAsmLayout *Layout) const;
145 void AddValueSymbols(MCAssembler *) const;
146 const MCSection *FindAssociatedSection() const {
147 return getSubExpr()->FindAssociatedSection();
150 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const;
152 static bool classof(const MCExpr *E) {
153 return E->getKind() == MCExpr::Target;
156 static bool classof(const AArch64MCExpr *) { return true; }
159 } // end namespace llvm