References to the stack frame are now rendered properly.
This commit is contained in:
parent
a8ee82d197
commit
b36897c299
|
@ -227,15 +227,15 @@ char* hop_render(struct hop* hop)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INSEL_ST_OFFSET:
|
case INSEL_ST_OFFSET:
|
||||||
appendf("(st+%d)", insel->u.hreg->offset);
|
appendf("%d", current_proc->fp_to_st + insel->u.hreg->offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INSEL_AB_OFFSET:
|
case INSEL_AB_OFFSET:
|
||||||
appendf("(ab+%d)", insel->u.offset);
|
appendf("%d", current_proc->fp_to_ab + insel->u.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INSEL_LB_OFFSET:
|
case INSEL_LB_OFFSET:
|
||||||
appendf("(lb+%d)", insel->u.offset);
|
appendf("%d", current_proc->fp_to_lb + insel->u.offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INSEL_VALUE:
|
case INSEL_VALUE:
|
||||||
|
@ -252,6 +252,12 @@ char* hop_render(struct hop* hop)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_LOCAL:
|
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:
|
case IR_CONST:
|
||||||
appendf("%d", ir->u.ivalue);
|
appendf("%d", ir->u.ivalue);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,21 +3,22 @@
|
||||||
/* mcg stack frames are laid out as:
|
/* mcg stack frames are laid out as:
|
||||||
*
|
*
|
||||||
* | ...params...
|
* | ...params...
|
||||||
* | --------------- <- ap
|
* | --------------- <- ab
|
||||||
* | saved regs
|
* | saved regs
|
||||||
* | --------------- <- st
|
* | ---------------
|
||||||
* | spills
|
* | spills
|
||||||
* | --------------- <- fp (a.k.a. lb)
|
* | --------------- <- st, fp (a.k.a. lb)
|
||||||
* | locals
|
* | locals
|
||||||
* | --------------- <- sp
|
* | --------------- <- sp
|
||||||
* V ...user area...
|
* V ...user area...
|
||||||
*
|
*
|
||||||
|
* st indexes up; lb indexes down.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void platform_calculate_offsets(void)
|
void platform_calculate_offsets(void)
|
||||||
{
|
{
|
||||||
current_proc->fp_to_st = current_proc->spills_size;
|
current_proc->fp_to_st = 0;
|
||||||
current_proc->fp_to_ap = current_proc->fp_to_st + current_proc->saved_size + 8;
|
current_proc->fp_to_ab = current_proc->spills_size + current_proc->saved_size + 8;
|
||||||
current_proc->fp_to_lb = 0;
|
current_proc->fp_to_lb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +26,10 @@ struct hop* platform_prologue(void)
|
||||||
{
|
{
|
||||||
struct hop* hop = new_hop(current_proc->entry, NULL);
|
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, "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 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);
|
hop_add_insel(hop, "stw 0, %d(sp)", current_proc->fp_to_st + current_proc->locals_size + 4);
|
||||||
|
|
|
@ -17,7 +17,7 @@ struct procedure
|
||||||
int spills_size;
|
int spills_size;
|
||||||
int saved_size;
|
int saved_size;
|
||||||
int fp_to_st;
|
int fp_to_st;
|
||||||
int fp_to_ap;
|
int fp_to_ab;
|
||||||
int fp_to_lb;
|
int fp_to_lb;
|
||||||
ARRAYOF(struct basicblock) blocks;
|
ARRAYOF(struct basicblock) blocks;
|
||||||
IMAPOF(struct local) locals;
|
IMAPOF(struct local) locals;
|
||||||
|
|
Loading…
Reference in a new issue