1 //===-- CSKYMCExpr.h - CSKY specific MC expression classes -*- C++ -*----===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIB_TARGET_LANAI_MCTARGETDESC_LANAIMCEXPR_H 10 #define LLVM_LIB_TARGET_LANAI_MCTARGETDESC_LANAIMCEXPR_H 11 12 #include "llvm/MC/MCExpr.h" 13 #include "llvm/MC/MCValue.h" 14 15 namespace llvm { 16 17 class CSKYMCExpr : public MCTargetExpr { 18 public: 19 enum VariantKind { 20 VK_CSKY_None, 21 VK_CSKY_ADDR, 22 VK_CSKY_PCREL, 23 VK_CSKY_GOT, 24 VK_CSKY_GOTPC, 25 VK_CSKY_GOTOFF, 26 VK_CSKY_PLT, 27 VK_CSKY_TPOFF, 28 VK_CSKY_TLSGD, 29 VK_CSKY_Invalid 30 }; 31 32 private: 33 const VariantKind Kind; 34 const MCExpr *Expr; 35 36 explicit CSKYMCExpr(VariantKind Kind, const MCExpr *Expr) 37 : Kind(Kind), Expr(Expr) {} 38 39 public: 40 static const CSKYMCExpr *create(const MCExpr *Expr, VariantKind Kind, 41 MCContext &Ctx); 42 43 // Returns the kind of this expression. 44 VariantKind getKind() const { return Kind; } 45 46 // Returns the child of this expression. 47 const MCExpr *getSubExpr() const { return Expr; } 48 49 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; 50 51 bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, 52 const MCFixup *Fixup) const override; 53 void visitUsedExpr(MCStreamer &Streamer) const override; 54 55 MCFragment *findAssociatedFragment() const override { 56 return getSubExpr()->findAssociatedFragment(); 57 } 58 59 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override; 60 61 static bool classof(const MCExpr *E) { 62 return E->getKind() == MCExpr::Target; 63 } 64 65 static StringRef getVariantKindName(VariantKind Kind); 66 }; 67 } // end namespace llvm 68 69 #endif 70