LLVM API Documentation

SparcMCExpr.h
Go to the documentation of this file.
00001 //====- SparcMCExpr.h - Sparc specific MC expression classes --*- C++ -*-=====//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file describes Sparc-specific MCExprs, used for modifiers like
00011 // "%hi" or "%lo" etc.,
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCEXPR_H
00016 #define LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCEXPR_H
00017 
00018 #include "SparcFixupKinds.h"
00019 #include "llvm/MC/MCExpr.h"
00020 
00021 namespace llvm {
00022 
00023 class StringRef;
00024 class SparcMCExpr : public MCTargetExpr {
00025 public:
00026   enum VariantKind {
00027     VK_Sparc_None,
00028     VK_Sparc_LO,
00029     VK_Sparc_HI,
00030     VK_Sparc_H44,
00031     VK_Sparc_M44,
00032     VK_Sparc_L44,
00033     VK_Sparc_HH,
00034     VK_Sparc_HM,
00035     VK_Sparc_PC22,
00036     VK_Sparc_PC10,
00037     VK_Sparc_GOT22,
00038     VK_Sparc_GOT10,
00039     VK_Sparc_WPLT30,
00040     VK_Sparc_R_DISP32,
00041     VK_Sparc_TLS_GD_HI22,
00042     VK_Sparc_TLS_GD_LO10,
00043     VK_Sparc_TLS_GD_ADD,
00044     VK_Sparc_TLS_GD_CALL,
00045     VK_Sparc_TLS_LDM_HI22,
00046     VK_Sparc_TLS_LDM_LO10,
00047     VK_Sparc_TLS_LDM_ADD,
00048     VK_Sparc_TLS_LDM_CALL,
00049     VK_Sparc_TLS_LDO_HIX22,
00050     VK_Sparc_TLS_LDO_LOX10,
00051     VK_Sparc_TLS_LDO_ADD,
00052     VK_Sparc_TLS_IE_HI22,
00053     VK_Sparc_TLS_IE_LO10,
00054     VK_Sparc_TLS_IE_LD,
00055     VK_Sparc_TLS_IE_LDX,
00056     VK_Sparc_TLS_IE_ADD,
00057     VK_Sparc_TLS_LE_HIX22,
00058     VK_Sparc_TLS_LE_LOX10
00059   };
00060 
00061 private:
00062   const VariantKind Kind;
00063   const MCExpr *Expr;
00064 
00065   explicit SparcMCExpr(VariantKind _Kind, const MCExpr *_Expr)
00066     : Kind(_Kind), Expr(_Expr) {}
00067 
00068 public:
00069   /// @name Construction
00070   /// @{
00071 
00072   static const SparcMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
00073                                  MCContext &Ctx);
00074   /// @}
00075   /// @name Accessors
00076   /// @{
00077 
00078   /// getOpcode - Get the kind of this expression.
00079   VariantKind getKind() const { return Kind; }
00080 
00081   /// getSubExpr - Get the child of this expression.
00082   const MCExpr *getSubExpr() const { return Expr; }
00083 
00084   /// getFixupKind - Get the fixup kind of this expression.
00085   Sparc::Fixups getFixupKind() const { return getFixupKind(Kind); }
00086 
00087   /// @}
00088   void PrintImpl(raw_ostream &OS) const override;
00089   bool EvaluateAsRelocatableImpl(MCValue &Res,
00090                                  const MCAsmLayout *Layout,
00091                                  const MCFixup *Fixup) const override;
00092   void visitUsedExpr(MCStreamer &Streamer) const override;
00093   const MCSection *FindAssociatedSection() const override {
00094     return getSubExpr()->FindAssociatedSection();
00095   }
00096 
00097   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
00098 
00099   static bool classof(const MCExpr *E) {
00100     return E->getKind() == MCExpr::Target;
00101   }
00102 
00103   static bool classof(const SparcMCExpr *) { return true; }
00104 
00105   static VariantKind parseVariantKind(StringRef name);
00106   static bool printVariantKind(raw_ostream &OS, VariantKind Kind);
00107   static Sparc::Fixups getFixupKind(VariantKind Kind);
00108 };
00109 
00110 } // end namespace llvm.
00111 
00112 #endif