From: David Given Date: Sat, 15 Oct 2016 21:33:30 +0000 (+0200) Subject: References to the stack frame are now rendered properly. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b36897c299c0513c953a74639db09d7f57a774c5;p=ack.git References to the stack frame are now rendered properly. --- diff --git a/mach/proto/mcg/hop.c b/mach/proto/mcg/hop.c index b5eaa0292..7bdb232ff 100644 --- a/mach/proto/mcg/hop.c +++ b/mach/proto/mcg/hop.c @@ -227,15 +227,15 @@ char* hop_render(struct hop* hop) break; case INSEL_ST_OFFSET: - appendf("(st+%d)", insel->u.hreg->offset); + appendf("%d", current_proc->fp_to_st + insel->u.hreg->offset); break; case INSEL_AB_OFFSET: - appendf("(ab+%d)", insel->u.offset); + appendf("%d", current_proc->fp_to_ab + insel->u.offset); break; case INSEL_LB_OFFSET: - appendf("(lb+%d)", insel->u.offset); + appendf("%d", current_proc->fp_to_lb + insel->u.offset); break; case INSEL_VALUE: @@ -252,6 +252,12 @@ char* hop_render(struct hop* hop) break; case IR_LOCAL: + if (ir->u.ivalue >= 0) + appendf("%d", current_proc->fp_to_ab + ir->u.ivalue); + else + appendf("%d", current_proc->fp_to_lb + ir->u.ivalue); + break; + case IR_CONST: appendf("%d", ir->u.ivalue); break; diff --git a/mach/proto/mcg/powerpc.c b/mach/proto/mcg/powerpc.c index a47d8a8cc..fbd669e3e 100644 --- a/mach/proto/mcg/powerpc.c +++ b/mach/proto/mcg/powerpc.c @@ -3,21 +3,22 @@ /* mcg stack frames are laid out as: * * | ...params... - * | --------------- <- ap + * | --------------- <- ab * | saved regs - * | --------------- <- st + * | --------------- * | spills - * | --------------- <- fp (a.k.a. lb) + * | --------------- <- st, fp (a.k.a. lb) * | locals * | --------------- <- sp * V ...user area... * + * st indexes up; lb indexes down. */ void platform_calculate_offsets(void) { - current_proc->fp_to_st = current_proc->spills_size; - current_proc->fp_to_ap = current_proc->fp_to_st + current_proc->saved_size + 8; + current_proc->fp_to_st = 0; + current_proc->fp_to_ab = current_proc->spills_size + current_proc->saved_size + 8; current_proc->fp_to_lb = 0; } @@ -25,7 +26,10 @@ struct hop* platform_prologue(void) { struct hop* hop = new_hop(current_proc->entry, NULL); - hop_add_insel(hop, "addi sp, sp, %d", current_proc->fp_to_ap + current_proc->locals_size); + hop_add_insel(hop, "! saved_size = %d+8 bytes", current_proc->saved_size); + hop_add_insel(hop, "! spills_size = %d bytes", current_proc->spills_size); + hop_add_insel(hop, "! locals_size = %d bytes", current_proc->locals_size); + hop_add_insel(hop, "addi sp, sp, %d", -(current_proc->fp_to_ab + current_proc->locals_size)); hop_add_insel(hop, "mfspr 0, lr"); hop_add_insel(hop, "stw fp, %d(sp)", current_proc->fp_to_st + current_proc->locals_size); hop_add_insel(hop, "stw 0, %d(sp)", current_proc->fp_to_st + current_proc->locals_size + 4); diff --git a/mach/proto/mcg/procedure.h b/mach/proto/mcg/procedure.h index 0cec9891f..2c0baf816 100644 --- a/mach/proto/mcg/procedure.h +++ b/mach/proto/mcg/procedure.h @@ -17,7 +17,7 @@ struct procedure int spills_size; int saved_size; int fp_to_st; - int fp_to_ap; + int fp_to_ab; int fp_to_lb; ARRAYOF(struct basicblock) blocks; IMAPOF(struct local) locals;