Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 673:442e90958386 ppc-almost-done
PS3 PPc almot done...
author | kono |
---|---|
date | Sat, 05 May 2007 08:10:56 +0900 |
parents | 3f559c67bc86 |
children | 68d70527b0c0 |
line wrap: on
line diff
--- a/mc-code-powerpc.c Sat May 05 03:39:29 2007 +0900 +++ b/mc-code-powerpc.c Sat May 05 08:10:56 2007 +0900 @@ -57,9 +57,13 @@ #define __extension__\n\ #define __const const\n\ #define __inline__ inline\n\ -#define __builtin_va_list int\n\ -#define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\ -#define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\ +#define __builtin_va_list struct __vv {int *p; double *d;}\n\ +#define __builtin_va_start(ap,arg) (ap.p=(((int)(&arg))+sizeof(arg)),\ + (ap.d=(double*)(ap.p+7)))\n\ +#define __builtin_va_arg(ap,type) \ + ((!__builtin_type_is_float(type))?\ + (*((type *)ap.p)++):\ + ((type)(*(ap.d++))))\n\ #define alloca __builtin_alloca\n\ #define __DBL_MIN_EXP__ (-1021)\n\ #define __FLT_MIN__ 1.17549435e-38F\n\ @@ -686,29 +690,29 @@ if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */ if (LARGE_OFFSET(CODE_CALLER_ARG(l-ARG_LVAR_OFFSET))) { rn=register_name(large_offset_reg=get_register()); - printf("\tla %s,1,%d@ha\n",rn, + printf("\taddis %s,1,%d@ha\n",rn, CODE_CALLER_ARG(l-ARG_LVAR_OFFSET)); } } else { if (LARGE_OFFSET(CODE_LVAR(l))) { rn=register_name(large_offset_reg=get_register()); - printf("\tla %s,%d,%d@ha\n",rn,REG_fp,CODE_LVAR(l)); + printf("\taddis %s,%d,%d@ha\n",rn,REG_fp,CODE_LVAR(l)); } } } else if (l<0) { /* local variable */ if (LARGE_OFFSET(FUNC_LVAR(l))) { rn=register_name(large_offset_reg=get_register()); - printf("\tla %s,%d,%d@ha\n",rn,REG_fp,FUNC_LVAR(l)); + printf("\taddis %s,%d,%d@ha\n",rn,REG_fp,FUNC_LVAR(l)); } } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */ if (LARGE_OFFSET(CALLER_ARG(l-ARG_LVAR_OFFSET))) { rn=register_name(large_offset_reg=get_register()); - printf("\tla %s,1,%d@ha\n",rn,CALLER_ARG(l-ARG_LVAR_OFFSET)); + printf("\taddis %s,1,%d@ha\n",rn,CALLER_ARG(l-ARG_LVAR_OFFSET)); } } else { /* callee's arguments */ if (LARGE_OFFSET(CALLEE_ARG(l))) { rn=register_name(large_offset_reg=get_register()); - printf("\tla %s,%d,%d+%s%d@ha\n", + printf("\taddis %s,%d,%d+%s%d@ha\n", rn,REG_fp,CALLEE_ARG(l),lpfx,lvar_offset_label); } } @@ -824,6 +828,11 @@ if (is_function(fnptr)) { code_save_input_registers(dots); #ifndef __APPLE__ + if (dots) { + arg_offset_v = + (MAX_TMP_REG -MIN_TMP_REG )*SIZE_OF_INT + + (MAX_TMP_FREG +MIN_TMP_FREG)*SIZE_OF_DOUBLE; + } printf(".set %s%d, %d\n",lpfx, arg_offset_label,arg_offset_v); #endif } @@ -1096,8 +1105,8 @@ i = REG_VAR_BASE-i; } else { if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0; + if (i%2==1) i++; i = i+MIN_TMP_REG; - if (i%2==1) i++; } ll = get_lregister1(i,i+1); #if ENDIAN_L==0 @@ -1813,7 +1822,9 @@ inc_cmpflag() { // gcc use cmpflag 4 and 7, and gcc4 believes flag 4 is preserved. - // cmpflag = (cmpflag+1)%8; + do { + cmpflag = (cmpflag+1)%8; + } while (cmpflag!=4 && cmpflag!=7); } #ifdef __APPLE__ @@ -2203,6 +2214,18 @@ offset+=SIZE_OF_INT; reg_var++; } +#ifndef __APPLE__ + int skip = fwdlabel(); + int freg_var = 0; + printf("\tbne 1,%s%d\n",lpfx,skip); + while ((reg = get_input_dregister_var(freg_var,0,0,1))) { + g_expr_u(assign_expr0( + list3(LVAR,offset,0),reg,DOUBLE,DOUBLE)); + offset+=SIZE_OF_DOUBLE; + freg_var++; + } + fwddef(skip); +#endif } my_func_args = offset; } @@ -2615,10 +2638,13 @@ } clear_ptr_cache(); #ifndef __APPLE__ - if (dots && freg_arg) { + if (dots) { + if (freg_arg) { // variadic function has floating value in register - printf("\tcreqv 6,6,6\n"); - // printf("\tcrxor 6,6,6\n"); for value in stack + printf("\tcreqv 6,6,6\n"); + } else { + // printf("\tcrxor 6,6,6\n"); // for value in stack + } } #endif if (car(e2) == FNAME) { @@ -4351,18 +4377,13 @@ ".text", " .align 2", "i2d_:", -" mflr 0", -" bcl 20,31,__i2dL1$pb", -"__i2dL1$pb:", -" mflr 10", -" mtlr 0", " xoris 3,3,0x8000", " stw 3,-28(1)", " lis 0,0x4330", " stw 0,-32(1)", " lfd 0,-32(1)", -" addis 9,10,__i2dLC0-__i2dL1$pb@ha", -" lfd 1,__i2dLC0-__i2dL1$pb@l(9)", +" lis 9,__i2dLC0@ha", +" lfd 1,__i2dLC0@l(9)", " fsub 1,0,1", " blr", 0 @@ -4426,13 +4447,8 @@ ".text", " .align 2", "d2u_:", -" mflr 0", -" bcl 20,31,__d2uL1$pb", -"__d2uL1$pb:", -" mflr 10", -" mtlr 0", -" addis 9,10,__d2uLC0-__d2uL1$pb@ha", -" lfd 0,__d2uLC0-__d2uL1$pb@l(9)", +" lis 9,__d2uLC0@ha", +" lfd 0,__d2uLC0@l(9)", " fcmpu 0,1,0", " cror 2,1,2", " beq- 0,__d2uL2", @@ -4441,8 +4457,8 @@ " lwz 3,-28(1)", " blr", "__d2uL2:", -" addis 9,10,__d2uLC0-__d2uL1$pb@ha", -" lfd 0,__d2uLC0-__d2uL1$pb@l(9)", +" lis 9,__d2uLC0@ha", +" lfd 0,__d2uLC0@l(9)", " fsub 0,1,0", " fctiwz 0,0", " stfd 0,-24(1)", @@ -4501,7 +4517,14 @@ " .long 0", ".text", " .align 2", -"u2d_:", +".u2d_:", +" stw 3,-28(1)", +" lis 0,0x4330", +" stw 0,-32(1)", +" lfd 0,-32(1)", +" lis 9,__u2dLC1@ha", +" lfd 1,__u2dLC1@l(9)", +" fsub 1,0,1", " blr", 0 }; @@ -4514,7 +4537,11 @@ clear_ptr_cache(); u2d_lib_used = 1; set_ireg(RET_REGISTER,1); +#ifdef __APPLE__ printf("\tbl u2d_\n"); +#else + printf("\tbl .u2d_\n"); +#endif set_freg(RET_FREGISTER,0); } @@ -5203,25 +5230,25 @@ ".lsrd__:", " mr. 5,5", " beqlr", -" subfic 2,5,32", +" subfic 8,5,32", " stw 3,-32(1)", " stw 4,-28(1)", -" cmpwi 7,2,0", +" cmpwi 7,8,0", " bgt+ 7,.L__lsrd1", " neg 0,2", -" lwz 2,-32(1)", +" lwz 8,-32(1)", " li 9,0", -" srw 2,2,0", +" srw 8,8,0", " stw 9,-48(1)", " b .L__lsrd2", ".L__lsrd1: lwz 0,-32(1)", -" slw 9,0,2", -" lwz 2,-28(1)", +" slw 9,0,8", +" lwz 8,-28(1)", " srw 0,0,5", -" srw 2,2,5", +" srw 8,8,5", " stw 0,-48(1)", -" or 2,2,9", -".L__lsrd2: stw 2,-44(1)", +" or 8,8,9", +".L__lsrd2: stw 8,-44(1)", " lwz 3,-48(1)", " lwz 4,-44(1)", " blr", @@ -5265,25 +5292,25 @@ ".asld__:", " mr. 5,5", " beqlr", -" subfic 2,5,32", +" subfic 8,5,32", " stw 3,-32(1)", " stw 4,-28(1)", -" cmpwi 7,2,0", +" cmpwi 7,8,0", " bgt+ 7,.L__asld1", -" neg 0,2", -" lwz 2,-28(1)", +" neg 0,8", +" lwz 8,-28(1)", " li 9,0", -" slw 2,2,0", +" slw 8,8,0", " stw 9,-44(1)", " b .L__asld2", ".L__asld1: lwz 0,-28(1)", -" srw 9,0,2", -" lwz 2,-32(1)", +" srw 9,0,8", +" lwz 8,-32(1)", " slw 0,0,5", -" slw 2,2,5", +" slw 8,8,5", " stw 0,-44(1)", -" or 2,2,9", -".L__asld2: stw 2,-48(1)", +" or 8,8,9", +".L__asld2: stw 8,-48(1)", " lwz 3,-48(1)", " lwz 4,-44(1)", " blr", @@ -5326,24 +5353,24 @@ ".asrd__:", " mr. 5,5", " beqlr", -" subfic 2,5,32", +" subfic 8,5,32", " stw 3,-32(1)", " stw 4,-28(1)", -" cmpwi 7,2,0", +" cmpwi 7,8,0", " bgt+ 7,.L__asrd1", " lwz 0,-32(1)", -" neg 2,2", -" sraw 2,0,2", +" neg 8,8", +" sraw 8,0,8", " srawi 0,0,31", " b .L__asrd2", ".L__asrd1: lwz 0,-32(1)", -" slw 9,0,2", -" lwz 2,-28(1)", +" slw 9,0,8", +" lwz 8,-28(1)", " sraw 0,0,5", -" srw 2,2,5", -" or 2,2,9", +" srw 8,8,5", +" or 8,8,9", ".L__asrd2: stw 0,-48(1)", -" stw 2,-44(1)", +" stw 8,-44(1)", " lwz 3,-48(1)", " lwz 4,-44(1)", " blr",