[docs] Fix build-docs.sh
[llvm-project.git] / llvm / unittests / tools / llvm-exegesis / RegisterValueTest.cpp
blob21332ad64f907ed0327df21f86fb565f5894db05
1 //===-- RegisterValueTest.cpp -----------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #include "RegisterValue.h"
10 #include "gmock/gmock.h"
11 #include "gtest/gtest.h"
13 namespace llvm {
14 namespace exegesis {
16 namespace {
18 #define CHECK(EXPECTED, ACTUAL) \
19 EXPECT_EQ(APInt(SizeInBits, EXPECTED, 16), \
20 bitcastFloatValue(Semantic, PredefinedValues::ACTUAL))
22 TEST(RegisterValueTest, Half) {
23 const size_t SizeInBits = 16;
24 const auto &Semantic = APFloatBase::IEEEhalf();
25 CHECK("0000", POS_ZERO);
26 CHECK("8000", NEG_ZERO);
27 CHECK("3C00", ONE);
28 CHECK("4000", TWO);
29 CHECK("7C00", INF);
30 CHECK("7E00", QNAN);
31 CHECK("7BFF", LARGEST);
32 CHECK("0400", SMALLEST_NORM);
33 CHECK("0001", SMALLEST);
34 CHECK("0001", ULP);
35 CHECK("3C01", ONE_PLUS_ULP);
38 TEST(RegisterValueTest, Single) {
39 const size_t SizeInBits = 32;
40 const auto &Semantic = APFloatBase::IEEEsingle();
41 CHECK("00000000", POS_ZERO);
42 CHECK("80000000", NEG_ZERO);
43 CHECK("3F800000", ONE);
44 CHECK("40000000", TWO);
45 CHECK("7F800000", INF);
46 CHECK("7FC00000", QNAN);
47 CHECK("7F7FFFFF", LARGEST);
48 CHECK("00800000", SMALLEST_NORM);
49 CHECK("00000001", SMALLEST);
50 CHECK("00000001", ULP);
51 CHECK("3F800001", ONE_PLUS_ULP);
54 TEST(RegisterValueTest, Double) {
55 const size_t SizeInBits = 64;
56 const auto &Semantic = APFloatBase::IEEEdouble();
57 CHECK("0000000000000000", POS_ZERO);
58 CHECK("8000000000000000", NEG_ZERO);
59 CHECK("3FF0000000000000", ONE);
60 CHECK("4000000000000000", TWO);
61 CHECK("7FF0000000000000", INF);
62 CHECK("7FF8000000000000", QNAN);
63 CHECK("7FEFFFFFFFFFFFFF", LARGEST);
64 CHECK("0010000000000000", SMALLEST_NORM);
65 CHECK("0000000000000001", SMALLEST);
66 CHECK("0000000000000001", ULP);
67 CHECK("3FF0000000000001", ONE_PLUS_ULP);
70 } // namespace
71 } // namespace exegesis
72 } // namespace llvm