mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
JitArm64: Implement frsqrte
This commit is contained in:
@ -26,6 +26,7 @@ elseif(_M_ARM_64)
|
||||
PowerPC/JitArm64/ConvertSingleDouble.cpp
|
||||
PowerPC/JitArm64/FPRF.cpp
|
||||
PowerPC/JitArm64/Fres.cpp
|
||||
PowerPC/JitArm64/Frsqrte.cpp
|
||||
PowerPC/JitArm64/MovI2R.cpp
|
||||
)
|
||||
else()
|
||||
|
66
Source/UnitTests/Core/PowerPC/JitArm64/Frsqrte.cpp
Normal file
66
Source/UnitTests/Core/PowerPC/JitArm64/Frsqrte.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright 2021 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "Common/Arm64Emitter.h"
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
|
||||
#include "Core/PowerPC/JitArm64/Jit.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace Arm64Gen;
|
||||
|
||||
class TestFrsqrte : public JitArm64
|
||||
{
|
||||
public:
|
||||
TestFrsqrte()
|
||||
{
|
||||
AllocCodeSpace(4096);
|
||||
|
||||
const u8* raw_frsqrte = GetCodePtr();
|
||||
GenerateFrsqrte();
|
||||
|
||||
frsqrte = Common::BitCast<u64 (*)(u64)>(GetCodePtr());
|
||||
MOV(ARM64Reg::X15, ARM64Reg::X30);
|
||||
MOV(ARM64Reg::X14, PPC_REG);
|
||||
MOVP2R(PPC_REG, &PowerPC::ppcState);
|
||||
MOV(ARM64Reg::X1, ARM64Reg::X0);
|
||||
m_float_emit.FMOV(ARM64Reg::D0, ARM64Reg::X0);
|
||||
m_float_emit.FRSQRTE(ARM64Reg::D0, ARM64Reg::D0);
|
||||
BL(raw_frsqrte);
|
||||
MOV(ARM64Reg::X30, ARM64Reg::X15);
|
||||
MOV(PPC_REG, ARM64Reg::X14);
|
||||
RET();
|
||||
}
|
||||
|
||||
std::function<u64(u64)> frsqrte;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(JitArm64, Frsqrte)
|
||||
{
|
||||
TestFrsqrte test;
|
||||
|
||||
for (const u64 ivalue : double_test_values)
|
||||
{
|
||||
const double dvalue = Common::BitCast<double>(ivalue);
|
||||
|
||||
const u64 expected = Common::BitCast<u64>(Common::ApproximateReciprocalSquareRoot(dvalue));
|
||||
const u64 actual = test.frsqrte(ivalue);
|
||||
|
||||
if (expected != actual)
|
||||
fmt::print("{:016x} -> {:016x} == {:016x}\n", ivalue, actual, expected);
|
||||
|
||||
EXPECT_EQ(expected, actual);
|
||||
}
|
||||
}
|
@ -85,6 +85,7 @@
|
||||
<ClCompile Include="Core\PowerPC\JitArm64\ConvertSingleDouble.cpp" />
|
||||
<ClCompile Include="Core\PowerPC\JitArm64\FPRF.cpp" />
|
||||
<ClCompile Include="Core\PowerPC\JitArm64\Fres.cpp" />
|
||||
<ClCompile Include="Core\PowerPC\JitArm64\Frsqrte.cpp" />
|
||||
<ClCompile Include="Core\PowerPC\JitArm64\MovI2R.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user