ir/value: Add IsSignedImmediate() and IsUnsignedImmediate() functions to Value's interface

This allows testing against arbitrary values while also simultaneously
eliminating the need to check IsImmediate() all the time in expressions.
This commit is contained in:
Lioncash
2018-10-04 05:18:22 -04:00
committed by MerryMage
parent e3258e8525
commit 0583d401e3
2 changed files with 31 additions and 1 deletions

View File

@@ -194,6 +194,14 @@ u64 Value::GetImmediateAsU64() const {
}
}
bool Value::IsSignedImmediate(s64 value) const {
return IsImmediate() && GetImmediateAsS64() == value;
}
bool Value::IsUnsignedImmediate(u64 value) const {
return IsImmediate() && GetImmediateAsU64() == value;
}
bool Value::HasAllBitsSet() const {
ASSERT(IsImmediate());
@@ -215,7 +223,7 @@ bool Value::HasAllBitsSet() const {
}
bool Value::IsZero() const {
return IsImmediate() && GetImmediateAsU64() == 0;
return IsUnsignedImmediate(0);
}
} // namespace Dynarmic::IR