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:
parent
01aa5096bf
commit
8f262d485a
@ -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
|
||||
|
@ -82,6 +82,28 @@ public:
|
||||
*/
|
||||
u64 GetImmediateAsU64() const;
|
||||
|
||||
/**
|
||||
* Determines whether or not the contained value matches the provided signed one.
|
||||
*
|
||||
* Note that this function will always return false if the contained
|
||||
* value is not a a constant value. In other words, if IsImmediate()
|
||||
* would return false on an instance, then so will this function.
|
||||
*
|
||||
* @param value The value to check against the contained value.
|
||||
*/
|
||||
bool IsSignedImmediate(s64 value) const;
|
||||
|
||||
/**
|
||||
* Determines whether or not the contained value matches the provided unsigned one.
|
||||
*
|
||||
* Note that this function will always return false if the contained
|
||||
* value is not a a constant value. In other words, if IsImmediate()
|
||||
* would return false on an instance, then so will this function.
|
||||
*
|
||||
* @param value The value to check against the contained value.
|
||||
*/
|
||||
bool IsUnsignedImmediate(u64 value) const;
|
||||
|
||||
/**
|
||||
* Determines whether or not the contained constant value has all bits set.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user