1 //===-- MipsMCSymbolRefExpr.h - Mips specific MCSymbolRefExpr class -------===// 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 MIPSMCSYMBOLREFEXPR_H 11 #define MIPSMCSYMBOLREFEXPR_H 12 #include "llvm/MC/MCExpr.h" 13 14 namespace llvm { 15 16 class MipsMCSymbolRefExpr : public MCTargetExpr { 17 public: 18 enum VariantKind { 19 VK_Mips_None, 20 VK_Mips_GPREL, 21 VK_Mips_GOT_CALL, 22 VK_Mips_GOT, 23 VK_Mips_ABS_HI, 24 VK_Mips_ABS_LO, 25 VK_Mips_TLSGD, 26 VK_Mips_GOTTPREL, 27 VK_Mips_TPREL_HI, 28 VK_Mips_TPREL_LO, 29 VK_Mips_GPOFF_HI, 30 VK_Mips_GPOFF_LO, 31 VK_Mips_GOT_DISP, 32 VK_Mips_GOT_PAGE, 33 VK_Mips_GOT_OFST 34 }; 35 36 private: 37 const VariantKind Kind; 38 const MCSymbol *Symbol; 39 int Offset; 40 MipsMCSymbolRefExpr(VariantKind _Kind,const MCSymbol * _Symbol,int _Offset)41 explicit MipsMCSymbolRefExpr(VariantKind _Kind, const MCSymbol *_Symbol, 42 int _Offset) 43 : Kind(_Kind), Symbol(_Symbol), Offset(_Offset) {} 44 45 public: 46 static const MipsMCSymbolRefExpr *Create(VariantKind Kind, 47 const MCSymbol *Symbol, int Offset, 48 MCContext &Ctx); 49 50 void PrintImpl(raw_ostream &OS) const; 51 bool EvaluateAsRelocatableImpl(MCValue &Res, 52 const MCAsmLayout *Layout) const; 53 void AddValueSymbols(MCAssembler *) const; 54 const MCSection *FindAssociatedSection() const; 55 classof(const MCExpr * E)56 static bool classof(const MCExpr *E) { 57 return E->getKind() == MCExpr::Target; 58 } 59 classof(const MipsMCSymbolRefExpr *)60 static bool classof(const MipsMCSymbolRefExpr *) { return true; } 61 getOffset()62 int getOffset() const { return Offset; } setOffset(int O)63 void setOffset(int O) { Offset = O; } 64 }; 65 } // end namespace llvm 66 67 #endif 68