Files
eden/src/shader_recompiler/frontend/maxwell/decode.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.4 KiB
C++
Raw Normal View History

2026-07-25 21:47:07 +02:00
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
2025-07-30 20:59:28 +02:00
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2021-01-09 03:30:07 -03:00
#include <algorithm>
#include <array>
#include <bit>
#include <memory>
#include <ranges>
#include <string_view>
2021-01-09 03:30:07 -03:00
#include "common/assert.h"
2021-01-09 03:30:07 -03:00
#include "common/common_types.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/maxwell/decode.h"
2021-02-05 23:11:23 -03:00
#include "shader_recompiler/frontend/maxwell/opcodes.h"
2021-01-09 03:30:07 -03:00
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]) {
2021-01-09 03:30:07 -03:00
case '0':
mask |= bit;
bit >>= 1;
2021-01-09 03:30:07 -03:00
break;
case '1':
mask |= bit;
value |= bit;
bit >>= 1;
2021-01-09 03:30:07 -03:00
break;
case '-':
bit >>= 1;
2021-01-09 03:30:07 -03:00
break;
default:
break;
2021-01-09 03:30:07 -03:00
}
return { mask, value };
2021-01-09 03:30:07 -03:00
}
Opcode Decode(u64 insn) {
#define INST(name, cute, encode) \
if (auto const p = MaskValueFromEncoding(encode); (insn & p.first) == p.second) \
return Opcode::name;
2021-01-09 03:30:07 -03:00
#include "maxwell.inc"
#undef INST
2026-07-25 21:47:07 +02:00
ASSERT_MSG(false, "Invalid insn {:#016x}", insn);
return Opcode::NOP;
2021-01-09 03:30:07 -03:00
}
} // namespace Shader::Maxwell