1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
| //===-- RegisterValueTest.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "RegisterValue.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace llvm {
namespace exegesis {
namespace {
#define CHECK(EXPECTED, ACTUAL) \
EXPECT_EQ(APInt(SizeInBits, EXPECTED, 16), \
bitcastFloatValue(Semantic, PredefinedValues::ACTUAL))
TEST(RegisterValueTest, Half) {
const size_t SizeInBits = 16;
const auto &Semantic = APFloatBase::IEEEhalf();
CHECK("0000", POS_ZERO);
CHECK("8000", NEG_ZERO);
CHECK("3C00", ONE);
CHECK("4000", TWO);
CHECK("7C00", INF);
CHECK("7E00", QNAN);
CHECK("7BFF", LARGEST);
CHECK("0400", SMALLEST_NORM);
CHECK("0001", SMALLEST);
CHECK("0001", ULP);
CHECK("3C01", ONE_PLUS_ULP);
}
TEST(RegisterValueTest, Single) {
const size_t SizeInBits = 32;
const auto &Semantic = APFloatBase::IEEEsingle();
CHECK("00000000", POS_ZERO);
CHECK("80000000", NEG_ZERO);
CHECK("3F800000", ONE);
CHECK("40000000", TWO);
CHECK("7F800000", INF);
CHECK("7FC00000", QNAN);
CHECK("7F7FFFFF", LARGEST);
CHECK("00800000", SMALLEST_NORM);
CHECK("00000001", SMALLEST);
CHECK("00000001", ULP);
CHECK("3F800001", ONE_PLUS_ULP);
}
TEST(RegisterValueTest, Double) {
const size_t SizeInBits = 64;
const auto &Semantic = APFloatBase::IEEEdouble();
CHECK("0000000000000000", POS_ZERO);
CHECK("8000000000000000", NEG_ZERO);
CHECK("3FF0000000000000", ONE);
CHECK("4000000000000000", TWO);
CHECK("7FF0000000000000", INF);
CHECK("7FF8000000000000", QNAN);
CHECK("7FEFFFFFFFFFFFFF", LARGEST);
CHECK("0010000000000000", SMALLEST_NORM);
CHECK("0000000000000001", SMALLEST);
CHECK("0000000000000001", ULP);
CHECK("3FF0000000000001", ONE_PLUS_ULP);
}
} // namespace
} // namespace exegesis
} // namespace llvm
|