Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- NVPTXMCExpr.cpp - NVPTX specific MC expression classes ------------===//
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
#include "NVPTXMCExpr.h"
10
#include "llvm/ADT/StringExtras.h"
11
#include "llvm/MC/MCAssembler.h"
12
#include "llvm/MC/MCContext.h"
13
#include "llvm/Support/Format.h"
14
using namespace llvm;
15
16
#define DEBUG_TYPE "nvptx-mcexpr"
17
18
const NVPTXFloatMCExpr *
19
132
NVPTXFloatMCExpr::create(VariantKind Kind, const APFloat &Flt, MCContext &Ctx) {
20
132
  return new (Ctx) NVPTXFloatMCExpr(Kind, Flt);
21
132
}
22
23
127
void NVPTXFloatMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
24
127
  bool Ignored;
25
127
  unsigned NumHex;
26
127
  APFloat APF = getAPFloat();
27
127
28
127
  switch (Kind) {
29
127
  
default: 0
llvm_unreachable0
("Invalid kind!");
30
127
  case VK_NVPTX_HALF_PREC_FLOAT:
31
10
    // ptxas does not have a way to specify half-precision floats.
32
10
    // Instead we have to print and load fp16 constants as .b16
33
10
    OS << "0x";
34
10
    NumHex = 4;
35
10
    APF.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &Ignored);
36
10
    break;
37
127
  case VK_NVPTX_SINGLE_PREC_FLOAT:
38
97
    OS << "0f";
39
97
    NumHex = 8;
40
97
    APF.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven, &Ignored);
41
97
    break;
42
127
  case VK_NVPTX_DOUBLE_PREC_FLOAT:
43
20
    OS << "0d";
44
20
    NumHex = 16;
45
20
    APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &Ignored);
46
20
    break;
47
127
  }
48
127
49
127
  APInt API = APF.bitcastToAPInt();
50
127
  OS << format_hex_no_prefix(API.getZExtValue(), NumHex, /*Upper=*/true);
51
127
}
52
53
const NVPTXGenericMCSymbolRefExpr*
54
NVPTXGenericMCSymbolRefExpr::create(const MCSymbolRefExpr *SymExpr,
55
1
                                    MCContext &Ctx) {
56
1
  return new (Ctx) NVPTXGenericMCSymbolRefExpr(SymExpr);
57
1
}
58
59
void NVPTXGenericMCSymbolRefExpr::printImpl(raw_ostream &OS,
60
1
                                            const MCAsmInfo *MAI) const {
61
1
  OS << "generic(";
62
1
  SymExpr->print(OS, MAI);
63
1
  OS << ")";
64
1
}