8 extern Target T_amd64_sysv
;
16 { "amd64_sysv", &T_amd64_sysv
},
17 { "arm64", &T_arm64
},
23 ['P'] = 0, /* parsing */
24 ['M'] = 0, /* memory optimization */
25 ['N'] = 0, /* ssa construction */
26 ['C'] = 0, /* copy elimination */
27 ['F'] = 0, /* constant folding */
28 ['A'] = 0, /* abi lowering */
29 ['I'] = 0, /* instruction selection */
30 ['L'] = 0, /* liveness */
31 ['S'] = 0, /* spilling */
32 ['R'] = 0, /* reg. allocation */
43 if (d
->type
== DEnd
) {
44 fputs("/* end data */\n\n", outf
);
56 fprintf(stderr
, "**** Function %s ****", fn
->name
);
58 fprintf(stderr
, "\n> After parsing:\n");
90 assert(fn
->rpo
[0] == fn
->start
);
92 if (n
== fn
->nblk
-1) {
96 fn
->rpo
[n
]->link
= fn
->rpo
[n
+1];
99 gasemitfntail(fn
->name
, outf
);
100 fprintf(outf
, "/* end function %s */\n\n", fn
->name
);
102 fprintf(stderr
, "\n");
107 main(int ac
, char *av
[])
117 while ((c
= getopt(ac
, av
, "hd:o:G:t:")) != -1)
120 for (; *optarg
; optarg
++)
121 if (isalpha(*optarg
)) {
122 debug
[toupper(*optarg
)] = 1;
127 if (strcmp(optarg
, "-") != 0) {
128 outf
= fopen(optarg
, "w");
130 fprintf(stderr
, "cannot open '%s'\n", optarg
);
136 for (tm
=tmap
;; tm
++) {
138 fprintf(stderr
, "unknown target '%s'\n", optarg
);
141 if (strcmp(optarg
, tm
->name
) == 0) {
148 if (strcmp(optarg
, "e") == 0)
150 else if (strcmp(optarg
, "m") == 0)
153 fprintf(stderr
, "unknown gas flavor '%s'\n", optarg
);
159 hf
= c
!= 'h' ? stderr
: stdout
;
160 fprintf(hf
, "%s [OPTIONS] {file.ssa, -}\n", av
[0]);
161 fprintf(hf
, "\t%-11s prints this help\n", "-h");
162 fprintf(hf
, "\t%-11s output to file\n", "-o file");
163 fprintf(hf
, "\t%-11s generate for a target among:\n", "-t <target>");
164 fprintf(hf
, "\t%-11s ", "");
165 for (tm
=tmap
, sep
=""; tm
->name
; tm
++, sep
=", ")
166 fprintf(hf
, "%s%s", sep
, tm
->name
);
168 fprintf(hf
, "\t%-11s generate gas (e) or osx (m) asm\n", "-G {e,m}");
169 fprintf(hf
, "\t%-11s dump debug information\n", "-d <flags>");
177 if (!f
|| strcmp(f
, "-") == 0) {
183 fprintf(stderr
, "cannot open '%s'\n", f
);
187 parse(inf
, f
, data
, func
);
188 } while (++optind
< ac
);
192 if (asmmode
== Gaself
)
193 fprintf(outf
, ".section .note.GNU-stack,\"\",@progbits\n");