1*9880d681SAndroid Build Coastguard Worker //===-- LanaiMCExpr.h - Lanai 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_LANAI_MCTARGETDESC_LANAIMCEXPR_H 11*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_LANAI_MCTARGETDESC_LANAIMCEXPR_H 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCExpr.h" 14*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCValue.h" 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker namespace llvm { 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker class LanaiMCExpr : public MCTargetExpr { 19*9880d681SAndroid Build Coastguard Worker public: 20*9880d681SAndroid Build Coastguard Worker enum VariantKind { VK_Lanai_None, VK_Lanai_ABS_HI, VK_Lanai_ABS_LO }; 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker private: 23*9880d681SAndroid Build Coastguard Worker const VariantKind Kind; 24*9880d681SAndroid Build Coastguard Worker const MCExpr *Expr; 25*9880d681SAndroid Build Coastguard Worker LanaiMCExpr(VariantKind Kind,const MCExpr * Expr)26*9880d681SAndroid Build Coastguard Worker explicit LanaiMCExpr(VariantKind Kind, const MCExpr *Expr) 27*9880d681SAndroid Build Coastguard Worker : Kind(Kind), Expr(Expr) {} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker public: 30*9880d681SAndroid Build Coastguard Worker static const LanaiMCExpr *create(VariantKind Kind, const MCExpr *Expr, 31*9880d681SAndroid Build Coastguard Worker MCContext &Ctx); 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker // Returns the kind of this expression. getKind()34*9880d681SAndroid Build Coastguard Worker VariantKind getKind() const { return Kind; } 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker // Returns the child of this expression. getSubExpr()37*9880d681SAndroid Build Coastguard Worker const MCExpr *getSubExpr() const { return Expr; } 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Worker void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; 40*9880d681SAndroid Build Coastguard Worker bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, 41*9880d681SAndroid Build Coastguard Worker const MCFixup *Fixup) const override; 42*9880d681SAndroid Build Coastguard Worker void visitUsedExpr(MCStreamer &Streamer) const override; findAssociatedFragment()43*9880d681SAndroid Build Coastguard Worker MCFragment *findAssociatedFragment() const override { 44*9880d681SAndroid Build Coastguard Worker return getSubExpr()->findAssociatedFragment(); 45*9880d681SAndroid Build Coastguard Worker } 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker // There are no TLS LanaiMCExprs at the moment. fixELFSymbolsInTLSFixups(MCAssembler & Asm)48*9880d681SAndroid Build Coastguard Worker void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} 49*9880d681SAndroid Build Coastguard Worker classof(const MCExpr * E)50*9880d681SAndroid Build Coastguard Worker static bool classof(const MCExpr *E) { 51*9880d681SAndroid Build Coastguard Worker return E->getKind() == MCExpr::Target; 52*9880d681SAndroid Build Coastguard Worker } 53*9880d681SAndroid Build Coastguard Worker }; 54*9880d681SAndroid Build Coastguard Worker } // end namespace llvm 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker #endif 57