Mercurial > hg > CbC > old > device
changeset 152:17c6598617f8
*** empty log message ***
author | kono |
---|---|
date | Sun, 20 Jul 2003 16:45:09 +0900 |
parents | 81032a1b8a5d |
children | 33b39002ac58 |
files | mc-code-mips.c |
diffstat | 1 files changed, 65 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-mips.c Mon Jul 14 14:40:35 2003 +0900 +++ b/mc-code-mips.c Sun Jul 20 16:45:09 2003 +0900 @@ -20,9 +20,10 @@ static int data_alignment = 0; static int code_disp_label; -static int code_setup; +static int disp_label; static int r1_offset_label; static int lvar_offset_label; +static int cprestore_label; static int reg_save; static int freg_save; @@ -61,7 +62,7 @@ #define DREG_VAR_BASE 29 #define DREG_VAR_MIN 18 #define MIN_TMP_DREG 4 -#define MAX_TMP_DREG 11 +#define MAX_TMP_DREG 17 #define PTRC_REG 3 @@ -197,16 +198,20 @@ /* + Reorder is automatically done in assembler. + delayed slot done within .set noreorder. + r0 return value etc. - r3-r10 input register + $2,$3 return value. (dpcmp return value on $2) + $0 special register + $4-$7 input register r22-r29 saved register variable (input register for code segement) - r30 stack pointer - r31 0 - r1 frame pointer + $31 stack pointer + $fp frame pointer - f0 return value etc. - f1-r8 input register - f24-f31 saved register variable + $f0 return value etc. + $f14,$f12 input register + $f20-$f31 saved register variable function call stack frame <------r1_offset------------------------------> @@ -450,7 +455,7 @@ code_dassign_lvar( (dreg_stack[i]=new_lvar(size_of_double)),reg,1); dreg_stack[i]= dreg_stack[i]-REG_LVAR_OFFSET; - return i; + return reg; } } /* clear integer register stack */ @@ -1083,31 +1088,31 @@ char * code_gt(int cond) { - return (cond?"\tslt %s,%s,%s\n\tbeq %s,$0,L%d\n": - "\tslt %s,%s,%s\n\tbne %s,$0,L%d\n"); + return (cond?"\tslt %s,%s,%s\n\tbeq %s,$0,L_%d\n": + "\tslt %s,%s,%s\n\tbne %s,$0,L_%d\n"); } char * code_ugt(int cond) { - return (cond?"\tsltu %s,%s,%s\n\tbeq %s,$0,L%d\n": - "\tsltu %s,%s,%s\n\tbne %s,$0,L%d\n"); + return (cond?"\tsltu %s,%s,%s\n\tbeq %s,$0,L_%d\n": + "\tsltu %s,%s,%s\n\tbne %s,$0,L_%d\n"); } char * code_ge(int cond) { - return (cond?"\tslt %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,L%d\n": - "\tslt %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,L%d\n"); + return (cond?"\tslt %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,L_%d\n": + "\tslt %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,L_%d\n"); } char * code_uge(int cond) { - return (cond?"\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,L%d\n": - "\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,L%d\n"); + return (cond?"\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,L_%d\n": + "\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,L_%d\n"); } char * code_eq(int cond) { - return (cond?"\tbeq %s,%s,L%d\n":"\tbne %s,%s,L%d\n"); + return (cond?"\tbeq %s,%s,L_%d\n":"\tbne %s,%s,L_%d\n"); } void @@ -1347,8 +1352,8 @@ free_register(creg); creg = dreg = reg; regs[dreg]=1; - regs[dreg_pair0[dreg]]=1; - regs[dreg_pair1[dreg]]=1; + regs[dreg_pair0[dreg-DREG_OFFSET]]=1; + regs[dreg_pair1[dreg-DREG_OFFSET]]=1; } } @@ -1968,10 +1973,12 @@ r1_offset_label = fwdlabel(); lvar_offset_label = fwdlabel(); + disp_label = fwdlabel(); mask_label = fwdlabel(); mask1_label = fwdlabel(); fmask_label = fwdlabel(); fmask1_label = fwdlabel(); + cprestore_label = fwdlabel(); printf("\t.frame $fp,L_%d,$31\n",r1_offset_label); printf("\t.mask L_%d,L_%d\n",mask_label,mask1_label); @@ -1980,8 +1987,8 @@ printf("\t.set noreorder\n"); printf("\t.cpload $25\n"); printf("\t.set reorder\n"); - printf("\tsubu $sp,$sp,L_%d\n",code_disp_label); - printf("\t.cprestore 16\n"); + printf("\tsubu $sp,$sp,L_%d\n",disp_label); + printf("\t.cprestore %d\n",cprestore_label); max_func_args = 0; } @@ -2007,68 +2014,66 @@ leave(int control, char *name) { int retcont1=0,sz; + int r1_offsetv; if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3; reg_save = reg_save_offset(); + freg_save = 0; if (control) { code_set_return_register(1); } if (retcont) { + /* return from CbC segement */ if (control) jmp(retlabel); retcont1 = fwdlabel(); fwddef(retcont); - if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) { - printf("\tfmr f1,f31\n"); + if (cadr(fnptr->ty)==FLOAT) { + if (freg!=RET_FREGISTER) + printf("\tmov.s %s,%s\n",register_name(RET_FREGISTER), + register_name(freg)); + } else if (cadr(fnptr->ty)==DOUBLE) { + move_dreg(RET_DREGISTER,dreg); } else if (cadr(fnptr->ty)>0&&( car(cadr(fnptr->ty))==STRUCT || car(cadr(fnptr->ty))==UNION)) { sz = size(cadr(fnptr->ty)); - printf("\tli r7,%d\n",sz); - printf("\tsubl r6,r7,r30\n"); - printf("\tlwz r3,lo16(%d)(r30)\n",(my_func_args-1)*size_of_int); + printf("\tli $4,%d\n",sz); + printf("\tsubl $5,$4,$fp\n"); + printf("\tlw $3,(%d)($fp)\n",(my_func_args-1)*size_of_int); emit_copy(6,3,sz,0,1,1); } else if (cadr(fnptr->ty)!=VOID) { - printf("\tmr r3,r29\n"); + if (creg!=RET_REGISTER) + printf("\tmove $3,%s\n",register_name(creg)); } -#if !R1SAVE - printf("\tla r1,lo16(%d)(r30)\n", - -reg_save+my_func_args*size_of_int); -#endif - printf("\tb L_%d\n",retcont1); + printf("\tj L_%d\n",retcont1); } fwddef(retlabel); - printf("\tlwz r1,0(r1)\n"); if (retcont) { fwddef(retcont1); } if (max_freg_var>=0) { - printf("\tlmw r%d,%d(r1)\n", - REG_VAR_BASE-max_reg_var,reg_save); - freg_save = 72-(REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*4; - printf("\tb restFP+%d ; restore f%d-f31\n", - freg_save, - FREG_VAR_BASE-max_freg_var); } else { - printf("\tlwz r0,8(r1)\n"); - printf("\tmtlr r0\n"); - printf("\tlmw r%d,%d(r1)\n", - REG_VAR_BASE-max_reg_var,reg_save); - printf("\tblr\n"); } + fprintf(asi,"L_%d=%d\n",r1_offset_label,0); + fprintf(asi,"L_%d=%d\n",lvar_offset_label,0); + fprintf(asi,"L_%d=%d\n",mask_label,0); + fprintf(asi,"L_%d=%d\n",mask1_label,0); + fprintf(asi,"L_%d=%d\n",fmask_label ,0); + fprintf(asi,"L_%d=%d\n",fmask1_label,0); + fprintf(asi,"L_%d=%d\n",cprestore_label ,0); disp &= -size_of_int; - fwddef(code_setup); - printf("\tstmw r%d,%d(r1)\n", - REG_VAR_BASE-max_reg_var,reg_save); - printf("\tstw r0,8(r1)\n"); - if (max_freg_var>=0) - printf("\tb saveFP+%d ; save f%d-f31\n", - freg_save, - FREG_VAR_BASE-max_freg_var); - else { - printf("\tblr\n"); - } + r1_offsetv = 0; + + printf("\tmove $sp,$fp\n"); + printf("\tlw $31,%d($sp)\n",-disp); + printf("\tlw $fp,%d($sp)\n",-disp-4); + printf("\taddu $sp,$sp,%d\n",r1_offsetv); + printf("\tj $31\n"); + printf("\t.end print\n"); + + fprintf(asi,"L_%d=%d\n",disp_label,-r1_offsetv); code_offset_set(); local_table(); @@ -2519,8 +2524,8 @@ void code_drlvar(int e2,int d,int freg) { if (d) { - printf("\tlw %s,\n",dregister_name0(freg)); lvar(e2); - printf("\tlw %s,\n",dregister_name1(freg)); lvar(e2+size_of_double/2); + printf("\tlw %s,",dregister_name0(freg)); lvar(e2); + printf("\tlw %s,",dregister_name1(freg)); lvar(e2+size_of_double/2); } else { printf("\tl.s %s,",fregister_name(freg)); lvar(e2); } @@ -2708,7 +2713,7 @@ set_dreg(RET_DREGISTER,0); printf("\tsw $2,0(%s)\n",crn); printf("\tsw $3,%d(%s)\n",size_of_int,crn); - free_register(freg); + free_register(dreg); set_dreg(g,0); creg = g; } else {