LLVM API Documentation
00001 //===-- PPCMCExpr.h - PPC 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 #ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H 00011 #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H 00012 00013 #include "llvm/MC/MCAsmLayout.h" 00014 #include "llvm/MC/MCExpr.h" 00015 #include "llvm/MC/MCValue.h" 00016 00017 namespace llvm { 00018 00019 class PPCMCExpr : public MCTargetExpr { 00020 public: 00021 enum VariantKind { 00022 VK_PPC_None, 00023 VK_PPC_LO, 00024 VK_PPC_HI, 00025 VK_PPC_HA, 00026 VK_PPC_HIGHER, 00027 VK_PPC_HIGHERA, 00028 VK_PPC_HIGHEST, 00029 VK_PPC_HIGHESTA 00030 }; 00031 00032 private: 00033 const VariantKind Kind; 00034 const MCExpr *Expr; 00035 bool IsDarwin; 00036 00037 int64_t EvaluateAsInt64(int64_t Value) const; 00038 00039 explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr, 00040 bool _IsDarwin) 00041 : Kind(_Kind), Expr(_Expr), IsDarwin(_IsDarwin) {} 00042 00043 public: 00044 /// @name Construction 00045 /// @{ 00046 00047 static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr, 00048 bool isDarwin, MCContext &Ctx); 00049 00050 static const PPCMCExpr *CreateLo(const MCExpr *Expr, 00051 bool isDarwin, MCContext &Ctx) { 00052 return Create(VK_PPC_LO, Expr, isDarwin, Ctx); 00053 } 00054 00055 static const PPCMCExpr *CreateHi(const MCExpr *Expr, 00056 bool isDarwin, MCContext &Ctx) { 00057 return Create(VK_PPC_HI, Expr, isDarwin, Ctx); 00058 } 00059 00060 static const PPCMCExpr *CreateHa(const MCExpr *Expr, 00061 bool isDarwin, MCContext &Ctx) { 00062 return Create(VK_PPC_HA, Expr, isDarwin, Ctx); 00063 } 00064 00065 /// @} 00066 /// @name Accessors 00067 /// @{ 00068 00069 /// getOpcode - Get the kind of this expression. 00070 VariantKind getKind() const { return Kind; } 00071 00072 /// getSubExpr - Get the child of this expression. 00073 const MCExpr *getSubExpr() const { return Expr; } 00074 00075 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax. 00076 bool isDarwinSyntax() const { return IsDarwin; } 00077 00078 00079 /// @} 00080 00081 void PrintImpl(raw_ostream &OS) const override; 00082 bool EvaluateAsRelocatableImpl(MCValue &Res, 00083 const MCAsmLayout *Layout, 00084 const MCFixup *Fixup) const override; 00085 void visitUsedExpr(MCStreamer &Streamer) const override; 00086 const MCSection *FindAssociatedSection() const override { 00087 return getSubExpr()->FindAssociatedSection(); 00088 } 00089 00090 // There are no TLS PPCMCExprs at the moment. 00091 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} 00092 00093 bool EvaluateAsConstant(int64_t &Res) const; 00094 00095 static bool classof(const MCExpr *E) { 00096 return E->getKind() == MCExpr::Target; 00097 } 00098 }; 00099 } // end namespace llvm 00100 00101 #endif