#include <ctype.h>
#include <assert.h>
+#include "xmalloc.h"
#include <obstack.h>
#ifdef obstack_chunk_alloc
# undef obstack_chunk_alloc
-# define obstack_chunk_alloc malloc
+# define obstack_chunk_alloc xmalloc
#else
-# define obstack_chunk_alloc malloc
+# define obstack_chunk_alloc xmalloc
# define obstack_chunk_free free
#endif
+extern int obstack_printf(struct obstack *obst, char *fmt, ...);
+
#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
*/
* size should be equal or bigger the number of fields
*/
type_size = get_type_size_bytes(ty);
- vals = calloc(type_size, sizeof(*vals));
+ vals = xcalloc(type_size, sizeof(*vals));
/* collect the values and store them at the offsets */
for(i = 0; i < get_compound_ent_n_values(ent); ++i) {
/* get the access path to the costant value */
graph_length = get_compound_graph_path_length(path);
- ai = calloc(graph_length, sizeof(struct arr_info));
+ ai = xcalloc(graph_length, sizeof(struct arr_info));
/* We wanna know how many arrays are on the path to the entity. We also have to know how
* many elements each array holds to calculate the offset for the entity. */
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);
}