comparison mc-code-arm.c @ 638:35014112c01d

multi dimentional array in functional arugments. (not yet fixed)
author kono
date Tue, 31 Oct 2006 22:40:19 +0900
parents 140b65f8ff03
children cddab906095e
comparison
equal deleted inserted replaced
637:140b65f8ff03 638:35014112c01d
2438 nargs ++ ; reg_arg++; 2438 nargs ++ ; reg_arg++;
2439 nargs ++ ; reg_arg++; 2439 nargs ++ ; reg_arg++;
2440 } else if (t==FLOAT) { 2440 } else if (t==FLOAT) {
2441 reg_arg ++ ; freg_arg++; 2441 reg_arg ++ ; freg_arg++;
2442 nargs += size(t)/SIZE_OF_INT; 2442 nargs += size(t)/SIZE_OF_INT;
2443 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION||car(t)==ARRAY)) { 2443 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
2444 nargs += round4(size(t))/SIZE_OF_INT; 2444 nargs += round4(size(t))/SIZE_OF_INT;
2445 } else { 2445 } else {
2446 error(TYERR); 2446 error(TYERR);
2447 nargs ++ ; 2447 nargs ++ ;
2448 } 2448 }
2483 return get_dregister_var(0,1); 2483 return get_dregister_var(0,1);
2484 } else if (reg_arg+1>=MAX_INPUT_DREGISTER_VAR) { 2484 } else if (reg_arg+1>=MAX_INPUT_DREGISTER_VAR) {
2485 return list3(LVAR,caller_arg_offset_v(nargs),0); 2485 return list3(LVAR,caller_arg_offset_v(nargs),0);
2486 } else 2486 } else
2487 return get_input_dregister_var(reg_arg,0,0,1); 2487 return get_input_dregister_var(reg_arg,0,0,1);
2488 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION||car(t)==ARRAY)) { 2488 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
2489 if (mode==AS_SAVE) { 2489 if (mode==AS_SAVE) {
2490 return get_register_var(0); 2490 return get_register_var(0);
2491 } else 2491 } else
2492 return list3(LVAR,caller_arg_offset_v(nargs),0); 2492 return list3(LVAR,caller_arg_offset_v(nargs),0);
2493 } else { 2493 } else {
2563 } 2563 }
2564 // memorise last complex arg parameter 2564 // memorise last complex arg parameter
2565 pnargs=nargs;preg_arg=reg_arg;pfreg_arg=freg_arg; 2565 pnargs=nargs;preg_arg=reg_arg;pfreg_arg=freg_arg;
2566 complex_ = e3; 2566 complex_ = e3;
2567 } 2567 }
2568 if (t>=0&&(car(t)==STRUCT||car(t)==UNION||car(t)==ARRAY)) { 2568 if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
2569 // The struct should be pushed after complex arguments. 2569 // The struct should be pushed after complex arguments.
2570 if (e5) { // compute address only, complex_ is me now. Clear it. 2570 if (e5) { // compute address only, complex_ is me now. Clear it.
2571 complex_ = 0; 2571 complex_ = 0;
2572 e4 = car(e3); 2572 e4 = car(e3);
2573 if (car(e4)!=RSTRUCT && car(e4)!=ARRAY) error(-1); 2573 if (car(e4)!=RSTRUCT) error(-1);
2574 if (!simple_arg(cadr(e4))) { 2574 if (!simple_arg(cadr(e4))) {
2575 // Calculate complex struct address here. 2575 // Calculate complex struct address here.
2576 // If simple, leave it. 2576 // If simple, leave it.
2577 arg = get_register_var(0); 2577 arg = get_register_var(0);
2578 g_expr_u(assign_expr0(arg,list2(ADDRESS,car(e3)),INT,INT)); 2578 g_expr_u(assign_expr0(arg,list2(ADDRESS,car(e3)),INT,INT));
3479 creg = lreg = cadr(get_input_dregister_var(0,0,1,1)); 3479 creg = lreg = cadr(get_input_dregister_var(0,0,1,1));
3480 set_dreg(RET_DREGISTER,1); 3480 set_dreg(RET_DREGISTER,1);
3481 #endif 3481 #endif
3482 } else if (cadr(fnptr->ty)>0&&( 3482 } else if (cadr(fnptr->ty)>0&&(
3483 car(cadr(fnptr->ty))==STRUCT || 3483 car(cadr(fnptr->ty))==STRUCT ||
3484 car(cadr(fnptr->ty))==UNION || 3484 car(cadr(fnptr->ty))==UNION)) {
3485 car(cadr(fnptr->ty))==ARRAY)) {
3486 sz = size(cadr(fnptr->ty)); 3485 sz = size(cadr(fnptr->ty));
3487 inc_inst(3); 3486 inc_inst(3);
3488 code_const(sz,REGISTER_OPERAND); 3487 code_const(sz,REGISTER_OPERAND);
3489 printf("\tsub\tr1, r2, fp\n"); 3488 printf("\tsub\tr1, r2, fp\n");
3490 printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT); 3489 printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT);