LLVM 22.0.0git
NVPTXMCExpr.h
Go to the documentation of this file.
1//===-- NVPTXMCExpr.h - NVPTX specific MC expression classes ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Modeled after ARMMCExpr
10
11#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
12#define LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
13
14#include "llvm/ADT/APFloat.h"
15#include "llvm/MC/MCExpr.h"
16#include <utility>
17
18namespace llvm {
19
21public:
24 VK_NVPTX_BFLOAT_PREC_FLOAT, // FP constant in bfloat-precision
25 VK_NVPTX_HALF_PREC_FLOAT, // FP constant in half-precision
26 VK_NVPTX_SINGLE_PREC_FLOAT, // FP constant in single-precision
27 VK_NVPTX_DOUBLE_PREC_FLOAT // FP constant in double-precision
28 };
29
30private:
31 const VariantKind Kind;
32 const APFloat Flt;
33
34 explicit NVPTXFloatMCExpr(VariantKind Kind, APFloat Flt)
35 : Kind(Kind), Flt(std::move(Flt)) {}
36
37public:
38 /// @name Construction
39 /// @{
40
41 static const NVPTXFloatMCExpr *create(VariantKind Kind, const APFloat &Flt,
42 MCContext &Ctx);
43
45 MCContext &Ctx) {
47 }
48
50 MCContext &Ctx) {
52 }
53
55 MCContext &Ctx) {
57 }
58
60 MCContext &Ctx) {
62 }
63
64 /// @}
65 /// @name Accessors
66 /// @{
67
68 /// getOpcode - Get the kind of this expression.
69 VariantKind getKind() const { return Kind; }
70
71 /// getSubExpr - Get the child of this expression.
72 APFloat getAPFloat() const { return Flt; }
73
74/// @}
75
76 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
78 const MCAssembler *Asm) const override {
79 return false;
80 }
81 void visitUsedExpr(MCStreamer &Streamer) const override {};
82 MCFragment *findAssociatedFragment() const override { return nullptr; }
83
84 static bool classof(const MCExpr *E) {
85 return E->getKind() == MCExpr::Target;
86 }
87};
88
89/// A wrapper for MCSymbolRefExpr that tells the assembly printer that the
90/// symbol should be enclosed by generic().
92private:
93 const MCSymbolRefExpr *SymExpr;
94
95 explicit NVPTXGenericMCSymbolRefExpr(const MCSymbolRefExpr *_SymExpr)
96 : SymExpr(_SymExpr) {}
97
98public:
99 /// @name Construction
100 /// @{
101
102 static const NVPTXGenericMCSymbolRefExpr
103 *create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx);
104
105 /// @}
106 /// @name Accessors
107 /// @{
108
109 /// getOpcode - Get the kind of this expression.
110 const MCSymbolRefExpr *getSymbolExpr() const { return SymExpr; }
111
112 /// @}
113
114 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
116 const MCAssembler *Asm) const override {
117 return false;
118 }
119 void visitUsedExpr(MCStreamer &Streamer) const override {};
120 MCFragment *findAssociatedFragment() const override { return nullptr; }
121
122 static bool classof(const MCExpr *E) {
123 return E->getKind() == MCExpr::Target;
124 }
125 };
126} // end namespace llvm
127
128#endif
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
raw_pwrite_stream & OS
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
@ Target
Target specific expression.
Definition: MCExpr.h:46
Streaming machine code generation interface.
Definition: MCStreamer.h:220
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:190
Extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:465
static const NVPTXFloatMCExpr * createConstantBFPHalf(const APFloat &Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.h:44
static const NVPTXFloatMCExpr * createConstantFPHalf(const APFloat &Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.h:49
APFloat getAPFloat() const
getSubExpr - Get the child of this expression.
Definition: NVPTXMCExpr.h:72
VariantKind getKind() const
getOpcode - Get the kind of this expression.
Definition: NVPTXMCExpr.h:69
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: NVPTXMCExpr.h:81
static const NVPTXFloatMCExpr * createConstantFPSingle(const APFloat &Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.h:54
static const NVPTXFloatMCExpr * create(VariantKind Kind, const APFloat &Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.cpp:20
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: NVPTXMCExpr.cpp:24
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const override
Definition: NVPTXMCExpr.h:77
static const NVPTXFloatMCExpr * createConstantFPDouble(const APFloat &Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.h:59
static bool classof(const MCExpr *E)
Definition: NVPTXMCExpr.h:84
MCFragment * findAssociatedFragment() const override
Definition: NVPTXMCExpr.h:82
A wrapper for MCSymbolRefExpr that tells the assembly printer that the symbol should be enclosed by g...
Definition: NVPTXMCExpr.h:91
static const NVPTXGenericMCSymbolRefExpr * create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx)
Definition: NVPTXMCExpr.cpp:60
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: NVPTXMCExpr.h:119
MCFragment * findAssociatedFragment() const override
Definition: NVPTXMCExpr.h:120
const MCSymbolRefExpr * getSymbolExpr() const
getOpcode - Get the kind of this expression.
Definition: NVPTXMCExpr.h:110
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const override
Definition: NVPTXMCExpr.h:115
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: NVPTXMCExpr.cpp:65
static bool classof(const MCExpr *E)
Definition: NVPTXMCExpr.h:122
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856