7 gasemitdat(Dat
*d
, FILE *f
)
10 static char *dtoa
[] = {
22 fprintf(f
, ".data\n");
28 fprintf(f
, ".balign 8\n");
29 p
= d
->u
.str
[0] == '"' ? "" : gassym
;
31 fprintf(f
, ".globl %s%s\n", p
, d
->u
.str
);
32 fprintf(f
, "%s%s:\n", p
, d
->u
.str
);
35 fprintf(f
, "\t.fill %"PRId64
",1,0\n", d
->u
.num
);
38 if (d
->type
== DAlign
)
43 err("strings only supported for 'b' currently");
44 fprintf(f
, "\t.ascii %s\n", d
->u
.str
);
47 p
= d
->u
.ref
.nam
[0] == '"' ? "" : gassym
;
48 fprintf(f
, "%s %s%s%+"PRId64
"\n",
49 dtoa
[d
->type
], p
, d
->u
.ref
.nam
,
53 fprintf(f
, "%s %"PRId64
"\n",
54 dtoa
[d
->type
], d
->u
.num
);
60 typedef struct Asmbits Asmbits
;
68 static Asmbits
*stash
;
71 gasstash(void *bits
, int size
)
76 assert(size
== 4 || size
== 8 || size
== 16);
77 for (pb
=&stash
, i
=0; (b
=*pb
); pb
=&b
->link
, i
++)
79 if (memcmp(bits
, b
->bits
, size
) == 0)
81 b
= emalloc(sizeof *b
);
82 memcpy(b
->bits
, bits
, size
);
99 fprintf(f
, "/* floating point constants */\n.data\n");
100 for (sz
=16; sz
>=4; sz
/=2)
101 for (b
=stash
, i
=0; b
; b
=b
->link
, i
++) {
108 for (p
=b
->bits
; p
<&b
->bits
[sz
]; p
+=4)
109 fprintf(f
, "\n\t.int %"PRId32
,
113 d
= *(float *)b
->bits
;
115 d
= *(double *)b
->bits
;
116 fprintf(f
, " /* %f */\n", d
);