Files
eden/src/shader_recompiler/frontend/maxwell/decode.cpp
T
lizzie fe6b6fbde5 [shader_recompiler] simplify decoder table logic and let compiler do tables for us (#2915)
The compiler is very smart, I trust the compiler to make a proper decoder selector rather than rolling our own.

Probably mostly benefitted on PGO builds.

Directly affects cache recompilation times (test with pipeline shaders OFF to force shaders to rebuild :)

Also restores CCTLT so we have the full ISA (or do we? Is ISBEWR missing? - someone should run fuzzing :)

Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2915
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
2025-11-01 03:57:28 +01:00

52 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/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
throw NotImplementedException("Invalid insn 0x{:016x}", insn);
}
} // namespace Shader::Maxwell