#include <ctype.h>
#include <assert.h>
-#include "xmalloc.h"
-#include <obstack.h>
-
-#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"
}
}
-/*
- * 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
*/
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".
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);
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);
obstack_init(&data);
obstack_init(&comm);
- fprintf(out, "\t.intel_syntax\n");
-
ia32_dump_globals(&rodata, &data, &comm);
size = obstack_object_size(&data);
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);
}