Renamed attr.load.load_mode to attr.load.mode
[libfirm] / ir / tv / strcalc.c
index 721eed2..804a071 100644 (file)
@@ -1019,7 +1019,7 @@ void sc_val_from_str(const char *str, unsigned int len, void *buffer, ir_mode *m
                case 'c':
                case 'b':
                case 'a':
-                       if (base[0] > SC_9 || base[1] > SC_0) { /* (base > 10) */
+                       if (base[0] > SC_A || base[1] > SC_0) { /* (base > 10) */
                                val[0] = _digit((*str)-'a'+10);
                        }
                        else
@@ -1032,7 +1032,7 @@ void sc_val_from_str(const char *str, unsigned int len, void *buffer, ir_mode *m
                case 'C':
                case 'B':
                case 'A':
-                       if (base[0] > SC_9 || base[1] > SC_0) { /* (base > 10) */
+                       if (base[0] > SC_A || base[1] > SC_0) { /* (base > 10) */
                                val[0] = _digit((*str)-'A'+10);
                        }
                        else
@@ -1041,7 +1041,7 @@ void sc_val_from_str(const char *str, unsigned int len, void *buffer, ir_mode *m
 
                case '9':
                case '8':
-                       if (base[0] > SC_7 || base[1] > SC_0) { /* (base > 8) */
+                       if (base[0] > SC_8 || base[1] > SC_0) { /* (base > 8) */
                                val[0] = _digit((*str)-'0');
                        }
                        else
@@ -1276,6 +1276,14 @@ int sc_get_bit_at(const void *value, unsigned pos) {
        return 0;
 }
 
+void sc_set_bit_at(void *value, unsigned pos)
+{
+       char *val = value;
+       unsigned nibble = pos >> 2;
+
+       val[nibble] = or_table[(int)val[nibble]][(int)shift_table[pos & 3]];
+}
+
 int sc_is_zero(const void *value) {
        const char* val = (const char *)value;
        int counter;
@@ -1364,7 +1372,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig
 
                /* last nibble must be masked */
                if (bits & 3) {
-                       mask = zex_digit[bits & 3];
+                       mask = zex_digit[(bits & 3) - 1];
                        x = and_table[_val(val[counter++])][mask];
                        *(--pos) = digits[_val(x)];
                }
@@ -1391,7 +1399,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig
 
                /* last nibble must be masked */
                if (bits & 3) {
-                       mask = zex_digit[bits & 3];
+                       mask = zex_digit[(bits & 3) - 1];
                        x = and_table[_val(val[counter++])][mask];
 
                        pos -= 4;
@@ -1431,7 +1439,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base, int sig
 
                /* last nibble must be masked */
                if (bits & 3) {
-                       mask = zex_digit[bits & 3];
+                       mask = zex_digit[(bits & 3) - 1];
                        div1_res[counter] = and_table[_val(p[counter])][mask];
                        ++counter;
                }