Various bits of cleanup; we should almost be ready to try sending this to the

assembler soon...
This commit is contained in:
David Given 2016-10-15 23:39:38 +02:00
parent 286435a2ed
commit 6a23906ad8
3 changed files with 5 additions and 2 deletions

View file

@ -101,6 +101,8 @@ int main(int argc, char* const argv[])
else else
outputfile = stdout; outputfile = stdout;
fprintf(outputfile, ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n");
/* Reads in the EM, outputs the data sections, parses any code and /* Reads in the EM, outputs the data sections, parses any code and
* generates IR trees. */ * generates IR trees. */

View file

@ -30,9 +30,9 @@ struct hop* platform_prologue(void)
hop_add_insel(hop, "! spills_size = %d bytes", current_proc->spills_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, "! 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, "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 r0, 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 r0, %d(sp)", current_proc->fp_to_st + current_proc->locals_size + 4);
hop_add_insel(hop, "addi fp, sp, %d", current_proc->locals_size); hop_add_insel(hop, "addi fp, sp, %d", current_proc->locals_size);
return hop; return hop;

View file

@ -110,6 +110,7 @@ static void emit_procedure(struct procedure* proc)
{ {
int i, j; int i, j;
fprintf(outputfile, "\n.sect .text\n");
for (i=0; i<dominance.preorder.count; i++) for (i=0; i<dominance.preorder.count; i++)
{ {
struct basicblock* bb = dominance.preorder.item[i]; struct basicblock* bb = dominance.preorder.item[i];