diff --git a/mach/proto/mcg/mcg.h b/mach/proto/mcg/mcg.h index 3db29b86c..78560499b 100644 --- a/mach/proto/mcg/mcg.h +++ b/mach/proto/mcg/mcg.h @@ -17,12 +17,14 @@ #include "em_flag.h" #include "em_ptyp.h" #include "array.h" +#include "imap.h" #include "pmap.h" #include "diagnostics.h" #include "astring.h" #include "ir.h" #include "mcgg.h" #include "hop.h" +#include "procedure.h" extern char em_pseu[][4]; extern char em_mnem[][4]; @@ -71,14 +73,6 @@ struct em } u; }; -struct procedure -{ - const char* name; - struct basicblock* root_bb; - size_t nlocals; - ARRAYOF(struct basicblock) blocks; -}; - struct basicblock { const char* name; @@ -118,7 +112,7 @@ extern void bb_print(char k, struct basicblock* block); extern void tb_filestart(void); extern void tb_fileend(void); extern void tb_procedure(struct procedure* proc); -extern void tb_regvar(arith offset, int size, int type, int priority); +extern void tb_regvar(struct procedure* proc, arith offset, int size, int type, int priority); extern void pass_convert_stack_ops(struct procedure* proc); extern void pass_remove_dead_blocks(struct procedure* proc); @@ -127,8 +121,6 @@ extern void pass_instruction_selector(struct procedure* proc); extern void pass_promote_float_ops(struct procedure* proc); extern void pass_group_irs(struct procedure* proc); -extern void procedure_compile(struct procedure* proc); - #endif /* vim: set sw=4 ts=4 expandtab : */ diff --git a/mach/proto/mcg/parse_em.c b/mach/proto/mcg/parse_em.c index 4508d594c..12ea25589 100644 --- a/mach/proto/mcg/parse_em.c +++ b/mach/proto/mcg/parse_em.c @@ -338,7 +338,7 @@ static void parse_mes(void) int size = mes_get_cst(); int type = mes_get_cst(); int priority = mes_get_cst(); - tb_regvar(offset, size, type, priority); + tb_regvar(current_proc, offset, size, type, priority); } break; } diff --git a/mach/proto/mcg/procedure.h b/mach/proto/mcg/procedure.h new file mode 100644 index 000000000..de11c5458 --- /dev/null +++ b/mach/proto/mcg/procedure.h @@ -0,0 +1,22 @@ +#ifndef PROCEDURE_H +#define PROCEDURE_H + +struct local +{ + bool is_register; +}; + +struct procedure +{ + const char* name; + struct basicblock* root_bb; + size_t nlocals; + ARRAYOF(struct basicblock) blocks; + IMAPOF(struct local) locals; +}; + +extern void procedure_compile(struct procedure* proc); + +#endif + +/* vim: set sw=4 ts=4 expandtab : */ diff --git a/mach/proto/mcg/treebuilder.c b/mach/proto/mcg/treebuilder.c index 8835c0b46..f4c481457 100644 --- a/mach/proto/mcg/treebuilder.c +++ b/mach/proto/mcg/treebuilder.c @@ -107,9 +107,12 @@ void tb_fileend(void) { } -void tb_regvar(arith offset, int size, int type, int priority) +void tb_regvar(struct procedure* procedure, arith offset, int size, int type, int priority) { - /* ignored */ + struct local* local = calloc(1, sizeof(*local)); + local->size = size; + local->is_register = true; + imap_put(&procedure->locals, offset, local); } static struct ir* address_of_external(const char* label, arith offset)