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_amd64_apple
;
23 extern Target T_arm64
;
24 extern Target T_arm64_apple
;
27 static Target
*tlist
[] = {
44 if (d
->type
== DEnd
) {
45 fputs("/* end data */\n\n", outf
);
56 fprintf(stderr
, "**** Function %s ****", fn
->name
);
58 fprintf(stderr
, "\n> After parsing:\n");
95 assert(fn
->rpo
[0] == fn
->start
);
97 if (n
== fn
->nblk
-1) {
101 fn
->rpo
[n
]->link
= fn
->rpo
[n
+1];
104 fprintf(outf
, "/* end function %s */\n\n", fn
->name
);
106 fprintf(stderr
, "\n");
113 emitdbgfile(fn
, outf
);
117 main(int ac
, char *av
[])
126 while ((c
= getopt(ac
, av
, "hd:o:t:")) != -1)
129 for (; *optarg
; optarg
++)
130 if (isalpha(*optarg
)) {
131 debug
[toupper(*optarg
)] = 1;
136 if (strcmp(optarg
, "-") != 0) {
137 outf
= fopen(optarg
, "w");
139 fprintf(stderr
, "cannot open '%s'\n", optarg
);
145 if (strcmp(optarg
, "?") == 0) {
149 for (t
=tlist
;; t
++) {
151 fprintf(stderr
, "unknown target '%s'\n", optarg
);
154 if (strcmp(optarg
, (*t
)->name
) == 0) {
162 hf
= c
!= 'h' ? stderr
: stdout
;
163 fprintf(hf
, "%s [OPTIONS] {file.ssa, -}\n", av
[0]);
164 fprintf(hf
, "\t%-11s prints this help\n", "-h");
165 fprintf(hf
, "\t%-11s output to file\n", "-o file");
166 fprintf(hf
, "\t%-11s generate for a target among:\n", "-t <target>");
167 fprintf(hf
, "\t%-11s ", "");
168 for (t
=tlist
, sep
=""; *t
; t
++, sep
=", ") {
169 fprintf(hf
, "%s%s", sep
, (*t
)->name
);
171 fputs(" (default)", hf
);
174 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
, dbgfile
, data
, func
);
192 } while (++optind
< ac
);