summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/microinstruction.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/frontend/ir/microinstruction.h')
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.h b/src/shader_recompiler/frontend/ir/microinstruction.h
index ddf0f90a9..5b244fa0b 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.h
+++ b/src/shader_recompiler/frontend/ir/microinstruction.h
@@ -12,6 +12,7 @@
12 12
13#include <boost/intrusive/list.hpp> 13#include <boost/intrusive/list.hpp>
14 14
15#include "common/bit_cast.h"
15#include "common/common_types.h" 16#include "common/common_types.h"
16#include "shader_recompiler/frontend/ir/opcodes.h" 17#include "shader_recompiler/frontend/ir/opcodes.h"
17#include "shader_recompiler/frontend/ir/type.h" 18#include "shader_recompiler/frontend/ir/type.h"
@@ -25,7 +26,7 @@ constexpr size_t MAX_ARG_COUNT = 4;
25 26
26class Inst : public boost::intrusive::list_base_hook<> { 27class Inst : public boost::intrusive::list_base_hook<> {
27public: 28public:
28 explicit Inst(Opcode op_, u64 flags_) noexcept; 29 explicit Inst(Opcode op_, u32 flags_) noexcept;
29 ~Inst(); 30 ~Inst();
30 31
31 Inst& operator=(const Inst&) = delete; 32 Inst& operator=(const Inst&) = delete;
@@ -86,13 +87,25 @@ public:
86 void ReplaceUsesWith(Value replacement); 87 void ReplaceUsesWith(Value replacement);
87 88
88 template <typename FlagsType> 89 template <typename FlagsType>
89 requires(sizeof(FlagsType) <= sizeof(u64) && std::is_trivially_copyable_v<FlagsType>) 90 requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>)
90 [[nodiscard]] FlagsType Flags() const noexcept { 91 [[nodiscard]] FlagsType Flags() const noexcept {
91 FlagsType ret; 92 FlagsType ret;
92 std::memcpy(&ret, &flags, sizeof(ret)); 93 std::memcpy(&ret, &flags, sizeof(ret));
93 return ret; 94 return ret;
94 } 95 }
95 96
97 /// Intrusively store the host definition of this instruction.
98 template <typename DefinitionType>
99 void SetDefinition(DefinitionType def) {
100 definition = Common::BitCast<u32>(def);
101 }
102
103 /// Return the intrusively stored host definition of this instruction.
104 template <typename DefinitionType>
105 [[nodiscard]] DefinitionType Definition() const noexcept {
106 return Common::BitCast<DefinitionType>(definition);
107 }
108
96private: 109private:
97 struct NonTriviallyDummy { 110 struct NonTriviallyDummy {
98 NonTriviallyDummy() noexcept {} 111 NonTriviallyDummy() noexcept {}
@@ -103,7 +116,8 @@ private:
103 116
104 IR::Opcode op{}; 117 IR::Opcode op{};
105 int use_count{}; 118 int use_count{};
106 u64 flags{}; 119 u32 flags{};
120 u32 definition{};
107 union { 121 union {
108 NonTriviallyDummy dummy{}; 122 NonTriviallyDummy dummy{};
109 std::array<Value, MAX_ARG_COUNT> args; 123 std::array<Value, MAX_ARG_COUNT> args;