7 gasemitdat(Dat
*d
, FILE *f
)
10 static char *dtoa
[] = {
21 fprintf(f
, ".data\n");
27 fprintf(f
, ".align 8\n");
29 fprintf(f
, ".globl %s%s\n", gassym
, d
->u
.str
);
30 fprintf(f
, "%s%s:\n", gassym
, d
->u
.str
);
33 fprintf(f
, "\t.fill %"PRId64
",1,0\n", d
->u
.num
);
36 if (d
->type
== DAlign
)
41 err("strings only supported for 'b' currently");
42 fprintf(f
, "\t.ascii \"%s\"\n", d
->u
.str
);
45 fprintf(f
, "%s %s%+"PRId64
"\n",
46 dtoa
[d
->type
], d
->u
.ref
.nam
,
50 fprintf(f
, "%s %"PRId64
"\n",
51 dtoa
[d
->type
], d
->u
.num
);
57 typedef struct Asmbits Asmbits
;
65 static Asmbits
*stash
;
68 gasstash(void *bits
, int size
)
73 assert(size
== 4 || size
== 8 || size
== 16);
74 for (pb
=&stash
, i
=0; (b
=*pb
); pb
=&b
->link
, i
++)
76 if (memcmp(bits
, b
->bits
, size
) == 0)
78 b
= emalloc(sizeof *b
);
79 memcpy(b
->bits
, bits
, size
);
96 fprintf(f
, "/* floating point constants */\n.data\n");
97 for (sz
=16; sz
>=4; sz
/=2)
98 for (b
=stash
, i
=0; b
; b
=b
->link
, i
++) {
105 for (p
=b
->bits
; p
<&b
->bits
[sz
]; p
+=4)
106 fprintf(f
, "\n\t.int %"PRId32
,
110 d
= *(float *)b
->bits
;
112 d
= *(double *)b
->bits
;
113 fprintf(f
, " /* %f */\n", d
);