diff options
Diffstat (limited to 'src/shader_recompiler/frontend')
6 files changed, 27 insertions, 13 deletions
diff --git a/src/shader_recompiler/frontend/ir/basic_block.cpp b/src/shader_recompiler/frontend/ir/basic_block.cpp index c97626712..5ae91dd7d 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.cpp +++ b/src/shader_recompiler/frontend/ir/basic_block.cpp | |||
| @@ -26,7 +26,7 @@ void Block::AppendNewInst(Opcode op, std::initializer_list<Value> args) { | |||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | Block::iterator Block::PrependNewInst(iterator insertion_point, Opcode op, | 28 | Block::iterator Block::PrependNewInst(iterator insertion_point, Opcode op, |
| 29 | std::initializer_list<Value> args, u64 flags) { | 29 | std::initializer_list<Value> args, u32 flags) { |
| 30 | Inst* const inst{inst_pool->Create(op, flags)}; | 30 | Inst* const inst{inst_pool->Create(op, flags)}; |
| 31 | const auto result_it{instructions.insert(insertion_point, *inst)}; | 31 | const auto result_it{instructions.insert(insertion_point, *inst)}; |
| 32 | 32 | ||
diff --git a/src/shader_recompiler/frontend/ir/basic_block.h b/src/shader_recompiler/frontend/ir/basic_block.h index 3205705e7..778b32e43 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.h +++ b/src/shader_recompiler/frontend/ir/basic_block.h | |||
| @@ -42,7 +42,7 @@ public: | |||
| 42 | 42 | ||
| 43 | /// Prepends a new instruction to this basic block before the insertion point. | 43 | /// Prepends a new instruction to this basic block before the insertion point. |
| 44 | iterator PrependNewInst(iterator insertion_point, Opcode op, | 44 | iterator PrependNewInst(iterator insertion_point, Opcode op, |
| 45 | std::initializer_list<Value> args = {}, u64 flags = 0); | 45 | std::initializer_list<Value> args = {}, u32 flags = 0); |
| 46 | 46 | ||
| 47 | /// Set the branches to jump to when all instructions have executed. | 47 | /// Set the branches to jump to when all instructions have executed. |
| 48 | void SetBranches(Condition cond, Block* branch_true, Block* branch_false); | 48 | void SetBranches(Condition cond, Block* branch_true, Block* branch_false); |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 4decb46bc..24b012a39 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -178,7 +178,7 @@ private: | |||
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | template <typename T> | 180 | template <typename T> |
| 181 | requires(sizeof(T) <= sizeof(u64) && std::is_trivially_copyable_v<T>) struct Flags { | 181 | requires(sizeof(T) <= sizeof(u32) && std::is_trivially_copyable_v<T>) struct Flags { |
| 182 | Flags() = default; | 182 | Flags() = default; |
| 183 | Flags(T proxy_) : proxy{proxy_} {} | 183 | Flags(T proxy_) : proxy{proxy_} {} |
| 184 | 184 | ||
| @@ -187,7 +187,7 @@ private: | |||
| 187 | 187 | ||
| 188 | template <typename T = Value, typename FlagType, typename... Args> | 188 | template <typename T = Value, typename FlagType, typename... Args> |
| 189 | T Inst(Opcode op, Flags<FlagType> flags, Args... args) { | 189 | T Inst(Opcode op, Flags<FlagType> flags, Args... args) { |
| 190 | u64 raw_flags{}; | 190 | u32 raw_flags{}; |
| 191 | std::memcpy(&raw_flags, &flags.proxy, sizeof(flags.proxy)); | 191 | std::memcpy(&raw_flags, &flags.proxy, sizeof(flags.proxy)); |
| 192 | auto it{block->PrependNewInst(insertion_point, op, {Value{args}...}, raw_flags)}; | 192 | auto it{block->PrependNewInst(insertion_point, op, {Value{args}...}, raw_flags)}; |
| 193 | return T{Value{&*it}}; | 193 | return T{Value{&*it}}; |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index 9279b9692..ee76db9ad 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -31,7 +31,7 @@ static void RemovePseudoInstruction(IR::Inst*& inst, IR::Opcode expected_opcode) | |||
| 31 | inst = nullptr; | 31 | inst = nullptr; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | Inst::Inst(IR::Opcode op_, u64 flags_) noexcept : op{op_}, flags{flags_} { | 34 | Inst::Inst(IR::Opcode op_, u32 flags_) noexcept : op{op_}, flags{flags_} { |
| 35 | if (op == Opcode::Phi) { | 35 | if (op == Opcode::Phi) { |
| 36 | std::construct_at(&phi_args); | 36 | std::construct_at(&phi_args); |
| 37 | } else { | 37 | } else { |
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 | ||
| 26 | class Inst : public boost::intrusive::list_base_hook<> { | 27 | class Inst : public boost::intrusive::list_base_hook<> { |
| 27 | public: | 28 | public: |
| 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 | |||
| 96 | private: | 109 | private: |
| 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; |
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.h index 28bb9e798..c288eede0 100644 --- a/src/shader_recompiler/frontend/ir/modifiers.h +++ b/src/shader_recompiler/frontend/ir/modifiers.h | |||
| @@ -6,13 +6,13 @@ | |||
| 6 | 6 | ||
| 7 | namespace Shader::IR { | 7 | namespace Shader::IR { |
| 8 | 8 | ||
| 9 | enum class FmzMode { | 9 | enum class FmzMode : u8 { |
| 10 | None, // Denorms are not flushed, NAN is propagated (nouveau) | 10 | None, // Denorms are not flushed, NAN is propagated (nouveau) |
| 11 | FTZ, // Flush denorms to zero, NAN is propagated (D3D11, NVN, GL, VK) | 11 | FTZ, // Flush denorms to zero, NAN is propagated (D3D11, NVN, GL, VK) |
| 12 | FMZ, // Flush denorms to zero, x * 0 == 0 (D3D9) | 12 | FMZ, // Flush denorms to zero, x * 0 == 0 (D3D9) |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | enum class FpRounding { | 15 | enum class FpRounding : u8 { |
| 16 | RN, // Round to nearest even, | 16 | RN, // Round to nearest even, |
| 17 | RM, // Round towards negative infinity | 17 | RM, // Round towards negative infinity |
| 18 | RP, // Round towards positive infinity | 18 | RP, // Round towards positive infinity |
| @@ -21,8 +21,8 @@ enum class FpRounding { | |||
| 21 | 21 | ||
| 22 | struct FpControl { | 22 | struct FpControl { |
| 23 | bool no_contraction{false}; | 23 | bool no_contraction{false}; |
| 24 | FpRounding rounding : 8 = FpRounding::RN; | 24 | FpRounding rounding{FpRounding::RN}; |
| 25 | FmzMode fmz_mode : 8 = FmzMode::FTZ; | 25 | FmzMode fmz_mode{FmzMode::FTZ}; |
| 26 | }; | 26 | }; |
| 27 | static_assert(sizeof(FpControl) <= sizeof(u64)); | 27 | static_assert(sizeof(FpControl) <= sizeof(u32)); |
| 28 | } // namespace Shader::IR | 28 | } // namespace Shader::IR |