diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-09 02:30:40 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-04-18 17:21:37 +0200 |
commit | 28cd6d609ea460c6138f8cd17f89fc9885fb7dc2 (patch) | |
tree | f61fcccb21475bb526aded4eb391a6471aa5ba74 | |
parent | 7ae82c3a41c71c977e409dd20679bc4aec19961c (diff) | |
download | sparse-28cd6d609ea460c6138f8cd17f89fc9885fb7dc2.tar.gz |
add helper is_positive()
Add a small helper to test if a pseudo is a positive (= non-negative)
constant (for a given bitsize).
It's meant to make some conditions more readable.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | linearize.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/linearize.h b/linearize.h index 7909b01f..65f54c28 100644 --- a/linearize.h +++ b/linearize.h @@ -58,6 +58,11 @@ static inline bool is_nonzero(pseudo_t pseudo) return pseudo->type == PSEUDO_VAL && pseudo->value != 0; } +static inline bool is_positive(pseudo_t pseudo, unsigned size) +{ + return pseudo->type == PSEUDO_VAL && !(pseudo->value & sign_bit(size)); +} + struct multijmp { struct basic_block *target; |