Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 809:476b53b61630 ps3-ppu-worked
PS3 PPU stdarg
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 24 Nov 2010 04:22:49 +0900 |
parents | 362b0258b4db |
children | 425768eb5e9e |
line wrap: on
line diff
--- a/mc-code-powerpc.c Tue Nov 23 23:39:41 2010 +0900 +++ b/mc-code-powerpc.c Wed Nov 24 04:22:49 2010 +0900 @@ -57,10 +57,57 @@ #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_arg(ap,type) (*((type *)__builtin_va_next((type),&ap)))\n\ +typedef struct __builtin_va_list { \\\n\ + long long_last; \\\n\ + long float_first; \\\n\ + long float_last; \\\n\ + long stack_top; \\\n\ + long arg; \\\n\ + long top; \\\n\ +} __builtin_va_list; \\\n\ + \\\n\ +#define __builtin_va_start(__ap0,v) \\\n\ +{ \\\n\ + __builtin_va_list *__ap = &__ap0; \\\n\ + long __top = __ap->top = (long)&__my_va_list; \\\n\ + __ap->long_last = __top +32; \\\n\ + __ap->float_first = __ap->long_last; \\\n\ + __ap->stack_top = __top+32+64+8; \\\n\ + long __adr = (long)(&v) + sizeof(v); \\\n\ + if (__adr >= __ap->stack_top) __ap->arg = __ap->float_first = __adr; \\\n\ + if (__builtin_types_compatible_p(typeof(v),double)) \\\n\ + __ap->float_first = __adr; \\\n\ + __ap->arg = __adr; \\\n\ +} \\\n\ +\n\ +#define __builtin_va_arg(__ap0,type) ({ \\\n\ + __builtin_va_list *__ap = &__ap0; \\\n\ + long __arg; \\\n\ + if (__builtin_types_compatible_p(type,double) \\\n\ + && __ap->float_first < __ap->stack_top) { \\\n\ + __arg = __ap->float_first; \\\n\ + __ap->float_first = __ap->float_first+8; \\\n\ + if (__ap->float_first==__ap->float_last) \\\n\ + __ap->float_first = __ap->stack_top;\\\n\ + } else { \\\n\ + if (__builtin_types_compatible_p(type,long long)) { \\\n\ + if (__ap->arg==__ap->top+4) __ap->arg += 4; \\\n\ + __arg = __ap->arg; \\\n\ + __ap->arg += 8; \\\n\ + if (__ap->arg==__ap->top+16+16) \\\n\ + __ap->arg = __ap->stack_top; \\\n\ + } else { \\\n\ + __arg = __ap->arg; \\\n\ + __ap->arg = __ap->arg+sizeof(type); \\\n\ + if (__ap->arg==__ap->long_last) \\\n\ + __ap->arg = __ap->stack_top; \\\n\ + } \\\n\ + } \\\n\ + *((type *)(__arg)); \\\n\ +}) \\\n\ +\n" + +"// #define __builtin_va_arg(ap,type) (*((type *)__builtin_va_next((type),&ap)))\n\ #define alloca __builtin_alloca\n\ #define __DBL_MIN_EXP__ (-1021)\n\ #define __FLT_MIN__ 1.17549435e-38F\n\ @@ -792,9 +839,17 @@ int dots; arg_offset_v = 0; + function_type(fnptr->ty,&dots); + + if (dots && (in || !parse_mode)) { + type = INT; + mode = LDECL; + stmode = 0; + n = def(lsearch("__my_va_list",0),0); + n->dsp = 0; // first argument + } if (in) return; - function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ n = ncadddr(args); @@ -4054,22 +4109,24 @@ int align = 1; if ((align=attr_value(n,ALIGNED))) { align = ilog(caddr(align)); - } else if (size(n->ty)>4) - align = 2; - else if (size(n->ty)>4) - align = 0; - switch(n->ty) { - case DOUBLE: - case LONGLONG: - case ULONGLONG: - align = 8; break; - case INT: - case UNSIGNED: - case FLOAT: - align = 4; break; - case SHORT: - case USHORT: - align = 2; break; + } else { + if (size(n->ty)>4) + align = 2; + else if (size(n->ty)>4) + align = 0; + switch(n->ty) { + case DOUBLE: + case LONGLONG: + case ULONGLONG: + align = 8; break; + case INT: + case UNSIGNED: + case FLOAT: + align = 4; break; + case SHORT: + case USHORT: + align = 2; break; + } } printf("\t.comm %s,%d,%d\n",n->nm,size(n->ty),align); } @@ -4080,6 +4137,7 @@ NMTBL *n; int init; init=0; + global_list = reversen(global_list); for(n=global_list;n;n=n->next) { if ((n->sc == GVAR) && n->dsp != -1) { /* n->dsp = -1 means initialized global */