Merge pull request #6884 from lioncash/bit
Interpreter_LoadStorePaired: Use Common::BitCast where applicable
This commit is contained in:
commit
7c9b0eb7ce
|
@ -2,12 +2,12 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
|
#include "Common/BitUtils.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "Core/PowerPC/Interpreter/Interpreter.h"
|
#include "Core/PowerPC/Interpreter/Interpreter.h"
|
||||||
|
@ -180,20 +180,18 @@ void Interpreter::Helper_Quantize(u32 addr, u32 instI, u32 instRS, u32 instW)
|
||||||
{
|
{
|
||||||
case QUANTIZE_FLOAT:
|
case QUANTIZE_FLOAT:
|
||||||
{
|
{
|
||||||
u64 integral_ps0;
|
const u64 integral_ps0 = Common::BitCast<u64>(ps0);
|
||||||
std::memcpy(&integral_ps0, &ps0, sizeof(u64));
|
|
||||||
|
|
||||||
const u32 conv_ps0 = ConvertToSingleFTZ(integral_ps0);
|
const u32 conv_ps0 = ConvertToSingleFTZ(integral_ps0);
|
||||||
|
|
||||||
if (instW)
|
if (instW)
|
||||||
{
|
{
|
||||||
WriteUnpaired<u32>(conv_ps0, addr);
|
WriteUnpaired<u32>(conv_ps0, addr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u64 integral_ps1;
|
const u64 integral_ps1 = Common::BitCast<u64>(ps1);
|
||||||
std::memcpy(&integral_ps1, &ps1, sizeof(double));
|
|
||||||
|
|
||||||
const u32 conv_ps1 = ConvertToSingleFTZ(integral_ps1);
|
const u32 conv_ps1 = ConvertToSingleFTZ(integral_ps1);
|
||||||
|
|
||||||
WritePair<u32>(conv_ps0, conv_ps1, addr);
|
WritePair<u32>(conv_ps0, conv_ps1, addr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -258,14 +256,14 @@ void Interpreter::Helper_Dequantize(u32 addr, u32 instI, u32 instRD, u32 instW)
|
||||||
if (instW)
|
if (instW)
|
||||||
{
|
{
|
||||||
const u32 value = ReadUnpaired<u32>(addr);
|
const u32 value = ReadUnpaired<u32>(addr);
|
||||||
std::memcpy(&ps0, &value, sizeof(float));
|
ps0 = Common::BitCast<float>(value);
|
||||||
ps1 = 1.0f;
|
ps1 = 1.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const std::pair<u32, u32> value = ReadPair<u32>(addr);
|
const std::pair<u32, u32> value = ReadPair<u32>(addr);
|
||||||
std::memcpy(&ps0, &value.first, sizeof(float));
|
ps0 = Common::BitCast<float>(value.first);
|
||||||
std::memcpy(&ps1, &value.second, sizeof(float));
|
ps1 = Common::BitCast<float>(value.second);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue