fehler64 (emit a 0 if none of the addressmode things is set)
[libfirm] / ir / be / begnuas.c
index 5f580e2..4b58de2 100644 (file)
@@ -168,7 +168,10 @@ static void dump_arith_tarval(obstack_t *obst, tarval *tv, int bytes)
        }
 }
 
-const char *gnu_label_prefix(void) {
+/**
+ * Return the label prefix for labeled blocks.
+ */
+const char *be_gas_label_prefix(void) {
        return ".LG";
 }
 
@@ -176,7 +179,7 @@ const char *gnu_label_prefix(void) {
  * Dump a label.
  */
 static void dump_label(obstack_t *obst, ir_label_t label) {
-       obstack_printf(obst, "%s%ld", gnu_label_prefix(), label);
+       obstack_printf(obst, "%s%ld", be_gas_label_prefix(), label);
 }
 
 /**
@@ -557,27 +560,24 @@ static void dump_compound_init(be_gas_decl_env_t *env, obstack_t *obst,
 
                if (offset_bits != 0 ||
                        (value_len != 8 && value_len != 16 && value_len != 32 && value_len != 64)) {
-                       tarval *shift, *shifted;
                        tarval *tv = get_atomic_init_tv(value);
+      unsigned char curr_bits, last_bits = 0;
                        if (tv == NULL) {
                                panic("Couldn't get numeric value for bitfield initializer '%s'\n",
                                      get_entity_ld_name(ent));
                        }
-                       tv = tarval_convert_to(tv, mode_Lu);
-                       shift = new_tarval_from_long(offset_bits, mode_Is);
-                       shifted = tarval_shl(tv, shift);
-                       if (shifted == tarval_bad || shifted == tarval_undefined) {
-                               panic("Couldn't shift numeric value for bitfield initializer '%s'\n",
-                                     get_entity_ld_name(ent));
-                       }
+      /* normalize offset */
+      offset += offset_bits >> 3;
+      offset_bits &= 7;
 
-                       for (j = 0; value_len > 0; ++j) {
+                       for (j = 0; value_len + offset_bits > 0; ++j) {
                                assert(offset + j < last_ofs);
                                assert(vals[offset + j].kind == BITFIELD || vals[offset + j].v.value == NULL);
                                vals[offset + j].kind = BITFIELD;
-                               vals[offset + j].v.bf_val |= get_tarval_sub_bits(shifted, j);
-                               value_len -= 8 - offset_bits;
-                               offset_bits = 0;
+        curr_bits = get_tarval_sub_bits(tv, j);
+                               vals[offset + j].v.bf_val |= (last_bits >> (8 - offset_bits)) | (curr_bits << offset_bits);
+                               value_len -= 8;
+        last_bits = curr_bits;
                        }
                } else {
                        assert(offset < last_ofs);