X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Ftv.c;h=36487127c25ae2adf56806deea25ba7875e790f1;hb=6571b31236f780199ba476adc33ee23518200497;hp=269b3e2e252a34577e386a81a333cbf305950397;hpb=e84184056559e90f2dffc7f7648f40705864e088;p=libfirm diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 269b3e2e2..36487127c 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -24,7 +24,7 @@ * @date 2003 * @author Mathias Heil * @version $Id$ - * @summary + * @brief * * Values are stored in a format depending upon chosen arithmetic * module. Default uses strcalc and fltcalc. @@ -33,21 +33,19 @@ */ #include "config.h" -#include /* assertions */ -#include /* atoi() */ -#ifdef HAVE_STRING_H -# include /* nice things for strings */ -#endif +#include +#include +#include #ifdef HAVE_STRINGS_H -#include /* strings.h also includes bsd only function strcasecmp */ +#include #endif #include #include "tv_t.h" -#include "set.h" /* to store tarvals in */ -#include "entity_t.h" /* needed to store pointers to entities */ +#include "set.h" +#include "entity_t.h" #include "irmode_t.h" -#include "irnode.h" /* defines boolean return values (pnc_number)*/ +#include "irnode.h" #include "strcalc.h" #include "fltcalc.h" #include "irtools.h" @@ -337,10 +335,10 @@ tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode) case irms_internal_boolean: /* match [tT][rR][uU][eE]|[fF][aA][lL][sS][eE] */ - if (strcasecmp(str, "true")) - return tarval_b_true; - else if (strcasecmp(str, "false")) + if (!strcasecmp(str, "true")) return tarval_b_true; + else if (!strcasecmp(str, "false")) + return tarval_b_false; else /* XXX This is C semantics */ return atoi(str) ? tarval_b_true : tarval_b_false; @@ -351,7 +349,9 @@ tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode) return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode); case irms_reference: - /* same as integer modes */ + if (!strcasecmp(str, "null")) + return get_tarval_null(mode); + /* FALLTHROUGH */ case irms_int_number: sc_val_from_str(str, len, NULL, mode); return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode); @@ -1439,7 +1439,7 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv) { switch (get_mode_sort(tv->mode)) { case irms_reference: if (tv == tv->mode->null) return snprintf(buf, len, "NULL"); - /* fall through */ + /* FALLTHROUGH */ case irms_int_number: switch (mode_info->mode_output) { @@ -1451,8 +1451,9 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv) { str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT, 0); break; - case TVO_HEX: case TVO_NATIVE: + prefix = "0x"; + case TVO_HEX: default: str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX, 0); break; @@ -1688,11 +1689,12 @@ tarval_int_overflow_mode_t tarval_get_integer_overflow_mode(void) { } /* Enable/Disable floating point constant folding. */ -int tarval_enable_fp_ops(int enable) { - int old = !no_float; - +void tarval_enable_fp_ops(int enable) { no_float = !enable; - return old; +} + +int tarval_fp_ops_enabled(void) { + return !no_float; } /**