2013-08-06 22:13:27 +08:00
|
|
|
//===-- NVPTXMCExpr.h - NVPTX specific MC expression classes ----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Modeled after ARMMCExpr
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
|
|
|
|
#define LLVM_LIB_TARGET_NVPTX_NVPTXMCEXPR_H
|
2013-08-06 22:13:27 +08:00
|
|
|
|
|
|
|
#include "llvm/ADT/APFloat.h"
|
|
|
|
#include "llvm/MC/MCExpr.h"
|
2016-05-27 22:27:24 +08:00
|
|
|
#include <utility>
|
2013-08-06 22:13:27 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class NVPTXFloatMCExpr : public MCTargetExpr {
|
|
|
|
public:
|
|
|
|
enum VariantKind {
|
|
|
|
VK_NVPTX_None,
|
2017-01-14 04:56:17 +08:00
|
|
|
VK_NVPTX_HALF_PREC_FLOAT, // FP constant in half-precision
|
|
|
|
VK_NVPTX_SINGLE_PREC_FLOAT, // FP constant in single-precision
|
|
|
|
VK_NVPTX_DOUBLE_PREC_FLOAT // FP constant in double-precision
|
2013-08-06 22:13:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
const VariantKind Kind;
|
|
|
|
const APFloat Flt;
|
|
|
|
|
2015-03-17 02:06:57 +08:00
|
|
|
explicit NVPTXFloatMCExpr(VariantKind Kind, APFloat Flt)
|
2016-05-27 22:27:24 +08:00
|
|
|
: Kind(Kind), Flt(std::move(Flt)) {}
|
2013-08-06 22:13:27 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// @name Construction
|
|
|
|
/// @{
|
|
|
|
|
2016-06-09 03:09:22 +08:00
|
|
|
static const NVPTXFloatMCExpr *create(VariantKind Kind, const APFloat &Flt,
|
2013-08-06 22:13:27 +08:00
|
|
|
MCContext &Ctx);
|
|
|
|
|
2017-01-14 04:56:17 +08:00
|
|
|
static const NVPTXFloatMCExpr *createConstantFPHalf(const APFloat &Flt,
|
|
|
|
MCContext &Ctx) {
|
|
|
|
return create(VK_NVPTX_HALF_PREC_FLOAT, Flt, Ctx);
|
|
|
|
}
|
|
|
|
|
2016-06-09 03:09:22 +08:00
|
|
|
static const NVPTXFloatMCExpr *createConstantFPSingle(const APFloat &Flt,
|
2013-08-06 22:13:27 +08:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 09:25:56 +08:00
|
|
|
return create(VK_NVPTX_SINGLE_PREC_FLOAT, Flt, Ctx);
|
2013-08-06 22:13:27 +08:00
|
|
|
}
|
|
|
|
|
2016-06-09 03:09:22 +08:00
|
|
|
static const NVPTXFloatMCExpr *createConstantFPDouble(const APFloat &Flt,
|
2013-08-06 22:13:27 +08:00
|
|
|
MCContext &Ctx) {
|
2015-05-30 09:25:56 +08:00
|
|
|
return create(VK_NVPTX_DOUBLE_PREC_FLOAT, Flt, Ctx);
|
2013-08-06 22:13:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
/// @name Accessors
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// getOpcode - Get the kind of this expression.
|
|
|
|
VariantKind getKind() const { return Kind; }
|
|
|
|
|
|
|
|
/// getSubExpr - Get the child of this expression.
|
|
|
|
APFloat getAPFloat() const { return Flt; }
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
2015-06-09 08:31:39 +08:00
|
|
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
2015-05-30 09:25:56 +08:00
|
|
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
2014-08-10 19:35:12 +08:00
|
|
|
const MCAsmLayout *Layout,
|
|
|
|
const MCFixup *Fixup) const override {
|
2013-08-06 22:13:27 +08:00
|
|
|
return false;
|
|
|
|
}
|
2014-06-25 23:45:33 +08:00
|
|
|
void visitUsedExpr(MCStreamer &Streamer) const override {};
|
2015-10-05 20:07:05 +08:00
|
|
|
MCFragment *findAssociatedFragment() const override { return nullptr; }
|
2013-08-06 22:13:27 +08:00
|
|
|
|
|
|
|
// There are no TLS NVPTXMCExprs at the moment.
|
2014-04-29 15:57:44 +08:00
|
|
|
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
|
2013-08-06 22:13:27 +08:00
|
|
|
|
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::Target;
|
|
|
|
}
|
|
|
|
};
|
2015-04-29 01:18:30 +08:00
|
|
|
|
|
|
|
/// A wrapper for MCSymbolRefExpr that tells the assembly printer that the
|
|
|
|
/// symbol should be enclosed by generic().
|
|
|
|
class NVPTXGenericMCSymbolRefExpr : public MCTargetExpr {
|
|
|
|
private:
|
|
|
|
const MCSymbolRefExpr *SymExpr;
|
|
|
|
|
|
|
|
explicit NVPTXGenericMCSymbolRefExpr(const MCSymbolRefExpr *_SymExpr)
|
|
|
|
: SymExpr(_SymExpr) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// @name Construction
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
static const NVPTXGenericMCSymbolRefExpr
|
2015-05-30 09:25:56 +08:00
|
|
|
*create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx);
|
2015-04-29 01:18:30 +08:00
|
|
|
|
|
|
|
/// @}
|
|
|
|
/// @name Accessors
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// getOpcode - Get the kind of this expression.
|
|
|
|
const MCSymbolRefExpr *getSymbolExpr() const { return SymExpr; }
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
2015-06-09 08:31:39 +08:00
|
|
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
2015-05-30 09:25:56 +08:00
|
|
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
2015-04-29 01:18:30 +08:00
|
|
|
const MCAsmLayout *Layout,
|
|
|
|
const MCFixup *Fixup) const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void visitUsedExpr(MCStreamer &Streamer) const override {};
|
2015-10-05 20:07:05 +08:00
|
|
|
MCFragment *findAssociatedFragment() const override { return nullptr; }
|
2015-04-29 01:18:30 +08:00
|
|
|
|
|
|
|
// There are no TLS NVPTXMCExprs at the moment.
|
|
|
|
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
|
|
|
|
|
|
|
|
static bool classof(const MCExpr *E) {
|
|
|
|
return E->getKind() == MCExpr::Target;
|
|
|
|
}
|
|
|
|
};
|
2013-08-06 22:13:27 +08:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|