1 //===-- NVPTXMCExpr.cpp - NVPTX specific MC expression classes ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #define DEBUG_TYPE "nvptx-mcexpr"
11 #include "NVPTXMCExpr.h"
12 #include "llvm/ADT/StringExtras.h"
13 #include "llvm/MC/MCAssembler.h"
14 #include "llvm/MC/MCContext.h"
17 const NVPTXFloatMCExpr*
18 NVPTXFloatMCExpr::Create(VariantKind Kind, APFloat Flt, MCContext &Ctx) {
19 return new (Ctx) NVPTXFloatMCExpr(Kind, Flt);
22 void NVPTXFloatMCExpr::PrintImpl(raw_ostream &OS) const {
25 APFloat APF = getAPFloat();
28 default: llvm_unreachable("Invalid kind!");
29 case VK_NVPTX_SINGLE_PREC_FLOAT:
32 APF.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &Ignored);
34 case VK_NVPTX_DOUBLE_PREC_FLOAT:
37 APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &Ignored);
41 APInt API = APF.bitcastToAPInt();
42 std::string HexStr(utohexstr(API.getZExtValue()));
43 if (HexStr.length() < NumHex)
44 OS << std::string(NumHex - HexStr.length(), '0');
45 OS << utohexstr(API.getZExtValue());