diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-04-21 03:20:46 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:28 +0200 |
commit | 79c2e43fcd5a254121d48e6957ac159041c4fac0 (patch) | |
tree | f5430fb38ac3fcc3dbb94adf7e8c4cdfad001124 /src/shader_recompiler/frontend/ir | |
parent | shader: Implement D3D samplers (diff) | |
download | yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.tar yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.tar.gz yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.tar.bz2 yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.tar.lz yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.tar.xz yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.tar.zst yuzu-79c2e43fcd5a254121d48e6957ac159041c4fac0.zip |
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
-rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/shader_recompiler/frontend/ir/opcodes.cpp b/src/shader_recompiler/frontend/ir/opcodes.cpp index 7f04b647b..4207d548c 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.cpp +++ b/src/shader_recompiler/frontend/ir/opcodes.cpp @@ -57,6 +57,17 @@ constexpr std::array META_TABLE{ #undef OPCODE }; +constexpr size_t CalculateNumArgsOf(Opcode op) { + const auto& arg_types{META_TABLE[static_cast<size_t>(op)].arg_types}; + return std::distance(arg_types.begin(), std::ranges::find(arg_types, Type::Void)); +} + +constexpr std::array NUM_ARGS{ +#define OPCODE(name_token, type_token, ...) CalculateNumArgsOf(Opcode::name_token), +#include "opcodes.inc" +#undef OPCODE +}; + void ValidateOpcode(Opcode op) { const size_t raw{static_cast<size_t>(op)}; if (raw >= META_TABLE.size()) { @@ -72,9 +83,7 @@ Type TypeOf(Opcode op) { size_t NumArgsOf(Opcode op) { ValidateOpcode(op); - const auto& arg_types{META_TABLE[static_cast<size_t>(op)].arg_types}; - const auto distance{std::distance(arg_types.begin(), std::ranges::find(arg_types, Type::Void))}; - return static_cast<size_t>(distance); + return NUM_ARGS[static_cast<size_t>(op)]; } Type ArgTypeOf(Opcode op, size_t arg_index) { |