summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/opcodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/frontend/ir/opcodes.h')
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/opcodes.h b/src/shader_recompiler/frontend/ir/opcodes.h
new file mode 100644
index 000000000..999fb2e77
--- /dev/null
+++ b/src/shader_recompiler/frontend/ir/opcodes.h
@@ -0,0 +1,44 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <string_view>
8
9#include <fmt/format.h>
10
11#include "shader_recompiler/frontend/ir/type.h"
12
13namespace Shader::IR {
14
15enum class Opcode {
16#define OPCODE(name, ...) name,
17#include "opcodes.inc"
18#undef OPCODE
19};
20
21/// Get return type of an opcode
22[[nodiscard]] Type TypeOf(Opcode op);
23
24/// Get the number of arguments an opcode accepts
25[[nodiscard]] size_t NumArgsOf(Opcode op);
26
27/// Get the required type of an argument of an opcode
28[[nodiscard]] Type ArgTypeOf(Opcode op, size_t arg_index);
29
30/// Get the name of an opcode
31[[nodiscard]] std::string_view NameOf(Opcode op);
32
33} // namespace Shader::IR
34
35template <>
36struct fmt::formatter<Shader::IR::Opcode> {
37 constexpr auto parse(format_parse_context& ctx) {
38 return ctx.begin();
39 }
40 template <typename FormatContext>
41 auto format(const Shader::IR::Opcode& op, FormatContext& ctx) {
42 return format_to(ctx.out(), "{}", Shader::IR::NameOf(op));
43 }
44};