Mercurial > hg > CbC > old > device
changeset 305:117baacd1ed0
stdarg powerpc passed except long long (macro problem)
author | kono |
---|---|
date | Wed, 09 Jun 2004 15:18:32 +0900 |
parents | 9df8aa0497ea |
children | 1ec915dcd2d1 |
files | Changes mc-code-mips.c mc-code-powerpc.c mc-codegen.c mc-codegen.h mc-parse.c test/tstdarg.c |
diffstat | 7 files changed, 84 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Tue Jun 08 16:40:32 2004 +0900 +++ b/Changes Wed Jun 09 15:18:32 2004 +0900 @@ -4839,3 +4839,17 @@ getch が null を返すのを認めれば良いんだけど、他のところの 影響が大きい。 +## l = va_arg(ap,long long); +## (*((longlong *)ap)++) + +うーん。macro 関係か。space 除いているの誰だろう? + +あ、そうか、register 上の引数は、varargs の場合は、 +すべてメモリに入れないといけないわけね。じゃぁ、 +浮動小数点か整数かはどうやって判断するの? + +Wed Jun 9 10:14:35 JST 2004 + +切符買わないと。なんか、関数の引数の型のチェックをしてない +みたい。 +
--- a/mc-code-mips.c Tue Jun 08 16:40:32 2004 +0900 +++ b/mc-code-mips.c Wed Jun 09 15:18:32 2004 +0900 @@ -270,7 +270,7 @@ #endif static void code_save_stacks(); -static void code_save_input_registers(); +static void code_save_input_registers(int dots); static void clear_ptr_cache_reg(int r); static void set_ireg(int,int); static void set_dreg(int,int); @@ -496,7 +496,9 @@ int reg; int i; int is_code0 = is_code(fnptr); - + int dots; + + function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ n = (NMTBL*)caddr(args); @@ -541,7 +543,7 @@ args = cadr(args); } if (is_function(fnptr)) - code_save_input_registers(); + code_save_input_registers(dots); } @@ -1737,7 +1739,7 @@ } void -code_save_input_registers() +code_save_input_registers(int dots) { int args; NMTBL *n; @@ -1747,6 +1749,7 @@ /* fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); */ int reg_offset = 0; int offset = 0; + int reg_var = 0; for(args = fnptr->dsp;args;args = cadr(args)) { n = (NMTBL *)caddr(args); @@ -1758,6 +1761,7 @@ n->dsp = offset; offset+=SIZE_OF_INT; t = INT; + reg_var++; } else if (tag==FREGISTER) { /* regs[reg]==INPUT_REG case should be considered */ n->dsp = offset; @@ -1770,16 +1774,19 @@ } // else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; reg_offset+=2; } else error(-1); + reg_var++; } else if (tag==DREGISTER) { /* regs[reg]==INPUT_REG case should be considered */ n->dsp = offset; t = n->ty; offset+=SIZE_OF_DOUBLE; reg_offset+=2; + reg_var += 2; } else if (tag==LREGISTER) { /* regs[reg]==INPUT_REG case should be considered */ n->dsp = offset; t = n->ty; offset+=SIZE_OF_LONGLONG; reg_offset+=2; + reg_var += 2; } else { offset += size(n->ty); continue; @@ -1790,6 +1797,14 @@ free_register(reg); } } + if (dots) { + while ((reg = get_input_register_var(reg_var,0,0))) { + g_expr_u(assign_expr0( + list2(LVAR,offset),reg,INT,INT)); + offset+=SIZE_OF_INT; + reg_var++; + } + } my_func_args = offset; }
--- a/mc-code-powerpc.c Tue Jun 08 16:40:32 2004 +0900 +++ b/mc-code-powerpc.c Wed Jun 09 15:18:32 2004 +0900 @@ -230,7 +230,7 @@ #endif static void code_save_stacks(); -static void code_save_input_registers(); +static void code_save_input_registers(int dots); static void clear_ptr_cache_reg(int r); static void set_ireg(int,int); static void set_freg(int,int); @@ -396,6 +396,8 @@ #define __BIG_ENDIAN__ 1\n\ #define __STDC__ 1\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\ "; void @@ -453,7 +455,9 @@ int reg; int i; int is_code0 = is_code(fnptr); - + int dots; + + function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ n = (NMTBL*)caddr(args); @@ -496,7 +500,7 @@ args = cadr(args); } if (is_function(fnptr)) - code_save_input_registers(); + code_save_input_registers(dots); } @@ -1713,7 +1717,7 @@ } void -code_save_input_registers() +code_save_input_registers(int dots) { int args; NMTBL *n; @@ -1724,6 +1728,7 @@ /* fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); */ int reg_offset = 0; int offset = 0; + int reg_var = 0; for(args = fnptr->dsp;args;args = cadr(args)) { n = (NMTBL *)caddr(args); @@ -1736,6 +1741,7 @@ offset+=SIZE_OF_INT; t = INT; reg += reg_offset; /* for duplicated floating point argument */ + reg_var++; } else if (tag==DREGISTER) { /* regs[reg]==INPUT_REG case should be considered */ n->dsp = offset; @@ -1743,22 +1749,33 @@ if(t==FLOAT) { offset+=SIZE_OF_FLOAT; reg_offset+=1; } else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; reg_offset+=2; } else error(-1); + reg_var += 2; } else if (tag==LREGISTER) { /* regs[reg]==INPUT_REG case should be considered */ n->dsp = offset; t = n->ty; offset+=SIZE_OF_LONGLONG; reg_offset+=2; + reg_var += 2; } else { offset += size(n->ty); continue; } n->sc = LVAR; lvar = list2(LVAR,n->dsp); - g_expr_u(assign_expr0(list2(LVAR,n->dsp),list3(tag,reg,(int)n),n->ty,t)); + g_expr_u(assign_expr0( + list2(LVAR,n->dsp),list3(tag,reg,(int)n),n->ty,t)); if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) { free_register(reg); } } + if (dots) { + while ((reg = get_input_register_var(reg_var,0,0))) { + g_expr_u(assign_expr0( + list2(LVAR,offset),reg,INT,INT)); + offset+=SIZE_OF_INT; + reg_var++; + } + } my_func_args = offset; } @@ -1918,6 +1935,7 @@ int stargs; special_lvar = -1; +#if 0 ret_type = cadr(cadddr(e1)); if (ret_type==CHAR) ret_type=INT; @@ -1930,6 +1948,9 @@ if (car(t)==DOTS) dots = 1; } } +#else + ret_type = function_type(cadddr(e1),&dots); +#endif arg_assign = 0; e2 = cadr(e1);
--- a/mc-codegen.c Tue Jun 08 16:40:32 2004 +0900 +++ b/mc-codegen.c Wed Jun 09 15:18:32 2004 +0900 @@ -650,6 +650,25 @@ return type==FUNCTION || (type>0 && car(type)==FUNCTION); } +int +function_type(int e1,int *dots) +{ + int ret_type,t; + ret_type = cadr(e1); + if (ret_type==CHAR) ret_type=INT; + + /* check argments type is DOTS? */ + t = caddr(e1); + if (t==0 || t==DOTS) *dots = 1; + else { + *dots = 0; + for(;t;t = cadr(t)) { + if (car(t)==DOTS) *dots = 1; + } + } + + return ret_type; +} static int register_to_lvar(int e)
--- a/mc-codegen.h Tue Jun 08 16:40:32 2004 +0900 +++ b/mc-codegen.h Wed Jun 09 15:18:32 2004 +0900 @@ -27,6 +27,7 @@ extern int is_code(NMTBL *fnptr); extern int is_function(NMTBL *fnptr); +extern int function_type(int e1,int *dots); extern void parallel_rassign(int list); extern int csvalue();
--- a/mc-parse.c Tue Jun 08 16:40:32 2004 +0900 +++ b/mc-parse.c Wed Jun 09 15:18:32 2004 +0900 @@ -4422,7 +4422,7 @@ chptr=chinput; while((c=*chinput++)&&(c!='\n')); if (lsrc && !asmf && !macro_if_skip) gen_comment(chinput); - if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) { + if (*chptr== '#' && !in_comment && !in_quote) { if (macro_processing()) return; } } else {
--- a/test/tstdarg.c Tue Jun 08 16:40:32 2004 +0900 +++ b/test/tstdarg.c Wed Jun 09 15:18:32 2004 +0900 @@ -20,13 +20,11 @@ if (t=='i') { i = va_arg(ap,int); printf("int arg: %d\n",i); +#if 0 } else if (t=='f') { -#if 0 f = va_arg(ap,float); -#ele - f = va_arg(ap,double); + printf("float arg: %g\n",f); #endif - printf("float arg: %g\n",f); } else if (t=='d') { d = va_arg(ap,double); printf("double arg: %g\n",d); @@ -49,7 +47,9 @@ var_args("iiiiii",1,2,3,4,5,6); var_args("llllll",(long long)1,(long long)2,(long long)3,(long long)4,(long long)5,(long long)6); +#if 0 var_args("ffffff",(float)1,(float)2,(float)3,(float)4,(float)5,(float)6); +#endif var_args("dddddd",(double)1,(double)2,(double)3,(double)4,(double)5,(double)6); var_args("ssssss","1","2","3","4","5","6");