mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-15 21:19:47 +00:00
312c1cc0f6
Function polymorphism where it wasn't needed? especially on tight code loops like translating code and whatnot? You may think the compiler was fine with this but nah, it just made codegen for all those paths; I didn't check LTO but I'd assume it behaves the same (since the "black box" from most walkers suck) - basically bunch of code that isn't longer used Also uniformly declaring all functions (i.e same args, return value) makes the entire switch statment way nicer Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2972 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
// 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 <algorithm>
|
|
#include <array>
|
|
#include <bit>
|
|
#include <memory>
|
|
#include <ranges>
|
|
#include <string_view>
|
|
|
|
#include "common/assert.h"
|
|
#include "common/common_types.h"
|
|
#include "shader_recompiler/exception.h"
|
|
#include "shader_recompiler/frontend/maxwell/decode.h"
|
|
#include "shader_recompiler/frontend/maxwell/opcodes.h"
|
|
|
|
namespace Shader::Maxwell {
|
|
|
|
consteval std::pair<u64, u64> MaskValueFromEncoding(const char data[20]) noexcept {
|
|
u64 mask = 0, value = 0, bit = u64(1) << 63;
|
|
for (int i = 0; i < 20; ++i)
|
|
switch (data[i]) {
|
|
case '0':
|
|
mask |= bit;
|
|
bit >>= 1;
|
|
break;
|
|
case '1':
|
|
mask |= bit;
|
|
value |= bit;
|
|
bit >>= 1;
|
|
break;
|
|
case '-':
|
|
bit >>= 1;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return { mask, value };
|
|
}
|
|
|
|
Opcode Decode(u64 insn) {
|
|
#define INST(name, cute, encode) \
|
|
if (auto const p = MaskValueFromEncoding(encode); (insn & p.first) == p.second) \
|
|
return Opcode::name;
|
|
#include "maxwell.inc"
|
|
#undef INST
|
|
ASSERT_MSG(false, "Invalid insn 0x{:016x}", insn);
|
|
return Opcode::NOP;
|
|
}
|
|
|
|
} // namespace Shader::Maxwell
|