diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-04-22 21:18:54 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:29 +0200 |
commit | 21e3382830e4a2b294ea8b84ffad531e752fc512 (patch) | |
tree | 5a67dc09a5548c7800e42ffb3907eeefbf679b8a /src/shader_recompiler/frontend/ir/opcodes.h | |
parent | shader: Implement indexed textures (diff) | |
download | yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.tar yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.tar.gz yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.tar.bz2 yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.tar.lz yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.tar.xz yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.tar.zst yuzu-21e3382830e4a2b294ea8b84ffad531e752fc512.zip |
Diffstat (limited to 'src/shader_recompiler/frontend/ir/opcodes.h')
-rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/shader_recompiler/frontend/ir/opcodes.h b/src/shader_recompiler/frontend/ir/opcodes.h index b5697c7f9..2b9c0ed8c 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.h +++ b/src/shader_recompiler/frontend/ir/opcodes.h @@ -4,8 +4,8 @@ #pragma once -#include <array> #include <algorithm> +#include <array> #include <string_view> #include <fmt/format.h> @@ -21,7 +21,6 @@ enum class Opcode { }; namespace Detail { - struct OpcodeMeta { std::string_view name; Type type; @@ -57,9 +56,9 @@ constexpr Type F64x2{Type::F64x2}; constexpr Type F64x3{Type::F64x3}; constexpr Type F64x4{Type::F64x4}; -constexpr std::array META_TABLE{ +constexpr OpcodeMeta META_TABLE[]{ #define OPCODE(name_token, type_token, ...) \ - OpcodeMeta{ \ + { \ .name{#name_token}, \ .type = type_token, \ .arg_types{__VA_ARGS__}, \ @@ -67,14 +66,13 @@ constexpr std::array META_TABLE{ #include "opcodes.inc" #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), +constexpr u8 NUM_ARGS[]{ +#define OPCODE(name_token, type_token, ...) static_cast<u8>(CalculateNumArgsOf(Opcode::name_token)), #include "opcodes.inc" #undef OPCODE }; @@ -87,7 +85,7 @@ constexpr std::array NUM_ARGS{ /// Get the number of arguments an opcode accepts [[nodiscard]] inline size_t NumArgsOf(Opcode op) noexcept { - return Detail::NUM_ARGS[static_cast<size_t>(op)]; + return static_cast<size_t>(Detail::NUM_ARGS[static_cast<size_t>(op)]); } /// Get the required type of an argument of an opcode |