made code C89 compliant (changed unnamed union in attributes)
[libfirm] / ir / be / ia32 / ia32_gen_decls.c
index 3b80c14..911a959 100644 (file)
 #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"
@@ -110,41 +113,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
  */
@@ -437,7 +405,7 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst
            * 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) {
@@ -448,7 +416,7 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst
 
             /* 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. */
@@ -567,6 +535,8 @@ 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);
@@ -586,7 +556,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);
   }