From 806ff40754652772d7a4ec137a234935d8c676e7 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 24 Jul 2008 12:27:11 +0000 Subject: [PATCH] - is_tarval() added [r20664] --- include/libfirm/tv.h | 10 ++++++++++ ir/tv/tv.c | 4 ++++ ir/tv/tv_t.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/include/libfirm/tv.h b/include/libfirm/tv.h index 4538e392d..70f96543a 100644 --- a/include/libfirm/tv.h +++ b/include/libfirm/tv.h @@ -686,4 +686,14 @@ int tarval_is_minus_inf(tarval *tv); */ int tarval_is_finite(tarval *tv); +/** + * Checks whether a pointer points to a tarval. + * + * @param thing an arbitrary pointer + * + * @return + * true if the thing is a tarval, else false + */ +int is_tarval(const void *thing); + #endif /* FIRM_TV_TV_H */ diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 1afb4a5a8..127ce68c7 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -1836,6 +1836,10 @@ void finish_tarval(void) { del_set(values); values = NULL; } +int (is_tarval)(const void *thing) { + return _is_tarval(thing); +} + /**************************************************************************** * end of tv.c ****************************************************************************/ diff --git a/ir/tv/tv_t.h b/ir/tv/tv_t.h index 86b2cf476..77503fdb3 100644 --- a/ir/tv/tv_t.h +++ b/ir/tv/tv_t.h @@ -29,6 +29,7 @@ #define FIRM_TV_TV_T_H #include "firm_config.h" +#include "firm_common.h" #include #include "irmode.h" @@ -113,11 +114,17 @@ _get_tarval_b_true(void) { return tarval_b_true; } +static INLINE int +_is_tarval(const void *thing) { + return get_kind(thing) == k_tarval; +} + #define get_tarval_mode(tv) _get_tarval_mode(tv) #define get_tarval_bad() _get_tarval_bad() #define get_tarval_undefined() _get_tarval_undefined() #define get_tarval_b_false() _get_tarval_b_false() #define get_tarval_b_true() _get_tarval_b_true() #define get_tarval_P_void() _get_tarval_P_void() +#define is_tarval(thing) _is_tarval(thing) #endif /* FIRM_TV_TV_T_H */ -- 2.20.1