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