# HG changeset patch # User kono # Date 948039659 -32400 # Node ID 77c0710a872978e9c95478504362538545296a46 # Parent a8a812dace2384245a856d13634caf8785211684 struct copy diff -r a8a812dace23 -r 77c0710a8729 mc-nop-386.c --- a/mc-nop-386.c Mon Jan 17 00:43:06 2000 +0900 +++ b/mc-nop-386.c Mon Jan 17 01:20:59 2000 +0900 @@ -757,37 +757,40 @@ break; default: if (length <=MAX_COPY_LEN) { - for(;length>4;length-=4,offset+=4); + for(;length>=4;length-=4,offset+=4) emit_copy(from,to,4,offset); - for(;length>2;length-=2,offset+=2); + for(;length>=2;length-=2,offset+=2) emit_copy(from,to,2,offset); if(length>0) emit_copy(from,to,length,offset); return; } - printf("\texch %%edi,%s\n",from); - printf("\texch %%esi,%s\n",to); - printf("\texch %%ecx,%s\n",drn); - printf("\tmovl $%d,%%ecx\n",length); + printf("\txchg %%edi,%s\n",from); + printf("\txchg %%esi,%s\n",to); + printf("\txchg %%ecx,%s\n",drn); + printf("\tmovl $%d,%%ecx\n",length/4); printf("\tcld\n\trep\n\tmovsl\n"); - printf("\texch %%ecx,%s\n",drn); - printf("\texch %%esi,%s\n",to); - printf("\texch %%edi,%s\n",from); + printf("\txchg %%ecx,%s\n",drn); + printf("\txchg %%esi,%s\n",to); + printf("\txchg %%edi,%s\n",from); + if(length%4) { + emit_copy("%esi","%edi",length,offset+length/4); + } } } int struct_push(int e4,int t) { - int e5; + int length; g_expr(e4); - e5=size(t); - if(e5%size_of_int) { - e5 += size_of_int - (e5%size_of_int); + length=size(t); + if(length%size_of_int) { + length += size_of_int - (length%size_of_int); } - printf("\tsubl $%d,%%esp\n",e5); - if (e5<=MAX_COPY_LEN) - emit_copy(crn,"%esp",e5,0); + printf("\tsubl $%d,%%esp\n",length); + if (length<=MAX_COPY_LEN) + emit_copy(crn,"%esp",length,0); else { printf("\tpushl %%edi\n"); printf("\tpushl %%esi\n"); @@ -795,13 +798,13 @@ printf("\tleal 12(%%esp),%%di\n"); if (rname[creg]!=REG_ESI) printf("\tmovl %s,%%esi\n",crn); - printf("\tmovl $%d,%%ecx\n",e5); + printf("\tmovl $%d,%%ecx\n",length/size_of_int); printf("\tcld\n\trep\n\tmovsl\n"); printf("\tpopl %%ecx\n"); printf("\tpopl %%esi\n"); printf("\tpopl %%edi\n"); } - return e5/size_of_int; + return length/size_of_int; } void @@ -1032,7 +1035,7 @@ e2 = cadr(e1); e3 = cadr(e2); e4 = caddr(e1); - sz = size(cadr(e2)); /* cld rep movsb */ + sz = cadddr(e1); /* cld rep movsb */ g_expr(e4); emit_push(); g_expr(e2); diff -r a8a812dace23 -r 77c0710a8729 mc-parse.c --- a/mc-parse.c Mon Jan 17 00:43:06 2000 +0900 +++ b/mc-parse.c Mon Jan 17 01:20:59 2000 +0900 @@ -722,9 +722,9 @@ nsc = LVAR; ndsp = (disp -= sz); } + n->sc = nsc; + n->dsp = ndsp; if(sym==ASS) { - n->sc = nsc; - n->dsp = ndsp; decl_data(type,n,0); } return; @@ -776,7 +776,7 @@ } else if (scalar(t)) { ass = list3(ASS,list2(LVAR,n->dsp+offset),e); } else if (car(t)==STRUCT || car(t)==UNION || car(t)==STRING) { - ass = list3(SASS,list2(LVAR,n->dsp+offset),e); + ass = list4(SASS,list2(LVAR,n->dsp+offset),e,size(t)); } else { error(DCERR); } @@ -1410,8 +1410,8 @@ error(TYERR); if(t==CHAR) { type= INT;return(list3(CASS,e1,e2)); - } else if(t==STRUCT||t==UNION) { - type= t;return(list3(SASS,e1,e2)); + } else if(!scalar(t)&&(car(t)==STRUCT||car(t)==UNION)) { + type= t;return(list4(SASS,e1,e2,size(t))); } type=t; return(list3(ASS,e1,e2));