1 //====- SparcMCExpr.h - Sparc 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 // This file describes Sparc-specific MCExprs, used for modifiers like 11 // "%hi" or "%lo" etc., 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCEXPR_H 16 #define LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCEXPR_H 17 18 #include "SparcFixupKinds.h" 19 #include "llvm/MC/MCExpr.h" 20 21 namespace llvm { 22 23 class StringRef; 24 class SparcMCExpr : public MCTargetExpr { 25 public: 26 enum VariantKind { 27 VK_Sparc_None, 28 VK_Sparc_LO, 29 VK_Sparc_HI, 30 VK_Sparc_H44, 31 VK_Sparc_M44, 32 VK_Sparc_L44, 33 VK_Sparc_HH, 34 VK_Sparc_HM, 35 VK_Sparc_PC22, 36 VK_Sparc_PC10, 37 VK_Sparc_GOT22, 38 VK_Sparc_GOT10, 39 VK_Sparc_WPLT30, 40 VK_Sparc_R_DISP32, 41 VK_Sparc_TLS_GD_HI22, 42 VK_Sparc_TLS_GD_LO10, 43 VK_Sparc_TLS_GD_ADD, 44 VK_Sparc_TLS_GD_CALL, 45 VK_Sparc_TLS_LDM_HI22, 46 VK_Sparc_TLS_LDM_LO10, 47 VK_Sparc_TLS_LDM_ADD, 48 VK_Sparc_TLS_LDM_CALL, 49 VK_Sparc_TLS_LDO_HIX22, 50 VK_Sparc_TLS_LDO_LOX10, 51 VK_Sparc_TLS_LDO_ADD, 52 VK_Sparc_TLS_IE_HI22, 53 VK_Sparc_TLS_IE_LO10, 54 VK_Sparc_TLS_IE_LD, 55 VK_Sparc_TLS_IE_LDX, 56 VK_Sparc_TLS_IE_ADD, 57 VK_Sparc_TLS_LE_HIX22, 58 VK_Sparc_TLS_LE_LOX10 59 }; 60 61 private: 62 const VariantKind Kind; 63 const MCExpr *Expr; 64 65 explicit SparcMCExpr(VariantKind Kind, const MCExpr *Expr) 66 : Kind(Kind), Expr(Expr) {} 67 68 public: 69 /// @name Construction 70 /// @{ 71 72 static const SparcMCExpr *create(VariantKind Kind, const MCExpr *Expr, 73 MCContext &Ctx); 74 /// @} 75 /// @name Accessors 76 /// @{ 77 78 /// getOpcode - Get the kind of this expression. 79 VariantKind getKind() const { return Kind; } 80 81 /// getSubExpr - Get the child of this expression. 82 const MCExpr *getSubExpr() const { return Expr; } 83 84 /// getFixupKind - Get the fixup kind of this expression. 85 Sparc::Fixups getFixupKind() const { return getFixupKind(Kind); } 86 87 /// @} 88 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; 89 bool evaluateAsRelocatableImpl(MCValue &Res, 90 const MCAsmLayout *Layout, 91 const MCFixup *Fixup) const override; 92 void visitUsedExpr(MCStreamer &Streamer) const override; 93 MCFragment *findAssociatedFragment() const override { 94 return getSubExpr()->findAssociatedFragment(); 95 } 96 97 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override; 98 99 static bool classof(const MCExpr *E) { 100 return E->getKind() == MCExpr::Target; 101 } 102 103 static bool classof(const SparcMCExpr *) { return true; } 104 105 static VariantKind parseVariantKind(StringRef name); 106 static bool printVariantKind(raw_ostream &OS, VariantKind Kind); 107 static Sparc::Fixups getFixupKind(VariantKind Kind); 108 }; 109 110 } // end namespace llvm. 111 112 #endif 113