From 4b57a396e1728067d6f023d87c73c28d9f1423de Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Fri, 26 Apr 2002 12:15:43 +0000 Subject: [PATCH] Added new constructor. [r385] --- ir/tv/tv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ir/tv/tv.c b/ir/tv/tv.c index d5bcd9b3d..b5e03d18e 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -35,6 +35,7 @@ # include "xprintf.h" #include #include +#include #include #include #include @@ -609,6 +610,28 @@ tarval_S_from_str (const char *s, size_t len) return tarval_identify (tv); } +tarval *tarval_int_from_str (const char *s, size_t len, int base, ir_mode *m) { + long val; + char *eptr; + char *buf; + + assert (mode_is_int(m)); + assert (!BUILDING); + + buf = alloca (len+1); + stripcpy (buf, s, len); + + errno = 0; + val = strtol(buf, &eptr, base); /* strtoll */ + assert (eptr == buf+strlen(buf)); + if ((errno == ERANGE) && + ((m == mode_l) || (m == mode_L)) ) { + printf("WARNING: Constant %s not representable. Continuing with %ld.\n", + s, val); + } + + return tarval_from_long(m, val); +} /* Create a tarval with mode `m' and value `i' casted to the type that represents such tarvals on host. The resulting value must be legal -- 2.20.1