- get_entity_nr() now takes an cont entity
[libfirm] / ir / tv / tv.c
index 9ccdbad..21dab02 100644 (file)
@@ -98,8 +98,8 @@ static long long count = 0;
 /****************************************************************************
  *   private variables
  ****************************************************************************/
-static struct set *tarvals;   /* container for tarval structs */
-static struct set *values;    /* container for values */
+static struct set *tarvals = NULL;   /* container for tarval structs */
+static struct set *values = NULL;    /* container for values */
 static tarval_int_overflow_mode_t int_overflow_mode = TV_OVERFLOW_WRAP;
 
 /****************************************************************************
@@ -908,7 +908,10 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m)
       switch (get_mode_sort(m)) {
         case irms_int_number:
         case irms_character:
-          return get_tarval_overflow(src->value, src->length, m);
+         buffer = alloca(sc_get_buffer_length());
+         memcpy(buffer, src->value, sc_get_buffer_length());
+         sign_extend(buffer, src->mode);
+          return get_tarval_overflow(buffer, src->length, m);
 
         case irms_internal_boolean:
           /* XXX C semantics */
@@ -923,7 +926,7 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m)
           /* decimal string representation because hexadecimal output is
            * interpreted unsigned by fc_val_from_str, so this is a HACK */
           snprintf(buffer, 100, "%s",
-                   sc_print(src->value, get_mode_size_bits(src->mode), SC_DEC));
+                   sc_print(src->value, get_mode_size_bits(src->mode), SC_DEC, mode_is_signed(src->mode)));
           buffer[100 - 1] = '\0';
           switch (get_mode_size_bits(m))
           {
@@ -1485,17 +1488,17 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv)
       switch (mode_info->mode_output) {
 
       case TVO_DECIMAL:
-        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC);
+        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC, mode_is_signed(tv->mode));
         break;
 
       case TVO_OCTAL:
-        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT);
+        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT, 0);
         break;
 
       case TVO_HEX:
       case TVO_NATIVE:
       default:
-        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
+        str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX, 0);
         break;
       }
       return snprintf(buf, len, "%s%s%s", prefix, str, suffix);