LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NVPTXMCExpr.cpp
Go to the documentation of this file.
1 //===-- NVPTXMCExpr.cpp - NVPTX specific MC expression classes ------------===//
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 #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"
15 using namespace llvm;
16 
17 const NVPTXFloatMCExpr*
19  return new (Ctx) NVPTXFloatMCExpr(Kind, Flt);
20 }
21 
23  bool Ignored;
24  unsigned NumHex;
25  APFloat APF = getAPFloat();
26 
27  switch (Kind) {
28  default: llvm_unreachable("Invalid kind!");
30  OS << "0f";
31  NumHex = 8;
33  break;
35  OS << "0d";
36  NumHex = 16;
38  break;
39  }
40 
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());
46 }
uint64_t getZExtValue() const
Get zero extended value.
Definition: APInt.h:1306
static const fltSemantics IEEEdouble
Definition: APFloat.h:133
static std::string utohexstr(uint64_t X)
Definition: StringExtras.h:67
#define llvm_unreachable(msg)
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
Definition: APFloat.h:122
void PrintImpl(raw_ostream &OS) const
Definition: NVPTXMCExpr.cpp:22
opStatus convert(const fltSemantics &, roundingMode, bool *)
Definition: APFloat.cpp:1938
APFloat getAPFloat() const
getSubExpr - Get the child of this expression.
Definition: NVPTXMCExpr.h:60
Class for arbitrary precision integers.
Definition: APInt.h:75
APInt bitcastToAPInt() const
Definition: APFloat.cpp:3050
static const fltSemantics IEEEsingle
Definition: APFloat.h:132
static const NVPTXFloatMCExpr * Create(VariantKind Kind, APFloat Flt, MCContext &Ctx)
Definition: NVPTXMCExpr.cpp:18