Merge pull request #9683 from JosJuice/ppc-test-values

UnitTests: Put PowerPC test values in a separate file
This commit is contained in:
Léo Lam 2021-05-07 14:44:27 +02:00 committed by GitHub
commit 70d8a78edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 115 additions and 179 deletions

View File

@ -31,3 +31,7 @@ else()
PowerPC/DivUtilsTest.cpp
)
endif()
target_sources(PowerPCTest PRIVATE
PowerPC/TestValues.h
)

View File

@ -4,7 +4,6 @@
#include <cstring>
#include <tuple>
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/x64ABI.h"
@ -14,6 +13,8 @@
#include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h"
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
#include "../TestValues.h"
#include <fmt/format.h>
#include <gtest/gtest.h>
@ -53,59 +54,7 @@ TEST(Jit64, ConvertDoubleToSingle)
{
TestCommonAsmRoutines routines;
const std::vector<u64> input_values{
// Special values
0x0000'0000'0000'0000, // positive zero
0x0000'0000'0000'0001, // smallest positive denormal
0x0000'0000'0100'0000,
0x000F'FFFF'FFFF'FFFF, // largest positive denormal
0x0010'0000'0000'0000, // smallest positive normal
0x0010'0000'0000'0002,
0x3FF0'0000'0000'0000, // 1.0
0x7FEF'FFFF'FFFF'FFFF, // largest positive normal
0x7FF0'0000'0000'0000, // positive infinity
0x7FF0'0000'0000'0001, // first positive SNaN
0x7FF7'FFFF'FFFF'FFFF, // last positive SNaN
0x7FF8'0000'0000'0000, // first positive QNaN
0x7FFF'FFFF'FFFF'FFFF, // last positive QNaN
0x8000'0000'0000'0000, // negative zero
0x8000'0000'0000'0001, // smallest negative denormal
0x8000'0000'0100'0000,
0x800F'FFFF'FFFF'FFFF, // largest negative denormal
0x8010'0000'0000'0000, // smallest negative normal
0x8010'0000'0000'0002,
0xBFF0'0000'0000'0000, // -1.0
0xFFEF'FFFF'FFFF'FFFF, // largest negative normal
0xFFF0'0000'0000'0000, // negative infinity
0xFFF0'0000'0000'0001, // first negative SNaN
0xFFF7'FFFF'FFFF'FFFF, // last negative SNaN
0xFFF8'0000'0000'0000, // first negative QNaN
0xFFFF'FFFF'FFFF'FFFF, // last negative QNaN
// (exp > 896) Boundary Case
0x3800'0000'0000'0000, // 2^(-127) = Denormal in single-prec
0x3810'0000'0000'0000, // 2^(-126) = Smallest single-prec normal
0xB800'0000'0000'0000, // -2^(-127) = Denormal in single-prec
0xB810'0000'0000'0000, // -2^(-126) = Smallest single-prec normal
0x3800'1234'5678'9ABC, 0x3810'1234'5678'9ABC, 0xB800'1234'5678'9ABC, 0xB810'1234'5678'9ABC,
// (exp >= 874) Boundary Case
0x3680'0000'0000'0000, // 2^(-150) = Unrepresentable in single-prec
0x36A0'0000'0000'0000, // 2^(-149) = Smallest single-prec denormal
0x36B0'0000'0000'0000, // 2^(-148) = Single-prec denormal
0xB680'0000'0000'0000, // -2^(-150) = Unrepresentable in single-prec
0xB6A0'0000'0000'0000, // -2^(-149) = Smallest single-prec denormal
0xB6B0'0000'0000'0000, // -2^(-148) = Single-prec denormal
0x3680'1234'5678'9ABC, 0x36A0'1234'5678'9ABC, 0x36B0'1234'5678'9ABC, 0xB680'1234'5678'9ABC,
0xB6A0'1234'5678'9ABC, 0xB6B0'1234'5678'9ABC,
// Some typical numbers
0x3FF8'0000'0000'0000, // 1.5
0x408F'4000'0000'0000, // 1000
0xC008'0000'0000'0000, // -3
};
for (const u64 input : input_values)
for (const u64 input : double_test_values)
{
const u32 expected = ConvertToSingle(input);
const u32 actual = routines.wrapped_cdts(input);

View File

@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include <cstring>
#include <vector>
#include "Common/BitUtils.h"
#include "Common/CommonTypes.h"
@ -14,6 +13,8 @@
#include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h"
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
#include "../TestValues.h"
#include <fmt/format.h>
#include <gtest/gtest.h>
@ -60,38 +61,9 @@ TEST(Jit64, Frsqrte)
{
TestCommonAsmRoutines routines;
const std::vector<u64> special_values{
0x0000'0000'0000'0000, // positive zero
0x0000'0000'0000'0001, // smallest positive denormal
0x0000'0000'0100'0000,
0x000F'FFFF'FFFF'FFFF, // largest positive denormal
0x0010'0000'0000'0000, // smallest positive normal
0x0010'0000'0000'0002,
0x3FF0'0000'0000'0000, // 1.0
0x7FEF'FFFF'FFFF'FFFF, // largest positive normal
0x7FF0'0000'0000'0000, // positive infinity
0x7FF0'0000'0000'0001, // first positive SNaN
0x7FF7'FFFF'FFFF'FFFF, // last positive SNaN
0x7FF8'0000'0000'0000, // first positive QNaN
0x7FFF'FFFF'FFFF'FFFF, // last positive QNaN
0x8000'0000'0000'0000, // negative zero
0x8000'0000'0000'0001, // smallest negative denormal
0x8000'0000'0100'0000,
0x800F'FFFF'FFFF'FFFF, // largest negative denormal
0x8010'0000'0000'0000, // smallest negative normal
0x8010'0000'0000'0002,
0xBFF0'0000'0000'0000, // -1.0
0xFFEF'FFFF'FFFF'FFFF, // largest negative normal
0xFFF0'0000'0000'0000, // negative infinity
0xFFF0'0000'0000'0001, // first negative SNaN
0xFFF7'FFFF'FFFF'FFFF, // last negative SNaN
0xFFF8'0000'0000'0000, // first negative QNaN
0xFFFF'FFFF'FFFF'FFFF, // last negative QNaN
};
UReg_FPSCR fpscr;
for (u64 ivalue : special_values)
for (const u64 ivalue : double_test_values)
{
double dvalue = Common::BitCast<double>(ivalue);

View File

@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include <functional>
#include <vector>
#include "Common/Arm64Emitter.h"
#include "Common/BitUtils.h"
@ -12,6 +11,8 @@
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
#include "Core/PowerPC/JitArm64/Jit.h"
#include "../TestValues.h"
#include <fmt/format.h>
#include <gtest/gtest.h>
@ -119,59 +120,7 @@ TEST(JitArm64, ConvertDoubleToSingle)
{
TestConversion test;
const std::vector<u64> input_values{
// Special values
0x0000'0000'0000'0000, // positive zero
0x0000'0000'0000'0001, // smallest positive denormal
0x0000'0000'0100'0000,
0x000F'FFFF'FFFF'FFFF, // largest positive denormal
0x0010'0000'0000'0000, // smallest positive normal
0x0010'0000'0000'0002,
0x3FF0'0000'0000'0000, // 1.0
0x7FEF'FFFF'FFFF'FFFF, // largest positive normal
0x7FF0'0000'0000'0000, // positive infinity
0x7FF0'0000'0000'0001, // first positive SNaN
0x7FF7'FFFF'FFFF'FFFF, // last positive SNaN
0x7FF8'0000'0000'0000, // first positive QNaN
0x7FFF'FFFF'FFFF'FFFF, // last positive QNaN
0x8000'0000'0000'0000, // negative zero
0x8000'0000'0000'0001, // smallest negative denormal
0x8000'0000'0100'0000,
0x800F'FFFF'FFFF'FFFF, // largest negative denormal
0x8010'0000'0000'0000, // smallest negative normal
0x8010'0000'0000'0002,
0xBFF0'0000'0000'0000, // -1.0
0xFFEF'FFFF'FFFF'FFFF, // largest negative normal
0xFFF0'0000'0000'0000, // negative infinity
0xFFF0'0000'0000'0001, // first negative SNaN
0xFFF7'FFFF'FFFF'FFFF, // last negative SNaN
0xFFF8'0000'0000'0000, // first negative QNaN
0xFFFF'FFFF'FFFF'FFFF, // last negative QNaN
// (exp > 896) Boundary Case
0x3800'0000'0000'0000, // 2^(-127) = Denormal in single-prec
0x3810'0000'0000'0000, // 2^(-126) = Smallest single-prec normal
0xB800'0000'0000'0000, // -2^(-127) = Denormal in single-prec
0xB810'0000'0000'0000, // -2^(-126) = Smallest single-prec normal
0x3800'1234'5678'9ABC, 0x3810'1234'5678'9ABC, 0xB800'1234'5678'9ABC, 0xB810'1234'5678'9ABC,
// (exp >= 874) Boundary Case
0x3680'0000'0000'0000, // 2^(-150) = Unrepresentable in single-prec
0x36A0'0000'0000'0000, // 2^(-149) = Smallest single-prec denormal
0x36B0'0000'0000'0000, // 2^(-148) = Single-prec denormal
0xB680'0000'0000'0000, // -2^(-150) = Unrepresentable in single-prec
0xB6A0'0000'0000'0000, // -2^(-149) = Smallest single-prec denormal
0xB6B0'0000'0000'0000, // -2^(-148) = Single-prec denormal
0x3680'1234'5678'9ABC, 0x36A0'1234'5678'9ABC, 0x36B0'1234'5678'9ABC, 0xB680'1234'5678'9ABC,
0xB6A0'1234'5678'9ABC, 0xB6B0'1234'5678'9ABC,
// Some typical numbers
0x3FF8'0000'0000'0000, // 1.5
0x408F'4000'0000'0000, // 1000
0xC008'0000'0000'0000, // -3
};
for (const u64 input : input_values)
for (const u64 input : double_test_values)
{
const u32 expected = ConvertToSingle(input);
const u32 actual = test.ConvertDoubleToSingle(input);
@ -182,9 +131,9 @@ TEST(JitArm64, ConvertDoubleToSingle)
EXPECT_EQ(expected, actual);
}
for (const u64 input1 : input_values)
for (const u64 input1 : double_test_values)
{
for (const u64 input2 : input_values)
for (const u64 input2 : double_test_values)
{
const u32 expected1 = ConvertToSingle(input1);
const u32 expected2 = ConvertToSingle(input2);
@ -206,42 +155,7 @@ TEST(JitArm64, ConvertSingleToDouble)
{
TestConversion test;
const std::vector<u32> input_values{
// Special values
0x0000'0000, // positive zero
0x0000'0001, // smallest positive denormal
0x0000'1000,
0x007F'FFFF, // largest positive denormal
0x0080'0000, // smallest positive normal
0x0080'0002,
0x3F80'0000, // 1.0
0x7F7F'FFFF, // largest positive normal
0x7F80'0000, // positive infinity
0x7F80'0001, // first positive SNaN
0x7FBF'FFFF, // last positive SNaN
0x7FC0'0000, // first positive QNaN
0x7FFF'FFFF, // last positive QNaN
0x8000'0000, // negative zero
0x8000'0001, // smallest negative denormal
0x8000'1000,
0x807F'FFFF, // largest negative denormal
0x8080'0000, // smallest negative normal
0x8080'0002,
0xBFF0'0000, // -1.0
0xFF7F'FFFF, // largest negative normal
0xFF80'0000, // negative infinity
0xFF80'0001, // first negative SNaN
0xFFBF'FFFF, // last negative SNaN
0xFFC0'0000, // first negative QNaN
0xFFFF'FFFF, // last negative QNaN
// Some typical numbers
0x3FC0'0000, // 1.5
0x447A'0000, // 1000
0xC040'0000, // -3
};
for (const u32 input : input_values)
for (const u32 input : single_test_values)
{
const u64 expected = ConvertToDouble(input);
const u64 actual = test.ConvertSingleToDouble(input);
@ -252,9 +166,9 @@ TEST(JitArm64, ConvertSingleToDouble)
EXPECT_EQ(expected, actual);
}
for (const u32 input1 : input_values)
for (const u32 input1 : single_test_values)
{
for (const u32 input2 : input_values)
for (const u32 input2 : single_test_values)
{
const u64 expected1 = ConvertToDouble(input1);
const u64 expected2 = ConvertToDouble(input2);

View File

@ -0,0 +1,96 @@
// Copyright 2021 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <array>
#include "Common/CommonTypes.h"
constexpr std::array<u64, 49> double_test_values{
// Special values
0x0000'0000'0000'0000, // positive zero
0x0000'0000'0000'0001, // smallest positive denormal
0x0000'0000'0100'0000,
0x000F'FFFF'FFFF'FFFF, // largest positive denormal
0x0010'0000'0000'0000, // smallest positive normal
0x0010'0000'0000'0002,
0x3FF0'0000'0000'0000, // 1.0
0x7FEF'FFFF'FFFF'FFFF, // largest positive normal
0x7FF0'0000'0000'0000, // positive infinity
0x7FF0'0000'0000'0001, // first positive SNaN
0x7FF7'FFFF'FFFF'FFFF, // last positive SNaN
0x7FF8'0000'0000'0000, // first positive QNaN
0x7FFF'FFFF'FFFF'FFFF, // last positive QNaN
0x8000'0000'0000'0000, // negative zero
0x8000'0000'0000'0001, // smallest negative denormal
0x8000'0000'0100'0000,
0x800F'FFFF'FFFF'FFFF, // largest negative denormal
0x8010'0000'0000'0000, // smallest negative normal
0x8010'0000'0000'0002,
0xBFF0'0000'0000'0000, // -1.0
0xFFEF'FFFF'FFFF'FFFF, // largest negative normal
0xFFF0'0000'0000'0000, // negative infinity
0xFFF0'0000'0000'0001, // first negative SNaN
0xFFF7'FFFF'FFFF'FFFF, // last negative SNaN
0xFFF8'0000'0000'0000, // first negative QNaN
0xFFFF'FFFF'FFFF'FFFF, // last negative QNaN
// (exp > 896) Boundary case for converting to single
0x3800'0000'0000'0000, // 2^(-127) = Denormal in single-prec
0x3810'0000'0000'0000, // 2^(-126) = Smallest single-prec normal
0xB800'0000'0000'0000, // -2^(-127) = Denormal in single-prec
0xB810'0000'0000'0000, // -2^(-126) = Smallest single-prec normal
0x3800'1234'5678'9ABC, 0x3810'1234'5678'9ABC, 0xB800'1234'5678'9ABC, 0xB810'1234'5678'9ABC,
// (exp >= 874) Boundary case for converting to single
0x3680'0000'0000'0000, // 2^(-150) = Unrepresentable in single-prec
0x36A0'0000'0000'0000, // 2^(-149) = Smallest single-prec denormal
0x36B0'0000'0000'0000, // 2^(-148) = Single-prec denormal
0xB680'0000'0000'0000, // -2^(-150) = Unrepresentable in single-prec
0xB6A0'0000'0000'0000, // -2^(-149) = Smallest single-prec denormal
0xB6B0'0000'0000'0000, // -2^(-148) = Single-prec denormal
0x3680'1234'5678'9ABC, 0x36A0'1234'5678'9ABC, 0x36B0'1234'5678'9ABC, 0xB680'1234'5678'9ABC,
0xB6A0'1234'5678'9ABC, 0xB6B0'1234'5678'9ABC,
// Some typical numbers
0x3FF8'0000'0000'0000, // 1.5
0x408F'4000'0000'0000, // 1000
0xC008'0000'0000'0000, // -3
};
constexpr std::array<u32, 29> single_test_values{
// Special values
0x0000'0000, // positive zero
0x0000'0001, // smallest positive denormal
0x0000'1000,
0x007F'FFFF, // largest positive denormal
0x0080'0000, // smallest positive normal
0x0080'0002,
0x3F80'0000, // 1.0
0x7F7F'FFFF, // largest positive normal
0x7F80'0000, // positive infinity
0x7F80'0001, // first positive SNaN
0x7FBF'FFFF, // last positive SNaN
0x7FC0'0000, // first positive QNaN
0x7FFF'FFFF, // last positive QNaN
0x8000'0000, // negative zero
0x8000'0001, // smallest negative denormal
0x8000'1000,
0x807F'FFFF, // largest negative denormal
0x8080'0000, // smallest negative normal
0x8080'0002,
0xBFF0'0000, // -1.0
0xFF7F'FFFF, // largest negative normal
0xFF80'0000, // negative infinity
0xFF80'0001, // first negative SNaN
0xFFBF'FFFF, // last negative SNaN
0xFFC0'0000, // first negative QNaN
0xFFFF'FFFF, // last negative QNaN
// Some typical numbers
0x3FC0'0000, // 1.5
0x447A'0000, // 1000
0xC040'0000, // -3
};

View File

@ -36,6 +36,7 @@
<ClInclude Include="Core\DSP\DSPTestText.h" />
<ClInclude Include="Core\DSP\HermesBinary.h" />
<ClInclude Include="Core\IOS\ES\TestBinaryData.h" />
<ClInclude Include="Core\PowerPC\TestValues.h" />
</ItemGroup>
<ItemGroup>
<!--gtest is rather small, so just include it into the build here-->