LLVM API Documentation

NVPTXMCExpr.h
Go to the documentation of this file.
00001 //===-- NVPTXMCExpr.h - NVPTX 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 // Modeled after ARMMCExpr
00011 
00012 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
00013 #define LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
00014 
00015 #include "llvm/ADT/APFloat.h"
00016 #include "llvm/MC/MCExpr.h"
00017 
00018 namespace llvm {
00019 
00020 class NVPTXFloatMCExpr : public MCTargetExpr {
00021 public:
00022   enum VariantKind {
00023     VK_NVPTX_None,
00024     VK_NVPTX_SINGLE_PREC_FLOAT,   // FP constant in single-precision
00025     VK_NVPTX_DOUBLE_PREC_FLOAT    // FP constant in double-precision
00026   };
00027 
00028 private:
00029   const VariantKind Kind;
00030   const APFloat Flt;
00031 
00032   explicit NVPTXFloatMCExpr(VariantKind _Kind, APFloat _Flt)
00033     : Kind(_Kind), Flt(_Flt) {}
00034 
00035 public:
00036   /// @name Construction
00037   /// @{
00038 
00039   static const NVPTXFloatMCExpr *Create(VariantKind Kind, APFloat Flt,
00040                                         MCContext &Ctx);
00041 
00042   static const NVPTXFloatMCExpr *CreateConstantFPSingle(APFloat Flt,
00043                                                         MCContext &Ctx) {
00044     return Create(VK_NVPTX_SINGLE_PREC_FLOAT, Flt, Ctx);
00045   }
00046 
00047   static const NVPTXFloatMCExpr *CreateConstantFPDouble(APFloat Flt,
00048                                                         MCContext &Ctx) {
00049     return Create(VK_NVPTX_DOUBLE_PREC_FLOAT, Flt, Ctx);
00050   }
00051 
00052   /// @}
00053   /// @name Accessors
00054   /// @{
00055 
00056   /// getOpcode - Get the kind of this expression.
00057   VariantKind getKind() const { return Kind; }
00058 
00059   /// getSubExpr - Get the child of this expression.
00060   APFloat getAPFloat() const { return Flt; }
00061 
00062 /// @}
00063 
00064   void PrintImpl(raw_ostream &OS) const override;
00065   bool EvaluateAsRelocatableImpl(MCValue &Res,
00066                                  const MCAsmLayout *Layout,
00067                                  const MCFixup *Fixup) const override {
00068     return false;
00069   }
00070   void visitUsedExpr(MCStreamer &Streamer) const override {};
00071   const MCSection *FindAssociatedSection() const override {
00072     return nullptr;
00073   }
00074 
00075   // There are no TLS NVPTXMCExprs at the moment.
00076   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
00077 
00078   static bool classof(const MCExpr *E) {
00079     return E->getKind() == MCExpr::Target;
00080   }
00081 };
00082 } // end namespace llvm
00083 
00084 #endif