9 ['P'] = 0, /* parsing */
10 ['M'] = 0, /* memory optimization */
11 ['N'] = 0, /* ssa construction */
12 ['C'] = 0, /* copy elimination */
13 ['F'] = 0, /* constant folding */
14 ['A'] = 0, /* abi lowering */
15 ['I'] = 0, /* instruction selection */
16 ['L'] = 0, /* liveness */
17 ['S'] = 0, /* spilling */
18 ['R'] = 0, /* reg. allocation */
21 extern Target T_amd64_sysv
;
22 extern Target T_arm64
;
25 static Target
*tlist
[] = {
39 if (d
->type
== DEnd
) {
40 fputs("/* end data */\n\n", outf
);
52 fprintf(stderr
, "**** Function %s ****", fn
->name
);
54 fprintf(stderr
, "\n> After parsing:\n");
86 assert(fn
->rpo
[0] == fn
->start
);
88 if (n
== fn
->nblk
-1) {
92 fn
->rpo
[n
]->link
= fn
->rpo
[n
+1];
95 gasemitfntail(fn
->name
, outf
);
96 fprintf(outf
, "/* end function %s */\n\n", fn
->name
);
98 fprintf(stderr
, "\n");
103 main(int ac
, char *av
[])
113 while ((c
= getopt(ac
, av
, "hd:o:G:t:")) != -1)
116 for (; *optarg
; optarg
++)
117 if (isalpha(*optarg
)) {
118 debug
[toupper(*optarg
)] = 1;
123 if (strcmp(optarg
, "-") != 0) {
124 outf
= fopen(optarg
, "w");
126 fprintf(stderr
, "cannot open '%s'\n", optarg
);
132 if (strcmp(optarg
, "?") == 0) {
136 for (t
=tlist
;; t
++) {
138 fprintf(stderr
, "unknown target '%s'\n", optarg
);
141 if (strcmp(optarg
, (*t
)->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 (t
=tlist
, sep
=""; *t
; t
++, sep
=", ") {
166 fprintf(hf
, "%s%s", sep
, (*t
)->name
);
168 fputs(" (default)", hf
);
171 fprintf(hf
, "\t%-11s generate gas (e) or osx (m) asm\n", "-G {e,m}");
172 fprintf(hf
, "\t%-11s dump debug information\n", "-d <flags>");
180 if (!f
|| strcmp(f
, "-") == 0) {
186 fprintf(stderr
, "cannot open '%s'\n", f
);
190 parse(inf
, f
, data
, func
);
192 } while (++optind
< ac
);