Mercurial > hg > CbC > old > device
changeset 763:3c09f0b8b377
stack 16 alignment
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 17 Nov 2010 18:29:40 +0900 |
parents | 236d49777503 |
children | 742d9fcb778e |
files | mc-code-i64.c |
diffstat | 1 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-i64.c Wed Nov 17 16:22:51 2010 +0900 +++ b/mc-code-i64.c Wed Nov 17 18:29:40 2010 +0900 @@ -567,8 +567,12 @@ #endif int code_f = is_code(fnptr); int lvar_offsetv = round16(-disp); - int r1_offsetv = round16(lvar_offsetv+max_func_args*SIZE_OF_INT+func_disp_offset)+8; - + int r1_offsetv = round16(lvar_offsetv+max_func_args*SIZE_OF_INT+func_disp_offset); + + if (max_reg_var>=0 && (max_reg_var)%2==0) { + // pushq makes rsp%8==8, make it round16 + r1_offsetv += 8; + } if (code_f) { printf("\t.set _%d,%d\n",code_disp_label,r1_offsetv); } else { @@ -2969,7 +2973,7 @@ code_register_pop() { int i = max_reg_var; - for(;i>0;i--) { + for(;i>=0;i--) { printf("\tpopq %s\n", register_name(REG_VAR_BASE-i,0)); } } @@ -2978,7 +2982,7 @@ code_register_push() { int i = 0; - for(;i<max_reg_var;i++) { + for(;i<=max_reg_var;i++) { printf("\tpushq %s\n", register_name(REG_VAR_BASE-i,0)); } } @@ -2989,7 +2993,7 @@ #ifdef __APPLE__ disp &= -(SIZE_OF_INT*4); // 16byte alignment - disp -= 12; + // disp -= 12; #else disp &= -SIZE_OF_INT; #endif @@ -3003,7 +3007,7 @@ fwddef(retlabel); int r1_offset = code_offset_set(fnptr); - printf("\tleaq %d(%%rbp),%%rsp\n",-12); + printf("\tleaq %d(%%rbp),%%rsp\n",max_reg_var<0?0:-(max_reg_var+1)*SIZE_OF_LONGLONG); code_register_pop(); printf("\tleave\n"); printf("\tret\n"); @@ -3619,7 +3623,12 @@ lb=fwdlabel(); printf("_%d:\n",lb); #if ENDIAN_D==0 - printf("\t.long\t0x%x,0x%x\n",code_d1(value),code_d2(value)); + if (d) + printf("\t.long\t0x%x,0x%x\n",code_d1(value),code_d2(value)); + else { + float f = (float) value; + printf("\t.long\t0x%x\n",*(unsigned *)(&f)); + } #endif if (output_mode==TEXT_EMIT_MODE) { printf(".text\n"); @@ -3627,9 +3636,9 @@ text_mode(0); } #ifdef __APPLE__ - printf("\tmovsd _%d(%%rip),%s\n",lb,fregister_name(freg)); + printf("\tmovs%s _%d(%%rip),%s\n",d?"d":"s",lb,fregister_name(freg)); #else - printf("\tmovsd _%d,%s\n",lb,fregister_name(freg)); + printf("\tmovs%s _%d,%s\n",d?"d":"s",lb,fregister_name(freg)); #endif }