[common] replace Common::BitCast with libc++ provided one (#2774)

Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2774
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-10-22 02:56:28 +02:00 committed by crueter
parent 6ff043c4fb
commit 992bae4e2a
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
25 changed files with 152 additions and 151 deletions

View file

@ -5,7 +5,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <fmt/ranges.h>
#include <bit>
#include "shader_recompiler/backend/glasm/reg_alloc.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/ir/value.h"
@ -78,7 +78,7 @@ Value RegAlloc::MakeImm(const IR::Value& value) {
break;
case IR::Type::F32:
ret.type = Type::U32;
ret.imm_u32 = Common::BitCast<u32>(value.F32());
ret.imm_u32 = std::bit_cast<u32>(value.F32());
break;
case IR::Type::U64:
ret.type = Type::U64;
@ -86,7 +86,7 @@ Value RegAlloc::MakeImm(const IR::Value& value) {
break;
case IR::Type::F64:
ret.type = Type::U64;
ret.imm_u64 = Common::BitCast<u64>(value.F64());
ret.imm_u64 = std::bit_cast<u64>(value.F64());
break;
default:
throw NotImplementedException("Immediate type {}", value.Type());

View file

@ -1,13 +1,16 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <bitset>
#include <bit>
#include <fmt/ranges.h>
#include <numeric>
#include "common/bit_cast.h"
#include "common/bit_field.h"
#include "common/common_types.h"
#include "shader_recompiler/exception.h"
@ -272,7 +275,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF32> {
case Shader::Backend::GLASM::Type::Register:
return Shader::Backend::GLASM::FormatTo<true>(ctx, value.id);
case Shader::Backend::GLASM::Type::U32:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f32>(value.imm_u32));
return fmt::format_to(ctx.out(), "{}", std::bit_cast<f32>(value.imm_u32));
case Shader::Backend::GLASM::Type::U64:
break;
}
@ -295,7 +298,7 @@ struct fmt::formatter<Shader::Backend::GLASM::ScalarF64> {
case Shader::Backend::GLASM::Type::U32:
break;
case Shader::Backend::GLASM::Type::U64:
return fmt::format_to(ctx.out(), "{}", Common::BitCast<f64>(value.imm_u64));
return fmt::format_to(ctx.out(), "{}", std::bit_cast<f64>(value.imm_u64));
}
throw Shader::InvalidArgument("Invalid value type {}", value.type);
}

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -7,10 +10,10 @@
#include <map>
#include <span>
#include <vector>
#include <bit>
#include <numeric>
#include <boost/intrusive/list.hpp>
#include "common/bit_cast.h"
#include "common/common_types.h"
#include "shader_recompiler/frontend/ir/condition.h"
#include "shader_recompiler/frontend/ir/value.h"
@ -70,13 +73,13 @@ public:
/// Intrusively store the host definition of this instruction.
template <typename DefinitionType>
void SetDefinition(DefinitionType def) {
definition = Common::BitCast<u32>(def);
definition = std::bit_cast<u32>(def);
}
/// Return the intrusively stored host definition of this instruction.
template <typename DefinitionType>
[[nodiscard]] DefinitionType Definition() const noexcept {
return Common::BitCast<DefinitionType>(definition);
return std::bit_cast<DefinitionType>(definition);
}
void SetSsaRegValue(IR::Reg reg, const Value& value) noexcept {

View file

@ -1,7 +1,10 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/bit_cast.h"
#include <numeric>
#include "shader_recompiler/frontend/ir/ir_emitter.h"
#include "shader_recompiler/frontend/ir/value.h"

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -14,7 +17,7 @@
#include <boost/intrusive/list.hpp>
#include "common/assert.h"
#include "common/bit_cast.h"
#include <numeric>
#include "common/common_types.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/ir/attribute.h"
@ -206,13 +209,13 @@ public:
/// Intrusively store the host definition of this instruction.
template <typename DefinitionType>
void SetDefinition(DefinitionType def) {
definition = Common::BitCast<u32>(def);
definition = std::bit_cast<u32>(def);
}
/// Return the intrusively stored host definition of this instruction.
template <typename DefinitionType>
[[nodiscard]] DefinitionType Definition() const noexcept {
return Common::BitCast<DefinitionType>(definition);
return std::bit_cast<DefinitionType>(definition);
}
/// Destructively remove one reference count from the instruction

View file

@ -204,7 +204,7 @@ IR::F32 TranslatorVisitor::GetFloatImm20(u64 insn) {
} const imm{insn};
const u32 sign_bit{static_cast<u32>(imm.is_negative != 0 ? (1ULL << 31) : 0)};
const u32 value{static_cast<u32>(imm.value) << 12};
return ir.Imm32(Common::BitCast<f32>(value | sign_bit));
return ir.Imm32(std::bit_cast<f32>(value | sign_bit));
}
IR::F64 TranslatorVisitor::GetDoubleImm20(u64 insn) {
@ -215,7 +215,7 @@ IR::F64 TranslatorVisitor::GetDoubleImm20(u64 insn) {
} const imm{insn};
const u64 sign_bit{imm.is_negative != 0 ? (1ULL << 63) : 0};
const u64 value{imm.value << 44};
return ir.Imm64(Common::BitCast<f64>(value | sign_bit));
return ir.Imm64(std::bit_cast<f64>(value | sign_bit));
}
IR::U64 TranslatorVisitor::GetPackedImm20(u64 insn) {
@ -236,7 +236,7 @@ IR::F32 TranslatorVisitor::GetFloatImm32(u64 insn) {
u64 raw;
BitField<20, 32, u64> value;
} const imm{insn};
return ir.Imm32(Common::BitCast<f32>(static_cast<u32>(imm.value)));
return ir.Imm32(std::bit_cast<f32>(static_cast<u32>(imm.value)));
}
void TranslatorVisitor::SetZFlag(const IR::U1& value) {

View file

@ -8,8 +8,8 @@
#include <functional>
#include <tuple>
#include <type_traits>
#include "common/bit_cast.h"
#include <bit>
#include <numeric>
#include "shader_recompiler/environment.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/ir/ir_emitter.h"
@ -536,7 +536,7 @@ template <IR::Opcode op, typename Dest, typename Source>
void FoldBitCast(IR::Inst& inst, IR::Opcode reverse) {
const IR::Value value{inst.Arg(0)};
if (value.IsImmediate()) {
inst.ReplaceUsesWith(IR::Value{Common::BitCast<Dest>(Arg<Source>(value))});
inst.ReplaceUsesWith(IR::Value{std::bit_cast<Dest>(Arg<Source>(value))});
return;
}
IR::Inst* const arg_inst{value.InstRecursive()};
@ -674,7 +674,7 @@ void FoldFSwizzleAdd(IR::Block& block, IR::Inst& inst) {
if (!value_2.IsImmediate() || !value_3.IsImmediate()) {
return;
}
if (Common::BitCast<u32>(value_2.F32()) != value_3.U32()) {
if (std::bit_cast<u32>(value_2.F32()) != value_3.U32()) {
return;
}
}
@ -821,7 +821,7 @@ bool FindGradient3DDerivatives(std::array<IR::Value, 3>& results, IR::Value coor
void ConvertDerivatives(std::array<IR::Value, 3>& results, IR::IREmitter& ir) {
for (size_t i = 0; i < 3; i++) {
if (results[i].Type() == IR::Type::U32) {
results[i] = results[i].IsImmediate() ? ir.Imm32(Common::BitCast<f32>(results[i].U32()))
results[i] = results[i].IsImmediate() ? ir.Imm32(std::bit_cast<f32>(results[i].U32()))
: ir.BitCast<IR::F32>(IR::U32(results[i]));
}
}
@ -927,7 +927,7 @@ void FoldDriverConstBuffer(Environment& env, IR::Block& block, IR::Inst& inst, u
inst.ReplaceUsesWith(IR::Value{env.ReadCbufValue(bank_value, offset_value)});
} else {
inst.ReplaceUsesWith(
IR::Value{Common::BitCast<f32>(env.ReadCbufValue(bank_value, offset_value))});
IR::Value{std::bit_cast<f32>(env.ReadCbufValue(bank_value, offset_value))});
}
}