1*9880d681SAndroid Build Coastguard Worker //===-- ARMMCExpr.h - ARM specific MC expression classes --------*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H 11*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCExpr.h" 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker namespace llvm { 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker class ARMMCExpr : public MCTargetExpr { 18*9880d681SAndroid Build Coastguard Worker public: 19*9880d681SAndroid Build Coastguard Worker enum VariantKind { 20*9880d681SAndroid Build Coastguard Worker VK_ARM_None, 21*9880d681SAndroid Build Coastguard Worker VK_ARM_HI16, // The R_ARM_MOVT_ABS relocation (:upper16: in the .s file) 22*9880d681SAndroid Build Coastguard Worker VK_ARM_LO16 // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the .s file) 23*9880d681SAndroid Build Coastguard Worker }; 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker private: 26*9880d681SAndroid Build Coastguard Worker const VariantKind Kind; 27*9880d681SAndroid Build Coastguard Worker const MCExpr *Expr; 28*9880d681SAndroid Build Coastguard Worker ARMMCExpr(VariantKind Kind,const MCExpr * Expr)29*9880d681SAndroid Build Coastguard Worker explicit ARMMCExpr(VariantKind Kind, const MCExpr *Expr) 30*9880d681SAndroid Build Coastguard Worker : Kind(Kind), Expr(Expr) {} 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker public: 33*9880d681SAndroid Build Coastguard Worker /// @name Construction 34*9880d681SAndroid Build Coastguard Worker /// @{ 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker static const ARMMCExpr *create(VariantKind Kind, const MCExpr *Expr, 37*9880d681SAndroid Build Coastguard Worker MCContext &Ctx); 38*9880d681SAndroid Build Coastguard Worker createUpper16(const MCExpr * Expr,MCContext & Ctx)39*9880d681SAndroid Build Coastguard Worker static const ARMMCExpr *createUpper16(const MCExpr *Expr, MCContext &Ctx) { 40*9880d681SAndroid Build Coastguard Worker return create(VK_ARM_HI16, Expr, Ctx); 41*9880d681SAndroid Build Coastguard Worker } 42*9880d681SAndroid Build Coastguard Worker createLower16(const MCExpr * Expr,MCContext & Ctx)43*9880d681SAndroid Build Coastguard Worker static const ARMMCExpr *createLower16(const MCExpr *Expr, MCContext &Ctx) { 44*9880d681SAndroid Build Coastguard Worker return create(VK_ARM_LO16, Expr, Ctx); 45*9880d681SAndroid Build Coastguard Worker } 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker /// @} 48*9880d681SAndroid Build Coastguard Worker /// @name Accessors 49*9880d681SAndroid Build Coastguard Worker /// @{ 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Worker /// getOpcode - Get the kind of this expression. getKind()52*9880d681SAndroid Build Coastguard Worker VariantKind getKind() const { return Kind; } 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard Worker /// getSubExpr - Get the child of this expression. getSubExpr()55*9880d681SAndroid Build Coastguard Worker const MCExpr *getSubExpr() const { return Expr; } 56*9880d681SAndroid Build Coastguard Worker 57*9880d681SAndroid Build Coastguard Worker /// @} 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; evaluateAsRelocatableImpl(MCValue & Res,const MCAsmLayout * Layout,const MCFixup * Fixup)60*9880d681SAndroid Build Coastguard Worker bool evaluateAsRelocatableImpl(MCValue &Res, 61*9880d681SAndroid Build Coastguard Worker const MCAsmLayout *Layout, 62*9880d681SAndroid Build Coastguard Worker const MCFixup *Fixup) const override { 63*9880d681SAndroid Build Coastguard Worker return false; 64*9880d681SAndroid Build Coastguard Worker } 65*9880d681SAndroid Build Coastguard Worker void visitUsedExpr(MCStreamer &Streamer) const override; findAssociatedFragment()66*9880d681SAndroid Build Coastguard Worker MCFragment *findAssociatedFragment() const override { 67*9880d681SAndroid Build Coastguard Worker return getSubExpr()->findAssociatedFragment(); 68*9880d681SAndroid Build Coastguard Worker } 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker // There are no TLS ARMMCExprs at the moment. fixELFSymbolsInTLSFixups(MCAssembler & Asm)71*9880d681SAndroid Build Coastguard Worker void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} 72*9880d681SAndroid Build Coastguard Worker classof(const MCExpr * E)73*9880d681SAndroid Build Coastguard Worker static bool classof(const MCExpr *E) { 74*9880d681SAndroid Build Coastguard Worker return E->getKind() == MCExpr::Target; 75*9880d681SAndroid Build Coastguard Worker } 76*9880d681SAndroid Build Coastguard Worker }; 77*9880d681SAndroid Build Coastguard Worker } // end namespace llvm 78*9880d681SAndroid Build Coastguard Worker 79*9880d681SAndroid Build Coastguard Worker #endif 80