diff options
| author | 2021-04-21 00:35:47 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:28 -0400 | |
| commit | 050e81500c002f304d581f28700de549b828a2bc (patch) | |
| tree | 906868122c08a0771987e6953c096476c0ebc277 /src/shader_recompiler | |
| parent | shader: Move siblings check to a separate function and comment them out (diff) | |
| download | yuzu-050e81500c002f304d581f28700de549b828a2bc.tar.gz yuzu-050e81500c002f304d581f28700de549b828a2bc.tar.xz yuzu-050e81500c002f304d581f28700de549b828a2bc.zip | |
shader: Move microinstruction header to the value header
Diffstat (limited to '')
19 files changed, 161 insertions, 180 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index 07963a760..3d7506de2 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt | |||
| @@ -36,7 +36,6 @@ add_library(shader_recompiler STATIC | |||
| 36 | frontend/ir/ir_emitter.cpp | 36 | frontend/ir/ir_emitter.cpp |
| 37 | frontend/ir/ir_emitter.h | 37 | frontend/ir/ir_emitter.h |
| 38 | frontend/ir/microinstruction.cpp | 38 | frontend/ir/microinstruction.cpp |
| 39 | frontend/ir/microinstruction.h | ||
| 40 | frontend/ir/modifiers.h | 39 | frontend/ir/modifiers.h |
| 41 | frontend/ir/opcodes.cpp | 40 | frontend/ir/opcodes.cpp |
| 42 | frontend/ir/opcodes.h | 41 | frontend/ir/opcodes.h |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 5d6fdeb65..815b3cd95 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | 10 | ||
| 11 | #include "shader_recompiler/backend/spirv/emit_spirv.h" | 11 | #include "shader_recompiler/backend/spirv/emit_spirv.h" |
| 12 | #include "shader_recompiler/frontend/ir/basic_block.h" | 12 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 13 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 14 | #include "shader_recompiler/frontend/ir/program.h" | 13 | #include "shader_recompiler/frontend/ir/program.h" |
| 15 | 14 | ||
| 16 | namespace Shader::Backend::SPIRV { | 15 | namespace Shader::Backend::SPIRV { |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.h b/src/shader_recompiler/backend/spirv/emit_spirv.h index 89a82e858..4562db45b 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "shader_recompiler/backend/spirv/emit_context.h" | 10 | #include "shader_recompiler/backend/spirv/emit_context.h" |
| 11 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 12 | #include "shader_recompiler/frontend/ir/program.h" | 11 | #include "shader_recompiler/frontend/ir/program.h" |
| 13 | #include "shader_recompiler/profile.h" | 12 | #include "shader_recompiler/profile.h" |
| 14 | 13 | ||
diff --git a/src/shader_recompiler/frontend/ir/basic_block.h b/src/shader_recompiler/frontend/ir/basic_block.h index 3a4230755..ab7ddb3d5 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.h +++ b/src/shader_recompiler/frontend/ir/basic_block.h | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | #include "common/bit_cast.h" | 14 | #include "common/bit_cast.h" |
| 15 | #include "shader_recompiler/frontend/ir/condition.h" | 15 | #include "shader_recompiler/frontend/ir/condition.h" |
| 16 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 17 | #include "shader_recompiler/frontend/ir/value.h" | 16 | #include "shader_recompiler/frontend/ir/value.h" |
| 18 | #include "shader_recompiler/object_pool.h" | 17 | #include "shader_recompiler/object_pool.h" |
| 19 | 18 | ||
diff --git a/src/shader_recompiler/frontend/ir/breadth_first_search.h b/src/shader_recompiler/frontend/ir/breadth_first_search.h index b35f062d4..a52ccbd58 100644 --- a/src/shader_recompiler/frontend/ir/breadth_first_search.h +++ b/src/shader_recompiler/frontend/ir/breadth_first_search.h | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | 10 | ||
| 11 | #include <boost/container/small_vector.hpp> | 11 | #include <boost/container/small_vector.hpp> |
| 12 | 12 | ||
| 13 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 14 | #include "shader_recompiler/frontend/ir/value.h" | 13 | #include "shader_recompiler/frontend/ir/value.h" |
| 15 | 14 | ||
| 16 | namespace Shader::IR { | 15 | namespace Shader::IR { |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 41f9fa0cd..701746a0c 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | 7 | ||
| 8 | #include "shader_recompiler/exception.h" | 8 | #include "shader_recompiler/exception.h" |
| 9 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 10 | #include "shader_recompiler/frontend/ir/type.h" | 9 | #include "shader_recompiler/frontend/ir/type.h" |
| 10 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 11 | 11 | ||
| 12 | namespace Shader::IR { | 12 | namespace Shader::IR { |
| 13 | namespace { | 13 | namespace { |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.h b/src/shader_recompiler/frontend/ir/microinstruction.h deleted file mode 100644 index ea55fc29c..000000000 --- a/src/shader_recompiler/frontend/ir/microinstruction.h +++ /dev/null | |||
| @@ -1,162 +0,0 @@ | |||
| 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 <array> | ||
| 8 | #include <cstring> | ||
| 9 | #include <type_traits> | ||
| 10 | #include <utility> | ||
| 11 | #include <vector> | ||
| 12 | |||
| 13 | #include <boost/container/small_vector.hpp> | ||
| 14 | #include <boost/intrusive/list.hpp> | ||
| 15 | |||
| 16 | #include "common/bit_cast.h" | ||
| 17 | #include "common/common_types.h" | ||
| 18 | #include "shader_recompiler/frontend/ir/opcodes.h" | ||
| 19 | #include "shader_recompiler/frontend/ir/type.h" | ||
| 20 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 21 | |||
| 22 | namespace Shader::IR { | ||
| 23 | |||
| 24 | class Block; | ||
| 25 | |||
| 26 | struct AssociatedInsts; | ||
| 27 | |||
| 28 | class Inst : public boost::intrusive::list_base_hook<> { | ||
| 29 | public: | ||
| 30 | explicit Inst(Opcode op_, u32 flags_) noexcept; | ||
| 31 | ~Inst(); | ||
| 32 | |||
| 33 | Inst& operator=(const Inst&) = delete; | ||
| 34 | Inst(const Inst&) = delete; | ||
| 35 | |||
| 36 | Inst& operator=(Inst&&) = delete; | ||
| 37 | Inst(Inst&&) = delete; | ||
| 38 | |||
| 39 | /// Get the number of uses this instruction has. | ||
| 40 | [[nodiscard]] int UseCount() const noexcept { | ||
| 41 | return use_count; | ||
| 42 | } | ||
| 43 | |||
| 44 | /// Determines whether this instruction has uses or not. | ||
| 45 | [[nodiscard]] bool HasUses() const noexcept { | ||
| 46 | return use_count > 0; | ||
| 47 | } | ||
| 48 | |||
| 49 | /// Get the opcode this microinstruction represents. | ||
| 50 | [[nodiscard]] IR::Opcode GetOpcode() const noexcept { | ||
| 51 | return op; | ||
| 52 | } | ||
| 53 | |||
| 54 | /// Determines if there is a pseudo-operation associated with this instruction. | ||
| 55 | [[nodiscard]] bool HasAssociatedPseudoOperation() const noexcept { | ||
| 56 | return associated_insts != nullptr; | ||
| 57 | } | ||
| 58 | |||
| 59 | /// Determines whether or not this instruction may have side effects. | ||
| 60 | [[nodiscard]] bool MayHaveSideEffects() const noexcept; | ||
| 61 | |||
| 62 | /// Determines whether or not this instruction is a pseudo-instruction. | ||
| 63 | /// Pseudo-instructions depend on their parent instructions for their semantics. | ||
| 64 | [[nodiscard]] bool IsPseudoInstruction() const noexcept; | ||
| 65 | |||
| 66 | /// Determines if all arguments of this instruction are immediates. | ||
| 67 | [[nodiscard]] bool AreAllArgsImmediates() const; | ||
| 68 | |||
| 69 | /// Gets a pseudo-operation associated with this instruction | ||
| 70 | [[nodiscard]] Inst* GetAssociatedPseudoOperation(IR::Opcode opcode); | ||
| 71 | |||
| 72 | /// Get the type this instruction returns. | ||
| 73 | [[nodiscard]] IR::Type Type() const; | ||
| 74 | |||
| 75 | /// Get the number of arguments this instruction has. | ||
| 76 | [[nodiscard]] size_t NumArgs() const { | ||
| 77 | return op == Opcode::Phi ? phi_args.size() : NumArgsOf(op); | ||
| 78 | } | ||
| 79 | |||
| 80 | /// Get the value of a given argument index. | ||
| 81 | [[nodiscard]] Value Arg(size_t index) const noexcept { | ||
| 82 | if (op == Opcode::Phi) { | ||
| 83 | return phi_args[index].second; | ||
| 84 | } else { | ||
| 85 | return args[index]; | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | /// Set the value of a given argument index. | ||
| 90 | void SetArg(size_t index, Value value); | ||
| 91 | |||
| 92 | /// Get a pointer to the block of a phi argument. | ||
| 93 | [[nodiscard]] Block* PhiBlock(size_t index) const; | ||
| 94 | /// Add phi operand to a phi instruction. | ||
| 95 | void AddPhiOperand(Block* predecessor, const Value& value); | ||
| 96 | |||
| 97 | void Invalidate(); | ||
| 98 | void ClearArgs(); | ||
| 99 | |||
| 100 | void ReplaceUsesWith(Value replacement); | ||
| 101 | |||
| 102 | void ReplaceOpcode(IR::Opcode opcode); | ||
| 103 | |||
| 104 | template <typename FlagsType> | ||
| 105 | requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) | ||
| 106 | [[nodiscard]] FlagsType Flags() const noexcept { | ||
| 107 | FlagsType ret; | ||
| 108 | std::memcpy(reinterpret_cast<char*>(&ret), &flags, sizeof(ret)); | ||
| 109 | return ret; | ||
| 110 | } | ||
| 111 | |||
| 112 | template <typename FlagsType> | ||
| 113 | requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) | ||
| 114 | [[nodiscard]] void SetFlags(FlagsType value) noexcept { | ||
| 115 | std::memcpy(&flags, &value, sizeof(value)); | ||
| 116 | } | ||
| 117 | |||
| 118 | /// Intrusively store the host definition of this instruction. | ||
| 119 | template <typename DefinitionType> | ||
| 120 | void SetDefinition(DefinitionType def) { | ||
| 121 | definition = Common::BitCast<u32>(def); | ||
| 122 | } | ||
| 123 | |||
| 124 | /// Return the intrusively stored host definition of this instruction. | ||
| 125 | template <typename DefinitionType> | ||
| 126 | [[nodiscard]] DefinitionType Definition() const noexcept { | ||
| 127 | return Common::BitCast<DefinitionType>(definition); | ||
| 128 | } | ||
| 129 | |||
| 130 | private: | ||
| 131 | struct NonTriviallyDummy { | ||
| 132 | NonTriviallyDummy() noexcept {} | ||
| 133 | }; | ||
| 134 | |||
| 135 | void Use(const Value& value); | ||
| 136 | void UndoUse(const Value& value); | ||
| 137 | |||
| 138 | IR::Opcode op{}; | ||
| 139 | int use_count{}; | ||
| 140 | u32 flags{}; | ||
| 141 | u32 definition{}; | ||
| 142 | union { | ||
| 143 | NonTriviallyDummy dummy{}; | ||
| 144 | boost::container::small_vector<std::pair<Block*, Value>, 2> phi_args; | ||
| 145 | std::array<Value, 5> args; | ||
| 146 | }; | ||
| 147 | std::unique_ptr<AssociatedInsts> associated_insts; | ||
| 148 | }; | ||
| 149 | static_assert(sizeof(Inst) <= 128, "Inst size unintentionally increased"); | ||
| 150 | |||
| 151 | struct AssociatedInsts { | ||
| 152 | union { | ||
| 153 | Inst* in_bounds_inst; | ||
| 154 | Inst* sparse_inst; | ||
| 155 | Inst* zero_inst{}; | ||
| 156 | }; | ||
| 157 | Inst* sign_inst{}; | ||
| 158 | Inst* carry_inst{}; | ||
| 159 | Inst* overflow_inst{}; | ||
| 160 | }; | ||
| 161 | |||
| 162 | } // namespace Shader::IR | ||
diff --git a/src/shader_recompiler/frontend/ir/program.cpp b/src/shader_recompiler/frontend/ir/program.cpp index 89a17fb1b..3fc06f855 100644 --- a/src/shader_recompiler/frontend/ir/program.cpp +++ b/src/shader_recompiler/frontend/ir/program.cpp | |||
| @@ -8,8 +8,8 @@ | |||
| 8 | #include <fmt/format.h> | 8 | #include <fmt/format.h> |
| 9 | 9 | ||
| 10 | #include "shader_recompiler/frontend/ir/basic_block.h" | 10 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 11 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 12 | #include "shader_recompiler/frontend/ir/program.h" | 11 | #include "shader_recompiler/frontend/ir/program.h" |
| 12 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 13 | 13 | ||
| 14 | namespace Shader::IR { | 14 | namespace Shader::IR { |
| 15 | 15 | ||
diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp index bf5f8c0c2..a8a919e0e 100644 --- a/src/shader_recompiler/frontend/ir/value.cpp +++ b/src/shader_recompiler/frontend/ir/value.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 6 | #include "shader_recompiler/frontend/ir/opcodes.h" | 5 | #include "shader_recompiler/frontend/ir/opcodes.h" |
| 7 | #include "shader_recompiler/frontend/ir/value.h" | 6 | #include "shader_recompiler/frontend/ir/value.h" |
| 8 | 7 | ||
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h index 303745563..d90a68b37 100644 --- a/src/shader_recompiler/frontend/ir/value.h +++ b/src/shader_recompiler/frontend/ir/value.h | |||
| @@ -4,19 +4,34 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <cstring> | ||
| 9 | #include <memory> | ||
| 10 | #include <type_traits> | ||
| 11 | #include <utility> | ||
| 12 | #include <vector> | ||
| 13 | |||
| 14 | #include <boost/container/small_vector.hpp> | ||
| 15 | #include <boost/intrusive/list.hpp> | ||
| 16 | |||
| 17 | #include "common/bit_cast.h" | ||
| 7 | #include "common/common_types.h" | 18 | #include "common/common_types.h" |
| 8 | #include "shader_recompiler/exception.h" | 19 | #include "shader_recompiler/exception.h" |
| 9 | #include "shader_recompiler/frontend/ir/attribute.h" | 20 | #include "shader_recompiler/frontend/ir/attribute.h" |
| 21 | #include "shader_recompiler/frontend/ir/opcodes.h" | ||
| 22 | #include "shader_recompiler/frontend/ir/patch.h" | ||
| 10 | #include "shader_recompiler/frontend/ir/pred.h" | 23 | #include "shader_recompiler/frontend/ir/pred.h" |
| 11 | #include "shader_recompiler/frontend/ir/reg.h" | 24 | #include "shader_recompiler/frontend/ir/reg.h" |
| 12 | #include "shader_recompiler/frontend/ir/patch.h" | ||
| 13 | #include "shader_recompiler/frontend/ir/type.h" | 25 | #include "shader_recompiler/frontend/ir/type.h" |
| 26 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 14 | 27 | ||
| 15 | namespace Shader::IR { | 28 | namespace Shader::IR { |
| 16 | 29 | ||
| 17 | class Block; | 30 | class Block; |
| 18 | class Inst; | 31 | class Inst; |
| 19 | 32 | ||
| 33 | struct AssociatedInsts; | ||
| 34 | |||
| 20 | class Value { | 35 | class Value { |
| 21 | public: | 36 | public: |
| 22 | Value() noexcept : type{IR::Type::Void}, inst{nullptr} {} | 37 | Value() noexcept : type{IR::Type::Void}, inst{nullptr} {} |
| @@ -101,6 +116,140 @@ public: | |||
| 101 | explicit TypedValue(IR::Inst* inst_) : TypedValue(Value(inst_)) {} | 116 | explicit TypedValue(IR::Inst* inst_) : TypedValue(Value(inst_)) {} |
| 102 | }; | 117 | }; |
| 103 | 118 | ||
| 119 | class Inst : public boost::intrusive::list_base_hook<> { | ||
| 120 | public: | ||
| 121 | explicit Inst(IR::Opcode op_, u32 flags_) noexcept; | ||
| 122 | ~Inst(); | ||
| 123 | |||
| 124 | Inst& operator=(const Inst&) = delete; | ||
| 125 | Inst(const Inst&) = delete; | ||
| 126 | |||
| 127 | Inst& operator=(Inst&&) = delete; | ||
| 128 | Inst(Inst&&) = delete; | ||
| 129 | |||
| 130 | /// Get the number of uses this instruction has. | ||
| 131 | [[nodiscard]] int UseCount() const noexcept { | ||
| 132 | return use_count; | ||
| 133 | } | ||
| 134 | |||
| 135 | /// Determines whether this instruction has uses or not. | ||
| 136 | [[nodiscard]] bool HasUses() const noexcept { | ||
| 137 | return use_count > 0; | ||
| 138 | } | ||
| 139 | |||
| 140 | /// Get the opcode this microinstruction represents. | ||
| 141 | [[nodiscard]] IR::Opcode GetOpcode() const noexcept { | ||
| 142 | return op; | ||
| 143 | } | ||
| 144 | |||
| 145 | /// Determines if there is a pseudo-operation associated with this instruction. | ||
| 146 | [[nodiscard]] bool HasAssociatedPseudoOperation() const noexcept { | ||
| 147 | return associated_insts != nullptr; | ||
| 148 | } | ||
| 149 | |||
| 150 | /// Determines whether or not this instruction may have side effects. | ||
| 151 | [[nodiscard]] bool MayHaveSideEffects() const noexcept; | ||
| 152 | |||
| 153 | /// Determines whether or not this instruction is a pseudo-instruction. | ||
| 154 | /// Pseudo-instructions depend on their parent instructions for their semantics. | ||
| 155 | [[nodiscard]] bool IsPseudoInstruction() const noexcept; | ||
| 156 | |||
| 157 | /// Determines if all arguments of this instruction are immediates. | ||
| 158 | [[nodiscard]] bool AreAllArgsImmediates() const; | ||
| 159 | |||
| 160 | /// Gets a pseudo-operation associated with this instruction | ||
| 161 | [[nodiscard]] Inst* GetAssociatedPseudoOperation(IR::Opcode opcode); | ||
| 162 | |||
| 163 | /// Get the type this instruction returns. | ||
| 164 | [[nodiscard]] IR::Type Type() const; | ||
| 165 | |||
| 166 | /// Get the number of arguments this instruction has. | ||
| 167 | [[nodiscard]] size_t NumArgs() const { | ||
| 168 | return op == IR::Opcode::Phi ? phi_args.size() : NumArgsOf(op); | ||
| 169 | } | ||
| 170 | |||
| 171 | /// Get the value of a given argument index. | ||
| 172 | [[nodiscard]] Value Arg(size_t index) const noexcept { | ||
| 173 | if (op == IR::Opcode::Phi) { | ||
| 174 | return phi_args[index].second; | ||
| 175 | } else { | ||
| 176 | return args[index]; | ||
| 177 | } | ||
| 178 | } | ||
| 179 | |||
| 180 | /// Set the value of a given argument index. | ||
| 181 | void SetArg(size_t index, Value value); | ||
| 182 | |||
| 183 | /// Get a pointer to the block of a phi argument. | ||
| 184 | [[nodiscard]] Block* PhiBlock(size_t index) const; | ||
| 185 | /// Add phi operand to a phi instruction. | ||
| 186 | void AddPhiOperand(Block* predecessor, const Value& value); | ||
| 187 | |||
| 188 | void Invalidate(); | ||
| 189 | void ClearArgs(); | ||
| 190 | |||
| 191 | void ReplaceUsesWith(Value replacement); | ||
| 192 | |||
| 193 | void ReplaceOpcode(IR::Opcode opcode); | ||
| 194 | |||
| 195 | template <typename FlagsType> | ||
| 196 | requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) | ||
| 197 | [[nodiscard]] FlagsType Flags() const noexcept { | ||
| 198 | FlagsType ret; | ||
| 199 | std::memcpy(reinterpret_cast<char*>(&ret), &flags, sizeof(ret)); | ||
| 200 | return ret; | ||
| 201 | } | ||
| 202 | |||
| 203 | template <typename FlagsType> | ||
| 204 | requires(sizeof(FlagsType) <= sizeof(u32) && std::is_trivially_copyable_v<FlagsType>) | ||
| 205 | [[nodiscard]] void SetFlags(FlagsType value) noexcept { | ||
| 206 | std::memcpy(&flags, &value, sizeof(value)); | ||
| 207 | } | ||
| 208 | |||
| 209 | /// Intrusively store the host definition of this instruction. | ||
| 210 | template <typename DefinitionType> | ||
| 211 | void SetDefinition(DefinitionType def) { | ||
| 212 | definition = Common::BitCast<u32>(def); | ||
| 213 | } | ||
| 214 | |||
| 215 | /// Return the intrusively stored host definition of this instruction. | ||
| 216 | template <typename DefinitionType> | ||
| 217 | [[nodiscard]] DefinitionType Definition() const noexcept { | ||
| 218 | return Common::BitCast<DefinitionType>(definition); | ||
| 219 | } | ||
| 220 | |||
| 221 | private: | ||
| 222 | struct NonTriviallyDummy { | ||
| 223 | NonTriviallyDummy() noexcept {} | ||
| 224 | }; | ||
| 225 | |||
| 226 | void Use(const Value& value); | ||
| 227 | void UndoUse(const Value& value); | ||
| 228 | |||
| 229 | IR::Opcode op{}; | ||
| 230 | int use_count{}; | ||
| 231 | u32 flags{}; | ||
| 232 | u32 definition{}; | ||
| 233 | union { | ||
| 234 | NonTriviallyDummy dummy{}; | ||
| 235 | boost::container::small_vector<std::pair<Block*, Value>, 2> phi_args; | ||
| 236 | std::array<Value, 5> args; | ||
| 237 | }; | ||
| 238 | std::unique_ptr<AssociatedInsts> associated_insts; | ||
| 239 | }; | ||
| 240 | static_assert(sizeof(Inst) <= 128, "Inst size unintentionally increased"); | ||
| 241 | |||
| 242 | struct AssociatedInsts { | ||
| 243 | union { | ||
| 244 | Inst* in_bounds_inst; | ||
| 245 | Inst* sparse_inst; | ||
| 246 | Inst* zero_inst{}; | ||
| 247 | }; | ||
| 248 | Inst* sign_inst{}; | ||
| 249 | Inst* carry_inst{}; | ||
| 250 | Inst* overflow_inst{}; | ||
| 251 | }; | ||
| 252 | |||
| 104 | using U1 = TypedValue<Type::U1>; | 253 | using U1 = TypedValue<Type::U1>; |
| 105 | using U8 = TypedValue<Type::U8>; | 254 | using U8 = TypedValue<Type::U8>; |
| 106 | using U16 = TypedValue<Type::U16>; | 255 | using U16 = TypedValue<Type::U16>; |
diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.h b/src/shader_recompiler/frontend/maxwell/structured_control_flow.h index e4797291e..a6be12ba2 100644 --- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.h +++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include "shader_recompiler/environment.h" | 12 | #include "shader_recompiler/environment.h" |
| 13 | #include "shader_recompiler/frontend/ir/basic_block.h" | 13 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 14 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 14 | #include "shader_recompiler/frontend/ir/value.h" |
| 15 | #include "shader_recompiler/frontend/maxwell/control_flow.h" | 15 | #include "shader_recompiler/frontend/maxwell/control_flow.h" |
| 16 | #include "shader_recompiler/object_pool.h" | 16 | #include "shader_recompiler/object_pool.h" |
| 17 | 17 | ||
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp index cccf0909d..bb4aeb57c 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "shader_recompiler/environment.h" | 5 | #include "shader_recompiler/environment.h" |
| 6 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 7 | #include "shader_recompiler/frontend/ir/modifiers.h" | 6 | #include "shader_recompiler/frontend/ir/modifiers.h" |
| 8 | #include "shader_recompiler/frontend/ir/program.h" | 7 | #include "shader_recompiler/frontend/ir/program.h" |
| 8 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 9 | #include "shader_recompiler/ir_opt/passes.h" | 9 | #include "shader_recompiler/ir_opt/passes.h" |
| 10 | #include "shader_recompiler/shader_info.h" | 10 | #include "shader_recompiler/shader_info.h" |
| 11 | 11 | ||
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp index 2206f93c2..770d3de61 100644 --- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "common/bit_util.h" | 11 | #include "common/bit_util.h" |
| 12 | #include "shader_recompiler/exception.h" | 12 | #include "shader_recompiler/exception.h" |
| 13 | #include "shader_recompiler/frontend/ir/ir_emitter.h" | 13 | #include "shader_recompiler/frontend/ir/ir_emitter.h" |
| 14 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 14 | #include "shader_recompiler/frontend/ir/value.h" |
| 15 | #include "shader_recompiler/ir_opt/passes.h" | 15 | #include "shader_recompiler/ir_opt/passes.h" |
| 16 | 16 | ||
| 17 | namespace Shader::Optimization { | 17 | namespace Shader::Optimization { |
diff --git a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp index 8ad59f42e..f9c5334b5 100644 --- a/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp +++ b/src/shader_recompiler/ir_opt/dead_code_elimination_pass.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <ranges> | 5 | #include <ranges> |
| 6 | 6 | ||
| 7 | #include "shader_recompiler/frontend/ir/basic_block.h" | 7 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 8 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 8 | #include "shader_recompiler/frontend/ir/value.h" |
| 9 | #include "shader_recompiler/ir_opt/passes.h" | 9 | #include "shader_recompiler/ir_opt/passes.h" |
| 10 | 10 | ||
| 11 | namespace Shader::Optimization { | 11 | namespace Shader::Optimization { |
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index f294d297f..87eca2a0d 100644 --- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | #include "shader_recompiler/frontend/ir/basic_block.h" | 15 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 16 | #include "shader_recompiler/frontend/ir/breadth_first_search.h" | 16 | #include "shader_recompiler/frontend/ir/breadth_first_search.h" |
| 17 | #include "shader_recompiler/frontend/ir/ir_emitter.h" | 17 | #include "shader_recompiler/frontend/ir/ir_emitter.h" |
| 18 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 18 | #include "shader_recompiler/frontend/ir/value.h" |
| 19 | #include "shader_recompiler/ir_opt/passes.h" | 19 | #include "shader_recompiler/ir_opt/passes.h" |
| 20 | 20 | ||
| 21 | namespace Shader::Optimization { | 21 | namespace Shader::Optimization { |
diff --git a/src/shader_recompiler/ir_opt/identity_removal_pass.cpp b/src/shader_recompiler/ir_opt/identity_removal_pass.cpp index 38af72dfe..6afbe24f7 100644 --- a/src/shader_recompiler/ir_opt/identity_removal_pass.cpp +++ b/src/shader_recompiler/ir_opt/identity_removal_pass.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <vector> | 5 | #include <vector> |
| 6 | 6 | ||
| 7 | #include "shader_recompiler/frontend/ir/basic_block.h" | 7 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 8 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 8 | #include "shader_recompiler/frontend/ir/value.h" |
| 9 | #include "shader_recompiler/ir_opt/passes.h" | 9 | #include "shader_recompiler/ir_opt/passes.h" |
| 10 | 10 | ||
| 11 | namespace Shader::Optimization { | 11 | namespace Shader::Optimization { |
diff --git a/src/shader_recompiler/ir_opt/lower_fp16_to_fp32.cpp b/src/shader_recompiler/ir_opt/lower_fp16_to_fp32.cpp index 62e73d52d..773e1f961 100644 --- a/src/shader_recompiler/ir_opt/lower_fp16_to_fp32.cpp +++ b/src/shader_recompiler/ir_opt/lower_fp16_to_fp32.cpp | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | 6 | ||
| 7 | #include "shader_recompiler/frontend/ir/ir_emitter.h" | 7 | #include "shader_recompiler/frontend/ir/ir_emitter.h" |
| 8 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 8 | #include "shader_recompiler/frontend/ir/value.h" |
| 9 | #include "shader_recompiler/ir_opt/passes.h" | 9 | #include "shader_recompiler/ir_opt/passes.h" |
| 10 | 10 | ||
| 11 | namespace Shader::Optimization { | 11 | namespace Shader::Optimization { |
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index bb1a90004..fe86a164b 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |||
| @@ -23,10 +23,10 @@ | |||
| 23 | #include <boost/container/flat_set.hpp> | 23 | #include <boost/container/flat_set.hpp> |
| 24 | 24 | ||
| 25 | #include "shader_recompiler/frontend/ir/basic_block.h" | 25 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 26 | #include "shader_recompiler/frontend/ir/microinstruction.h" | ||
| 27 | #include "shader_recompiler/frontend/ir/opcodes.h" | 26 | #include "shader_recompiler/frontend/ir/opcodes.h" |
| 28 | #include "shader_recompiler/frontend/ir/pred.h" | 27 | #include "shader_recompiler/frontend/ir/pred.h" |
| 29 | #include "shader_recompiler/frontend/ir/reg.h" | 28 | #include "shader_recompiler/frontend/ir/reg.h" |
| 29 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 30 | #include "shader_recompiler/ir_opt/passes.h" | 30 | #include "shader_recompiler/ir_opt/passes.h" |
| 31 | 31 | ||
| 32 | namespace Shader::Optimization { | 32 | namespace Shader::Optimization { |
diff --git a/src/shader_recompiler/ir_opt/verification_pass.cpp b/src/shader_recompiler/ir_opt/verification_pass.cpp index dbec96d84..62bf5f8ff 100644 --- a/src/shader_recompiler/ir_opt/verification_pass.cpp +++ b/src/shader_recompiler/ir_opt/verification_pass.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "shader_recompiler/exception.h" | 7 | #include "shader_recompiler/exception.h" |
| 8 | #include "shader_recompiler/frontend/ir/basic_block.h" | 8 | #include "shader_recompiler/frontend/ir/basic_block.h" |
| 9 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 9 | #include "shader_recompiler/frontend/ir/value.h" |
| 10 | #include "shader_recompiler/ir_opt/passes.h" | 10 | #include "shader_recompiler/ir_opt/passes.h" |
| 11 | 11 | ||
| 12 | namespace Shader::Optimization { | 12 | namespace Shader::Optimization { |