From 852d3a691d22f664e24741ffe5cb545c96ce5cdb Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 11 Nov 2016 21:48:36 +0100 Subject: [PATCH] Update the table to return call output values in the right registers. Fix the register allocator so the corrupted registers only apply to throughs (otherwise, you can't put output registers in corrupted registers). --- mach/powerpc/mcg/table | 22 +++++++++++----------- mach/proto/mcg/pass_registerallocator.c | 8 +++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/mach/powerpc/mcg/table b/mach/powerpc/mcg/table index 486d983ed..a6f416b65 100644 --- a/mach/powerpc/mcg/table +++ b/mach/powerpc/mcg/table @@ -19,7 +19,7 @@ REGISTERS r6 int volatile; r5 int volatile; r4 int volatile; - r3 int volatile ret; + r3 int volatile iret; r31 int; r30 int; @@ -185,7 +185,7 @@ PATTERNS emit "addi sp, sp, 8" cost 8; - SETRET.I(in:(ret)reg) + SETRET.I(in:(iret)reg) emit "! setret4" cost 1; @@ -392,12 +392,12 @@ PATTERNS emit "li32 %out.1, 0" cost 8; - out:(ret)reg = FROMF.I(in:(dret)reg) + out:(iret)reg = FROMF.I(in:(dret)reg) with corrupted(volatile) emit "bl .fromf2i" cost 4; - out:(ret)reg = FROMD.I(in:(dret)reg) + out:(iret)reg = FROMD.I(in:(dret)reg) with corrupted(volatile) emit "bl .fromd2i" cost 4; @@ -407,17 +407,17 @@ PATTERNS emit "bl .fromf2l" cost 4; - out:(dret)reg = FROMSI.D(in:(ret)reg) + out:(dret)reg = FROMSI.D(in:(iret)reg) with corrupted(volatile) emit "bl .fromsi2d" cost 4; - out:(fret)reg = FROMUI.F(in:(ret)reg) + out:(fret)reg = FROMUI.F(in:(iret)reg) with corrupted(volatile) emit "bl .fromui2f" cost 4; - out:(dret)reg = FROMUI.D(in:(ret)reg) + out:(dret)reg = FROMUI.D(in:(iret)reg) with corrupted(volatile) emit "bl .fromui2d" cost 4; @@ -493,8 +493,8 @@ PATTERNS cost 4; CALLLABEL(CALL) - out:(int)reg = CALLLABEL(CALL.I) - out:(long)reg = CALLLABEL(CALL.L) + out:(iret)reg = CALLLABEL(CALL.I) + out:(lret)reg = CALLLABEL(CALL.L) #define CALLINDIRECT(insn) \ insn (dest:(int)reg) \ @@ -504,8 +504,8 @@ PATTERNS cost 8; CALLINDIRECT(CALL) - out:(int)reg = CALLINDIRECT(CALL.I) - out:(long)reg = CALLINDIRECT(CALL.L) + out:(iret)reg = CALLINDIRECT(CALL.I) + out:(lret)reg = CALLINDIRECT(CALL.L) JUMP(dest:LABEL.I) emit "b $dest" diff --git a/mach/proto/mcg/pass_registerallocator.c b/mach/proto/mcg/pass_registerallocator.c index 7c348f0a3..a064adb8e 100644 --- a/mach/proto/mcg/pass_registerallocator.c +++ b/mach/proto/mcg/pass_registerallocator.c @@ -153,8 +153,7 @@ static bool allocatable_stackable_input(struct hreg* hreg, struct vreg* vreg) static bool allocatable_stackable_output(struct hreg* hreg, struct vreg* vreg) { return !register_used(current_outs, hreg) && - (hreg->attrs & vreg->type) && - !(hreg->attrs & current_hop->insndata->corrupts); + (hreg->attrs & vreg->type); } static bool allocatable_input(struct hreg* hreg, struct vreg* vreg) @@ -174,7 +173,8 @@ static bool allocatable_output(struct hreg* hreg, struct vreg* vreg) static bool allocatable_through(struct hreg* hreg, struct vreg* vreg) { return allocatable_stackable_input(hreg, vreg) && - allocatable_stackable_output(hreg, vreg); + allocatable_stackable_output(hreg, vreg) && + !(hreg->attrs & current_hop->insndata->corrupts); } static struct hreg* find_input_reg(struct vreg* vreg) @@ -203,9 +203,7 @@ static struct hreg* find_output_reg(struct vreg* vreg) { hreg = hregs.item[i]; if (allocatable_output(hreg, vreg)) - { return hreg; - } } return NULL; -- 2.34.1