mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-04 13:44:31 +01:00
ir/value: Add an IsZero() member function to Value's interface
By far, one of the most common things to check for is whether or not a value is zero, as it typically allows folding away unnecesary operations (other close contenders that can help with eliding operations are 1 and -1). So instead of requiring a check for an immediate and then actually retrieving the integral value and checking it, we can wrap it within a function to make it more convenient.
This commit is contained in:
parent
783fc707fa
commit
4a3c064b15
3 changed files with 20 additions and 13 deletions
|
|
@ -194,4 +194,8 @@ bool Value::HasAllBitsSet() const {
|
|||
}
|
||||
}
|
||||
|
||||
bool Value::IsZero() const {
|
||||
return IsImmediate() && GetImmediateAsU64() == 0;
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::IR
|
||||
|
|
|
|||
|
|
@ -82,6 +82,15 @@ public:
|
|||
*/
|
||||
bool HasAllBitsSet() const;
|
||||
|
||||
/**
|
||||
* Whether or not the current value contains a representation of zero.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
bool IsZero() const;
|
||||
|
||||
private:
|
||||
Type type;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue