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

Changeset 828

Show
Ignore:
Timestamp:
12/30/10 09:14:27 (14 years ago)
Author:
walter
Message:

more 64 fixes

Files:

Legend:

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

    r814 r828  
    35863586  dstregs = (config.exe & EX_flat) ? mDI : mES|mDI; 
    35873587  if (e1->Eoper == OPind)               /* if (*p = ..)                 */ 
    35883588  { 
    35893589        if (tyreg(e1->E1->Ety)) 
    35903590            dstregs = mDI; 
    35913591        c2 = cod2_setES(e1->E1->Ety); 
    35923592        c2 = cat(c2,scodelem(e1->E1,&dstregs,srcregs,FALSE)); 
    35933593  } 
    35943594  else 
    35953595        c2 = cdrelconst(e1,&dstregs); 
    35963596  freenode(e1); 
    35973597 
    35983598  c3 = getregs((srcregs | dstregs) & (mLSW | mDI)); 
    35993599  if (need_DS) 
    36003600  {     assert(!(config.exe & EX_flat)); 
    36013601        c3 = gen1(c3,0x1E);                     /* PUSH DS              */ 
    36023602        gen2(c3,0x8E,modregrm(3,SEG_DS,CX));    /* MOV DS,CX            */ 
    36033603  } 
    36043604  if (numbytes <= REGSIZE * (6 + (REGSIZE == 4))) 
    36053605  {     while (numbytes >= REGSIZE) 
    3606         {   c3 = gen1(c3,0xA5);         /* MOVSW                        */ 
     3606        { 
     3607            if (REGSIZE == 8) 
     3608                c3 = gen1(c3,REX | REX_W); 
     3609            c3 = gen1(c3,0xA5);         /* MOVSW                        */ 
    36073610            code_orrex(c3, rex); 
    36083611            numbytes -= REGSIZE; 
    36093612        } 
    36103613        //if (numbytes) 
    36113614        //    printf("cdstreq numbytes %d\n",numbytes); 
    36123615        while (numbytes--) 
    36133616            c3 = gen1(c3,0xA4);         /* MOVSB                        */ 
    36143617  } 
    36153618    else 
    36163619    { 
    36173620#if 1 
    36183621        unsigned remainder; 
    36193622 
    36203623        remainder = numbytes & (REGSIZE - 1); 
    36213624        numbytes /= REGSIZE;            // number of words 
    36223625        c3 = cat(c3,getregs_imm(mCX)); 
    36233626        c3 = movregconst(c3,CX,numbytes,0);     // # of bytes/words 
    36243627        gen1(c3,0xF3);                          // REP 
     3628        if (REGSIZE == 8) 
     3629            gen1(c3,REX | REX_W); 
    36253630        gen1(c3,0xA5);                  // REP MOVSD 
    36263631        regimmed_set(CX,0);             // note that CX == 0 
    36273632        for (; remainder; remainder--) 
    36283633        { 
    36293634            gen1(c3, 0xA4);             // MOVSB 
    36303635        } 
    36313636#else 
    36323637        unsigned movs; 
    36333638 
    36343639        if (numbytes & (REGSIZE - 1))   /* if odd                       */ 
    36353640                movs = 0xA4;            /* MOVSB                        */ 
    36363641        else 
    36373642        {       movs = 0xA5;            /* MOVSW                        */ 
    36383643                numbytes /= REGSIZE;    /* # of words                   */ 
    36393644        } 
    36403645        c3 = cat(c3,getregs_imm(mCX)); 
    36413646        c3 = movregconst(c3,CX,numbytes,0);     /* # of bytes/words     */ 
    36423647        gen1(c3,0xF3);                          /* REP                  */ 
    36433648        gen1(c3,movs); 
    36443649        regimmed_set(CX,0);             /* note that CX == 0            */ 
  • branches/dmd-1.x/src/backend/cod3.c

    r772 r828  
    42034203            if (is32bitaddr( I32, flags)) 
    42044204            { 
    42054205                if (issib(rm)) 
    42064206                    GEN(c->Isib); 
    42074207                switch (rm & 0xC0) 
    42084208                {   case 0x40: 
    42094209                        do8bit((enum FL) c->IFL1,&c->IEV1);     // 8 bit 
    42104210                        break; 
    42114211                    case 0: 
    42124212                        if (!(issib(rm) && (c->Isib & 7) == 5 || 
    42134213                              (rm & 7) == 5)) 
    42144214                            break; 
    42154215                    case 0x80: 
    42164216                    {   int flags = CFoff; 
    42174217                        targ_size_t val = 0; 
    42184218                        if (I64) 
    42194219                        { 
    42204220                            if ((rm & modregrm(3,0,7)) == modregrm(0,0,5))      // if disp32[RIP] 
    42214221                            {   flags |= CFpc32; 
    42224222                                val = -4; 
    4223                                 if (ins & T
     4223                                if (ins & T || op == 0xF6 || op == 0xF7
    42244224                                {   if (ins & E) 
    42254225                                        val = -5; 
    42264226                                    else if (c->Iflags & CFopsize) 
    42274227                                        val = -6; 
    42284228                                    else 
    42294229                                        val = -8; 
    42304230                                } 
    42314231                            } 
    42324232                        } 
    42334233                        do32bit((enum FL)c->IFL1,&c->IEV1,flags,val); 
    42344234                        break; 
    42354235                    } 
    42364236                } 
    42374237            } 
    42384238            else 
    42394239            { 
    42404240                switch (rm & 0xC0) 
    42414241                {   case 0x40: 
    42424242                        do8bit((enum FL) c->IFL1,&c->IEV1);     // 8 bit 
    42434243                        break; 
  • branches/dmd-1.x/src/backend/cod4.c

    r814 r828  
    31553155    if (e2->Eoper == OPconst) 
    31563156    { 
    31573157        cs.Iop = 0x0FBA;                         // BT rm,imm8 
    31583158        cs.Irm |= modregrm(0,mode,0); 
    31593159        cs.Iflags |= CFpsw | word; 
    31603160        cs.IFL2 = FLconst; 
    31613161        if (tysize[ty1] == SHORTSIZE) 
    31623162        { 
    31633163            cs.IEVoffset1 += (e2->EV.Vuns & ~15) >> 3; 
    31643164            cs.IEV2.Vint = e2->EV.Vint & 15; 
    31653165        } 
    31663166        else if (tysize[ty1] == 4) 
    31673167        { 
    31683168            cs.IEVoffset1 += (e2->EV.Vuns & ~31) >> 3; 
    31693169            cs.IEV2.Vint = e2->EV.Vint & 31; 
    31703170        } 
    31713171        else 
    31723172        { 
    31733173            cs.IEVoffset1 += (e2->EV.Vuns & ~63) >> 3; 
    31743174            cs.IEV2.Vint = e2->EV.Vint & 63; 
     3175            if (I64) 
     3176                cs.Irex |= REX_W; 
    31753177        } 
    31763178        c2 = gen(CNIL,&cs); 
    31773179    } 
    31783180    else 
    31793181    { 
    31803182        retregs = ALLREGS & ~idxregs; 
    31813183        c2 = scodelem(e2,&retregs,idxregs,TRUE); 
    31823184        reg = findreg(retregs); 
    31833185 
    31843186        cs.Iop = 0x0F00 | op;                     // BT rm,reg 
    31853187        code_newreg(&cs,reg); 
    31863188        cs.Iflags |= CFpsw | word; 
    31873189        c2 = gen(c2,&cs); 
    31883190    } 
    31893191 
    31903192    if ((retregs = (*pretregs & (ALLREGS | mBP))) != 0) // if return result in register 
    31913193    { 
    31923194        code *nop = CNIL; 
    31933195        regm_t save = regcon.immed.mval; 
    31943196        code *cg = allocreg(&retregs,&reg,TYint); 
  • branches/dmd-1.x/src/mtype.c

    r767 r828  
    36903690 
    36913691    if (sc->parameterSpecialization) 
    36923692    { 
    36933693        unsigned errors = global.errors; 
    36943694        global.gag++; 
    36953695 
    36963696        resolve(loc, sc, &e, &t, &s); 
    36973697 
    36983698        global.gag--; 
    36993699        if (errors != global.errors) 
    37003700        {   if (global.gag == 0) 
    37013701                global.errors = errors; 
    37023702            return this; 
    37033703        } 
    37043704    } 
    37053705    else 
    37063706        resolve(loc, sc, &e, &t, &s); 
    37073707 
    37083708    if (!t) 
    37093709    { 
    3710 #ifdef DEBUG 
     3710#if 0 
    37113711        if (s) printf("s = %s\n", s->kind()); 
    37123712        printf("2: e:%p s:%p ", e, s); 
    37133713#endif 
    37143714        error(loc, "%s is used as a type", toChars()); 
    37153715        t = tvoid; 
    37163716    } 
    37173717    return t; 
    37183718} 
    37193719 
    37203720Dsymbol *TypeInstance::toDsymbol(Scope *sc) 
    37213721{ 
    37223722    Type *t; 
    37233723    Expression *e; 
    37243724    Dsymbol *s; 
    37253725 
    37263726    //printf("TypeInstance::semantic(%s)\n", toChars()); 
    37273727 
    37283728    if (sc->parameterSpecialization) 
    37293729    { 
    37303730        unsigned errors = global.errors; 
  • branches/dmd-1.x/src/toir.c

    r767 r828  
    391391        "9intrinsic5outplFNbkkZk", 
    392392        "9intrinsic5outpwFNbktZt", 
    393393#endif 
    394394    }; 
    395395    static const char *namearray64[] = 
    396396    { 
    397397#if DMDV1 
    398398        "4math3cosFeZe", 
    399399        "4math3sinFeZe", 
    400400        "4math4fabsFeZe", 
    401401        "4math4rintFeZe", 
    402402        "4math4sqrtFdZd", 
    403403        "4math4sqrtFeZe", 
    404404        "4math4sqrtFfZf", 
    405405        "4math4yl2xFeeZe", 
    406406        "4math5ldexpFeiZe", 
    407407        "4math6rndtolFeZl", 
    408408        "4math6yl2xp1FeeZe", 
    409409 
    410410        "9intrinsic2btFPmmZi", 
    411         "9intrinsic3bsfFkZi", 
    412         "9intrinsic3bsrFkZi", 
     411        "9intrinsic3bsfFmZi", 
     412        "9intrinsic3bsrFmZi", 
    413413        "9intrinsic3btcFPmmZi", 
    414414        "9intrinsic3btrFPmmZi", 
    415415        "9intrinsic3btsFPmmZi", 
    416416        "9intrinsic3inpFkZh", 
    417417        "9intrinsic4inplFkZk", 
    418418        "9intrinsic4inpwFkZt", 
    419419        "9intrinsic4outpFkhZh", 
    420420        "9intrinsic5bswapFkZk", 
    421421        "9intrinsic5outplFkkZk", 
    422422        "9intrinsic5outpwFktZt", 
    423423#elif DMDV2 
    424424        /* The names are mangled differently because of the pure and 
    425425         * nothrow attributes. 
    426426         */ 
    427427        "4math3cosFNaNbNfeZe", 
    428428        "4math3sinFNaNbNfeZe", 
    429429        "4math4fabsFNaNbNfeZe", 
    430430        "4math4rintFNaNbNfeZe", 
    431431        "4math4sqrtFNaNbNfdZd", 
    432432        "4math4sqrtFNaNbNfeZe", 
  • trunk/src/backend/cod2.c

    r813 r828  
    35863586  dstregs = (config.exe & EX_flat) ? mDI : mES|mDI; 
    35873587  if (e1->Eoper == OPind)               /* if (*p = ..)                 */ 
    35883588  { 
    35893589        if (tyreg(e1->E1->Ety)) 
    35903590            dstregs = mDI; 
    35913591        c2 = cod2_setES(e1->E1->Ety); 
    35923592        c2 = cat(c2,scodelem(e1->E1,&dstregs,srcregs,FALSE)); 
    35933593  } 
    35943594  else 
    35953595        c2 = cdrelconst(e1,&dstregs); 
    35963596  freenode(e1); 
    35973597 
    35983598  c3 = getregs((srcregs | dstregs) & (mLSW | mDI)); 
    35993599  if (need_DS) 
    36003600  {     assert(!(config.exe & EX_flat)); 
    36013601        c3 = gen1(c3,0x1E);                     /* PUSH DS              */ 
    36023602        gen2(c3,0x8E,modregrm(3,SEG_DS,CX));    /* MOV DS,CX            */ 
    36033603  } 
    36043604  if (numbytes <= REGSIZE * (6 + (REGSIZE == 4))) 
    36053605  {     while (numbytes >= REGSIZE) 
    3606         {   c3 = gen1(c3,0xA5);         /* MOVSW                        */ 
     3606        { 
     3607            if (REGSIZE == 8) 
     3608                c3 = gen1(c3,REX | REX_W); 
     3609            c3 = gen1(c3,0xA5);         /* MOVSW                        */ 
    36073610            code_orrex(c3, rex); 
    36083611            numbytes -= REGSIZE; 
    36093612        } 
    36103613        //if (numbytes) 
    36113614        //    printf("cdstreq numbytes %d\n",numbytes); 
    36123615        while (numbytes--) 
    36133616            c3 = gen1(c3,0xA4);         /* MOVSB                        */ 
    36143617  } 
    36153618    else 
    36163619    { 
    36173620#if 1 
    36183621        unsigned remainder; 
    36193622 
    36203623        remainder = numbytes & (REGSIZE - 1); 
    36213624        numbytes /= REGSIZE;            // number of words 
    36223625        c3 = cat(c3,getregs_imm(mCX)); 
    36233626        c3 = movregconst(c3,CX,numbytes,0);     // # of bytes/words 
    36243627        gen1(c3,0xF3);                          // REP 
     3628        if (REGSIZE == 8) 
     3629            gen1(c3,REX | REX_W); 
    36253630        gen1(c3,0xA5);                  // REP MOVSD 
    36263631        regimmed_set(CX,0);             // note that CX == 0 
    36273632        for (; remainder; remainder--) 
    36283633        { 
    36293634            gen1(c3, 0xA4);             // MOVSB 
    36303635        } 
    36313636#else 
    36323637        unsigned movs; 
    36333638 
    36343639        if (numbytes & (REGSIZE - 1))   /* if odd                       */ 
    36353640                movs = 0xA4;            /* MOVSB                        */ 
    36363641        else 
    36373642        {       movs = 0xA5;            /* MOVSW                        */ 
    36383643                numbytes /= REGSIZE;    /* # of words                   */ 
    36393644        } 
    36403645        c3 = cat(c3,getregs_imm(mCX)); 
    36413646        c3 = movregconst(c3,CX,numbytes,0);     /* # of bytes/words     */ 
    36423647        gen1(c3,0xF3);                          /* REP                  */ 
    36433648        gen1(c3,movs); 
    36443649        regimmed_set(CX,0);             /* note that CX == 0            */ 
  • trunk/src/backend/cod3.c

    r772 r828  
    42034203            if (is32bitaddr( I32, flags)) 
    42044204            { 
    42054205                if (issib(rm)) 
    42064206                    GEN(c->Isib); 
    42074207                switch (rm & 0xC0) 
    42084208                {   case 0x40: 
    42094209                        do8bit((enum FL) c->IFL1,&c->IEV1);     // 8 bit 
    42104210                        break; 
    42114211                    case 0: 
    42124212                        if (!(issib(rm) && (c->Isib & 7) == 5 || 
    42134213                              (rm & 7) == 5)) 
    42144214                            break; 
    42154215                    case 0x80: 
    42164216                    {   int flags = CFoff; 
    42174217                        targ_size_t val = 0; 
    42184218                        if (I64) 
    42194219                        { 
    42204220                            if ((rm & modregrm(3,0,7)) == modregrm(0,0,5))      // if disp32[RIP] 
    42214221                            {   flags |= CFpc32; 
    42224222                                val = -4; 
    4223                                 if (ins & T
     4223                                if (ins & T || op == 0xF6 || op == 0xF7
    42244224                                {   if (ins & E) 
    42254225                                        val = -5; 
    42264226                                    else if (c->Iflags & CFopsize) 
    42274227                                        val = -6; 
    42284228                                    else 
    42294229                                        val = -8; 
    42304230                                } 
    42314231                            } 
    42324232                        } 
    42334233                        do32bit((enum FL)c->IFL1,&c->IEV1,flags,val); 
    42344234                        break; 
    42354235                    } 
    42364236                } 
    42374237            } 
    42384238            else 
    42394239            { 
    42404240                switch (rm & 0xC0) 
    42414241                {   case 0x40: 
    42424242                        do8bit((enum FL) c->IFL1,&c->IEV1);     // 8 bit 
    42434243                        break; 
  • trunk/src/backend/cod4.c

    r813 r828  
    31553155    if (e2->Eoper == OPconst) 
    31563156    { 
    31573157        cs.Iop = 0x0FBA;                         // BT rm,imm8 
    31583158        cs.Irm |= modregrm(0,mode,0); 
    31593159        cs.Iflags |= CFpsw | word; 
    31603160        cs.IFL2 = FLconst; 
    31613161        if (tysize[ty1] == SHORTSIZE) 
    31623162        { 
    31633163            cs.IEVoffset1 += (e2->EV.Vuns & ~15) >> 3; 
    31643164            cs.IEV2.Vint = e2->EV.Vint & 15; 
    31653165        } 
    31663166        else if (tysize[ty1] == 4) 
    31673167        { 
    31683168            cs.IEVoffset1 += (e2->EV.Vuns & ~31) >> 3; 
    31693169            cs.IEV2.Vint = e2->EV.Vint & 31; 
    31703170        } 
    31713171        else 
    31723172        { 
    31733173            cs.IEVoffset1 += (e2->EV.Vuns & ~63) >> 3; 
    31743174            cs.IEV2.Vint = e2->EV.Vint & 63; 
     3175            if (I64) 
     3176                cs.Irex |= REX_W; 
    31753177        } 
    31763178        c2 = gen(CNIL,&cs); 
    31773179    } 
    31783180    else 
    31793181    { 
    31803182        retregs = ALLREGS & ~idxregs; 
    31813183        c2 = scodelem(e2,&retregs,idxregs,TRUE); 
    31823184        reg = findreg(retregs); 
    31833185 
    31843186        cs.Iop = 0x0F00 | op;                     // BT rm,reg 
    31853187        code_newreg(&cs,reg); 
    31863188        cs.Iflags |= CFpsw | word; 
    31873189        c2 = gen(c2,&cs); 
    31883190    } 
    31893191 
    31903192    if ((retregs = (*pretregs & (ALLREGS | mBP))) != 0) // if return result in register 
    31913193    { 
    31923194        code *nop = CNIL; 
    31933195        regm_t save = regcon.immed.mval; 
    31943196        code *cg = allocreg(&retregs,&reg,TYint); 
  • trunk/src/iasm.c

    r771 r828  
    13131313                        (uSizemaskTable1 & _32 && aoptyTable1 == _mnoi) || 
    13141314                        (ptb.pptb1->usFlags & _16_bit_addr))) || 
    13151315                     (I16 && 
    13161316                      (amod1 == _addr32 || 
    13171317                        (uSizemaskTable1 & _32 && aoptyTable1 == _rel) || 
    13181318                        (uSizemaskTable1 & _48 && aoptyTable1 == _mnoi) || 
    13191319                         (ptb.pptb1->usFlags & _32_bit_addr)))) 
    13201320                { 
    13211321                        emit(0x67);     // address size prefix 
    13221322                        pc->Iflags |= CFaddrsize; 
    13231323                        if (I32) 
    13241324                            amod1 = _addr16; 
    13251325                        else 
    13261326                            amod1 = _addr32; 
    13271327                        popnd1->usFlags &= ~CONSTRUCT_FLAGS(0,0,7,0); 
    13281328                        popnd1->usFlags |= CONSTRUCT_FLAGS(0,0,amod1,0); 
    13291329                } 
    13301330 
    13311331                // If the size of the operand is unknown, assume that it is 
    13321332                // the default size 
    1333                 if ((I32 && (ptb.pptb0->usFlags & _16_bit)) || 
     1333                if (((I64 || I32) && (ptb.pptb0->usFlags & _16_bit)) || 
    13341334                    (I16 && (ptb.pptb0->usFlags & _32_bit))) 
    13351335                { 
    13361336                    //if (asmstate.ucItype != ITjump) 
    13371337                    {   emit(0x66); 
    13381338                        pc->Iflags |= CFopsize; 
    13391339                    } 
    13401340                } 
    13411341                if (((pregSegment = (popndTmp = popnd1)->segreg) != NULL) || 
    13421342                        ((popndTmp = popnd2) != NULL && 
    13431343                        (pregSegment = popndTmp->segreg) != NULL) 
    13441344                  ) 
    13451345                { 
    13461346                    if ((popndTmp->pregDisp1 && 
    13471347                            popndTmp->pregDisp1->val == _BP) || 
    13481348                            popndTmp->pregDisp2 && 
    13491349                            popndTmp->pregDisp2->val == _BP) 
    13501350                            usDefaultseg = _SS; 
    13511351                    else 
    13521352                            usDefaultseg = _DS; 
    13531353                    if (pregSegment->val != usDefaultseg)