diff options
| author | 2021-02-05 19:19:36 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:21 -0400 | |
| commit | be94ee88d227d0d3dbeabe9ade98bacd910c7a7e (patch) | |
| tree | 68a2043d48b8d1ecb7df23d03c1f92f277c70f9a /src/shader_recompiler/frontend/ir/value.cpp | |
| parent | shader: Remove illegal character in SSA pass (diff) | |
| download | yuzu-be94ee88d227d0d3dbeabe9ade98bacd910c7a7e.tar.gz yuzu-be94ee88d227d0d3dbeabe9ade98bacd910c7a7e.tar.xz yuzu-be94ee88d227d0d3dbeabe9ade98bacd910c7a7e.zip | |
shader: Make typed IR
Diffstat (limited to 'src/shader_recompiler/frontend/ir/value.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp index 59a9b10dc..93ff8ccf1 100644 --- a/src/shader_recompiler/frontend/ir/value.cpp +++ b/src/shader_recompiler/frontend/ir/value.cpp | |||
| @@ -26,8 +26,12 @@ Value::Value(u16 value) noexcept : type{Type::U16}, imm_u16{value} {} | |||
| 26 | 26 | ||
| 27 | Value::Value(u32 value) noexcept : type{Type::U32}, imm_u32{value} {} | 27 | Value::Value(u32 value) noexcept : type{Type::U32}, imm_u32{value} {} |
| 28 | 28 | ||
| 29 | Value::Value(f32 value) noexcept : type{Type::F32}, imm_f32{value} {} | ||
| 30 | |||
| 29 | Value::Value(u64 value) noexcept : type{Type::U64}, imm_u64{value} {} | 31 | Value::Value(u64 value) noexcept : type{Type::U64}, imm_u64{value} {} |
| 30 | 32 | ||
| 33 | Value::Value(f64 value) noexcept : type{Type::F64}, imm_f64{value} {} | ||
| 34 | |||
| 31 | bool Value::IsIdentity() const noexcept { | 35 | bool Value::IsIdentity() const noexcept { |
| 32 | return type == Type::Opaque && inst->Opcode() == Opcode::Identity; | 36 | return type == Type::Opaque && inst->Opcode() == Opcode::Identity; |
| 33 | } | 37 | } |
| @@ -122,6 +126,14 @@ u32 Value::U32() const { | |||
| 122 | return imm_u32; | 126 | return imm_u32; |
| 123 | } | 127 | } |
| 124 | 128 | ||
| 129 | f32 Value::F32() const { | ||
| 130 | if (IsIdentity()) { | ||
| 131 | return inst->Arg(0).F32(); | ||
| 132 | } | ||
| 133 | ValidateAccess(Type::F32); | ||
| 134 | return imm_f32; | ||
| 135 | } | ||
| 136 | |||
| 125 | u64 Value::U64() const { | 137 | u64 Value::U64() const { |
| 126 | if (IsIdentity()) { | 138 | if (IsIdentity()) { |
| 127 | return inst->Arg(0).U64(); | 139 | return inst->Arg(0).U64(); |
| @@ -152,11 +164,27 @@ bool Value::operator==(const Value& other) const { | |||
| 152 | case Type::U8: | 164 | case Type::U8: |
| 153 | return imm_u8 == other.imm_u8; | 165 | return imm_u8 == other.imm_u8; |
| 154 | case Type::U16: | 166 | case Type::U16: |
| 167 | case Type::F16: | ||
| 155 | return imm_u16 == other.imm_u16; | 168 | return imm_u16 == other.imm_u16; |
| 156 | case Type::U32: | 169 | case Type::U32: |
| 170 | case Type::F32: | ||
| 157 | return imm_u32 == other.imm_u32; | 171 | return imm_u32 == other.imm_u32; |
| 158 | case Type::U64: | 172 | case Type::U64: |
| 173 | case Type::F64: | ||
| 159 | return imm_u64 == other.imm_u64; | 174 | return imm_u64 == other.imm_u64; |
| 175 | case Type::U32x2: | ||
| 176 | case Type::U32x3: | ||
| 177 | case Type::U32x4: | ||
| 178 | case Type::F16x2: | ||
| 179 | case Type::F16x3: | ||
| 180 | case Type::F16x4: | ||
| 181 | case Type::F32x2: | ||
| 182 | case Type::F32x3: | ||
| 183 | case Type::F32x4: | ||
| 184 | case Type::F64x2: | ||
| 185 | case Type::F64x3: | ||
| 186 | case Type::F64x4: | ||
| 187 | break; | ||
| 160 | } | 188 | } |
| 161 | throw LogicError("Invalid type {}", type); | 189 | throw LogicError("Invalid type {}", type); |
| 162 | } | 190 | } |