Changeset 592
- Timestamp:
- 08/02/10 21:36:58 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/backend/cod1.c (modified) (1 diff)
- branches/dmd-1.x/src/glue.c (modified) (2 diffs)
- trunk/src/backend/cod1.c (modified) (1 diff)
- trunk/src/glue.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/backend/cod1.c
r581 r592 2477 2477 int xmmcnt = XMM0; 2478 2478 for (int i = np; --i >= 0;) 2479 2479 { 2480 2480 static const unsigned char argregs[6] = { DI,SI,DX,CX,R8,R9 }; 2481 2481 elem *ep = parameters[i].e; 2482 2482 tym_t ty = ep->Ety; 2483 2483 if (r < sizeof(argregs)/sizeof(argregs[0])) // if more arg regs 2484 2484 { 2485 2485 if ( 2486 2486 // This must match type_jparam() 2487 2487 ty64reg(ty) || 2488 2488 ((tybasic(ty) == TYstruct || tybasic(ty) == TYarray) && 2489 2489 ep->Enumbytes <= REGSIZE && ep->Enumbytes != 3 && ep->Enumbytes) 2490 2490 ) 2491 2491 { 2492 2492 parameters[i].reg = argregs[r]; 2493 2493 r++; 2494 2494 continue; // goes in register, not stack 2495 2495 } 2496 2496 } 2497 elseif (xmmcnt < XMM7)2497 if (xmmcnt < XMM7) 2498 2498 { 2499 2499 if (tyfloating(ty) && tysize(ty) <= 8) 2500 2500 { 2501 2501 parameters[i].reg = xmmcnt; 2502 2502 xmmcnt++; 2503 2503 continue; // goes in register, not stack 2504 2504 } 2505 2505 } 2506 2506 parameters[i].reg = -1; // -1 means no register 2507 2507 numpara += paramsize(ep,stackalign); 2508 2508 } 2509 2509 assert((numpara & (REGSIZE - 1)) == 0); 2510 2510 assert((stackpush & (REGSIZE - 1)) == 0); 2511 2511 2512 2512 /* Adjust start of the stack so after all args are pushed, 2513 2513 * the stack will be aligned. 2514 2514 */ 2515 2515 if (STACKALIGN == 16 && (numpara + stackpush) & (STACKALIGN - 1)) 2516 2516 { 2517 2517 numalign = STACKALIGN - ((numpara + stackpush) & (STACKALIGN - 1)); branches/dmd-1.x/src/glue.c
r591 r592 719 719 params[pi] = v_arguments->toSymbol(); 720 720 pi += 1; 721 721 } 722 722 if (parameters) 723 723 { 724 724 for (i = 0; i < parameters->dim; i++) 725 725 { VarDeclaration *v = (VarDeclaration *)parameters->data[i]; 726 726 if (v->csym) 727 727 { 728 728 error("compiler error, parameter '%s', bugzilla 2962?", v->toChars()); 729 729 assert(0); 730 730 } 731 731 params[pi + i] = v->toSymbol(); 732 732 } 733 733 pi += i; 734 734 } 735 735 736 736 if (reverse) 737 737 { // Reverse params[] entries 738 738 for (i = 0; i < pi/2; i++) 739 { Symbol *sptmp; 740 741 sptmp = params[i]; 739 { 740 Symbol *sptmp = params[i]; 742 741 params[i] = params[pi - 1 - i]; 743 742 params[pi - 1 - i] = sptmp; 744 743 } 745 744 } 746 745 747 746 if (shidden) 748 747 { 749 748 #if 0 750 749 // shidden becomes last parameter 751 750 params[pi] = shidden; 752 751 #else 753 752 // shidden becomes first parameter 754 753 memmove(params + 1, params, pi * sizeof(params[0])); 755 754 params[0] = shidden; 756 755 #endif 757 756 pi++; 758 757 } 759 758 760 759 761 760 if (sthis) … … 772 771 } 773 772 774 773 if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) && 775 774 linkage != LINKd && shidden && sthis) 776 775 { 777 776 /* swap shidden and sthis 778 777 */ 779 778 Symbol *sp = params[0]; 780 779 params[0] = params[1]; 781 780 params[1] = sp; 782 781 } 783 782 784 783 for (i = 0; i < pi; i++) 785 784 { Symbol *sp = params[i]; 786 785 sp->Sclass = SCparameter; 787 786 sp->Sflags &= ~SFLspill; 788 787 sp->Sfl = FLpara; 789 788 symbol_add(sp); 790 789 } 791 790 792 // First parameter goes in register791 // Determine register assignments 793 792 if (pi) 794 793 { 795 Symbol *sp = params[0]; 796 if ((tyf == TYjfunc || tyf == TYmfunc) && 797 type_jparam(sp->Stype)) 798 { sp->Sclass = SCfastpar; 799 sp->Spreg = (tyf == TYjfunc) ? AX : CX; 800 sp->Sfl = FLauto; 801 //printf("'%s' is SCfastpar\n",sp->Sident); 794 if (global.params.isX86_64) 795 { 796 // Order of assignment of pointer or integer parameters 797 static const unsigned char argregs[6] = { DI,SI,DX,CX,R8,R9 }; 798 int r = 0; 799 int xmmcnt = XMM0; 800 801 for (int i = 0; i < pi; i++) 802 { Symbol *sp = params[i]; 803 tym_t ty = tybasic(sp->Stype->Tty); 804 // BUG: doesn't work for structs 805 if (r < sizeof(argregs)/sizeof(argregs[0])) 806 { 807 if (type_jparam(sp->Stype)) 808 { 809 sp->Sclass = SCfastpar; 810 sp->Spreg = r; 811 sp->Sfl = FLauto; 812 ++r; 813 } 814 } 815 if (xmmcnt < XMM7) 816 { 817 if (tyfloating(ty) && tysize(ty) <= 8) 818 { 819 sp->Sclass = SCfastpar; 820 sp->Spreg = xmmcnt; 821 sp->Sfl = FLauto; 822 ++xmmcnt; 823 } 824 } 825 } 826 } 827 else 828 { 829 // First parameter goes in register 830 Symbol *sp = params[0]; 831 if ((tyf == TYjfunc || tyf == TYmfunc) && 832 type_jparam(sp->Stype)) 833 { sp->Sclass = SCfastpar; 834 sp->Spreg = (tyf == TYjfunc) ? AX : CX; 835 sp->Sfl = FLauto; 836 //printf("'%s' is SCfastpar\n",sp->Sident); 837 } 802 838 } 803 839 } 804 840 805 841 if (func->fbody) 806 842 { block *b; 807 843 Blockx bx; 808 844 Statement *sbody; 809 845 810 846 localgot = NULL; 811 847 812 848 sbody = func->fbody; 813 849 memset(&bx,0,sizeof(bx)); 814 850 bx.startblock = block_calloc(); 815 851 bx.curblock = bx.startblock; 816 852 bx.funcsym = s; 817 853 bx.scope_index = -1; 818 854 bx.classdec = cd; 819 855 bx.member = func; 820 856 bx.module = getModule(); 821 857 irs.blx = &bx; trunk/src/backend/cod1.c
r581 r592 2477 2477 int xmmcnt = XMM0; 2478 2478 for (int i = np; --i >= 0;) 2479 2479 { 2480 2480 static const unsigned char argregs[6] = { DI,SI,DX,CX,R8,R9 }; 2481 2481 elem *ep = parameters[i].e; 2482 2482 tym_t ty = ep->Ety; 2483 2483 if (r < sizeof(argregs)/sizeof(argregs[0])) // if more arg regs 2484 2484 { 2485 2485 if ( 2486 2486 // This must match type_jparam() 2487 2487 ty64reg(ty) || 2488 2488 ((tybasic(ty) == TYstruct || tybasic(ty) == TYarray) && 2489 2489 ep->Enumbytes <= REGSIZE && ep->Enumbytes != 3 && ep->Enumbytes) 2490 2490 ) 2491 2491 { 2492 2492 parameters[i].reg = argregs[r]; 2493 2493 r++; 2494 2494 continue; // goes in register, not stack 2495 2495 } 2496 2496 } 2497 elseif (xmmcnt < XMM7)2497 if (xmmcnt < XMM7) 2498 2498 { 2499 2499 if (tyfloating(ty) && tysize(ty) <= 8) 2500 2500 { 2501 2501 parameters[i].reg = xmmcnt; 2502 2502 xmmcnt++; 2503 2503 continue; // goes in register, not stack 2504 2504 } 2505 2505 } 2506 2506 parameters[i].reg = -1; // -1 means no register 2507 2507 numpara += paramsize(ep,stackalign); 2508 2508 } 2509 2509 assert((numpara & (REGSIZE - 1)) == 0); 2510 2510 assert((stackpush & (REGSIZE - 1)) == 0); 2511 2511 2512 2512 /* Adjust start of the stack so after all args are pushed, 2513 2513 * the stack will be aligned. 2514 2514 */ 2515 2515 if (STACKALIGN == 16 && (numpara + stackpush) & (STACKALIGN - 1)) 2516 2516 { 2517 2517 numalign = STACKALIGN - ((numpara + stackpush) & (STACKALIGN - 1)); trunk/src/glue.c
r591 r592 719 719 params[pi] = v_arguments->toSymbol(); 720 720 pi += 1; 721 721 } 722 722 if (parameters) 723 723 { 724 724 for (i = 0; i < parameters->dim; i++) 725 725 { VarDeclaration *v = (VarDeclaration *)parameters->data[i]; 726 726 if (v->csym) 727 727 { 728 728 error("compiler error, parameter '%s', bugzilla 2962?", v->toChars()); 729 729 assert(0); 730 730 } 731 731 params[pi + i] = v->toSymbol(); 732 732 } 733 733 pi += i; 734 734 } 735 735 736 736 if (reverse) 737 737 { // Reverse params[] entries 738 738 for (i = 0; i < pi/2; i++) 739 { Symbol *sptmp; 740 741 sptmp = params[i]; 739 { 740 Symbol *sptmp = params[i]; 742 741 params[i] = params[pi - 1 - i]; 743 742 params[pi - 1 - i] = sptmp; 744 743 } 745 744 } 746 745 747 746 if (shidden) 748 747 { 749 748 #if 0 750 749 // shidden becomes last parameter 751 750 params[pi] = shidden; 752 751 #else 753 752 // shidden becomes first parameter 754 753 memmove(params + 1, params, pi * sizeof(params[0])); 755 754 params[0] = shidden; 756 755 #endif 757 756 pi++; 758 757 } 759 758 760 759 761 760 if (sthis) … … 772 771 } 773 772 774 773 if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) && 775 774 linkage != LINKd && shidden && sthis) 776 775 { 777 776 /* swap shidden and sthis 778 777 */ 779 778 Symbol *sp = params[0]; 780 779 params[0] = params[1]; 781 780 params[1] = sp; 782 781 } 783 782 784 783 for (i = 0; i < pi; i++) 785 784 { Symbol *sp = params[i]; 786 785 sp->Sclass = SCparameter; 787 786 sp->Sflags &= ~SFLspill; 788 787 sp->Sfl = FLpara; 789 788 symbol_add(sp); 790 789 } 791 790 792 // First parameter goes in register791 // Determine register assignments 793 792 if (pi) 794 793 { 795 Symbol *sp = params[0]; 796 if ((tyf == TYjfunc || tyf == TYmfunc) && 797 type_jparam(sp->Stype)) 798 { sp->Sclass = SCfastpar; 799 sp->Spreg = (tyf == TYjfunc) ? AX : CX; 800 sp->Sfl = FLauto; 801 //printf("'%s' is SCfastpar\n",sp->Sident); 794 if (global.params.isX86_64) 795 { 796 // Order of assignment of pointer or integer parameters 797 static const unsigned char argregs[6] = { DI,SI,DX,CX,R8,R9 }; 798 int r = 0; 799 int xmmcnt = XMM0; 800 801 for (int i = 0; i < pi; i++) 802 { Symbol *sp = params[i]; 803 tym_t ty = tybasic(sp->Stype->Tty); 804 // BUG: doesn't work for structs 805 if (r < sizeof(argregs)/sizeof(argregs[0])) 806 { 807 if (type_jparam(sp->Stype)) 808 { 809 sp->Sclass = SCfastpar; 810 sp->Spreg = r; 811 sp->Sfl = FLauto; 812 ++r; 813 } 814 } 815 if (xmmcnt < XMM7) 816 { 817 if (tyfloating(ty) && tysize(ty) <= 8) 818 { 819 sp->Sclass = SCfastpar; 820 sp->Spreg = xmmcnt; 821 sp->Sfl = FLauto; 822 ++xmmcnt; 823 } 824 } 825 } 826 } 827 else 828 { 829 // First parameter goes in register 830 Symbol *sp = params[0]; 831 if ((tyf == TYjfunc || tyf == TYmfunc) && 832 type_jparam(sp->Stype)) 833 { sp->Sclass = SCfastpar; 834 sp->Spreg = (tyf == TYjfunc) ? AX : CX; 835 sp->Sfl = FLauto; 836 //printf("'%s' is SCfastpar\n",sp->Sident); 837 } 802 838 } 803 839 } 804 840 805 841 if (func->fbody) 806 842 { block *b; 807 843 Blockx bx; 808 844 Statement *sbody; 809 845 810 846 localgot = NULL; 811 847 812 848 sbody = func->fbody; 813 849 memset(&bx,0,sizeof(bx)); 814 850 bx.startblock = block_calloc(); 815 851 bx.curblock = bx.startblock; 816 852 bx.funcsym = s; 817 853 bx.scope_index = -1; 818 854 bx.classdec = cd; 819 855 bx.member = func; 820 856 bx.module = getModule(); 821 857 irs.blx = &bx;
