#ifndef LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64MCEXPR_H
#define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64MCEXPR_H
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
class AArch64MCExpr : public MCTargetExpr {
public:
enum VariantKind {
VK_ABS = 0x001,
VK_SABS = 0x002,
VK_PREL = 0x003,
VK_GOT = 0x004,
VK_DTPREL = 0x005,
VK_GOTTPREL = 0x006,
VK_TPREL = 0x007,
VK_TLSDESC = 0x008,
VK_SECREL = 0x009,
VK_SymLocBits = 0x00f,
VK_PAGE = 0x010,
VK_PAGEOFF = 0x020,
VK_HI12 = 0x030,
VK_G0 = 0x040,
VK_G1 = 0x050,
VK_G2 = 0x060,
VK_G3 = 0x070,
VK_LO15 = 0x080,
VK_AddressFragBits = 0x0f0,
VK_NC = 0x100,
VK_CALL = VK_ABS,
VK_ABS_PAGE = VK_ABS | VK_PAGE,
VK_ABS_PAGE_NC = VK_ABS | VK_PAGE | VK_NC,
VK_ABS_G3 = VK_ABS | VK_G3,
VK_ABS_G2 = VK_ABS | VK_G2,
VK_ABS_G2_S = VK_SABS | VK_G2,
VK_ABS_G2_NC = VK_ABS | VK_G2 | VK_NC,
VK_ABS_G1 = VK_ABS | VK_G1,
VK_ABS_G1_S = VK_SABS | VK_G1,
VK_ABS_G1_NC = VK_ABS | VK_G1 | VK_NC,
VK_ABS_G0 = VK_ABS | VK_G0,
VK_ABS_G0_S = VK_SABS | VK_G0,
VK_ABS_G0_NC = VK_ABS | VK_G0 | VK_NC,
VK_LO12 = VK_ABS | VK_PAGEOFF | VK_NC,
VK_PREL_G3 = VK_PREL | VK_G3,
VK_PREL_G2 = VK_PREL | VK_G2,
VK_PREL_G2_NC = VK_PREL | VK_G2 | VK_NC,
VK_PREL_G1 = VK_PREL | VK_G1,
VK_PREL_G1_NC = VK_PREL | VK_G1 | VK_NC,
VK_PREL_G0 = VK_PREL | VK_G0,
VK_PREL_G0_NC = VK_PREL | VK_G0 | VK_NC,
VK_GOT_LO12 = VK_GOT | VK_PAGEOFF | VK_NC,
VK_GOT_PAGE = VK_GOT | VK_PAGE,
VK_GOT_PAGE_LO15 = VK_GOT | VK_LO15 | VK_NC,
VK_DTPREL_G2 = VK_DTPREL | VK_G2,
VK_DTPREL_G1 = VK_DTPREL | VK_G1,
VK_DTPREL_G1_NC = VK_DTPREL | VK_G1 | VK_NC,
VK_DTPREL_G0 = VK_DTPREL | VK_G0,
VK_DTPREL_G0_NC = VK_DTPREL | VK_G0 | VK_NC,
VK_DTPREL_HI12 = VK_DTPREL | VK_HI12,
VK_DTPREL_LO12 = VK_DTPREL | VK_PAGEOFF,
VK_DTPREL_LO12_NC = VK_DTPREL | VK_PAGEOFF | VK_NC,
VK_GOTTPREL_PAGE = VK_GOTTPREL | VK_PAGE,
VK_GOTTPREL_LO12_NC = VK_GOTTPREL | VK_PAGEOFF | VK_NC,
VK_GOTTPREL_G1 = VK_GOTTPREL | VK_G1,
VK_GOTTPREL_G0_NC = VK_GOTTPREL | VK_G0 | VK_NC,
VK_TPREL_G2 = VK_TPREL | VK_G2,
VK_TPREL_G1 = VK_TPREL | VK_G1,
VK_TPREL_G1_NC = VK_TPREL | VK_G1 | VK_NC,
VK_TPREL_G0 = VK_TPREL | VK_G0,
VK_TPREL_G0_NC = VK_TPREL | VK_G0 | VK_NC,
VK_TPREL_HI12 = VK_TPREL | VK_HI12,
VK_TPREL_LO12 = VK_TPREL | VK_PAGEOFF,
VK_TPREL_LO12_NC = VK_TPREL | VK_PAGEOFF | VK_NC,
VK_TLSDESC_LO12 = VK_TLSDESC | VK_PAGEOFF,
VK_TLSDESC_PAGE = VK_TLSDESC | VK_PAGE,
VK_SECREL_LO12 = VK_SECREL | VK_PAGEOFF,
VK_SECREL_HI12 = VK_SECREL | VK_HI12,
VK_INVALID = 0xfff
};
private:
const MCExpr *Expr;
const VariantKind Kind;
explicit AArch64MCExpr(const MCExpr *Expr, VariantKind Kind)
: Expr(Expr), Kind(Kind) {}
public:
static const AArch64MCExpr *create(const MCExpr *Expr, VariantKind Kind,
MCContext &Ctx);
VariantKind getKind() const { return Kind; }
const MCExpr *getSubExpr() const { return Expr; }
static VariantKind getSymbolLoc(VariantKind Kind) {
return static_cast<VariantKind>(Kind & VK_SymLocBits);
}
static VariantKind getAddressFrag(VariantKind Kind) {
return static_cast<VariantKind>(Kind & VK_AddressFragBits);
}
static bool isNotChecked(VariantKind Kind) { return Kind & VK_NC; }
StringRef getVariantKindName() const;
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
void visitUsedExpr(MCStreamer &Streamer) const override;
MCFragment *findAssociatedFragment() const override;
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
const MCFixup *Fixup) const override;
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
static bool classof(const MCExpr *E) {
return E->getKind() == MCExpr::Target;
}
static bool classof(const AArch64MCExpr *) { return true; }
};
}
#endif