diff options
| author | 2021-04-21 02:42:36 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:28 -0400 | |
| commit | c84bbd9e44e34bba0e602c1a6736535aa531445c (patch) | |
| tree | 6e1a97dd556fe51d70c5acc18b7258655430e131 /src/shader_recompiler/frontend/ir | |
| parent | shader: Move microinstruction header to the value header (diff) | |
| download | yuzu-c84bbd9e44e34bba0e602c1a6736535aa531445c.tar.gz yuzu-c84bbd9e44e34bba0e602c1a6736535aa531445c.tar.xz yuzu-c84bbd9e44e34bba0e602c1a6736535aa531445c.zip | |
shader: Inline common Value functions into the header
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.cpp | 19 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/value.h | 23 |
2 files changed, 23 insertions, 19 deletions
diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp index a8a919e0e..c021d3fa9 100644 --- a/src/shader_recompiler/frontend/ir/value.cpp +++ b/src/shader_recompiler/frontend/ir/value.cpp | |||
| @@ -33,25 +33,6 @@ Value::Value(u64 value) noexcept : type{Type::U64}, imm_u64{value} {} | |||
| 33 | 33 | ||
| 34 | Value::Value(f64 value) noexcept : type{Type::F64}, imm_f64{value} {} | 34 | Value::Value(f64 value) noexcept : type{Type::F64}, imm_f64{value} {} |
| 35 | 35 | ||
| 36 | bool Value::IsIdentity() const noexcept { | ||
| 37 | return type == Type::Opaque && inst->GetOpcode() == Opcode::Identity; | ||
| 38 | } | ||
| 39 | |||
| 40 | bool Value::IsPhi() const noexcept { | ||
| 41 | return type == Type::Opaque && inst->GetOpcode() == Opcode::Phi; | ||
| 42 | } | ||
| 43 | |||
| 44 | bool Value::IsEmpty() const noexcept { | ||
| 45 | return type == Type::Void; | ||
| 46 | } | ||
| 47 | |||
| 48 | bool Value::IsImmediate() const noexcept { | ||
| 49 | if (IsIdentity()) { | ||
| 50 | return inst->Arg(0).IsImmediate(); | ||
| 51 | } | ||
| 52 | return type != Type::Opaque; | ||
| 53 | } | ||
| 54 | |||
| 55 | bool Value::IsLabel() const noexcept { | 36 | bool Value::IsLabel() const noexcept { |
| 56 | return type == Type::Label; | 37 | return type == Type::Label; |
| 57 | } | 38 | } |
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h index d90a68b37..5425e42a1 100644 --- a/src/shader_recompiler/frontend/ir/value.h +++ b/src/shader_recompiler/frontend/ir/value.h | |||
| @@ -264,4 +264,27 @@ using U16U32U64 = TypedValue<Type::U16 | Type::U32 | Type::U64>; | |||
| 264 | using F16F32F64 = TypedValue<Type::F16 | Type::F32 | Type::F64>; | 264 | using F16F32F64 = TypedValue<Type::F16 | Type::F32 | Type::F64>; |
| 265 | using UAny = TypedValue<Type::U8 | Type::U16 | Type::U32 | Type::U64>; | 265 | using UAny = TypedValue<Type::U8 | Type::U16 | Type::U32 | Type::U64>; |
| 266 | 266 | ||
| 267 | inline bool Value::IsIdentity() const noexcept { | ||
| 268 | return type == Type::Opaque && inst->GetOpcode() == Opcode::Identity; | ||
| 269 | } | ||
| 270 | |||
| 271 | inline bool Value::IsPhi() const noexcept { | ||
| 272 | return type == Type::Opaque && inst->GetOpcode() == Opcode::Phi; | ||
| 273 | } | ||
| 274 | |||
| 275 | inline bool Value::IsEmpty() const noexcept { | ||
| 276 | return type == Type::Void; | ||
| 277 | } | ||
| 278 | |||
| 279 | inline bool Value::IsImmediate() const noexcept { | ||
| 280 | IR::Type current_type{type}; | ||
| 281 | const IR::Inst* current_inst{inst}; | ||
| 282 | while (current_type == Type::Opaque && current_inst->GetOpcode() == Opcode::Identity) { | ||
| 283 | const Value& arg{current_inst->Arg(0)}; | ||
| 284 | current_type = arg.type; | ||
| 285 | current_inst = arg.inst; | ||
| 286 | } | ||
| 287 | return current_type != Type::Opaque; | ||
| 288 | } | ||
| 289 | |||
| 267 | } // namespace Shader::IR | 290 | } // namespace Shader::IR |