summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/opcode.h
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-01-09 03:30:07 -0300
committerGravatar ameerj2021-07-22 21:51:21 -0400
commit2d48a7b4d0666ad16d03a22d85712617a0849046 (patch)
treedd1069afca86f66e77e3438da77421a43adf5091 /src/shader_recompiler/frontend/ir/opcode.h
parentthread_worker: Fix compile time error (diff)
downloadyuzu-2d48a7b4d0666ad16d03a22d85712617a0849046.tar.gz
yuzu-2d48a7b4d0666ad16d03a22d85712617a0849046.tar.xz
yuzu-2d48a7b4d0666ad16d03a22d85712617a0849046.zip
shader: Initial recompiler work
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/frontend/ir/opcode.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/opcode.h b/src/shader_recompiler/frontend/ir/opcode.h
new file mode 100644
index 000000000..1f4440379
--- /dev/null
+++ b/src/shader_recompiler/frontend/ir/opcode.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 "opcode.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};