diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-05-30 05:53:31 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-17 18:21:21 +0100 |
| commit | 4a036fd55cb47e88119c792018904511401ddd79 (patch) | |
| tree | 7950b12c5f3a6cb4ac0ab9237187f2c9bc51f5b5 /linearize.h | |
| parent | 0e49c8b5a06e95b10b6e3986535325edf319fbb5 (diff) | |
| download | sparse-dev-4a036fd55cb47e88119c792018904511401ddd79.tar.gz | |
add an helper to test the value of a pseudo against zero
Testing the value of a pseudo against zero is relatively
common but it needs to test the type of the pseudo before
testing the value itself.
Add 2 small helpers for this: is_zero() & is_nonzero().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'linearize.h')
| -rw-r--r-- | linearize.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/linearize.h b/linearize.h index 79c0c09b..74114107 100644 --- a/linearize.h +++ b/linearize.h @@ -45,6 +45,17 @@ extern struct pseudo void_pseudo; #define VOID (&void_pseudo) +static inline bool is_zero(pseudo_t pseudo) +{ + return pseudo->type == PSEUDO_VAL && pseudo->value == 0; +} + +static inline bool is_nonzero(pseudo_t pseudo) +{ + return pseudo->type == PSEUDO_VAL && pseudo->value != 0; +} + + struct multijmp { struct basic_block *target; long long begin, end; |
