LLVM  3.7.0
NVPTXMCExpr.h
Go to the documentation of this file.
1 //===-- NVPTXMCExpr.h - NVPTX specific MC expression classes ----*- C++ -*-===//
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 // Modeled after ARMMCExpr
11 
12 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
13 #define LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
14 
15 #include "llvm/ADT/APFloat.h"
16 #include "llvm/MC/MCExpr.h"
17 
18 namespace llvm {
19 
21 public:
22  enum VariantKind {
24  VK_NVPTX_SINGLE_PREC_FLOAT, // FP constant in single-precision
25  VK_NVPTX_DOUBLE_PREC_FLOAT // FP constant in double-precision
26  };
27 
28 private:
29  const VariantKind Kind;
30  const APFloat Flt;
31 
32  explicit NVPTXFloatMCExpr(VariantKind Kind, APFloat Flt)
33  : Kind(Kind), Flt(Flt) {}
34 
35 public:
36  /// @name Construction
37  /// @{
38 
39  static const NVPTXFloatMCExpr *create(VariantKind Kind, APFloat Flt,
40  MCContext &Ctx);
41 
43  MCContext &Ctx) {
44  return create(VK_NVPTX_SINGLE_PREC_FLOAT, Flt, Ctx);
45  }
46 
48  MCContext &Ctx) {
49  return create(VK_NVPTX_DOUBLE_PREC_FLOAT, Flt, Ctx);
50  }
51 
52  /// @}
53  /// @name Accessors
54  /// @{
55 
56  /// getOpcode - Get the kind of this expression.
57  VariantKind getKind() const { return Kind; }
58 
59  /// getSubExpr - Get the child of this expression.
60  APFloat getAPFloat() const { return Flt; }
61 
62 /// @}
63 
64  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
66  const MCAsmLayout *Layout,
67  const MCFixup *Fixup) const override {
68  return false;
69  }
70  void visitUsedExpr(MCStreamer &Streamer) const override {};
71  MCSection *findAssociatedSection() const override { return nullptr; }
72 
73  // There are no TLS NVPTXMCExprs at the moment.
74  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
75 
76  static bool classof(const MCExpr *E) {
77  return E->getKind() == MCExpr::Target;
78  }
79 };
80 
81 /// A wrapper for MCSymbolRefExpr that tells the assembly printer that the
82 /// symbol should be enclosed by generic().
84 private:
85  const MCSymbolRefExpr *SymExpr;
86 
87  explicit NVPTXGenericMCSymbolRefExpr(const MCSymbolRefExpr *_SymExpr)
88  : SymExpr(_SymExpr) {}
89 
90 public:
91  /// @name Construction
92  /// @{
93 
94  static const NVPTXGenericMCSymbolRefExpr
95  *create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx);
96 
97  /// @}
98  /// @name Accessors
99  /// @{
100 
101  /// getOpcode - Get the kind of this expression.
102  const MCSymbolRefExpr *getSymbolExpr() const { return SymExpr; }
103 
104  /// @}
105 
106  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
108  const MCAsmLayout *Layout,
109  const MCFixup *Fixup) const override {
110  return false;
111  }
112  void visitUsedExpr(MCStreamer &Streamer) const override {};
113  MCSection *findAssociatedSection() const override { return nullptr; }
114 
115  // There are no TLS NVPTXMCExprs at the moment.
116  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
117 
118  static bool classof(const MCExpr *E) {
119  return E->getKind() == MCExpr::Target;
120  }
121  };
122 } // end namespace llvm
123 
124 #endif
static const NVPTXFloatMCExpr * createConstantFPDouble(APFloat Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.h:47
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: NVPTXMCExpr.h:112
This represents an "assembler immediate".
Definition: MCValue.h:44
ExprKind getKind() const
Definition: MCExpr.h:69
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:62
MCSection * findAssociatedSection() const override
Definition: NVPTXMCExpr.h:113
MCSection * findAssociatedSection() const override
Definition: NVPTXMCExpr.h:71
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
VariantKind getKind() const
getOpcode - Get the kind of this expression.
Definition: NVPTXMCExpr.h:57
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:548
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:159
Context object for machine code objects.
Definition: MCContext.h:48
static const NVPTXFloatMCExpr * createConstantFPSingle(APFloat Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.h:42
static const NVPTXGenericMCSymbolRefExpr * create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx)
Definition: NVPTXMCExpr.cpp:50
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:58
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
Definition: APFloat.h:122
Streaming machine code generation interface.
Definition: MCStreamer.h:157
static bool classof(const MCExpr *E)
Definition: NVPTXMCExpr.h:118
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: NVPTXMCExpr.h:65
This file declares a class to represent arbitrary precision floating point values and provide a varie...
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: NVPTXMCExpr.h:74
APFloat getAPFloat() const
getSubExpr - Get the child of this expression.
Definition: NVPTXMCExpr.h:60
PowerPC TLS Dynamic Call Fixup
static bool classof(const MCExpr *E)
Definition: NVPTXMCExpr.h:76
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: NVPTXMCExpr.h:70
static const NVPTXFloatMCExpr * create(VariantKind Kind, APFloat Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.cpp:19
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: NVPTXMCExpr.cpp:55
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: NVPTXMCExpr.h:116
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: NVPTXMCExpr.cpp:23
const MCSymbolRefExpr * getSymbolExpr() const
getOpcode - Get the kind of this expression.
Definition: NVPTXMCExpr.h:102
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: NVPTXMCExpr.h:107
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
A wrapper for MCSymbolRefExpr that tells the assembly printer that the symbol should be enclosed by g...
Definition: NVPTXMCExpr.h:83
Target specific expression.
Definition: MCExpr.h:40