comparison mc-codegen.c @ 783:feeb9b9f8236

i64 code segement goto statement
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 20 Nov 2010 13:49:56 +0900
parents 003067098032
children 33d9a4b05bc8
comparison
equal deleted inserted replaced
782:003067098032 783:feeb9b9f8236
1611 if (lsrc)printf("## division sz %d\n",sz); 1611 if (lsrc)printf("## division sz %d\n",sz);
1612 #endif 1612 #endif
1613 caddr(e2) = int_unsigned; 1613 caddr(e2) = int_unsigned;
1614 caddddr(e2) = list3( 1614 caddddr(e2) = list3(
1615 cadddr(e2)=list3n(LVAR,cadr(s0),0), 1615 cadddr(e2)=list3n(LVAR,cadr(s0),0),
1616 0, size_of_int); 1616 0, int_size);
1617 #if DEBUG_PARALLEL_ASSIGN 1617 #if DEBUG_PARALLEL_ASSIGN
1618 if (lsrc)printf("## div 0 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),int_size); 1618 if (lsrc)printf("## div 0 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),int_size);
1619 #endif 1619 #endif
1620 for(e4=int_size;e4<sz;) { 1620 for(e4=int_size;e4<sz;) {
1621 cadr(e2) = list5(car(e2),cadr(e2), 1621 cadr(e2) = list5(car(e2),cadr(e2),
1623 switch(sz-e4) { 1623 switch(sz-e4) {
1624 case 1: caddr(e2) = UCHAR; r = 1; break; 1624 case 1: caddr(e2) = UCHAR; r = 1; break;
1625 case 2: 1625 case 2:
1626 case 3: caddr(e2) = USHORT; r = size_of_short; break; 1626 case 3: caddr(e2) = USHORT; r = size_of_short; break;
1627 case 4: if (lp64) { caddr(e2) = UNSIGNED; r = size_of_int; break; } 1627 case 4: if (lp64) { caddr(e2) = UNSIGNED; r = size_of_int; break; }
1628 default: caddr(e2) = int_unsigned; r = size_of_int; 1628 default: caddr(e2) = int_unsigned; r = int_size;
1629 } 1629 }
1630 if (e4==int_size) e3=cadr(e2); 1630 if (e4==int_size) e3=cadr(e2);
1631 car(e2) = list3n(LVAR,cadr(t0)+e4,0); 1631 car(e2) = list3n(LVAR,cadr(t0)+e4,0);
1632 caddddr(e2) = list3( 1632 caddddr(e2) = list3(
1633 cadddr(e2) = list3n(LVAR,cadr(s0)+e4,0),0, r); 1633 cadddr(e2) = list3n(LVAR,cadr(s0)+e4,0),0, r);
3570 return n; 3570 return n;
3571 } 3571 }
3572 3572
3573 // standard 32bit alignment 3573 // standard 32bit alignment
3574 3574
3575 // for code 3575
3576 // for function
3576 extern int 3577 extern int
3577 code_arg_alignment1(int offset,NMTBL *n, int type0,int sz, int is_code) 3578 code_arg_alignment0(int offset,NMTBL *n, int type0,int sz, int is_code)
3578 { 3579 {
3579 if(type0==CHAR||type0==UCHAR) { 3580 if(type0==CHAR||type0==UCHAR) {
3580 if (n->dsp==0) { 3581 if (n->dsp==0) {
3581 n->dsp = -offset; 3582 n->dsp = is_code? -offset-size_of_int:offset;
3582 if (endian) n->dsp += size_of_int-1; 3583 if (endian) n->dsp += size_of_int-1;
3583 } 3584 }
3584 offset += size_of_int; 3585 offset += size_of_int;
3585 } else if(type0==SHORT||type0==USHORT) { 3586 } else if(type0==SHORT||type0==USHORT) {
3586 if (n->dsp==0) { 3587 if (n->dsp==0) {
3587 n->dsp = -offset; 3588 n->dsp = is_code? -offset-size_of_int: offset;
3588 if (endian) n->dsp += size_of_int-size_of_short; 3589 if (endian) n->dsp += size_of_int-size_of_short;
3589 } 3590 }
3590 offset += size_of_int; 3591 offset += size_of_int;
3591 } else if(type0>0&&(car(type0)==UNION||car(type0)==STRUCT)) { 3592 } else if(type0>0&&(car(type0)==UNION||car(type0)==STRUCT)) {
3592 /* alignment in struct in argument */ 3593 /* alignment in struct in argument */
3593 /* should be GCD of member alignment */ 3594 /* should be GCD of member alignment */
3594 /* __attribute(alignment(16)) is ignored in argments */ 3595 /* __attribute(alignment(16)) is ignored in argments */
3595 n->dsp = -offset; 3596 int asz = align(sz,size_of_int);
3596 offset += align(sz,size_of_int); 3597 n->dsp = is_code? -offset-asz:offset;
3598 offset += asz;
3597 } else { 3599 } else {
3598 /* if (n->dsp==0) (argument list in ADECL is useless, type 3600 /* if (n->dsp==0) (argument list in ADECL is useless, type
3599 list can be found in type ) */ 3601 list can be found in type ) */
3600 n->dsp = -offset; 3602 n->dsp = is_code? -offset-size_of_int: offset;
3601 offset += sz;
3602 }
3603 return offset;
3604 }
3605
3606 // for function
3607 extern int
3608 code_arg_alignment0(int offset,NMTBL *n, int type0,int sz, int is_code)
3609 {
3610 if (is_code) return code_arg_alignment1(offset,n,type0,sz,is_code);
3611
3612 if(type0==CHAR||type0==UCHAR) {
3613 if (n->dsp==0) {
3614 n->dsp = offset;
3615 if (endian) n->dsp += size_of_int-1;
3616 }
3617 offset += size_of_int;
3618 } else if(type0==SHORT||type0==USHORT) {
3619 if (n->dsp==0) {
3620 n->dsp = offset;
3621 if (endian) n->dsp += size_of_int-size_of_short;
3622 }
3623 offset += size_of_int;
3624 } else if(type0>0&&(car(type0)==UNION||car(type0)==STRUCT)) {
3625 /* alignment in struct in argument */
3626 /* should be GCD of member alignment */
3627 /* __attribute(alignment(16)) is ignored in argments */
3628 n->dsp = offset;
3629 offset += align(sz,size_of_int);
3630 } else {
3631 /* if (n->dsp==0) (argument list in ADECL is useless, type
3632 list can be found in type ) */
3633 n->dsp = offset;
3634 offset += sz; 3603 offset += sz;
3635 } 3604 }
3636 return offset; 3605 return offset;
3637 } 3606 }
3638 3607