Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 592

Show
Ignore:
Timestamp:
08/02/10 21:36:58 (14 years ago)
Author:
walter
Message:

more 64

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/backend/cod1.c

    r581 r592  
    24772477            int xmmcnt = XMM0; 
    24782478            for (int i = np; --i >= 0;) 
    24792479            { 
    24802480                static const unsigned char argregs[6] = { DI,SI,DX,CX,R8,R9 }; 
    24812481                elem *ep = parameters[i].e; 
    24822482                tym_t ty = ep->Ety; 
    24832483                if (r < sizeof(argregs)/sizeof(argregs[0]))     // if more arg regs 
    24842484                { 
    24852485                    if ( 
    24862486                        // This must match type_jparam() 
    24872487                        ty64reg(ty) || 
    24882488                        ((tybasic(ty) == TYstruct || tybasic(ty) == TYarray) && 
    24892489                         ep->Enumbytes <= REGSIZE && ep->Enumbytes != 3 && ep->Enumbytes) 
    24902490                        ) 
    24912491                    { 
    24922492                        parameters[i].reg = argregs[r]; 
    24932493                        r++; 
    24942494                        continue;       // goes in register, not stack 
    24952495                    } 
    24962496                } 
    2497                 else if (xmmcnt < XMM7) 
     2497                if (xmmcnt < XMM7) 
    24982498                { 
    24992499                    if (tyfloating(ty) && tysize(ty) <= 8) 
    25002500                    { 
    25012501                        parameters[i].reg = xmmcnt; 
    25022502                        xmmcnt++; 
    25032503                        continue;       // goes in register, not stack 
    25042504                    } 
    25052505                } 
    25062506                parameters[i].reg = -1;         // -1 means no register 
    25072507                numpara += paramsize(ep,stackalign); 
    25082508            } 
    25092509            assert((numpara & (REGSIZE - 1)) == 0); 
    25102510            assert((stackpush & (REGSIZE - 1)) == 0); 
    25112511 
    25122512            /* Adjust start of the stack so after all args are pushed, 
    25132513             * the stack will be aligned. 
    25142514             */ 
    25152515            if (STACKALIGN == 16 && (numpara + stackpush) & (STACKALIGN - 1)) 
    25162516            { 
    25172517                numalign = STACKALIGN - ((numpara + stackpush) & (STACKALIGN - 1)); 
  • branches/dmd-1.x/src/glue.c

    r591 r592  
    719719        params[pi] = v_arguments->toSymbol(); 
    720720        pi += 1; 
    721721    } 
    722722    if (parameters) 
    723723    { 
    724724        for (i = 0; i < parameters->dim; i++) 
    725725        {   VarDeclaration *v = (VarDeclaration *)parameters->data[i]; 
    726726            if (v->csym) 
    727727            { 
    728728                error("compiler error, parameter '%s', bugzilla 2962?", v->toChars()); 
    729729                assert(0); 
    730730            } 
    731731            params[pi + i] = v->toSymbol(); 
    732732        } 
    733733        pi += i; 
    734734    } 
    735735 
    736736    if (reverse) 
    737737    {   // Reverse params[] entries 
    738738        for (i = 0; i < pi/2; i++) 
    739         {   Symbol *sptmp; 
    740  
    741             sptmp = params[i]; 
     739        { 
     740            Symbol *sptmp = params[i]; 
    742741            params[i] = params[pi - 1 - i]; 
    743742            params[pi - 1 - i] = sptmp; 
    744743        } 
    745744    } 
    746745 
    747746    if (shidden) 
    748747    { 
    749748#if 0 
    750749        // shidden becomes last parameter 
    751750        params[pi] = shidden; 
    752751#else 
    753752        // shidden becomes first parameter 
    754753        memmove(params + 1, params, pi * sizeof(params[0])); 
    755754        params[0] = shidden; 
    756755#endif 
    757756        pi++; 
    758757    } 
    759758 
    760759 
    761760    if (sthis) 
     
    772771    } 
    773772 
    774773    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) && 
    775774         linkage != LINKd && shidden && sthis) 
    776775    { 
    777776        /* swap shidden and sthis 
    778777         */ 
    779778        Symbol *sp = params[0]; 
    780779        params[0] = params[1]; 
    781780        params[1] = sp; 
    782781    } 
    783782 
    784783    for (i = 0; i < pi; i++) 
    785784    {   Symbol *sp = params[i]; 
    786785        sp->Sclass = SCparameter; 
    787786        sp->Sflags &= ~SFLspill; 
    788787        sp->Sfl = FLpara; 
    789788        symbol_add(sp); 
    790789    } 
    791790 
    792     // First parameter goes in register 
     791    // Determine register assignments 
    793792    if (pi) 
    794793    { 
    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            } 
    802838        } 
    803839    } 
    804840 
    805841    if (func->fbody) 
    806842    {   block *b; 
    807843        Blockx bx; 
    808844        Statement *sbody; 
    809845 
    810846        localgot = NULL; 
    811847 
    812848        sbody = func->fbody; 
    813849        memset(&bx,0,sizeof(bx)); 
    814850        bx.startblock = block_calloc(); 
    815851        bx.curblock = bx.startblock; 
    816852        bx.funcsym = s; 
    817853        bx.scope_index = -1; 
    818854        bx.classdec = cd; 
    819855        bx.member = func; 
    820856        bx.module = getModule(); 
    821857        irs.blx = &bx; 
  • trunk/src/backend/cod1.c

    r581 r592  
    24772477            int xmmcnt = XMM0; 
    24782478            for (int i = np; --i >= 0;) 
    24792479            { 
    24802480                static const unsigned char argregs[6] = { DI,SI,DX,CX,R8,R9 }; 
    24812481                elem *ep = parameters[i].e; 
    24822482                tym_t ty = ep->Ety; 
    24832483                if (r < sizeof(argregs)/sizeof(argregs[0]))     // if more arg regs 
    24842484                { 
    24852485                    if ( 
    24862486                        // This must match type_jparam() 
    24872487                        ty64reg(ty) || 
    24882488                        ((tybasic(ty) == TYstruct || tybasic(ty) == TYarray) && 
    24892489                         ep->Enumbytes <= REGSIZE && ep->Enumbytes != 3 && ep->Enumbytes) 
    24902490                        ) 
    24912491                    { 
    24922492                        parameters[i].reg = argregs[r]; 
    24932493                        r++; 
    24942494                        continue;       // goes in register, not stack 
    24952495                    } 
    24962496                } 
    2497                 else if (xmmcnt < XMM7) 
     2497                if (xmmcnt < XMM7) 
    24982498                { 
    24992499                    if (tyfloating(ty) && tysize(ty) <= 8) 
    25002500                    { 
    25012501                        parameters[i].reg = xmmcnt; 
    25022502                        xmmcnt++; 
    25032503                        continue;       // goes in register, not stack 
    25042504                    } 
    25052505                } 
    25062506                parameters[i].reg = -1;         // -1 means no register 
    25072507                numpara += paramsize(ep,stackalign); 
    25082508            } 
    25092509            assert((numpara & (REGSIZE - 1)) == 0); 
    25102510            assert((stackpush & (REGSIZE - 1)) == 0); 
    25112511 
    25122512            /* Adjust start of the stack so after all args are pushed, 
    25132513             * the stack will be aligned. 
    25142514             */ 
    25152515            if (STACKALIGN == 16 && (numpara + stackpush) & (STACKALIGN - 1)) 
    25162516            { 
    25172517                numalign = STACKALIGN - ((numpara + stackpush) & (STACKALIGN - 1)); 
  • trunk/src/glue.c

    r591 r592  
    719719        params[pi] = v_arguments->toSymbol(); 
    720720        pi += 1; 
    721721    } 
    722722    if (parameters) 
    723723    { 
    724724        for (i = 0; i < parameters->dim; i++) 
    725725        {   VarDeclaration *v = (VarDeclaration *)parameters->data[i]; 
    726726            if (v->csym) 
    727727            { 
    728728                error("compiler error, parameter '%s', bugzilla 2962?", v->toChars()); 
    729729                assert(0); 
    730730            } 
    731731            params[pi + i] = v->toSymbol(); 
    732732        } 
    733733        pi += i; 
    734734    } 
    735735 
    736736    if (reverse) 
    737737    {   // Reverse params[] entries 
    738738        for (i = 0; i < pi/2; i++) 
    739         {   Symbol *sptmp; 
    740  
    741             sptmp = params[i]; 
     739        { 
     740            Symbol *sptmp = params[i]; 
    742741            params[i] = params[pi - 1 - i]; 
    743742            params[pi - 1 - i] = sptmp; 
    744743        } 
    745744    } 
    746745 
    747746    if (shidden) 
    748747    { 
    749748#if 0 
    750749        // shidden becomes last parameter 
    751750        params[pi] = shidden; 
    752751#else 
    753752        // shidden becomes first parameter 
    754753        memmove(params + 1, params, pi * sizeof(params[0])); 
    755754        params[0] = shidden; 
    756755#endif 
    757756        pi++; 
    758757    } 
    759758 
    760759 
    761760    if (sthis) 
     
    772771    } 
    773772 
    774773    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) && 
    775774         linkage != LINKd && shidden && sthis) 
    776775    { 
    777776        /* swap shidden and sthis 
    778777         */ 
    779778        Symbol *sp = params[0]; 
    780779        params[0] = params[1]; 
    781780        params[1] = sp; 
    782781    } 
    783782 
    784783    for (i = 0; i < pi; i++) 
    785784    {   Symbol *sp = params[i]; 
    786785        sp->Sclass = SCparameter; 
    787786        sp->Sflags &= ~SFLspill; 
    788787        sp->Sfl = FLpara; 
    789788        symbol_add(sp); 
    790789    } 
    791790 
    792     // First parameter goes in register 
     791    // Determine register assignments 
    793792    if (pi) 
    794793    { 
    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            } 
    802838        } 
    803839    } 
    804840 
    805841    if (func->fbody) 
    806842    {   block *b; 
    807843        Blockx bx; 
    808844        Statement *sbody; 
    809845 
    810846        localgot = NULL; 
    811847 
    812848        sbody = func->fbody; 
    813849        memset(&bx,0,sizeof(bx)); 
    814850        bx.startblock = block_calloc(); 
    815851        bx.curblock = bx.startblock; 
    816852        bx.funcsym = s; 
    817853        bx.scope_index = -1; 
    818854        bx.classdec = cd; 
    819855        bx.member = func; 
    820856        bx.module = getModule(); 
    821857        irs.blx = &bx;