diff options
| author | 2021-02-03 16:43:04 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:21 -0400 | |
| commit | d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f (patch) | |
| tree | 0108a028b437bc59dfe7864f333cf4c50a46d3b5 /src/shader_recompiler/frontend/ir/microinstruction.h | |
| parent | shader: SSA and dominance (diff) | |
| download | yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.gz yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.tar.xz yuzu-d24a16045f0f6b0b873d5e3b5bf187c1a8c4343f.zip | |
shader: Initial instruction support
Diffstat (limited to 'src/shader_recompiler/frontend/ir/microinstruction.h')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.h b/src/shader_recompiler/frontend/ir/microinstruction.h index 7f1ed6710..61849695a 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.h +++ b/src/shader_recompiler/frontend/ir/microinstruction.h | |||
| @@ -5,7 +5,9 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstring> | ||
| 8 | #include <span> | 9 | #include <span> |
| 10 | #include <type_traits> | ||
| 9 | #include <vector> | 11 | #include <vector> |
| 10 | 12 | ||
| 11 | #include <boost/intrusive/list.hpp> | 13 | #include <boost/intrusive/list.hpp> |
| @@ -23,7 +25,7 @@ constexpr size_t MAX_ARG_COUNT = 4; | |||
| 23 | 25 | ||
| 24 | class Inst : public boost::intrusive::list_base_hook<> { | 26 | class Inst : public boost::intrusive::list_base_hook<> { |
| 25 | public: | 27 | public: |
| 26 | explicit Inst(Opcode op_) noexcept : op(op_) {} | 28 | explicit Inst(Opcode op_, u64 flags_) noexcept : op{op_}, flags{flags_} {} |
| 27 | 29 | ||
| 28 | /// Get the number of uses this instruction has. | 30 | /// Get the number of uses this instruction has. |
| 29 | [[nodiscard]] int UseCount() const noexcept { | 31 | [[nodiscard]] int UseCount() const noexcept { |
| @@ -73,6 +75,14 @@ public: | |||
| 73 | 75 | ||
| 74 | void ReplaceUsesWith(Value replacement); | 76 | void ReplaceUsesWith(Value replacement); |
| 75 | 77 | ||
| 78 | template <typename FlagsType> | ||
| 79 | requires(sizeof(FlagsType) <= sizeof(u64) && std::is_trivially_copyable_v<FlagsType>) | ||
| 80 | [[nodiscard]] FlagsType Flags() const noexcept { | ||
| 81 | FlagsType ret; | ||
| 82 | std::memcpy(&ret, &flags, sizeof(ret)); | ||
| 83 | return ret; | ||
| 84 | } | ||
| 85 | |||
| 76 | private: | 86 | private: |
| 77 | void Use(const Value& value); | 87 | void Use(const Value& value); |
| 78 | void UndoUse(const Value& value); | 88 | void UndoUse(const Value& value); |