set names for ia32 default pns
[libfirm] / ir / be / begnuas.c
index 7269b3f..4b58de2 100644 (file)
@@ -168,10 +168,24 @@ static void dump_arith_tarval(obstack_t *obst, tarval *tv, int bytes)
        }
 }
 
+/**
+ * Return the label prefix for labeled blocks.
+ */
+const char *be_gas_label_prefix(void) {
+       return ".LG";
+}
+
+/**
+ * Dump a label.
+ */
+static void dump_label(obstack_t *obst, ir_label_t label) {
+       obstack_printf(obst, "%s%ld", be_gas_label_prefix(), label);
+}
+
 /**
  * Return the tarval of an atomic initializer.
  *
- * @param init  a node representing the initializer (on teh const code irg)
+ * @param init  a node representing the initializer (on the const code irg)
  *
  * @return the tarval
  */
@@ -207,6 +221,9 @@ static tarval *get_atomic_init_tv(ir_node *init)
                        case symconst_enum_const:
                                return get_enumeration_value(get_SymConst_enum(init));
 
+                       case symconst_label:
+                               return NULL;
+
                        default:
                                return NULL;
                        }
@@ -230,6 +247,7 @@ static void do_dump_atomic_init(be_gas_decl_env_t *env, obstack_t *obst,
        ir_mode *mode = get_irn_mode(init);
        int bytes     = get_mode_size_bytes(mode);
        tarval *tv;
+       ir_label_t label;
        ir_entity *ent;
 
        switch (get_irn_opcode(init)) {
@@ -288,6 +306,11 @@ static void do_dump_atomic_init(be_gas_decl_env_t *env, obstack_t *obst,
                        dump_arith_tarval(obst, tv, bytes);
                        break;
 
+               case symconst_label:
+                       label = get_SymConst_label(init);
+                       dump_label(obst, label);
+                       break;
+
                default:
                        assert(!"dump_atomic_init(): don't know how to init from this SymConst");
                }
@@ -537,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);
@@ -583,7 +603,6 @@ static void dump_compound_init(be_gas_decl_env_t *env, obstack_t *obst,
                }
 
                ++i;
-               space = 0;
                while (i < last_ofs && vals[i].kind == NORMAL && vals[i].v.value == NULL) {
                        ++space;
                        ++i;
@@ -683,6 +702,7 @@ static void dump_global(be_gas_decl_env_t *env, ir_entity *ent, int emit_commons
                                break;
                        case tpo_struct:
                        case tpo_class:
+                       case tpo_union:
                                dump_compound_init(env, obst, ent);
                                break;
                        default: