LLVM API Documentation

MipsMCExpr.h
Go to the documentation of this file.
00001 //===-- MipsMCExpr.h - Mips 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_MIPS_MCTARGETDESC_MIPSMCEXPR_H
00011 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCEXPR_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 MipsMCExpr : public MCTargetExpr {
00020 public:
00021   enum VariantKind {
00022     VK_Mips_None,
00023     VK_Mips_LO,
00024     VK_Mips_HI,
00025     VK_Mips_HIGHER,
00026     VK_Mips_HIGHEST
00027   };
00028 
00029 private:
00030   const VariantKind Kind;
00031   const MCExpr *Expr;
00032 
00033   explicit MipsMCExpr(VariantKind Kind, const MCExpr *Expr)
00034     : Kind(Kind), Expr(Expr) {}
00035 
00036 public:
00037   static bool isSupportedBinaryExpr(MCSymbolRefExpr::VariantKind VK,
00038                                     const MCBinaryExpr *BE);
00039 
00040   static const MipsMCExpr *Create(MCSymbolRefExpr::VariantKind VK,
00041                                   const MCExpr *Expr, MCContext &Ctx);
00042 
00043   /// getOpcode - Get the kind of this expression.
00044   VariantKind getKind() const { return Kind; }
00045 
00046   /// getSubExpr - Get the child of this expression.
00047   const MCExpr *getSubExpr() const { return Expr; }
00048 
00049   void PrintImpl(raw_ostream &OS) const override;
00050   bool EvaluateAsRelocatableImpl(MCValue &Res,
00051                                  const MCAsmLayout *Layout,
00052                                  const MCFixup *Fixup) const override;
00053   void visitUsedExpr(MCStreamer &Streamer) const override;
00054   const MCSection *FindAssociatedSection() const override {
00055     return getSubExpr()->FindAssociatedSection();
00056   }
00057 
00058   // There are no TLS MipsMCExprs at the moment.
00059   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
00060 
00061   static bool classof(const MCExpr *E) {
00062     return E->getKind() == MCExpr::Target;
00063   }
00064 };
00065 } // end namespace llvm
00066 
00067 #endif