Replace Common::BitCast with std::bit_cast
This commit is contained in:
1 parent
57c890d4fc
commit
fbbfea8e8e
36 files changed
+177
-215
No files matched your search
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <bit>
|
||||
#include <iterator>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -31,7 +32,6 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Common/IniFile.h"
|
||||
@@ -519,10 +519,10 @@ static bool Subtype_AddCode(const Core::CPUThreadGuard& guard, const ARAddr& add
|
||||
LogInfo("--------");
|
||||
|
||||
const u32 read = PowerPC::MMU::HostRead_U32(guard, new_addr);
|
||||
const float read_float = Common::BitCast<float>(read);
|
||||
const float read_float = std::bit_cast<float>(read);
|
||||
// data contains an (unsigned?) integer value
|
||||
const float fread = read_float + static_cast<float>(data);
|
||||
const u32 newval = Common::BitCast<u32>(fread);
|
||||
const u32 newval = std::bit_cast<u32>(fread);
|
||||
PowerPC::MMU::HostWrite_U32(guard, newval, new_addr);
|
||||
LogInfo("Old Value {:08x}", read);
|
||||
LogInfo("Increment {:08x}", data);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Core/CheatSearch.h"
|
||||
|
||||
#include <bit>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -13,7 +14,6 @@
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/AchievementManager.h"
|
||||
@@ -83,17 +83,17 @@ std::vector<u8> Cheats::GetValueAsByteVector(const Cheats::SearchValue& value)
|
||||
case Cheats::DataType::U64:
|
||||
return ToByteVector(Common::swap64(std::get<u64>(value.m_value)));
|
||||
case Cheats::DataType::S8:
|
||||
return {Common::BitCast<u8>(std::get<s8>(value.m_value))};
|
||||
return {std::bit_cast<u8>(std::get<s8>(value.m_value))};
|
||||
case Cheats::DataType::S16:
|
||||
return ToByteVector(Common::swap16(Common::BitCast<u16>(std::get<s16>(value.m_value))));
|
||||
return ToByteVector(Common::swap16(std::bit_cast<u16>(std::get<s16>(value.m_value))));
|
||||
case Cheats::DataType::S32:
|
||||
return ToByteVector(Common::swap32(Common::BitCast<u32>(std::get<s32>(value.m_value))));
|
||||
return ToByteVector(Common::swap32(std::bit_cast<u32>(std::get<s32>(value.m_value))));
|
||||
case Cheats::DataType::S64:
|
||||
return ToByteVector(Common::swap64(Common::BitCast<u64>(std::get<s64>(value.m_value))));
|
||||
return ToByteVector(Common::swap64(std::bit_cast<u64>(std::get<s64>(value.m_value))));
|
||||
case Cheats::DataType::F32:
|
||||
return ToByteVector(Common::swap32(Common::BitCast<u32>(std::get<float>(value.m_value))));
|
||||
return ToByteVector(Common::swap32(std::bit_cast<u32>(std::get<float>(value.m_value))));
|
||||
case Cheats::DataType::F64:
|
||||
return ToByteVector(Common::swap64(Common::BitCast<u64>(std::get<double>(value.m_value))));
|
||||
return ToByteVector(Common::swap64(std::bit_cast<u64>(std::get<double>(value.m_value))));
|
||||
default:
|
||||
DEBUG_ASSERT(false);
|
||||
return {};
|
||||
@@ -147,7 +147,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
|
||||
auto tmp = PowerPC::MMU::HostTryReadU8(guard, addr, space);
|
||||
if (!tmp)
|
||||
return std::nullopt;
|
||||
return PowerPC::ReadResult<s8>(tmp->translated, Common::BitCast<s8>(tmp->value));
|
||||
return PowerPC::ReadResult<s8>(tmp->translated, std::bit_cast<s8>(tmp->value));
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -158,7 +158,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
|
||||
auto tmp = PowerPC::MMU::HostTryReadU16(guard, addr, space);
|
||||
if (!tmp)
|
||||
return std::nullopt;
|
||||
return PowerPC::ReadResult<s16>(tmp->translated, Common::BitCast<s16>(tmp->value));
|
||||
return PowerPC::ReadResult<s16>(tmp->translated, std::bit_cast<s16>(tmp->value));
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -169,7 +169,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
|
||||
auto tmp = PowerPC::MMU::HostTryReadU32(guard, addr, space);
|
||||
if (!tmp)
|
||||
return std::nullopt;
|
||||
return PowerPC::ReadResult<s32>(tmp->translated, Common::BitCast<s32>(tmp->value));
|
||||
return PowerPC::ReadResult<s32>(tmp->translated, std::bit_cast<s32>(tmp->value));
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -180,7 +180,7 @@ TryReadValueFromEmulatedMemory(const Core::CPUThreadGuard& guard, u32 addr,
|
||||
auto tmp = PowerPC::MMU::HostTryReadU64(guard, addr, space);
|
||||
if (!tmp)
|
||||
return std::nullopt;
|
||||
return PowerPC::ReadResult<s64>(tmp->translated, Common::BitCast<s64>(tmp->value));
|
||||
return PowerPC::ReadResult<s64>(tmp->translated, std::bit_cast<s64>(tmp->value));
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -573,16 +573,16 @@ std::string Cheats::CheatSearchSession<T>::GetResultValueAsString(size_t index,
|
||||
{
|
||||
if constexpr (std::is_same_v<T, float>)
|
||||
{
|
||||
return fmt::format("0x{0:08x}", Common::BitCast<s32>(m_search_results[index].m_value));
|
||||
return fmt::format("0x{0:08x}", std::bit_cast<s32>(m_search_results[index].m_value));
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, double>)
|
||||
{
|
||||
return fmt::format("0x{0:016x}", Common::BitCast<s64>(m_search_results[index].m_value));
|
||||
return fmt::format("0x{0:016x}", std::bit_cast<s64>(m_search_results[index].m_value));
|
||||
}
|
||||
else
|
||||
{
|
||||
return fmt::format("0x{0:0{1}x}",
|
||||
Common::BitCast<std::make_unsigned_t<T>>(m_search_results[index].m_value),
|
||||
std::bit_cast<std::make_unsigned_t<T>>(m_search_results[index].m_value),
|
||||
sizeof(T) * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/EnumUtils.h"
|
||||
#include "Core/PowerPC/Gekko.h"
|
||||
@@ -26,8 +26,7 @@ struct FakeBranchWatchCollectionKey
|
||||
u32 origin_addr;
|
||||
u32 destin_addr;
|
||||
|
||||
// TODO C++20: constexpr w/ std::bit_cast
|
||||
inline operator u64() const { return Common::BitCast<u64>(*this); }
|
||||
constexpr operator u64() const { return std::bit_cast<u64>(*this); }
|
||||
};
|
||||
struct BranchWatchCollectionKey : FakeBranchWatchCollectionKey
|
||||
{
|
||||
@@ -155,37 +154,37 @@ public:
|
||||
// but also increment the total_hits by N (see dcbx JIT code).
|
||||
static void HitVirtualTrue_fk(BranchWatch* branch_watch, u64 fake_key, u32 inst)
|
||||
{
|
||||
branch_watch->m_collection_vt[{Common::BitCast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
branch_watch->m_collection_vt[{std::bit_cast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
.total_hits += 1;
|
||||
}
|
||||
|
||||
static void HitPhysicalTrue_fk(BranchWatch* branch_watch, u64 fake_key, u32 inst)
|
||||
{
|
||||
branch_watch->m_collection_pt[{Common::BitCast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
branch_watch->m_collection_pt[{std::bit_cast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
.total_hits += 1;
|
||||
}
|
||||
|
||||
static void HitVirtualFalse_fk(BranchWatch* branch_watch, u64 fake_key, u32 inst)
|
||||
{
|
||||
branch_watch->m_collection_vf[{Common::BitCast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
branch_watch->m_collection_vf[{std::bit_cast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
.total_hits += 1;
|
||||
}
|
||||
|
||||
static void HitPhysicalFalse_fk(BranchWatch* branch_watch, u64 fake_key, u32 inst)
|
||||
{
|
||||
branch_watch->m_collection_pf[{Common::BitCast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
branch_watch->m_collection_pf[{std::bit_cast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
.total_hits += 1;
|
||||
}
|
||||
|
||||
static void HitVirtualTrue_fk_n(BranchWatch* branch_watch, u64 fake_key, u32 inst, u32 n)
|
||||
{
|
||||
branch_watch->m_collection_vt[{Common::BitCast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
branch_watch->m_collection_vt[{std::bit_cast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
.total_hits += n;
|
||||
}
|
||||
|
||||
static void HitPhysicalTrue_fk_n(BranchWatch* branch_watch, u64 fake_key, u32 inst, u32 n)
|
||||
{
|
||||
branch_watch->m_collection_pt[{Common::BitCast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
branch_watch->m_collection_pt[{std::bit_cast<FakeBranchWatchCollectionKey>(fake_key), inst}]
|
||||
.total_hits += n;
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ std::string GetStringVA(HLEPrintArgs* args, std::string_view string)
|
||||
if (string[i] == '*')
|
||||
{
|
||||
++i;
|
||||
const s32 result_tmp = Common::BitCast<s32>(args->GetU32());
|
||||
const s32 result_tmp = std::bit_cast<s32>(args->GetU32());
|
||||
if (result_tmp >= 0)
|
||||
return static_cast<u32>(result_tmp);
|
||||
|
||||
@@ -415,7 +415,7 @@ std::string GetStringVA(HLEPrintArgs* args, std::string_view string)
|
||||
}
|
||||
case 'c':
|
||||
{
|
||||
const s32 value = Common::BitCast<s32>(args->GetU32());
|
||||
const s32 value = std::bit_cast<s32>(args->GetU32());
|
||||
if (length_modifier == LengthModifier::l)
|
||||
{
|
||||
// Same problem as with wide strings here.
|
||||
@@ -443,12 +443,12 @@ std::string GetStringVA(HLEPrintArgs* args, std::string_view string)
|
||||
precision ? fmt::format(".{}", *precision) : "");
|
||||
if (length_modifier == LengthModifier::ll)
|
||||
{
|
||||
const s64 value = Common::BitCast<s64>(args->GetU64());
|
||||
const s64 value = std::bit_cast<s64>(args->GetU64());
|
||||
result += fmt::sprintf(fmt::format("%{}" PRId64, options).c_str(), value);
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 value = Common::BitCast<s32>(args->GetU32());
|
||||
s32 value = std::bit_cast<s32>(args->GetU32());
|
||||
if (length_modifier == LengthModifier::h)
|
||||
value = static_cast<s16>(value);
|
||||
else if (length_modifier == LengthModifier::hh)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "Core/HW/AddressSpace.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/DSP.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
@@ -55,7 +55,7 @@ void Accessors::WriteU64(const Core::CPUThreadGuard& guard, u32 address, u64 val
|
||||
|
||||
float Accessors::ReadF32(const Core::CPUThreadGuard& guard, u32 address) const
|
||||
{
|
||||
return Common::BitCast<float>(ReadU32(guard, address));
|
||||
return std::bit_cast<float>(ReadU32(guard, address));
|
||||
}
|
||||
|
||||
Accessors::iterator Accessors::begin() const
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "Core/HW/EXI/BBA/BuiltIn.h"
|
||||
|
||||
#include <bit>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ws2ipdef.h>
|
||||
#else
|
||||
@@ -303,7 +305,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket&
|
||||
const auto& [hwdata, ip_header, tcp_header, ip_options, tcp_options, data] = packet;
|
||||
sf::IpAddress target;
|
||||
StackRef* ref = m_network_ref.GetTCPSlot(tcp_header.source_port, tcp_header.destination_port,
|
||||
Common::BitCast<u32>(ip_header.destination_addr));
|
||||
std::bit_cast<u32>(ip_header.destination_addr));
|
||||
const u16 flags = ntohs(tcp_header.properties) & 0xfff;
|
||||
if (flags & (TCP_FLAG_FIN | TCP_FLAG_RST))
|
||||
{
|
||||
@@ -344,16 +346,16 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket&
|
||||
ref->type = IPPROTO_TCP;
|
||||
for (auto& tcp_buf : ref->tcp_buffers)
|
||||
tcp_buf.used = false;
|
||||
const u32 destination_ip = Common::BitCast<u32>(ip_header.destination_addr);
|
||||
const u32 destination_ip = std::bit_cast<u32>(ip_header.destination_addr);
|
||||
ref->from.sin_addr.s_addr = destination_ip;
|
||||
ref->from.sin_port = tcp_header.destination_port;
|
||||
ref->to.sin_addr.s_addr = Common::BitCast<u32>(ip_header.source_addr);
|
||||
ref->to.sin_addr.s_addr = std::bit_cast<u32>(ip_header.source_addr);
|
||||
ref->to.sin_port = tcp_header.source_port;
|
||||
ref->bba_mac = m_current_mac;
|
||||
ref->my_mac = ResolveAddress(destination_ip);
|
||||
ref->tcp_socket.setBlocking(false);
|
||||
ref->ready = false;
|
||||
ref->ip = Common::BitCast<u32>(ip_header.destination_addr);
|
||||
ref->ip = std::bit_cast<u32>(ip_header.destination_addr);
|
||||
|
||||
target = sf::IpAddress(ntohl(destination_ip));
|
||||
ref->tcp_socket.Connect(target, ntohs(tcp_header.destination_port), m_current_ip);
|
||||
@@ -450,7 +452,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleUDPFrame(const Common::UDPPacket&
|
||||
sf::IpAddress target;
|
||||
const u32 destination_addr = ip_header.destination_addr == Common::IP_ADDR_ANY ?
|
||||
m_router_ip : // dns request
|
||||
Common::BitCast<u32>(ip_header.destination_addr);
|
||||
std::bit_cast<u32>(ip_header.destination_addr);
|
||||
|
||||
StackRef* ref = m_network_ref.GetAvailableSlot(udp_header.source_port);
|
||||
if (ref->ip == 0)
|
||||
@@ -463,7 +465,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleUDPFrame(const Common::UDPPacket&
|
||||
ref->my_mac = m_router_mac;
|
||||
ref->from.sin_addr.s_addr = destination_addr;
|
||||
ref->from.sin_port = udp_header.destination_port;
|
||||
ref->to.sin_addr.s_addr = Common::BitCast<u32>(ip_header.source_addr);
|
||||
ref->to.sin_addr.s_addr = std::bit_cast<u32>(ip_header.source_addr);
|
||||
ref->to.sin_port = udp_header.source_port;
|
||||
ref->udp_socket.setBlocking(false);
|
||||
if (ref->udp_socket.Bind(ntohs(udp_header.source_port), m_current_ip) != sf::Socket::Done)
|
||||
@@ -483,7 +485,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleUDPFrame(const Common::UDPPacket&
|
||||
reply.eth_header.destination = hwdata.source;
|
||||
reply.eth_header.source = hwdata.destination;
|
||||
reply.ip_header.destination_addr = ip_header.source_addr;
|
||||
reply.ip_header.source_addr = Common::BitCast<Common::IPAddress>(destination_addr);
|
||||
reply.ip_header.source_addr = std::bit_cast<Common::IPAddress>(destination_addr);
|
||||
WriteToQueue(reply.Build());
|
||||
}
|
||||
}
|
||||
@@ -491,7 +493,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleUDPFrame(const Common::UDPPacket&
|
||||
if (ntohs(udp_header.destination_port) == 53)
|
||||
target = sf::IpAddress(m_dns_ip.c_str()); // dns server ip
|
||||
else
|
||||
target = sf::IpAddress(ntohl(Common::BitCast<u32>(ip_header.destination_addr)));
|
||||
target = sf::IpAddress(ntohl(std::bit_cast<u32>(ip_header.destination_addr)));
|
||||
ref->udp_socket.send(data.data(), data.size(), target, ntohs(udp_header.destination_port));
|
||||
}
|
||||
|
||||
@@ -921,7 +923,7 @@ sf::Socket::Status BbaUdpSocket::Bind(u16 port, u32 net_ip)
|
||||
// Subscribe to the SSDP multicast group
|
||||
// NB: Other groups aren't supported because of HLE
|
||||
struct ip_mreq mreq;
|
||||
mreq.imr_multiaddr.s_addr = Common::BitCast<u32>(Common::IP_ADDR_SSDP);
|
||||
mreq.imr_multiaddr.s_addr = std::bit_cast<u32>(Common::IP_ADDR_SSDP);
|
||||
mreq.imr_interface.s_addr = net_ip;
|
||||
if (setsockopt(getHandle(), IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast<const char*>(&mreq),
|
||||
sizeof(mreq)) != 0)
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <bit>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/GPFifo.h"
|
||||
#include "Core/HW/MMIOHandlers.h"
|
||||
@@ -88,7 +88,7 @@ inline u16* LowPart(u32* ptr)
|
||||
inline u16* LowPart(std::atomic<u32>* ptr)
|
||||
{
|
||||
static_assert(std::atomic<u32>::is_always_lock_free && sizeof(std::atomic<u32>) == sizeof(u32));
|
||||
return LowPart(Common::BitCast<u32*>(ptr));
|
||||
return LowPart(std::bit_cast<u32*>(ptr));
|
||||
}
|
||||
inline u16* HighPart(u32* ptr)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ inline u16* HighPart(u32* ptr)
|
||||
inline u16* HighPart(std::atomic<u32>* ptr)
|
||||
{
|
||||
static_assert(std::atomic<u32>::is_always_lock_free && sizeof(std::atomic<u32>) == sizeof(u32));
|
||||
return HighPart(Common::BitCast<u32*>(ptr));
|
||||
return HighPart(std::bit_cast<u32*>(ptr));
|
||||
}
|
||||
} // namespace Utils
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ static std::optional<u32> inet_pton(const char* src)
|
||||
}
|
||||
if (octets < 4)
|
||||
return std::nullopt;
|
||||
return Common::BitCast<u32>(tmp);
|
||||
return std::bit_cast<u32>(tmp);
|
||||
}
|
||||
|
||||
// Maps SOCKOPT level from Wii to native
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include <expr.h>
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Core/Core.h"
|
||||
@@ -84,7 +83,7 @@ static double HostReadFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||
const u32 address = static_cast<u32>(expr_eval(&vec_nth(args, 0)));
|
||||
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
return Common::BitCast<T>(HostRead<U>(guard, address));
|
||||
return std::bit_cast<T>(HostRead<U>(guard, address));
|
||||
}
|
||||
|
||||
template <typename T, typename U = T>
|
||||
@@ -96,7 +95,7 @@ static double HostWriteFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||
const u32 address = static_cast<u32>(expr_eval(&vec_nth(args, 1)));
|
||||
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
HostWrite<U>(guard, Common::BitCast<U>(var), address);
|
||||
HostWrite<U>(guard, std::bit_cast<U>(var), address);
|
||||
return var;
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ static double CastFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||
{
|
||||
if (vec_len(args) != 1)
|
||||
return 0;
|
||||
return Common::BitCast<T>(static_cast<U>(expr_eval(&vec_nth(args, 0))));
|
||||
return std::bit_cast<T>(static_cast<U>(expr_eval(&vec_nth(args, 0))));
|
||||
}
|
||||
|
||||
static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bit>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FloatUtils.h"
|
||||
@@ -59,13 +59,13 @@ inline float ForceSingle(const UReg_FPSCR& fpscr, double value)
|
||||
|
||||
constexpr u64 smallest_normal_single = 0x3810000000000000;
|
||||
const u64 value_without_sign =
|
||||
Common::BitCast<u64>(value) & (Common::DOUBLE_EXP | Common::DOUBLE_FRAC);
|
||||
std::bit_cast<u64>(value) & (Common::DOUBLE_EXP | Common::DOUBLE_FRAC);
|
||||
|
||||
if (value_without_sign < smallest_normal_single)
|
||||
{
|
||||
const u64 flushed_double = Common::BitCast<u64>(value) & Common::DOUBLE_SIGN;
|
||||
const u64 flushed_double = std::bit_cast<u64>(value) & Common::DOUBLE_SIGN;
|
||||
const u32 flushed_single = static_cast<u32>(flushed_double >> 32);
|
||||
return Common::BitCast<float>(flushed_single);
|
||||
return std::bit_cast<float>(flushed_single);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,18 +90,18 @@ inline double ForceDouble(const UReg_FPSCR& fpscr, double d)
|
||||
|
||||
inline double Force25Bit(double d)
|
||||
{
|
||||
u64 integral = Common::BitCast<u64>(d);
|
||||
u64 integral = std::bit_cast<u64>(d);
|
||||
|
||||
integral = (integral & 0xFFFFFFFFF8000000ULL) + (integral & 0x8000000);
|
||||
|
||||
return Common::BitCast<double>(integral);
|
||||
return std::bit_cast<double>(integral);
|
||||
}
|
||||
|
||||
inline double MakeQuiet(double d)
|
||||
{
|
||||
const u64 integral = Common::BitCast<u64>(d) | Common::DOUBLE_QBIT;
|
||||
const u64 integral = std::bit_cast<u64>(d) | Common::DOUBLE_QBIT;
|
||||
|
||||
return Common::BitCast<double>(integral);
|
||||
return std::bit_cast<double>(integral);
|
||||
}
|
||||
|
||||
// these functions allow globally modify operations behaviour
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "Core/PowerPC/Interpreter/Interpreter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Core/PowerPC/Interpreter/ExceptionUtils.h"
|
||||
@@ -186,7 +186,7 @@ static void Helper_Quantize(PowerPC::MMU& mmu, const PowerPC::PowerPCState* ppcs
|
||||
{
|
||||
case QUANTIZE_FLOAT:
|
||||
{
|
||||
const u64 integral_ps0 = Common::BitCast<u64>(ps0);
|
||||
const u64 integral_ps0 = std::bit_cast<u64>(ps0);
|
||||
const u32 conv_ps0 = ConvertToSingleFTZ(integral_ps0);
|
||||
|
||||
if (instW != 0)
|
||||
@@ -195,7 +195,7 @@ static void Helper_Quantize(PowerPC::MMU& mmu, const PowerPC::PowerPCState* ppcs
|
||||
}
|
||||
else
|
||||
{
|
||||
const u64 integral_ps1 = Common::BitCast<u64>(ps1);
|
||||
const u64 integral_ps1 = std::bit_cast<u64>(ps1);
|
||||
const u32 conv_ps1 = ConvertToSingleFTZ(integral_ps1);
|
||||
|
||||
WritePair<u32>(mmu, conv_ps0, conv_ps1, addr);
|
||||
@@ -265,14 +265,14 @@ static void Helper_Dequantize(PowerPC::MMU& mmu, PowerPC::PowerPCState* ppcs, u3
|
||||
if (instW != 0)
|
||||
{
|
||||
const u32 value = ReadUnpaired<u32>(mmu, addr);
|
||||
ps0 = Common::BitCast<double>(ConvertToDouble(value));
|
||||
ps0 = std::bit_cast<double>(ConvertToDouble(value));
|
||||
ps1 = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto [first, second] = ReadPair<u32>(mmu, addr);
|
||||
ps0 = Common::BitCast<double>(ConvertToDouble(first));
|
||||
ps1 = Common::BitCast<double>(ConvertToDouble(second));
|
||||
ps0 = std::bit_cast<double>(ConvertToDouble(first));
|
||||
ps1 = std::bit_cast<double>(ConvertToDouble(second));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include "Core/PowerPC/JitArm64/Jit.h"
|
||||
|
||||
#include <bit>
|
||||
#include <limits>
|
||||
|
||||
#include "Common/Arm64Emitter.h"
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Common/FloatUtils.h"
|
||||
@@ -300,8 +300,7 @@ void JitArm64::GenerateFres()
|
||||
SetJumpTarget(small_exponent);
|
||||
TST(ARM64Reg::X1, LogicalImm(Common::DOUBLE_EXP | Common::DOUBLE_FRAC, GPRSize::B64));
|
||||
FixupBranch zero = B(CCFlags::CC_EQ);
|
||||
MOVI2R(ARM64Reg::X4,
|
||||
Common::BitCast<u64>(static_cast<double>(std::numeric_limits<float>::max())));
|
||||
MOVI2R(ARM64Reg::X4, std::bit_cast<u64>(static_cast<double>(std::numeric_limits<float>::max())));
|
||||
ORR(ARM64Reg::X0, ARM64Reg::X3, ARM64Reg::X4);
|
||||
RET();
|
||||
|
||||
@@ -374,7 +373,7 @@ void JitArm64::GenerateFrsqrte()
|
||||
B(positive_normal);
|
||||
|
||||
SetJumpTarget(nan_or_inf);
|
||||
MOVI2R(ARM64Reg::X2, Common::BitCast<u64>(-std::numeric_limits<double>::infinity()));
|
||||
MOVI2R(ARM64Reg::X2, std::bit_cast<u64>(-std::numeric_limits<double>::infinity()));
|
||||
CMP(ARM64Reg::X1, ARM64Reg::X2);
|
||||
B(CCFlags::CC_NEQ, done);
|
||||
|
||||
|
||||
@@ -668,7 +668,7 @@ std::optional<ReadResult<float>> MMU::HostTryReadF32(const Core::CPUThreadGuard&
|
||||
const auto result = HostTryReadUX<u32>(guard, address, space);
|
||||
if (!result)
|
||||
return std::nullopt;
|
||||
return ReadResult<float>(result->translated, Common::BitCast<float>(result->value));
|
||||
return ReadResult<float>(result->translated, std::bit_cast<float>(result->value));
|
||||
}
|
||||
|
||||
std::optional<ReadResult<double>> MMU::HostTryReadF64(const Core::CPUThreadGuard& guard,
|
||||
@@ -677,7 +677,7 @@ std::optional<ReadResult<double>> MMU::HostTryReadF64(const Core::CPUThreadGuard
|
||||
const auto result = HostTryReadUX<u64>(guard, address, space);
|
||||
if (!result)
|
||||
return std::nullopt;
|
||||
return ReadResult<double>(result->translated, Common::BitCast<double>(result->value));
|
||||
return ReadResult<double>(result->translated, std::bit_cast<double>(result->value));
|
||||
}
|
||||
|
||||
void MMU::Write_U8(const u32 var, const u32 address)
|
||||
@@ -745,14 +745,14 @@ float MMU::HostRead_F32(const Core::CPUThreadGuard& guard, const u32 address)
|
||||
{
|
||||
const u32 integral = HostRead_U32(guard, address);
|
||||
|
||||
return Common::BitCast<float>(integral);
|
||||
return std::bit_cast<float>(integral);
|
||||
}
|
||||
|
||||
double MMU::HostRead_F64(const Core::CPUThreadGuard& guard, const u32 address)
|
||||
{
|
||||
const u64 integral = HostRead_U64(guard, address);
|
||||
|
||||
return Common::BitCast<double>(integral);
|
||||
return std::bit_cast<double>(integral);
|
||||
}
|
||||
|
||||
void MMU::HostWrite_U8(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
|
||||
@@ -782,14 +782,14 @@ void MMU::HostWrite_U64(const Core::CPUThreadGuard& guard, const u64 var, const
|
||||
|
||||
void MMU::HostWrite_F32(const Core::CPUThreadGuard& guard, const float var, const u32 address)
|
||||
{
|
||||
const u32 integral = Common::BitCast<u32>(var);
|
||||
const u32 integral = std::bit_cast<u32>(var);
|
||||
|
||||
HostWrite_U32(guard, integral, address);
|
||||
}
|
||||
|
||||
void MMU::HostWrite_F64(const Core::CPUThreadGuard& guard, const double var, const u32 address)
|
||||
{
|
||||
const u64 integral = Common::BitCast<u64>(var);
|
||||
const u64 integral = std::bit_cast<u64>(var);
|
||||
|
||||
HostWrite_U64(guard, integral, address);
|
||||
}
|
||||
@@ -852,14 +852,14 @@ std::optional<WriteResult> MMU::HostTryWriteU64(const Core::CPUThreadGuard& guar
|
||||
std::optional<WriteResult> MMU::HostTryWriteF32(const Core::CPUThreadGuard& guard, const float var,
|
||||
const u32 address, RequestedAddressSpace space)
|
||||
{
|
||||
const u32 integral = Common::BitCast<u32>(var);
|
||||
const u32 integral = std::bit_cast<u32>(var);
|
||||
return HostTryWriteU32(guard, integral, address, space);
|
||||
}
|
||||
|
||||
std::optional<WriteResult> MMU::HostTryWriteF64(const Core::CPUThreadGuard& guard, const double var,
|
||||
const u32 address, RequestedAddressSpace space)
|
||||
{
|
||||
const u64 integral = Common::BitCast<u64>(var);
|
||||
const u64 integral = std::bit_cast<u64>(var);
|
||||
return HostTryWriteU64(guard, integral, address, space);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
@@ -11,7 +12,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FPURoundMode.h"
|
||||
@@ -37,22 +37,22 @@ namespace PowerPC
|
||||
{
|
||||
double PairedSingle::PS0AsDouble() const
|
||||
{
|
||||
return Common::BitCast<double>(ps0);
|
||||
return std::bit_cast<double>(ps0);
|
||||
}
|
||||
|
||||
double PairedSingle::PS1AsDouble() const
|
||||
{
|
||||
return Common::BitCast<double>(ps1);
|
||||
return std::bit_cast<double>(ps1);
|
||||
}
|
||||
|
||||
void PairedSingle::SetPS0(double value)
|
||||
{
|
||||
ps0 = Common::BitCast<u64>(value);
|
||||
ps0 = std::bit_cast<u64>(value);
|
||||
}
|
||||
|
||||
void PairedSingle::SetPS1(double value)
|
||||
{
|
||||
ps1 = Common::BitCast<u64>(value);
|
||||
ps1 = std::bit_cast<u64>(value);
|
||||
}
|
||||
|
||||
static void InvalidateCacheThreadSafe(Core::System& system, u64 userdata, s64 cyclesLate)
|
||||
|
||||
Reference in new issue
Block a user