diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-04-21 02:42:36 -0300 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-22 21:51:28 -0400 |
commit | c84bbd9e44e34bba0e602c1a6736535aa531445c (patch) | |
tree | 6e1a97dd556fe51d70c5acc18b7258655430e131 /src/shader_recompiler/frontend/ir/value.h | |
parent | 050e81500c002f304d581f28700de549b828a2bc (diff) |
shader: Inline common Value functions into the header
Diffstat (limited to 'src/shader_recompiler/frontend/ir/value.h')
-rw-r--r-- | src/shader_recompiler/frontend/ir/value.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h index d90a68b377..5425e42a1e 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>; using F16F32F64 = TypedValue<Type::F16 | Type::F32 | Type::F64>; using UAny = TypedValue<Type::U8 | Type::U16 | Type::U32 | Type::U64>; +inline bool Value::IsIdentity() const noexcept { + return type == Type::Opaque && inst->GetOpcode() == Opcode::Identity; +} + +inline bool Value::IsPhi() const noexcept { + return type == Type::Opaque && inst->GetOpcode() == Opcode::Phi; +} + +inline bool Value::IsEmpty() const noexcept { + return type == Type::Void; +} + +inline bool Value::IsImmediate() const noexcept { + IR::Type current_type{type}; + const IR::Inst* current_inst{inst}; + while (current_type == Type::Opaque && current_inst->GetOpcode() == Opcode::Identity) { + const Value& arg{current_inst->Arg(0)}; + current_type = arg.type; + current_inst = arg.inst; + } + return current_type != Type::Opaque; +} + } // namespace Shader::IR |