Mercurial > hg > CbC > old > device
changeset 796:80a59598df5f
ia64 stdarg
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 23 Nov 2010 17:45:40 +0900 |
parents | a4fd2ab28e24 |
children | e2f7680a574a |
files | mc-code-i64.c test/tstdarg.c |
diffstat | 2 files changed, 21 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-i64.c Tue Nov 23 12:45:22 2010 +0900 +++ b/mc-code-i64.c Tue Nov 23 17:45:40 2010 +0900 @@ -52,7 +52,7 @@ #define __builtin_va_start(ap,v) \\\n\ { \\\n\ ap = &__my_va_list; \\\n\ - ap->float_first = ap->long_last+8; \\\n\ + ap->float_first = ap->long_last-8; \\\n\ long adr = (long)&v; \\\n\ if (adr >= ap->stack_top) ap->arg = ap->float_first = adr; \\\n\ if (__builtin_types_compatible_p(typeof(v),double)) \\\n\ @@ -1243,14 +1243,17 @@ int stype = type; int smode = mode; int sstmode = stmode; - - NMTBL *nptr =name_space_search(get_name("__builtin_va_list1",0,NONDEF),0); - if (!nptr) error(-1); - type = nptr->ty; - typedefed=glist3n(TYPEDEF,typedefed,nptr); - mode = LDECL; - stmode = 0; - NMTBL *n = def(lsearch("__my_va_list",0),0); + NMTBL *n; + + if (!parse_mode || inmode) { + NMTBL *nptr =name_space_search(get_name("__builtin_va_list1",0,NONDEF),0); + if (!nptr) error(-1); + type = nptr->ty; + typedefed=glist3n(TYPEDEF,typedefed,nptr); + mode = LDECL; + stmode = 0; + n = def(lsearch("__my_va_list",0),0); + } // ssetup va_list structure // __my_va_list is defined as local in code_arg_register @@ -1261,19 +1264,19 @@ long float_last; \n\ long stack_top; \n\ */ - if (inmode) { + if (parse_mode && inmode) { parse = list5n(ST_DECL,parse,list3(mode,0,0),0,n); // long_last - parse = list3(ST_COMP,parse,assign_expr0( list3n(LVAR,n->dsp,n),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,FUNC_LVAR(long_last))),LONGLONG,LONGLONG)); + parse = list3(ST_COMP,parse,assign_expr0( list3n(IVAR,n->dsp,n),list2(ADDRESS,list3n(LVAR,long_last,0)),LONGLONG,LONGLONG)); // float_last - parse = list3(ST_COMP,parse,assign_expr0( list3(ADD,list3n(LVAR,n->dsp,n),list2(CONST,16)),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,FUNC_LVAR(float_last))),LONGLONG,LONGLONG)); + parse = list3(ST_COMP,parse,assign_expr0( list3(LADD,list3n(IVAR,n->dsp,n),llist2(LCONST,16)),list2(ADDRESS,list3n(LVAR,float_last,0)),LONGLONG,LONGLONG)); // stack_top - parse = list3(ST_COMP,parse,assign_expr0( list3(ADD,list3n(LVAR,n->dsp,n),list2(CONST,24)),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,16)),LONGLONG,LONGLONG)); - } else { + parse = list3(ST_COMP,parse,assign_expr0( list3(LADD,list3n(IVAR,n->dsp,n),llist2(LCONST,24)),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,16)),LONGLONG,LONGLONG)); + } else if (!parse_mode && !inmode) { // long_last - g_expr_u(assign_expr0( list3n(LVAR,n->dsp,n),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,FUNC_LVAR(long_last))),LONGLONG,LONGLONG)); + g_expr_u(assign_expr0( list3n(LVAR,n->dsp,n),list2(ADDRESS,list3n(LVAR,long_last,0)),LONGLONG,LONGLONG)); // float_last - g_expr_u(assign_expr0( list3n(LVAR,n->dsp+16,n),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,FUNC_LVAR(float_last))),LONGLONG,LONGLONG)); + g_expr_u(assign_expr0( list3n(LVAR,n->dsp+16,n),list2(ADDRESS,list3n(LVAR,float_last,0)),LONGLONG,LONGLONG)); // stack_top g_expr_u(assign_expr0( list3n(LVAR,n->dsp+24,n),list3(LADD,list2(LREGISTER,REG_EBP),llist2(LCONST,16)),LONGLONG,LONGLONG)); } @@ -1352,8 +1355,8 @@ MAX_INPUT_REGISTER_VAR*SIZE_OF_LONGLONG + MAX_INPUT_DREGISTER_VAR*SIZE_OF_DOUBLE; - int long_last = -arg_offset_v + reg_var*SIZE_OF_LONGLONG; - int float_last = long_last + freg_var*SIZE_OF_LONGLONG; + int long_last = -arg_offset_v + (MAX_INPUT_REGISTER_VAR)*SIZE_OF_LONGLONG; + int float_last = long_last + (MAX_INPUT_DREGISTER_VAR)*SIZE_OF_DOUBLE; def_va_list_truct(long_last,float_last); #ifndef __APPLE__
--- a/test/tstdarg.c Tue Nov 23 12:45:22 2010 +0900 +++ b/test/tstdarg.c Tue Nov 23 17:45:40 2010 +0900 @@ -15,22 +15,10 @@ va_list ap; va_start(ap,numtypes); - -printf("__my_va_list.long_last = %llx\n", __my_va_list.long_last); -printf("__my_va_list.float_first = %llx\n", __my_va_list.float_first); -printf("__my_va_list.float_last = %llx\n", __my_va_list.float_last); -printf("__my_va_list.stack_top = %llx\n", __my_va_list.stack_top); -printf("__my_va_list.arg = %llx\n", __my_va_list.arg); - while((t= *numtypes++)) { if (t=='i') { i = va_arg(ap,int); printf("#0021:int arg: %d\n",i); -printf("__my_va_list.long_last = %llx\n", __my_va_list.long_last); -printf("__my_va_list.float_first = %llx\n", __my_va_list.float_first); -printf("__my_va_list.float_last = %llx\n", __my_va_list.float_last); -printf("__my_va_list.stack_top = %llx\n", __my_va_list.stack_top); -printf("__my_va_list.arg = %llx\n", __my_va_list.arg); #if 0 /* ‘float’ is promoted to ‘double’ when passed through ‘...’ */ } else if (t=='f') {