5 #include "expression.h"
10 static void output_bb(struct basic_block
*bb
, unsigned long generation
)
12 struct instruction
*insn
;
14 bb
->generation
= generation
;
17 FOR_EACH_PTR(bb
->insns
, insn
) {
20 printf("\t%s\n", show_instruction(insn
));
22 END_FOR_EACH_PTR(insn
);
27 static void output_fn(struct entrypoint
*ep
)
29 struct basic_block
*bb
;
30 unsigned long generation
= ++bb_generation
;
31 struct symbol
*sym
= ep
->name
;
32 const char *name
= show_ident(sym
->ident
);
34 if (sym
->ctype
.modifiers
& MOD_STATIC
)
35 printf("\n\n%s:\n", name
);
37 printf("\n\n.globl %s\n%s:\n", name
, name
);
41 FOR_EACH_PTR(ep
->bbs
, bb
) {
42 if (bb
->generation
== generation
)
44 output_bb(bb
, generation
);
49 static int output_data(struct symbol
*sym
)
51 printf("symbol %s:\n", show_ident(sym
->ident
));
52 printf("\ttype = %d\n", sym
->ctype
.base_type
->type
);
53 printf("\tmodif= %lx\n", sym
->ctype
.modifiers
);
58 static int compile(struct symbol_list
*list
)
61 FOR_EACH_PTR(list
, sym
) {
62 struct entrypoint
*ep
;
64 ep
= linearize_symbol(sym
);
70 END_FOR_EACH_PTR(sym
);
75 int main(int argc
, char **argv
)
77 compile(sparse_initialize(argc
, argv
));
79 compile(sparse(argv
));