diff options
| author | 2021-01-09 03:30:07 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:21 -0400 | |
| commit | 2d48a7b4d0666ad16d03a22d85712617a0849046 (patch) | |
| tree | dd1069afca86f66e77e3438da77421a43adf5091 /src/shader_recompiler/frontend/maxwell/instruction.h | |
| parent | thread_worker: Fix compile time error (diff) | |
| download | yuzu-2d48a7b4d0666ad16d03a22d85712617a0849046.tar.gz yuzu-2d48a7b4d0666ad16d03a22d85712617a0849046.tar.xz yuzu-2d48a7b4d0666ad16d03a22d85712617a0849046.zip | |
shader: Initial recompiler work
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/instruction.h')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/instruction.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/instruction.h b/src/shader_recompiler/frontend/maxwell/instruction.h new file mode 100644 index 000000000..57fd531f2 --- /dev/null +++ b/src/shader_recompiler/frontend/maxwell/instruction.h | |||
| @@ -0,0 +1,62 @@ | |||
| 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 "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "shader_recompiler/frontend/ir/flow_test.h" | ||
| 10 | |||
| 11 | namespace Shader::Maxwell { | ||
| 12 | |||
| 13 | struct Predicate { | ||
| 14 | Predicate() = default; | ||
| 15 | Predicate(unsigned index_, bool negated_ = false) : index{index_}, negated{negated_} {} | ||
| 16 | Predicate(bool value) : index{7}, negated{!value} {} | ||
| 17 | Predicate(u64 raw) : index{static_cast<unsigned>(raw & 7)}, negated{(raw & 8) != 0} {} | ||
| 18 | |||
| 19 | unsigned index; | ||
| 20 | bool negated; | ||
| 21 | }; | ||
| 22 | |||
| 23 | inline bool operator==(const Predicate& lhs, const Predicate& rhs) noexcept { | ||
| 24 | return lhs.index == rhs.index && lhs.negated == rhs.negated; | ||
| 25 | } | ||
| 26 | |||
| 27 | inline bool operator!=(const Predicate& lhs, const Predicate& rhs) noexcept { | ||
| 28 | return !(lhs == rhs); | ||
| 29 | } | ||
| 30 | |||
| 31 | union Instruction { | ||
| 32 | Instruction(u64 raw_) : raw{raw_} {} | ||
| 33 | |||
| 34 | u64 raw; | ||
| 35 | |||
| 36 | union { | ||
| 37 | BitField<5, 1, u64> is_cbuf; | ||
| 38 | BitField<0, 5, IR::FlowTest> flow_test; | ||
| 39 | |||
| 40 | [[nodiscard]] u32 Absolute() const noexcept { | ||
| 41 | return static_cast<u32>(absolute); | ||
| 42 | } | ||
| 43 | |||
| 44 | [[nodiscard]] s32 Offset() const noexcept { | ||
| 45 | return static_cast<s32>(offset); | ||
| 46 | } | ||
| 47 | |||
| 48 | private: | ||
| 49 | BitField<20, 24, s64> offset; | ||
| 50 | BitField<20, 32, u64> absolute; | ||
| 51 | } branch; | ||
| 52 | |||
| 53 | [[nodiscard]] Predicate Pred() const noexcept { | ||
| 54 | return Predicate{pred}; | ||
| 55 | } | ||
| 56 | |||
| 57 | private: | ||
| 58 | BitField<16, 4, u64> pred; | ||
| 59 | }; | ||
| 60 | static_assert(std::is_trivially_copyable_v<Instruction>); | ||
| 61 | |||
| 62 | } // namespace Shader::Maxwell | ||