#include "entity.h"
#include "irprog.h"
+#include "ia32_emitter.h"
#include "ia32_gen_decls.h"
/************************************************************************/
return res;
}
+static void ia32_dump_comm(struct obstack *obst, const char *name, visibility vis, int size, int align) {
+ switch (asm_flavour) {
+ case ASM_LINUX_GAS:
+ if (vis == visibility_local)
+ obstack_printf(obst, "\t.local\t%s\n", name);
+ obstack_printf(obst, "\t.comm\t%s,%d,%d\n", name, size, align);
+ break;
+ case ASM_MINGW_GAS:
+ if (vis == visibility_local)
+ obstack_printf(obst, "\t.lcomm\t%s,%d\n", name, size);
+ else
+ obstack_printf(obst, "\t.comm\t%s,%d\n", name, size);
+ break;
+ }
+}
+
/*
* output the alignment
*/
tv = get_Const_tarval(init);
/* beware of old stuff */
- assert(! mode_is_reference(mode));
+ //assert(! mode_is_reference(mode));
/* it's a arithmetic value */
dump_arith_tarval(obst, tv, bytes);
obstack_printf(obst, "%s", get_entity_ld_name(get_SymConst_entity(init)));
break;
- case symconst_size:
+ case symconst_type_size:
obstack_printf(obst, "%d", get_type_size_bytes(get_SymConst_type(init)));
break;
+ case symconst_type_align:
+ obstack_printf(obst, "%d", get_type_alignment_bytes(get_SymConst_type(init)));
+ break;
+
default:
assert(0 && "dump_atomic_init(): don't know how to init from this SymConst");
}
case '\n': obstack_printf(obst, "\\n"); break;
case '\r': obstack_printf(obst, "\\r"); break;
case '\t': obstack_printf(obst, "\\t"); break;
+ case '\\': obstack_printf(obst, "\\\\"); break;
default :
if (isprint(c))
obstack_printf(obst, "%c", c);
};
static void dump_object_size(struct obstack *obst, const char *name, int size) {
- obstack_printf(obst, "\t.type\t%s,@object\n", name);
- obstack_printf(obst, "\t.size\t%s,%d\n", name, size);
+ switch (asm_flavour) {
+ case ASM_LINUX_GAS:
+ obstack_printf(obst, "\t.type\t%s,@object\n", name);
+ obstack_printf(obst, "\t.size\t%s,%d\n", name, size);
+ break;
+ }
}
/*
stepsize = (get_type_size_bits(step_type) + 7) >> 3;
/* Search the next free position in vals depending on the information from above (ai). */
- while (vals[offset]) {
+ while (vals[offset] && aipos >= 0) {
if (ai[aipos].visit_cnt < ai[aipos].n_elems) {
offset += stepsize;
ai[aipos].visit_cnt++;
obstack_printf(obst, "\n");
}
else if (visibility != visibility_external_allocated) {
- if (visibility == visibility_local) {
- obstack_printf(comm_obstack, "\t.local\t%s\n", ld_name);
- }
-
/* calculate the alignment */
align = get_type_alignment_bytes(ty);
h = highest_bit(align);
if (align < 1)
align = 1;
- obstack_printf(comm_obstack, "\t.comm\t%s,%d,%d\n", ld_name, (get_type_size_bits(ty) + 7) >> 3, align);
+ ia32_dump_comm(comm_obstack, ld_name, visibility,
+ (get_type_size_bits(ty) + 7) >> 3, align);
}
}
}
size = obstack_object_size(&data);
cp = obstack_finish(&data);
if (size > 0) {
- fprintf(out, "\t.data\n");
+ ia32_switch_section(out, SECTION_DATA);
fwrite(cp, 1, size, out);
}
size = obstack_object_size(&comm);
cp = obstack_finish(&comm);
if (size > 0) {
- fprintf(out, "\t.text\n");
+ ia32_switch_section(out, SECTION_COMMON);
fwrite(cp, 1, size, out);
}