X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fia32%2Fia32_gen_decls.c;h=4704437bcdff12caa936f6d87f301524850172fd;hb=08fe790a5784b31964a8783f6af1d14d62c366c4;hp=e005dfd59267600705b4d0818111906d95e6c76b;hpb=229a3ad498ecc9348064416ca2dd22578a276377;p=libfirm diff --git a/ir/be/ia32/ia32_gen_decls.c b/ir/be/ia32/ia32_gen_decls.c index e005dfd59..4704437bc 100644 --- a/ir/be/ia32/ia32_gen_decls.c +++ b/ir/be/ia32/ia32_gen_decls.c @@ -10,19 +10,7 @@ #include #include -#include "xmalloc.h" -#include - -#ifdef obstack_chunk_alloc -# undef obstack_chunk_alloc -# define obstack_chunk_alloc xmalloc -#else -# define obstack_chunk_alloc xmalloc -# define obstack_chunk_free free -#endif - -extern int obstack_printf(struct obstack *obst, char *fmt, ...); - +#include "obst.h" #include "tv.h" #include "irnode.h" #include "entity.h" @@ -113,41 +101,6 @@ static void dump_arith_tarval(struct obstack *obst, tarval *tv, int bytes) } } -/* - * dump an arithmetic tarval - */ -static void ia32_dump_arith_tarval(struct obstack *obst, tarval *tv, int bytes) -{ - switch (bytes) { - - case 1: - obstack_printf(obst, "\t.byte\t"); - break; - - case 2: - obstack_printf(obst, "\t.value\t"); - break; - - case 4: - obstack_printf(obst, "\t.long\t"); - break; - - case 8: - obstack_printf(obst, "\t.quad\t"); - break; - - case 10: - case 12: - break; - - default: - fprintf(stderr, "Try to dump an tarval with %d bytes\n", bytes); - assert(0); - } - dump_arith_tarval(obst, tv, bytes); -} - - /* * dump an atomic value */ @@ -355,6 +308,11 @@ struct arr_info { int size; }; +static void dump_object_size(struct obstack *obst, 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); +} + /* * Dumps the initialization of global variables that are not * "uninitialized". @@ -378,13 +336,12 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst obst = rdata_obstack; } - /* check, wether it is initialized, if yes create data */ + /* check, whether it is initialized, if yes create data */ if (variability != variability_uninitialized) { if (visibility == visibility_external_visible) { obstack_printf(obst, ".globl\t%s\n", ld_name); } - obstack_printf(obst, "\t.type\t%s,@object\n", ld_name); - obstack_printf(obst, "\t.size\t%s,%d\n", ld_name, (get_type_size_bits(ty) + 7) >> 3); + dump_object_size(obst, ld_name, (get_type_size_bits(ty) + 7) >> 3); align = get_type_alignment_bytes(ty); ia32_dump_align(obst, align); @@ -392,20 +349,20 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst obstack_printf(obst, "%s:\n", ld_name); if (is_atomic_type(ty)) { - if (get_entity_visibility(ent) != visibility_external_allocated) + if (get_entity_visibility(ent) != visibility_external_allocated) dump_atomic_init(obst, get_atomic_ent_value(ent)); } else { - int i, size = 0; + int i, size = 0; - if (ent_is_string_const(ent)) { - dump_string_cst(obst, ent); - } - else if (is_Array_type(ty)) { + if (ent_is_string_const(ent)) { + dump_string_cst(obst, ent); + } + else if (is_Array_type(ty)) { int filler; /* potential spare values should be already included! */ - for (i = 0; i < get_compound_ent_n_values(ent); ++i) { + for (i = 0; i < get_compound_ent_n_values(ent); ++i) { entity *step = get_compound_ent_value_member(ent, i); ir_type *stype = get_entity_type(step); @@ -570,8 +527,6 @@ void ia32_gen_decls(FILE *out) { obstack_init(&data); obstack_init(&comm); - fprintf(out, "\t.intel_syntax\n"); - ia32_dump_globals(&rodata, &data, &comm); size = obstack_object_size(&data); @@ -591,7 +546,7 @@ void ia32_gen_decls(FILE *out) { size = obstack_object_size(&comm); cp = obstack_finish(&comm); if (size > 0) { - fprintf(out, "\t.common\n"); + fprintf(out, "\t.text\n"); fwrite(cp, 1, size, out); }