From c672807de37dc187a38d854b0d99bf9b68db5f56 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 30 Aug 2018 23:38:44 +0200 Subject: [PATCH] Archival checkin for merge. --- build.lua | 2 +- mach/powerpc/mcg/table | 126 ++++++++++-------------- mach/proto/mcg/pass_assignvregs.c | 26 ++++- mach/proto/mcg/pass_registerallocator.c | 16 +++ mach/proto/mcg/pass_typeinference.c | 5 +- mach/proto/mcg/reg.h | 2 +- 6 files changed, 97 insertions(+), 80 deletions(-) diff --git a/build.lua b/build.lua index f7b0ca1ea..a8e054739 100644 --- a/build.lua +++ b/build.lua @@ -1,5 +1,5 @@ vars.cflags = { - "-g", "-O" + "-g", "-Og", } vars.ackcflags = { "-O6" diff --git a/mach/powerpc/mcg/table b/mach/powerpc/mcg/table index 93a120522..5de33aec0 100644 --- a/mach/powerpc/mcg/table +++ b/mach/powerpc/mcg/table @@ -1,13 +1,29 @@ +TYPES + + /* These are special and must always exist. */ + + int; + long; + float; + double; + + /* Any number of additional types can be defined, but they're of fairly limited use as values + * of these types will never be spilt or copied. */ + + cr; + REGISTERS /* Registers are allocated top down; the order here is odd in order to make * sure that non-volatile registers get allocated from r31 (or f31) down. * - * Attributes may have at most one of: int, float, long, double. These - * indicate that the register is used to store a value of that type. If - * your register can store more than one type, create an alias. Registers - * with none of these cannot be copied by the code generator (and so cannot - * be moved from register to register or spilt). + * Each register must be declared as having at least one type (listed above). + * This allows the register to contain values of that type. They may also be + * declared as having any number of additional attributes, which can be used + * to constrain register selection. + * + * Register aliases may be defined with uses(reg1, reg2, ...). These work like + * any other register, but they share hardware resources with some real registers. */ r12 int volatile; @@ -57,73 +73,39 @@ REGISTERS r15r16 named("r15", "r16") uses(r15, r16) long; r13r14 named("r13", "r14") uses(r13, r14) long; - f14 float volatile; - f13 float volatile; - f12 float volatile; - f11 float volatile; - f10 float volatile; - f9 float volatile; - f8 float volatile; - f7 float volatile; - f6 float volatile; - f5 float volatile; - f4 float volatile; - f3 float volatile fret; - f2 float volatile; - f1 float volatile; - f0 float volatile; - - f31 float; - f30 float; - f29 float; - f28 float; - f27 float; - f26 float; - f25 float; - f24 float; - f23 float; - f22 float; - f21 float; - f20 float; - f19 float; - f18 float; - f17 float; - f16 float; - f15 float; - - d14 named("f14") uses(f14) double volatile; - d13 named("f13") uses(f13) double volatile; - d12 named("f12") uses(f12) double volatile; - d11 named("f11") uses(f11) double volatile; - d10 named("f10") uses(f10) double volatile; - d9 named("f9") uses(f9) double volatile; - d8 named("f8") uses(f8) double volatile; - d7 named("f7") uses(f7) double volatile; - d6 named("f6") uses(f6) double volatile; - d5 named("f5") uses(f5) double volatile; - d4 named("f4") uses(f4) double volatile; - d3 named("f3") uses(f3) double volatile dret; - d2 named("f2") uses(f2) double volatile; - d1 named("f1") uses(f1) double volatile; - d0 named("f0") uses(f0) double volatile; - - d31 named("f31") uses(f31) double; - d30 named("f30") uses(f30) double; - d29 named("f29") uses(f29) double; - d28 named("f28") uses(f28) double; - d27 named("f27") uses(f27) double; - d26 named("f26") uses(f26) double; - d25 named("f25") uses(f25) double; - d24 named("f24") uses(f24) double; - d23 named("f23") uses(f23) double; - d22 named("f22") uses(f22) double; - d21 named("f21") uses(f21) double; - d20 named("f20") uses(f20) double; - d19 named("f19") uses(f19) double; - d18 named("f18") uses(f18) double; - d17 named("f17") uses(f17) double; - d16 named("f16") uses(f16) double; - d15 named("f15") uses(f15) double; + f14 float double volatile; + f13 float double volatile; + f12 float double volatile; + f11 float double volatile; + f10 float double volatile; + f9 float double volatile; + f8 float double volatile; + f7 float double volatile; + f6 float double volatile; + f5 float double volatile; + f4 float double volatile; + f3 float double volatile fret dret; + f2 float double volatile; + f1 float double volatile; + f0 float double volatile; + + f31 float double; + f30 float double; + f29 float double; + f28 float double; + f27 float double; + f26 float double; + f25 float double; + f24 float double; + f23 float double; + f22 float double; + f21 float double; + f20 float double; + f19 float double; + f18 float double; + f17 float double; + f16 float double; + f15 float double; cr0 cr; diff --git a/mach/proto/mcg/pass_assignvregs.c b/mach/proto/mcg/pass_assignvregs.c index 2aa80f263..3a6f3011a 100644 --- a/mach/proto/mcg/pass_assignvregs.c +++ b/mach/proto/mcg/pass_assignvregs.c @@ -49,6 +49,18 @@ static bool hop_reads_value(struct hop* hop, struct value* value) return usage->input || usage->through; } +static void setup_regclass(struct vreg* vreg, struct value* value) +{ + const struct burm_regclass_data* regclass = &burm_regclass_data[value->regclass]; + assert(!vreg->regclass || (vreg->regclass == regclass)); + + if (!vreg->regclass) + { + memcpy(vreg->registers, regclass->bitmap, sizeof(burm_register_bitmap_t)); + vreg->regclass = regclass; + } +} + static void assign_vregs(void) { int i, j; @@ -112,7 +124,9 @@ static void assign_vregs(void) { struct value* value = hit.key; struct vreg* vreg = hit.value; + hop_add_input_vreg(hop, vreg); + setup_regclass(vreg, value); } } @@ -137,18 +151,22 @@ static void assign_vregs(void) { struct value* value = hit.key; struct valueusage* usage = hit.value; + struct vreg* vreg = NULL; assert(!(usage->through && usage->output)); if (usage->through) { - struct vreg* invreg = hop_find_input_vreg(hop, value); - hop_add_through_vreg(hop, invreg, invreg); + vreg = hop_find_input_vreg(hop, value); + hop_add_through_vreg(hop, vreg, vreg); } if (usage->output) { - struct vreg* outvreg = create_and_map_vreg(value); - hop_add_output_vreg(hop, outvreg); + vreg = create_and_map_vreg(value); + hop_add_output_vreg(hop, vreg); } + + if (vreg) + setup_regclass(vreg, value); } } } diff --git a/mach/proto/mcg/pass_registerallocator.c b/mach/proto/mcg/pass_registerallocator.c index 6a3a7bfb9..8678b382f 100644 --- a/mach/proto/mcg/pass_registerallocator.c +++ b/mach/proto/mcg/pass_registerallocator.c @@ -28,6 +28,17 @@ static void coalesce(struct vreg* vmaster, struct vreg* vslave) { vmaster = actual(vmaster); vslave = actual(vslave); + if (vmaster->regclass && vslave->regclass) + { + bitmap_and(vmaster->registers, burm_register_count, vslave->registers); + assert(bitmap_count_set_bits(vmaster->registers, burm_register_count) > 0); + } + else if (!vmaster->regclass && vslave->regclass) + { + memcpy(vmaster->registers, vslave->registers, sizeof(burm_register_bitmap_t)); + vmaster->regclass = vslave->regclass; + } + vmaster->needs_register |= vslave->needs_register; vslave->coalesced_with = vmaster; } @@ -120,9 +131,14 @@ static void check_graph(void) static void dump_vreg(struct vreg* vreg) { + int i; + fprintf(regalloc_dot_file, "[%%%d]", vreg->id); if (!vreg->needs_register) fprintf(regalloc_dot_file, "S"); + fprintf(regalloc_dot_file, "\n%s", vreg->regclass ? vreg->regclass->name : "ANY"); + for (i=0; iregisters[i]); } static void dump_interference_graph(void) diff --git a/mach/proto/mcg/pass_typeinference.c b/mach/proto/mcg/pass_typeinference.c index ae45468c8..d8554c2ef 100644 --- a/mach/proto/mcg/pass_typeinference.c +++ b/mach/proto/mcg/pass_typeinference.c @@ -17,7 +17,7 @@ static void addall(struct ir* ir) static void collect_irs(void) { int i; - + set_empty(&irs); for (i=0; iu.phivalue.item[j].left; struct ir* copy = new_copy(wanted, real, childir); copy->root = copy; + copy->bb = childbb; /* The copy gets inserted as the second last item of the child * basic block. That way it'll happen before the final jump diff --git a/mach/proto/mcg/reg.h b/mach/proto/mcg/reg.h index ef39cc59e..d7e2924a9 100644 --- a/mach/proto/mcg/reg.h +++ b/mach/proto/mcg/reg.h @@ -22,7 +22,7 @@ struct vreg int neighbours; bool needs_register; bool is_spilt; - struct burm_regclass_data* regclass; + const struct burm_regclass_data* regclass; burm_register_bitmap_t registers; }; -- 2.34.1