Changeset 828
- Timestamp:
- 12/30/10 09:14:27 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/backend/cod2.c (modified) (1 diff)
- branches/dmd-1.x/src/backend/cod3.c (modified) (1 diff)
- branches/dmd-1.x/src/backend/cod4.c (modified) (1 diff)
- branches/dmd-1.x/src/mtype.c (modified) (1 diff)
- branches/dmd-1.x/src/toir.c (modified) (1 diff)
- trunk/src/backend/cod2.c (modified) (1 diff)
- trunk/src/backend/cod3.c (modified) (1 diff)
- trunk/src/backend/cod4.c (modified) (1 diff)
- trunk/src/iasm.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/backend/cod2.c
r814 r828 3586 3586 dstregs = (config.exe & EX_flat) ? mDI : mES|mDI; 3587 3587 if (e1->Eoper == OPind) /* if (*p = ..) */ 3588 3588 { 3589 3589 if (tyreg(e1->E1->Ety)) 3590 3590 dstregs = mDI; 3591 3591 c2 = cod2_setES(e1->E1->Ety); 3592 3592 c2 = cat(c2,scodelem(e1->E1,&dstregs,srcregs,FALSE)); 3593 3593 } 3594 3594 else 3595 3595 c2 = cdrelconst(e1,&dstregs); 3596 3596 freenode(e1); 3597 3597 3598 3598 c3 = getregs((srcregs | dstregs) & (mLSW | mDI)); 3599 3599 if (need_DS) 3600 3600 { assert(!(config.exe & EX_flat)); 3601 3601 c3 = gen1(c3,0x1E); /* PUSH DS */ 3602 3602 gen2(c3,0x8E,modregrm(3,SEG_DS,CX)); /* MOV DS,CX */ 3603 3603 } 3604 3604 if (numbytes <= REGSIZE * (6 + (REGSIZE == 4))) 3605 3605 { 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 */ 3607 3610 code_orrex(c3, rex); 3608 3611 numbytes -= REGSIZE; 3609 3612 } 3610 3613 //if (numbytes) 3611 3614 // printf("cdstreq numbytes %d\n",numbytes); 3612 3615 while (numbytes--) 3613 3616 c3 = gen1(c3,0xA4); /* MOVSB */ 3614 3617 } 3615 3618 else 3616 3619 { 3617 3620 #if 1 3618 3621 unsigned remainder; 3619 3622 3620 3623 remainder = numbytes & (REGSIZE - 1); 3621 3624 numbytes /= REGSIZE; // number of words 3622 3625 c3 = cat(c3,getregs_imm(mCX)); 3623 3626 c3 = movregconst(c3,CX,numbytes,0); // # of bytes/words 3624 3627 gen1(c3,0xF3); // REP 3628 if (REGSIZE == 8) 3629 gen1(c3,REX | REX_W); 3625 3630 gen1(c3,0xA5); // REP MOVSD 3626 3631 regimmed_set(CX,0); // note that CX == 0 3627 3632 for (; remainder; remainder--) 3628 3633 { 3629 3634 gen1(c3, 0xA4); // MOVSB 3630 3635 } 3631 3636 #else 3632 3637 unsigned movs; 3633 3638 3634 3639 if (numbytes & (REGSIZE - 1)) /* if odd */ 3635 3640 movs = 0xA4; /* MOVSB */ 3636 3641 else 3637 3642 { movs = 0xA5; /* MOVSW */ 3638 3643 numbytes /= REGSIZE; /* # of words */ 3639 3644 } 3640 3645 c3 = cat(c3,getregs_imm(mCX)); 3641 3646 c3 = movregconst(c3,CX,numbytes,0); /* # of bytes/words */ 3642 3647 gen1(c3,0xF3); /* REP */ 3643 3648 gen1(c3,movs); 3644 3649 regimmed_set(CX,0); /* note that CX == 0 */ branches/dmd-1.x/src/backend/cod3.c
r772 r828 4203 4203 if (is32bitaddr( I32, flags)) 4204 4204 { 4205 4205 if (issib(rm)) 4206 4206 GEN(c->Isib); 4207 4207 switch (rm & 0xC0) 4208 4208 { case 0x40: 4209 4209 do8bit((enum FL) c->IFL1,&c->IEV1); // 8 bit 4210 4210 break; 4211 4211 case 0: 4212 4212 if (!(issib(rm) && (c->Isib & 7) == 5 || 4213 4213 (rm & 7) == 5)) 4214 4214 break; 4215 4215 case 0x80: 4216 4216 { int flags = CFoff; 4217 4217 targ_size_t val = 0; 4218 4218 if (I64) 4219 4219 { 4220 4220 if ((rm & modregrm(3,0,7)) == modregrm(0,0,5)) // if disp32[RIP] 4221 4221 { flags |= CFpc32; 4222 4222 val = -4; 4223 if (ins & T )4223 if (ins & T || op == 0xF6 || op == 0xF7) 4224 4224 { if (ins & E) 4225 4225 val = -5; 4226 4226 else if (c->Iflags & CFopsize) 4227 4227 val = -6; 4228 4228 else 4229 4229 val = -8; 4230 4230 } 4231 4231 } 4232 4232 } 4233 4233 do32bit((enum FL)c->IFL1,&c->IEV1,flags,val); 4234 4234 break; 4235 4235 } 4236 4236 } 4237 4237 } 4238 4238 else 4239 4239 { 4240 4240 switch (rm & 0xC0) 4241 4241 { case 0x40: 4242 4242 do8bit((enum FL) c->IFL1,&c->IEV1); // 8 bit 4243 4243 break; branches/dmd-1.x/src/backend/cod4.c
r814 r828 3155 3155 if (e2->Eoper == OPconst) 3156 3156 { 3157 3157 cs.Iop = 0x0FBA; // BT rm,imm8 3158 3158 cs.Irm |= modregrm(0,mode,0); 3159 3159 cs.Iflags |= CFpsw | word; 3160 3160 cs.IFL2 = FLconst; 3161 3161 if (tysize[ty1] == SHORTSIZE) 3162 3162 { 3163 3163 cs.IEVoffset1 += (e2->EV.Vuns & ~15) >> 3; 3164 3164 cs.IEV2.Vint = e2->EV.Vint & 15; 3165 3165 } 3166 3166 else if (tysize[ty1] == 4) 3167 3167 { 3168 3168 cs.IEVoffset1 += (e2->EV.Vuns & ~31) >> 3; 3169 3169 cs.IEV2.Vint = e2->EV.Vint & 31; 3170 3170 } 3171 3171 else 3172 3172 { 3173 3173 cs.IEVoffset1 += (e2->EV.Vuns & ~63) >> 3; 3174 3174 cs.IEV2.Vint = e2->EV.Vint & 63; 3175 if (I64) 3176 cs.Irex |= REX_W; 3175 3177 } 3176 3178 c2 = gen(CNIL,&cs); 3177 3179 } 3178 3180 else 3179 3181 { 3180 3182 retregs = ALLREGS & ~idxregs; 3181 3183 c2 = scodelem(e2,&retregs,idxregs,TRUE); 3182 3184 reg = findreg(retregs); 3183 3185 3184 3186 cs.Iop = 0x0F00 | op; // BT rm,reg 3185 3187 code_newreg(&cs,reg); 3186 3188 cs.Iflags |= CFpsw | word; 3187 3189 c2 = gen(c2,&cs); 3188 3190 } 3189 3191 3190 3192 if ((retregs = (*pretregs & (ALLREGS | mBP))) != 0) // if return result in register 3191 3193 { 3192 3194 code *nop = CNIL; 3193 3195 regm_t save = regcon.immed.mval; 3194 3196 code *cg = allocreg(&retregs,®,TYint); branches/dmd-1.x/src/mtype.c
r767 r828 3690 3690 3691 3691 if (sc->parameterSpecialization) 3692 3692 { 3693 3693 unsigned errors = global.errors; 3694 3694 global.gag++; 3695 3695 3696 3696 resolve(loc, sc, &e, &t, &s); 3697 3697 3698 3698 global.gag--; 3699 3699 if (errors != global.errors) 3700 3700 { if (global.gag == 0) 3701 3701 global.errors = errors; 3702 3702 return this; 3703 3703 } 3704 3704 } 3705 3705 else 3706 3706 resolve(loc, sc, &e, &t, &s); 3707 3707 3708 3708 if (!t) 3709 3709 { 3710 #if def DEBUG3710 #if 0 3711 3711 if (s) printf("s = %s\n", s->kind()); 3712 3712 printf("2: e:%p s:%p ", e, s); 3713 3713 #endif 3714 3714 error(loc, "%s is used as a type", toChars()); 3715 3715 t = tvoid; 3716 3716 } 3717 3717 return t; 3718 3718 } 3719 3719 3720 3720 Dsymbol *TypeInstance::toDsymbol(Scope *sc) 3721 3721 { 3722 3722 Type *t; 3723 3723 Expression *e; 3724 3724 Dsymbol *s; 3725 3725 3726 3726 //printf("TypeInstance::semantic(%s)\n", toChars()); 3727 3727 3728 3728 if (sc->parameterSpecialization) 3729 3729 { 3730 3730 unsigned errors = global.errors; branches/dmd-1.x/src/toir.c
r767 r828 391 391 "9intrinsic5outplFNbkkZk", 392 392 "9intrinsic5outpwFNbktZt", 393 393 #endif 394 394 }; 395 395 static const char *namearray64[] = 396 396 { 397 397 #if DMDV1 398 398 "4math3cosFeZe", 399 399 "4math3sinFeZe", 400 400 "4math4fabsFeZe", 401 401 "4math4rintFeZe", 402 402 "4math4sqrtFdZd", 403 403 "4math4sqrtFeZe", 404 404 "4math4sqrtFfZf", 405 405 "4math4yl2xFeeZe", 406 406 "4math5ldexpFeiZe", 407 407 "4math6rndtolFeZl", 408 408 "4math6yl2xp1FeeZe", 409 409 410 410 "9intrinsic2btFPmmZi", 411 "9intrinsic3bsfF kZi",412 "9intrinsic3bsrF kZi",411 "9intrinsic3bsfFmZi", 412 "9intrinsic3bsrFmZi", 413 413 "9intrinsic3btcFPmmZi", 414 414 "9intrinsic3btrFPmmZi", 415 415 "9intrinsic3btsFPmmZi", 416 416 "9intrinsic3inpFkZh", 417 417 "9intrinsic4inplFkZk", 418 418 "9intrinsic4inpwFkZt", 419 419 "9intrinsic4outpFkhZh", 420 420 "9intrinsic5bswapFkZk", 421 421 "9intrinsic5outplFkkZk", 422 422 "9intrinsic5outpwFktZt", 423 423 #elif DMDV2 424 424 /* The names are mangled differently because of the pure and 425 425 * nothrow attributes. 426 426 */ 427 427 "4math3cosFNaNbNfeZe", 428 428 "4math3sinFNaNbNfeZe", 429 429 "4math4fabsFNaNbNfeZe", 430 430 "4math4rintFNaNbNfeZe", 431 431 "4math4sqrtFNaNbNfdZd", 432 432 "4math4sqrtFNaNbNfeZe", trunk/src/backend/cod2.c
r813 r828 3586 3586 dstregs = (config.exe & EX_flat) ? mDI : mES|mDI; 3587 3587 if (e1->Eoper == OPind) /* if (*p = ..) */ 3588 3588 { 3589 3589 if (tyreg(e1->E1->Ety)) 3590 3590 dstregs = mDI; 3591 3591 c2 = cod2_setES(e1->E1->Ety); 3592 3592 c2 = cat(c2,scodelem(e1->E1,&dstregs,srcregs,FALSE)); 3593 3593 } 3594 3594 else 3595 3595 c2 = cdrelconst(e1,&dstregs); 3596 3596 freenode(e1); 3597 3597 3598 3598 c3 = getregs((srcregs | dstregs) & (mLSW | mDI)); 3599 3599 if (need_DS) 3600 3600 { assert(!(config.exe & EX_flat)); 3601 3601 c3 = gen1(c3,0x1E); /* PUSH DS */ 3602 3602 gen2(c3,0x8E,modregrm(3,SEG_DS,CX)); /* MOV DS,CX */ 3603 3603 } 3604 3604 if (numbytes <= REGSIZE * (6 + (REGSIZE == 4))) 3605 3605 { 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 */ 3607 3610 code_orrex(c3, rex); 3608 3611 numbytes -= REGSIZE; 3609 3612 } 3610 3613 //if (numbytes) 3611 3614 // printf("cdstreq numbytes %d\n",numbytes); 3612 3615 while (numbytes--) 3613 3616 c3 = gen1(c3,0xA4); /* MOVSB */ 3614 3617 } 3615 3618 else 3616 3619 { 3617 3620 #if 1 3618 3621 unsigned remainder; 3619 3622 3620 3623 remainder = numbytes & (REGSIZE - 1); 3621 3624 numbytes /= REGSIZE; // number of words 3622 3625 c3 = cat(c3,getregs_imm(mCX)); 3623 3626 c3 = movregconst(c3,CX,numbytes,0); // # of bytes/words 3624 3627 gen1(c3,0xF3); // REP 3628 if (REGSIZE == 8) 3629 gen1(c3,REX | REX_W); 3625 3630 gen1(c3,0xA5); // REP MOVSD 3626 3631 regimmed_set(CX,0); // note that CX == 0 3627 3632 for (; remainder; remainder--) 3628 3633 { 3629 3634 gen1(c3, 0xA4); // MOVSB 3630 3635 } 3631 3636 #else 3632 3637 unsigned movs; 3633 3638 3634 3639 if (numbytes & (REGSIZE - 1)) /* if odd */ 3635 3640 movs = 0xA4; /* MOVSB */ 3636 3641 else 3637 3642 { movs = 0xA5; /* MOVSW */ 3638 3643 numbytes /= REGSIZE; /* # of words */ 3639 3644 } 3640 3645 c3 = cat(c3,getregs_imm(mCX)); 3641 3646 c3 = movregconst(c3,CX,numbytes,0); /* # of bytes/words */ 3642 3647 gen1(c3,0xF3); /* REP */ 3643 3648 gen1(c3,movs); 3644 3649 regimmed_set(CX,0); /* note that CX == 0 */ trunk/src/backend/cod3.c
r772 r828 4203 4203 if (is32bitaddr( I32, flags)) 4204 4204 { 4205 4205 if (issib(rm)) 4206 4206 GEN(c->Isib); 4207 4207 switch (rm & 0xC0) 4208 4208 { case 0x40: 4209 4209 do8bit((enum FL) c->IFL1,&c->IEV1); // 8 bit 4210 4210 break; 4211 4211 case 0: 4212 4212 if (!(issib(rm) && (c->Isib & 7) == 5 || 4213 4213 (rm & 7) == 5)) 4214 4214 break; 4215 4215 case 0x80: 4216 4216 { int flags = CFoff; 4217 4217 targ_size_t val = 0; 4218 4218 if (I64) 4219 4219 { 4220 4220 if ((rm & modregrm(3,0,7)) == modregrm(0,0,5)) // if disp32[RIP] 4221 4221 { flags |= CFpc32; 4222 4222 val = -4; 4223 if (ins & T )4223 if (ins & T || op == 0xF6 || op == 0xF7) 4224 4224 { if (ins & E) 4225 4225 val = -5; 4226 4226 else if (c->Iflags & CFopsize) 4227 4227 val = -6; 4228 4228 else 4229 4229 val = -8; 4230 4230 } 4231 4231 } 4232 4232 } 4233 4233 do32bit((enum FL)c->IFL1,&c->IEV1,flags,val); 4234 4234 break; 4235 4235 } 4236 4236 } 4237 4237 } 4238 4238 else 4239 4239 { 4240 4240 switch (rm & 0xC0) 4241 4241 { case 0x40: 4242 4242 do8bit((enum FL) c->IFL1,&c->IEV1); // 8 bit 4243 4243 break; trunk/src/backend/cod4.c
r813 r828 3155 3155 if (e2->Eoper == OPconst) 3156 3156 { 3157 3157 cs.Iop = 0x0FBA; // BT rm,imm8 3158 3158 cs.Irm |= modregrm(0,mode,0); 3159 3159 cs.Iflags |= CFpsw | word; 3160 3160 cs.IFL2 = FLconst; 3161 3161 if (tysize[ty1] == SHORTSIZE) 3162 3162 { 3163 3163 cs.IEVoffset1 += (e2->EV.Vuns & ~15) >> 3; 3164 3164 cs.IEV2.Vint = e2->EV.Vint & 15; 3165 3165 } 3166 3166 else if (tysize[ty1] == 4) 3167 3167 { 3168 3168 cs.IEVoffset1 += (e2->EV.Vuns & ~31) >> 3; 3169 3169 cs.IEV2.Vint = e2->EV.Vint & 31; 3170 3170 } 3171 3171 else 3172 3172 { 3173 3173 cs.IEVoffset1 += (e2->EV.Vuns & ~63) >> 3; 3174 3174 cs.IEV2.Vint = e2->EV.Vint & 63; 3175 if (I64) 3176 cs.Irex |= REX_W; 3175 3177 } 3176 3178 c2 = gen(CNIL,&cs); 3177 3179 } 3178 3180 else 3179 3181 { 3180 3182 retregs = ALLREGS & ~idxregs; 3181 3183 c2 = scodelem(e2,&retregs,idxregs,TRUE); 3182 3184 reg = findreg(retregs); 3183 3185 3184 3186 cs.Iop = 0x0F00 | op; // BT rm,reg 3185 3187 code_newreg(&cs,reg); 3186 3188 cs.Iflags |= CFpsw | word; 3187 3189 c2 = gen(c2,&cs); 3188 3190 } 3189 3191 3190 3192 if ((retregs = (*pretregs & (ALLREGS | mBP))) != 0) // if return result in register 3191 3193 { 3192 3194 code *nop = CNIL; 3193 3195 regm_t save = regcon.immed.mval; 3194 3196 code *cg = allocreg(&retregs,®,TYint); trunk/src/iasm.c
r771 r828 1313 1313 (uSizemaskTable1 & _32 && aoptyTable1 == _mnoi) || 1314 1314 (ptb.pptb1->usFlags & _16_bit_addr))) || 1315 1315 (I16 && 1316 1316 (amod1 == _addr32 || 1317 1317 (uSizemaskTable1 & _32 && aoptyTable1 == _rel) || 1318 1318 (uSizemaskTable1 & _48 && aoptyTable1 == _mnoi) || 1319 1319 (ptb.pptb1->usFlags & _32_bit_addr)))) 1320 1320 { 1321 1321 emit(0x67); // address size prefix 1322 1322 pc->Iflags |= CFaddrsize; 1323 1323 if (I32) 1324 1324 amod1 = _addr16; 1325 1325 else 1326 1326 amod1 = _addr32; 1327 1327 popnd1->usFlags &= ~CONSTRUCT_FLAGS(0,0,7,0); 1328 1328 popnd1->usFlags |= CONSTRUCT_FLAGS(0,0,amod1,0); 1329 1329 } 1330 1330 1331 1331 // If the size of the operand is unknown, assume that it is 1332 1332 // the default size 1333 if (( I32&& (ptb.pptb0->usFlags & _16_bit)) ||1333 if (((I64 || I32) && (ptb.pptb0->usFlags & _16_bit)) || 1334 1334 (I16 && (ptb.pptb0->usFlags & _32_bit))) 1335 1335 { 1336 1336 //if (asmstate.ucItype != ITjump) 1337 1337 { emit(0x66); 1338 1338 pc->Iflags |= CFopsize; 1339 1339 } 1340 1340 } 1341 1341 if (((pregSegment = (popndTmp = popnd1)->segreg) != NULL) || 1342 1342 ((popndTmp = popnd2) != NULL && 1343 1343 (pregSegment = popndTmp->segreg) != NULL) 1344 1344 ) 1345 1345 { 1346 1346 if ((popndTmp->pregDisp1 && 1347 1347 popndTmp->pregDisp1->val == _BP) || 1348 1348 popndTmp->pregDisp2 && 1349 1349 popndTmp->pregDisp2->val == _BP) 1350 1350 usDefaultseg = _SS; 1351 1351 else 1352 1352 usDefaultseg = _DS; 1353 1353 if (pregSegment->val != usDefaultseg)
