diff --git a/compiler/src/dmd/backend/cgcod.d b/compiler/src/dmd/backend/cgcod.d index dcfbc22782ac..a7f2c44d35b4 100644 --- a/compiler/src/dmd/backend/cgcod.d +++ b/compiler/src/dmd/backend/cgcod.d @@ -110,8 +110,6 @@ private Symbol *retsym; // set to symbol that should be placed in regm_t msavereg; // Mask of registers that we would like to save. // they are temporaries (set by scodelem()) regm_t mfuncreg; // Mask of registers preserved by a function - -regm_t allregs; // ALLREGS optionally including mBP } /********************************* @@ -131,7 +129,7 @@ void codgen(Symbol *sfunc) cgreg_init(); CSE.initialize(); - allregs = ALLREGS; + cgstate.allregs = ALLREGS; cgstate.Alloca.initialize(); anyiasm = 0; @@ -272,12 +270,12 @@ void codgen(Symbol *sfunc) } // See which variables we can put into registers - allregs |= cod3_useBP(); // use EBP as general purpose register + cgstate.allregs |= cod3_useBP(); // use EBP as general purpose register // If pic code, but EBX was never needed - if (!(allregs & mask(PICREG)) && !gotref) + if (!(cgstate.allregs & mask(PICREG)) && !gotref) { - allregs |= mask(PICREG); // EBX can now be used + cgstate.allregs |= mask(PICREG); // EBX can now be used cgreg_assign(retsym); pass = BackendPass.reg; } @@ -1634,7 +1632,7 @@ static if (0) } tym = tybasic(tym); uint size = _tysize[tym]; - outretregs &= mES | allregs | XMMREGS; + outretregs &= mES | cgstate.allregs | XMMREGS; regm_t retregs = outretregs; regm_t[] lastRetregs = cgstate.lastRetregs[]; @@ -1661,12 +1659,12 @@ static if (0) } int count = 0; L1: - //printf("L1: allregs = %s, outretregs = %s\n", regm_str(allregs), regm_str(outretregs)); + //printf("L1: allregs = %s, outretregs = %s\n", regm_str(cgstate.allregs), regm_str(outretregs)); assert(++count < 20); /* fail instead of hanging if blocked */ assert(retregs); reg_t msreg = NOREG, lsreg = NOREG; /* no value assigned yet */ L3: - //printf("L2: allregs = %s, outretregs = %s\n", regm_str(allregs), regm_str(outretregs)); + //printf("L2: allregs = %s, outretregs = %s\n", regm_str(cgstate.allregs), regm_str(outretregs)); regm_t r = retregs & ~(msavereg | regcon.cse.mval | regcon.params); if (!r) { @@ -1816,10 +1814,10 @@ regm_t lpadregs() { regm_t used; if (config.ehmethod == EHmethod.EH_DWARF) - used = allregs & ~mfuncreg; + used = cgstate.allregs & ~mfuncreg; else - used = (I32 | I64) ? allregs : (ALLREGS | mES); - //printf("lpadregs(): used=%s, allregs=%s, mfuncreg=%s\n", regm_str(used), regm_str(allregs), regm_str(mfuncreg)); + used = (I32 | I64) ? cgstate.allregs : (ALLREGS | mES); + //printf("lpadregs(): used=%s, allregs=%s, mfuncreg=%s\n", regm_str(used), regm_str(cgstate.llregs), regm_str(mfuncreg)); return used; } @@ -2039,7 +2037,7 @@ bool evalinregister(elem *e) sz <= REGSIZE) { // Do it only if at least 2 registers are available - regm_t m = allregs & ~regcon.mvar; + regm_t m = cgstate.allregs & ~regcon.mvar; if (sz == 1) m &= BYTEREGS; if (m & (m - 1)) // if more than one register @@ -2080,7 +2078,7 @@ regm_t getscratch() regm_t scratch = 0; if (pass == BackendPass.final_) { - scratch = allregs & ~(regcon.mvar | regcon.mpvar | regcon.cse.mval | + scratch = cgstate.allregs & ~(regcon.mvar | regcon.mpvar | regcon.cse.mval | regcon.immed.mval | regcon.params | mfuncreg); } return scratch; @@ -2197,8 +2195,8 @@ private void comsub(ref CodeBuilder cdb,elem *e, ref regm_t pretregs) retregs = pretregs; if (byte_ && !(retregs & BYTEREGS)) retregs = BYTEREGS; - else if (!(retregs & allregs)) - retregs = allregs; + else if (!(retregs & cgstate.allregs)) + retregs = cgstate.allregs; reg = allocreg(cdb,retregs,tym); code *cr = &cse.csimple; cr.setReg(reg); @@ -2851,7 +2849,7 @@ void scodelem(ref CodeBuilder cdb, elem *e,regm_t *pretregs,regm_t keepmsk,bool touse = 0; // PUSH/POP pairs are always shorter else { - touse = mfuncreg & allregs & ~(msavereg | oldregcon | regcon.cse.mval); + touse = mfuncreg & cgstate.allregs & ~(msavereg | oldregcon | regcon.cse.mval); /* Don't use registers we'll have to save/restore */ touse &= ~(fregsaved & oldmfuncreg); /* Don't use registers that have constant values in them, since @@ -2966,8 +2964,8 @@ const(char)* regm_str(regm_t rm) return "ALLREGS"; if (rm == BYTEREGS) return "BYTEREGS"; - if (rm == allregs) - return "allregs"; + if (rm == cgstate.allregs) + return "cgstate.allregs"; if (rm == XMMREGS) return "XMMREGS"; char *p = str[i].ptr; diff --git a/compiler/src/dmd/backend/cgreg.d b/compiler/src/dmd/backend/cgreg.d index 668b213634ba..8310b1dfcd29 100644 --- a/compiler/src/dmd/backend/cgreg.d +++ b/compiler/src/dmd/backend/cgreg.d @@ -911,13 +911,13 @@ int cgreg_assign(Symbol *retsym) continue; // If BP isn't available, can't assign to it - if (reg == BP && !(allregs & mBP)) + if (reg == BP && !(cgstate.allregs & mBP)) continue; static if (0 && TARGET_LINUX) { // Need EBX for static pointer - if (reg == BX && !(allregs & mBX)) + if (reg == BX && !(cgstate.allregs & mBX)) continue; } /* Don't enregister any parameters to variadicPrologRegs diff --git a/compiler/src/dmd/backend/cgsched.d b/compiler/src/dmd/backend/cgsched.d index 4bf2efb83b38..51e427ced3cf 100644 --- a/compiler/src/dmd/backend/cgsched.d +++ b/compiler/src/dmd/backend/cgsched.d @@ -158,7 +158,7 @@ public void cgsched_block(block* b) config.target_cpu >= TARGET_Pentium && b.BC != BCasm) { - regm_t scratch = allregs; + regm_t scratch = cgstate.allregs; scratch &= ~(b.Bregcon.used | b.Bregcon.params | mfuncreg); scratch &= ~(b.Bregcon.immed.mval | b.Bregcon.cse.mval); diff --git a/compiler/src/dmd/backend/cod1.d b/compiler/src/dmd/backend/cod1.d index bbaaecdab106..a33d0678de43 100644 --- a/compiler/src/dmd/backend/cod1.d +++ b/compiler/src/dmd/backend/cod1.d @@ -984,7 +984,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk) /*assert(datafl[f]);*/ /* what if addr of func? */ if (!I16) { /* Any register can be an index register */ - regm_t idxregs = allregs & ~keepmsk; + regm_t idxregs = cgstate.allregs & ~keepmsk; assert(idxregs); /* See if e1.E1 can be a scaled index */ @@ -1185,7 +1185,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk) /* The rest of the cases could be a far pointer */ regm_t idxregs; - idxregs = (I16 ? IDXREGS : allregs) & ~keepmsk; // only these can be index regs + idxregs = (I16 ? IDXREGS : cgstate.allregs) & ~keepmsk; // only these can be index regs assert(idxregs); if (!I16 && (sz == REGSIZE || (I64 && sz == 4)) && @@ -1283,7 +1283,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk) if (ss) { scodelem(cdb, e11, &idxregs, keepmsk, true); - idxregs2 = allregs & ~(idxregs | keepmsk); + idxregs2 = cgstate.allregs & ~(idxregs | keepmsk); cdisscaledindex(cdb, e12, &idxregs2, keepmsk | idxregs); } @@ -1292,7 +1292,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk) { idxregs2 = idxregs; cdisscaledindex(cdb, e11, &idxregs2, keepmsk); - idxregs = allregs & ~(idxregs2 | keepmsk); + idxregs = cgstate.allregs & ~(idxregs2 | keepmsk); scodelem(cdb, e12, &idxregs, keepmsk | idxregs2, true); } // Look for *(((v1 << scale) + c1) + v2) @@ -1304,7 +1304,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk) pcs.IEV1.Vuns = e11.E2.Vuns; idxregs2 = idxregs; cdisscaledindex(cdb, e11.E1, &idxregs2, keepmsk); - idxregs = allregs & ~(idxregs2 | keepmsk); + idxregs = cgstate.allregs & ~(idxregs2 | keepmsk); scodelem(cdb, e12, &idxregs, keepmsk | idxregs2, true); freenode(e11.E2); freenode(e11); @@ -1312,7 +1312,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk) else { scodelem(cdb, e11, &idxregs, keepmsk, true); - idxregs2 = allregs & ~(idxregs | keepmsk); + idxregs2 = cgstate.allregs & ~(idxregs | keepmsk); scodelem(cdb, e12, &idxregs2, keepmsk | idxregs, true); } base = findreg(idxregs); @@ -1764,7 +1764,7 @@ void tstresult(ref CodeBuilder cdb, regm_t regm, tym_t tym, uint saveflag) { if (saveflag) { - scrregm = allregs & ~regm; // possible scratch regs + scrregm = cgstate.allregs & ~regm; // possible scratch regs scrreg = allocreg(cdb, scrregm, TYoffset); // allocate scratch reg genmovreg(cdb, scrreg, reg); // MOV scrreg,msreg reg = scrreg; @@ -3747,7 +3747,7 @@ void cdfunc(ref CodeBuilder cdb, elem* e, regm_t* pretregs) void cdstrthis(ref CodeBuilder cdb, elem* e, regm_t* pretregs) { assert(tysize(e.Ety) == REGSIZE); - const reg = findreg(*pretregs & allregs); + const reg = findreg(*pretregs & cgstate.allregs); getregs(cdb,mask(reg)); // LEA reg,np[ESP] uint np = stackpush - e.Vuns; // stack delta to parameter @@ -3836,7 +3836,7 @@ private void funccall(ref CodeBuilder cdb, elem* e, uint numpara, uint numalign, } if (sytab[s.Sclass] & SCSS) // if function is on stack (!) { - retregs = allregs & ~keepmsk; + retregs = cgstate.allregs & ~keepmsk; s.Sflags &= ~GTregcand; s.Sflags |= SFLread; cdrelconst(cdbe,e1,&retregs); @@ -3926,7 +3926,7 @@ private void funccall(ref CodeBuilder cdb, elem* e, uint numpara, uint numalign, if ((!OTleaf(e11.Eoper) || e11.Eoper == OPconst) && (e11.Eoper != OPind || e11.Ecount)) { - retregs = allregs & ~keepmsk; + retregs = cgstate.allregs & ~keepmsk; cgstate.stackclean++; scodelem(cdbe,e11,&retregs,keepmsk,true); cgstate.stackclean--; @@ -4273,7 +4273,7 @@ private void movParams(ref CodeBuilder cdb, elem* e, uint stackalign, uint funca int i = cast(int)sz; do { int regsize = REGSIZE; - regm_t retregs = (sz == 1) ? BYTEREGS : allregs; + regm_t retregs = (sz == 1) ? BYTEREGS : cgstate.allregs; reg_t reg; if (reghasvalue(retregs,*p,reg)) { @@ -4305,7 +4305,7 @@ private void movParams(ref CodeBuilder cdb, elem* e, uint stackalign, uint funca default: break; } - regm_t retregs = tybyte(tym) ? BYTEREGS : allregs; + regm_t retregs = tybyte(tym) ? BYTEREGS : cgstate.allregs; if (tyvector(tym) || config.fpxmmregs && tyxmmreg(tym) && // If not already in x87 register from function call return @@ -4827,7 +4827,7 @@ void pushParams(ref CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf) for (int i = 0; i < 3; ++i) { reg_t reg; - if (reghasvalue(allregs, value, reg)) + if (reghasvalue(cgstate.allregs, value, reg)) cdb.gen1(0x50 + reg); // PUSH reg else cdb.genc2(0x68,0,value); // PUSH value @@ -4898,16 +4898,16 @@ void pushParams(ref CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf) { if (I64 && regsize == 8 && value != cast(int)value) { - reg = regwithvalue(cdb,allregs,value,64); + reg = regwithvalue(cdb,cgstate.allregs,value,64); goto Preg; // cannot push imm64 unless it is sign extended 32 bit value } - if (regsize == REGSIZE && reghasvalue(allregs,value,reg)) + if (regsize == REGSIZE && reghasvalue(cgstate.allregs,value,reg)) goto Preg; cdb.genc2((szb == 1) ? 0x6A : 0x68, 0, value); // PUSH value } else { - reg = regwithvalue(cdb, allregs, value, 0); + reg = regwithvalue(cdb, cgstate.allregs, value, 0); Preg: genpush(cdb,reg); // PUSH reg } @@ -4938,7 +4938,7 @@ void pushParams(ref CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf) } else { - regm_t regs = allregs; + regm_t regs = cgstate.allregs; codelem(cdb, e, ®s, false); genpush(cdb, findregmsw(regs)); // PUSH msreg genpush(cdb, findreglsw(regs)); // PUSH lsreg @@ -4969,7 +4969,7 @@ void pushParams(ref CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf) } else { - regm_t regs = allregs; + regm_t regs = cgstate.allregs; codelem(cdb, e, ®s, false); genpush(cdb, findregmsw(regs)); // PUSH msreg genpush(cdb, findreglsw(regs)); // PUSH lsreg @@ -4983,7 +4983,7 @@ void pushParams(ref CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf) break; } - regm_t retregs = tybyte(tym) ? BYTEREGS : allregs; + regm_t retregs = tybyte(tym) ? BYTEREGS : cgstate.allregs; if (tyvector(tym) || (tyxmmreg(tym) && config.fpxmmregs)) { regm_t retxmm = XMMREGS; @@ -5178,7 +5178,7 @@ void loaddata(ref CodeBuilder cdb, elem* e, ref regm_t outretregs) if (outretregs == mPSW) { Symbol *s; - regm = allregs; + regm = cgstate.allregs; if (e.Eoper == OPconst) { /* true: OR SP,SP (SP is never 0) */ /* false: CMP SP,SP (always equal) */ diff --git a/compiler/src/dmd/backend/cod2.d b/compiler/src/dmd/backend/cod2.d index 32edfc4f3fa3..8161368a466e 100644 --- a/compiler/src/dmd/backend/cod2.d +++ b/compiler/src/dmd/backend/cod2.d @@ -519,7 +519,7 @@ void cdorth(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } } - regm_t posregs = (isbyte) ? BYTEREGS : (mES | allregs); + regm_t posregs = (isbyte) ? BYTEREGS : (mES | cgstate.allregs); regm_t retregs = *pretregs & posregs; if (retregs == 0) /* if no return regs speced */ /* (like if wanted flags only) */ @@ -993,7 +993,7 @@ void cdmul(ref CodeBuilder cdb,elem *e,regm_t *pretregs) */ regm_t retregs = mAX | mDX; codelem(cdb,e1,&retregs,false); // eval left leaf - reg_t reg = allocScratchReg(cdb, allregs & ~(mAX | mDX)); + reg_t reg = allocScratchReg(cdb, cgstate.allregs & ~(mAX | mDX)); getregs(cdb,mDX | mAX); const lsw = cast(targ_int)(e2factor & ((1L << (REGSIZE * 8)) - 1)); @@ -1174,7 +1174,7 @@ void cdmul(ref CodeBuilder cdb,elem *e,regm_t *pretregs) codelem(cdb,e1,&retregs,false); // eval left leaf if (config.target_cpu >= TARGET_PentiumPro) { - regm_t rretregs = allregs & ~retregs; // second arg + regm_t rretregs = cgstate.allregs & ~retregs; // second arg scodelem(cdb,e2,&rretregs,retregs,true); // get rvalue regm_t rlo = findreglsw(rretregs); regm_t rhi = findregmsw(rretregs); @@ -1365,7 +1365,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) const int N = sz * 8; const bool mhighbit = choose_multiplier(N, d, N - 1, &m, &shpost); - regm_t regm = allregs & ~(mAX | mDX); + regm_t regm = cgstate.allregs & ~(mAX | mDX); codelem(cdb,e1,®m,false); // eval left leaf const reg_t reg = findreg(regm); getregs(cdb,regm | mDX | mAX); @@ -1478,7 +1478,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) */ assert(shpre == 0); - regm = allregs & ~(mAX | mDX); + regm = cgstate.allregs & ~(mAX | mDX); codelem(cdb,e1,®m,false); // eval left leaf reg = findreg(regm); getregs(cdb,mAX | mDX); @@ -1489,7 +1489,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) genmovreg(cdb,AX,reg); // MOV EAX,reg cdb.gen2(0x2B,grex | modregrm(3,AX,DX)); // SUB EAX,EDX cdb.genc2(0xC1,grex | modregrm(3,5,AX),1); // SHR EAX,1 - regm_t regm3 = allregs; + regm_t regm3 = cgstate.allregs; if (oper == OPmod || oper == OPremquo) { regm3 &= ~regm; @@ -1511,7 +1511,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) */ regm = mAX; if (oper == OPmod || oper == OPremquo) - regm = allregs & ~(mAX|mDX); + regm = cgstate.allregs & ~(mAX|mDX); codelem(cdb,e1,®m,false); // eval left leaf reg = findreg(regm); @@ -1614,7 +1614,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) if (pow2 < 32) { - reg_t r1 = allocScratchReg(cdb, allregs & ~retregs); + reg_t r1 = allocScratchReg(cdb, cgstate.allregs & ~retregs); genmovreg(cdb,r1,rhi); // MOV r1,rhi if (pow2 == 1) @@ -1631,7 +1631,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (pow2 == 32) { - reg_t r1 = allocScratchReg(cdb, allregs & ~retregs); + reg_t r1 = allocScratchReg(cdb, cgstate.allregs & ~retregs); genmovreg(cdb,r1,rhi); // MOV r1,rhi cdb.genc2(0xC1,grex | modregrmx(3,7,r1),REGSIZE * 8 - 1); // SAR r1,31 @@ -1642,8 +1642,8 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (pow2 < 63) { - reg_t r1 = allocScratchReg(cdb, allregs & ~retregs); - reg_t r2 = allocScratchReg(cdb, allregs & ~(retregs | mask(r1))); + reg_t r1 = allocScratchReg(cdb, cgstate.allregs & ~retregs); + reg_t r2 = allocScratchReg(cdb, cgstate.allregs & ~(retregs | mask(r1))); genmovreg(cdb,r1,rhi); // MOV r1,rhi cdb.genc2(0xC1,grex | modregrmx(3,7,r1),REGSIZE * 8 - 1); // SAR r1,31 @@ -1695,7 +1695,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) freenode(e2); getregs(cdb,retregs); - regm_t scratchm = allregs & ~retregs; + regm_t scratchm = cgstate.allregs & ~retregs; if (pow2 == 63) scratchm &= BYTEREGS; // because of SETZ reg_t r1 = allocScratchReg(cdb, scratchm); @@ -1721,7 +1721,7 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (pow2 < 63) { - reg_t r2 = allocScratchReg(cdb, allregs & ~(retregs | mask(r1))); + reg_t r2 = allocScratchReg(cdb, cgstate.allregs & ~(retregs | mask(r1))); cdb.genmovreg(r1,rhi); // MOV r1,rhi cdb.genc2(0xC1,grex | modregrmx(3,7,r1),REGSIZE * 8 - 1); // SAR r1,31 @@ -1767,13 +1767,13 @@ void cddiv(ref CodeBuilder cdb,elem *e,regm_t *pretregs) ADD reg,r SAR reg,1 */ - regm_t retregs = allregs; + regm_t retregs = cgstate.allregs; codelem(cdb,e.E1,&retregs,false); // eval left leaf const reg = findreg(retregs); freenode(e2); getregs(cdb,retregs); - reg_t r = allocScratchReg(cdb, allregs & ~retregs); + reg_t r = allocScratchReg(cdb, cgstate.allregs & ~retregs); genmovreg(cdb,r,reg); // MOV r,reg cdb.genc2(0xC1,grex | modregxrmx(3,5,r),(sz * 8 - 1)); // SHR r,31 cdb.gen2(0x03,grex | modregxrmx(3,reg,r)); // ADD reg,r @@ -2171,7 +2171,7 @@ void cdcom(ref CodeBuilder cdb,elem *e,regm_t *pretregs) tym_t tym = tybasic(e.Ety); int sz = _tysize[tym]; uint rex = (I64 && sz == 8) ? REX_W : 0; - regm_t possregs = (sz == 1) ? BYTEREGS : allregs; + regm_t possregs = (sz == 1) ? BYTEREGS : cgstate.allregs; regm_t retregs = *pretregs & possregs; if (retregs == 0) retregs = possregs; @@ -2217,7 +2217,7 @@ void cdbswap(ref CodeBuilder cdb,elem *e,regm_t *pretregs) const tym = tybasic(e.Ety); const sz = _tysize[tym]; - const posregs = (sz == 2) ? mAX|mBX|mCX|mDX : allregs; + const posregs = (sz == 2) ? mAX|mBX|mCX|mDX : cgstate.allregs; regm_t retregs = *pretregs & posregs; if (retregs == 0) retregs = posregs; @@ -2654,7 +2654,7 @@ void cdloglog(ref CodeBuilder cdb,elem *e,regm_t *pretregs) assert(stackpush == stackpushsave); assert(sz <= 4); // result better be int - regm_t retregs = *pretregs & allregs; + regm_t retregs = *pretregs & cgstate.allregs; const reg = allocreg(cdb1,retregs,TYint); // allocate reg for result movregconst(cdb1,reg,e.Eoper == OPoror,0); // reg = 1 regcon.immed.mval &= ~mask(reg); // mark reg as unavail @@ -3410,7 +3410,7 @@ void cdind(ref CodeBuilder cdb,elem *e,regm_t *pretregs) // the addressing mode. if ((retregs & idxregs) == retregs) { - retregs = mMSW & allregs & ~idxregs; + retregs = mMSW & cgstate.allregs & ~idxregs; if (!retregs) retregs |= mCX; retregs |= mLSW & ~idxregs; @@ -4175,7 +4175,7 @@ void cdmemset(ref CodeBuilder cdb,elem *e,regm_t *pretregs) else { genregs(cdb,MOVZXb,AX,AX); // MOVZX EAX,AL - regm_t regm = allregs & ~(mAX | retregs2); + regm_t regm = cgstate.allregs & ~(mAX | retregs2); const r = regwithvalue(cdb,regm,cast(targ_size_t)0x01010101_01010101,64); // MOV reg,0x01010101_01010101 cdb.gen2(0x0FAF,grex | modregrmx(3,AX,r)); // IMUL RAX,reg } @@ -4256,7 +4256,7 @@ void cdmemset(ref CodeBuilder cdb,elem *e,regm_t *pretregs) REP STOSB */ - regm_t regs = allregs & (*pretregs ? ~(mAX|mBX|mCX|mDI) : ~(mAX|mCX|mDI)); + regm_t regs = cgstate.allregs & (*pretregs ? ~(mAX|mBX|mCX|mDI) : ~(mAX|mCX|mDI)); const sreg = allocreg(cdb,regs,TYint); genregs(cdb,0x89,CX,sreg); // MOV sreg,ECX (32 bits only) @@ -4315,7 +4315,7 @@ private void cdmemsetn(ref CodeBuilder cdb,elem *e,regm_t *pretregs) codelem(cdb,enelems,&mregcx,false); // Get value into AX - regm_t retregs3 = allregs & ~mregcx; + regm_t retregs3 = cgstate.allregs & ~mregcx; if (sz == 2 * REGSIZE) retregs3 &= ~(mBP | IDXREGS); // BP cannot be used for register pair, // IDXREGS could deplete index regs - see sdtor.d test14815() @@ -4355,7 +4355,7 @@ private void cdmemsetn(ref CodeBuilder cdb,elem *e,regm_t *pretregs) { mregbx = *pretregs & ~(mregidx | mregcx | retregs3); if (!mregbx) - mregbx = allregs & ~(mregidx | mregcx | retregs3); + mregbx = cgstate.allregs & ~(mregidx | mregcx | retregs3); const regbx = allocreg(cdb, mregbx, TYnptr); getregs(cdb, mregbx); genmovreg(cdb,regbx,idxreg); // MOV BX,DI @@ -5011,7 +5011,7 @@ void cdneg(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } const uint isbyte = sz == 1; - const possregs = (isbyte) ? BYTEREGS : allregs; + const possregs = (isbyte) ? BYTEREGS : cgstate.allregs; regm_t retregs = *pretregs & possregs; if (retregs == 0) retregs = possregs; @@ -5091,9 +5091,9 @@ void cdabs(ref CodeBuilder cdb,elem *e, regm_t *pretregs) const uint isbyte = sz == 1; assert(isbyte == 0); - regm_t possregs = (sz <= REGSIZE) ? cast(regm_t) mAX : allregs; + regm_t possregs = (sz <= REGSIZE) ? cast(regm_t) mAX : cgstate.allregs; if (!I16 && sz == REGSIZE) - possregs = allregs; + possregs = cgstate.allregs; regm_t retregs = *pretregs & possregs; if (retregs == 0) retregs = possregs; @@ -5116,7 +5116,7 @@ void cdabs(ref CodeBuilder cdb,elem *e, regm_t *pretregs) if (!I16 && sz == REGSIZE) { reg = findreg(retregs); - r = allocScratchReg(cdb, allregs & ~retregs); + r = allocScratchReg(cdb, cgstate.allregs & ~retregs); getregs(cdb,retregs); genmovreg(cdb,r,reg); // MOV r,reg cdb.genc2(0xC1,modregrmx(3,7,r),REGSIZE * 8 - 1); // SAR r,31/63 @@ -5306,7 +5306,7 @@ if (config.exe & EX_windos) assert(e2.Eoper == OPconst); uint isbyte = (sz == 1); - regm_t possregs = isbyte ? BYTEREGS : allregs; + regm_t possregs = isbyte ? BYTEREGS : cgstate.allregs; getlvalue(cdb,&cs,e.E1,0); freenode(e.E1); regm_t idxregs = idxregm(&cs); // mask of index regs used @@ -5527,7 +5527,7 @@ if (config.exe & EX_windos) } else if (sz == 2 * REGSIZE) { - regm_t retregs = allregs & ~idxregs & *pretregs; + regm_t retregs = cgstate.allregs & ~idxregs & *pretregs; if ((retregs & mLSW) == 0) retregs |= mLSW & ~idxregs; if ((retregs & mMSW) == 0) @@ -5645,7 +5645,7 @@ void cdddtor(ref CodeBuilder cdb,elem *e,regm_t *pretregs) cdb.gen(&cs); // Mark all registers as destroyed - getregsNoSave(allregs); + getregsNoSave(cgstate.allregs); assert(*pretregs == 0); codelem(cdb,e.E1,pretregs,false); @@ -5681,7 +5681,7 @@ void cdddtor(ref CodeBuilder cdb,elem *e,regm_t *pretregs) // by except_fillInEHTable() // Mark all registers as destroyed - getregsNoSave(allregs); + getregsNoSave(cgstate.allregs); assert(*pretregs == 0); CodeBuilder cdbx; diff --git a/compiler/src/dmd/backend/cod3.d b/compiler/src/dmd/backend/cod3.d index d08cfc5d03da..a4bbe674cbc5 100644 --- a/compiler/src/dmd/backend/cod3.d +++ b/compiler/src/dmd/backend/cod3.d @@ -1039,7 +1039,7 @@ static if (NTEXCEPTIONS) assert(!e); usednteh |= NTEH_except; nteh_setsp(cdb,0x8B); - getregsNoSave(allregs); + getregsNoSave(cgstate.allregs); nextb = bl.nthSucc(0); goto L5; } @@ -1048,7 +1048,7 @@ static if (NTEXCEPTIONS) nteh_filter(cdb, bl); // Mark all registers as destroyed. This will prevent // register assignments to variables used in filter blocks. - getregsNoSave(allregs); + getregsNoSave(cgstate.allregs); regm_t retregsx = regmask(e.Ety, TYnfunc); gencodelem(cdb,e,&retregsx,true); cdb.gen1(0xC3); // RET @@ -2650,9 +2650,9 @@ void gen_loadcse(ref CodeBuilder cdb, tym_t tym, reg_t reg, size_t slot) @trusted void cdframeptr(ref CodeBuilder cdb, elem *e, regm_t *pretregs) { - regm_t retregs = *pretregs & allregs; + regm_t retregs = *pretregs & cgstate.allregs; if (!retregs) - retregs = allregs; + retregs = cgstate.allregs; const reg = allocreg(cdb,retregs, TYint); code cs; @@ -2674,9 +2674,9 @@ void cdgot(ref CodeBuilder cdb, elem *e, regm_t *pretregs) { if (config.exe & (EX_OSX | EX_OSX64)) { - regm_t retregs = *pretregs & allregs; + regm_t retregs = *pretregs & cgstate.allregs; if (!retregs) - retregs = allregs; + retregs = cgstate.allregs; const reg = allocreg(cdb,retregs, TYnptr); cdb.genc(CALL,0,0,0,FLgot,0); // CALL L1 @@ -2686,9 +2686,9 @@ void cdgot(ref CodeBuilder cdb, elem *e, regm_t *pretregs) } else if (config.exe & EX_posix) { - regm_t retregs = *pretregs & allregs; + regm_t retregs = *pretregs & cgstate.allregs; if (!retregs) - retregs = allregs; + retregs = cgstate.allregs; const reg = allocreg(cdb,retregs, TYnptr); cdb.genc2(CALL,0,0); // CALL L1 diff --git a/compiler/src/dmd/backend/cod4.d b/compiler/src/dmd/backend/cod4.d index 4af16ceb2c09..d431202aef04 100644 --- a/compiler/src/dmd/backend/cod4.d +++ b/compiler/src/dmd/backend/cod4.d @@ -417,7 +417,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) /* Will need 1 register for evaluation, +2 registers for * e1's addressing mode */ - regm_t m = allregs & ~regcon.mvar; // mask of non-register variables + regm_t m = cgstate.allregs & ~regcon.mvar; // mask of non-register variables m &= m - 1; // clear least significant bit m &= m - 1; // clear least significant bit plenty = m != 0; // at least 3 registers @@ -468,7 +468,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) { // MOV reg,imm64 // MOV EA,reg - regm_t rregm = allregs & ~idxregm(&cs); + regm_t rregm = cgstate.allregs & ~idxregm(&cs); const regx = regwithvalue(cdb,rregm,e2.Vpointer,64); cs.Iop = STO; cs.Irm |= modregrm(0,regx & 7,0); @@ -482,7 +482,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) { // MOV reg,imm // MOV EA,reg - regm_t rregm = allregs & ~idxregm(&cs); + regm_t rregm = cgstate.allregs & ~idxregm(&cs); const regx = regwithvalue(cdb,rregm,e2.Vint,0); cs.Iop = STO; cs.Irm |= modregrm(0,regx & 7,0); @@ -572,7 +572,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) { // Use 64 bit MOV, as the 32 bit one gets sign extended // MOV reg,imm64 // MOV EA,reg - regm_t rregm = allregs & ~idxregm(&cs); + regm_t rregm = cgstate.allregs & ~idxregm(&cs); const regx = regwithvalue(cdb,rregm,*p,64); cs.Iop = STO; cs.Irm |= modregrm(0,regx & 7,0); @@ -592,7 +592,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (I64 && sz == 16 && *p >= 0x80000000) { - regm_t rregm = allregs & ~idxregm(&cs); + regm_t rregm = cgstate.allregs & ~idxregm(&cs); const regx = regwithvalue(cdb,rregm,*p,64); cs.Iop = STO; cs.Irm |= modregrm(0,regx & 7,0); @@ -601,7 +601,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else { - regm_t retregsx = (sz == 1) ? BYTEREGS : allregs; + regm_t retregsx = (sz == 1) ? BYTEREGS : cgstate.allregs; reg_t regx; if (reghasvalue(retregsx,*p,regx)) { @@ -632,13 +632,13 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) freenode(e2); goto Lp; } - retregs = allregs; // pick a reg, any reg + retregs = cgstate.allregs; // pick a reg, any reg if (sz == 2 * REGSIZE) retregs &= ~mBP; // BP cannot be used for register pair } if (retregs == mPSW) { - retregs = allregs; + retregs = cgstate.allregs; if (sz == 2 * REGSIZE) retregs &= ~mBP; // BP cannot be used for register pair } @@ -658,7 +658,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) ) ) // getlvalue() needs ES, so we can't return it - retregs = allregs; // no conflicts with ES + retregs = cgstate.allregs; // no conflicts with ES else if (tyml == TYdouble || tyml == TYdouble_alias || retregs & mST0) retregs = DOUBLEREGS; @@ -1091,7 +1091,7 @@ void cdaddass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) code cs2; // Determine which registers to use - sregm = allregs & ~idxregm(&cs); + sregm = cgstate.allregs & ~idxregm(&cs); if (isbyte) sregm &= BYTEREGS; if (sregm & forregs) @@ -1465,7 +1465,7 @@ void cdmulass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) regm_t idxregs = idxregm(&cs); regm_t regm = *pretregs & ~(idxregs | mBP | mR13); // don't use EBP if (!regm) - regm = allregs & ~(idxregs | mBP | mR13); + regm = cgstate.allregs & ~(idxregs | mBP | mR13); const reg = allocreg(cdb,regm,tyml); cs.Iop = LOD; code_newreg(&cs,reg); @@ -1505,9 +1505,9 @@ void cdmulass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) regm_t idxregs = idxregm(&cs); regm_t regm = *pretregs & ~(idxregs | mBP | mR13); // don't use EBP if (!regm) - regm = allregs & ~(idxregs | mBP | mR13); + regm = cgstate.allregs & ~(idxregs | mBP | mR13); const reg = allocreg(cdb,regm,tyml); // return register - const sreg = allocScratchReg(cdb, allregs & ~(regm | idxregs | mBP | mR13)); + const sreg = allocScratchReg(cdb, cgstate.allregs & ~(regm | idxregs | mBP | mR13)); cs.Iop = LOD; code_newreg(&cs,sreg); @@ -1605,7 +1605,7 @@ void cdmulass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) opAssLoadPair(cdb, cs, e, rhi, rlo, retregs, 0); const regm_t keepmsk = idxregm(&cs); - reg_t reg = allocScratchReg(cdb, allregs & ~(retregs | keepmsk)); + reg_t reg = allocScratchReg(cdb, cgstate.allregs & ~(retregs | keepmsk)); targ_size_t e2factor = cast(targ_size_t)el_tolong(e2); const lsw = cast(targ_int)(e2factor & ((1L << (REGSIZE * 8)) - 1)); @@ -1628,7 +1628,7 @@ void cdmulass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) else { retregs = mDX | mAX; - regm_t rretregs = (config.target_cpu >= TARGET_PentiumPro) ? allregs & ~retregs : mCX | mBX; + regm_t rretregs = (config.target_cpu >= TARGET_PentiumPro) ? cgstate.allregs & ~retregs : mCX | mBX; codelem(cdb,e2,&rretregs,false); getlvalue(cdb,&cs,e1,retregs | rretregs); getregs(cdb,retregs); @@ -1768,7 +1768,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) freenode(e2); getlvalue(cdb,&cs,e1,mAX | mDX); - const reg = opAssLoadReg(cdb, cs, e, allregs & ~( mAX | mDX | idxregm(&cs))); // MOV reg,EA + const reg = opAssLoadReg(cdb, cs, e, cgstate.allregs & ~( mAX | mDX | idxregm(&cs))); // MOV reg,EA getregs(cdb, mAX|mDX); /* Algorithm 5.2 @@ -1862,7 +1862,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) freenode(e2); getlvalue(cdb,&cs,e1,mAX | mDX); regm_t idxregs = idxregm(&cs); - reg = opAssLoadReg(cdb, cs, e, allregs & ~(mAX|mDX | idxregs)); // MOV reg,EA + reg = opAssLoadReg(cdb, cs, e, cgstate.allregs & ~(mAX|mDX | idxregs)); // MOV reg,EA getregs(cdb, mAX|mDX); genmovreg(cdb,AX,reg); // MOV EAX,reg @@ -1872,7 +1872,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) genmovreg(cdb,AX,reg); // MOV EAX,reg cdb.gen2(0x2B,grex | modregrm(3,AX,DX)); // SUB EAX,EDX cdb.genc2(0xC1,grex | modregrm(3,5,AX),1); // SHR EAX,1 - regm_t regm3 = allregs & ~idxregs; + regm_t regm3 = cgstate.allregs & ~idxregs; if (op == OPmodass) { regm3 &= ~mask(reg); @@ -1896,7 +1896,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) freenode(e2); getlvalue(cdb,&cs,e1,mAX | mDX); regm_t idxregs = idxregm(&cs); - reg = opAssLoadReg(cdb, cs, e, allregs & ~(mAX|mDX | idxregs)); // MOV reg,EA + reg = opAssLoadReg(cdb, cs, e, cgstate.allregs & ~(mAX|mDX | idxregs)); // MOV reg,EA getregs(cdb, mAX|mDX); if (reg != AX) @@ -1981,8 +1981,8 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) */ getlvalue(cdb,&cs,e1,0); regm_t idxregs = idxregm(&cs); - const reg = opAssLoadReg(cdb,cs,e,allregs & ~idxregs); // MOV reg,EA - const r = allocScratchReg(cdb, allregs & ~(idxregs | mask(reg))); + const reg = opAssLoadReg(cdb,cs,e,cgstate.allregs & ~idxregs); // MOV reg,EA + const r = allocScratchReg(cdb, cgstate.allregs & ~(idxregs | mask(reg))); genmovreg(cdb,r,reg); // MOV r,reg cdb.genc2(0xC1,grex | modregxrmx(3,5,r),(sz * 8 - 1)); // SHR r,31 cdb.gen2(0x03,grex | modregxrmx(3,reg,r)); // ADD reg,r @@ -2093,7 +2093,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) if (pow2 < 32) { - reg_t r1 = allocScratchReg(cdb, allregs & ~(retregs | keepmsk)); + reg_t r1 = allocScratchReg(cdb, cgstate.allregs & ~(retregs | keepmsk)); genmovreg(cdb,r1,rhi); // MOV r1,rhi if (pow2 == 1) @@ -2110,7 +2110,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (pow2 == 32) { - reg_t r1 = allocScratchReg(cdb, allregs & ~(retregs | keepmsk)); + reg_t r1 = allocScratchReg(cdb, cgstate.allregs & ~(retregs | keepmsk)); genmovreg(cdb,r1,rhi); // MOV r1,rhi cdb.genc2(0xC1,grex | modregrmx(3,7,r1),REGSIZE * 8 - 1); // SAR r1,31 @@ -2121,8 +2121,8 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (pow2 < 63) { - reg_t r1 = allocScratchReg(cdb, allregs & ~(retregs | keepmsk)); - reg_t r2 = allocScratchReg(cdb, allregs & ~(retregs | keepmsk | mask(r1))); + reg_t r1 = allocScratchReg(cdb, cgstate.allregs & ~(retregs | keepmsk)); + reg_t r2 = allocScratchReg(cdb, cgstate.allregs & ~(retregs | keepmsk | mask(r1))); genmovreg(cdb,r1,rhi); // MOV r1,rhi cdb.genc2(0xC1,grex | modregrmx(3,7,r1),REGSIZE * 8 - 1); // SAR r1,31 @@ -2175,7 +2175,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) opAssLoadPair(cdb, cs, e, rhi, rlo, retregs, 0); const regm_t keepmsk = idxregm(&cs); - regm_t scratchm = allregs & ~(retregs | keepmsk); + regm_t scratchm = cgstate.allregs & ~(retregs | keepmsk); if (pow2 == 63) scratchm &= BYTEREGS; // because of SETZ reg_t r1 = allocScratchReg(cdb, scratchm); @@ -2201,7 +2201,7 @@ void cddivass(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (pow2 < 63) { - scratchm = allregs & ~(retregs | scratchm); + scratchm = cgstate.allregs & ~(retregs | scratchm); const r2 = allocreg(cdb,scratchm,TYint); cdb.genmovreg(r1,rhi); // MOV r1,rhi @@ -2666,7 +2666,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) reverse ^= 2; } - retregs = allregs; + retregs = cgstate.allregs; if (isbyte) retregs = BYTEREGS; @@ -2681,7 +2681,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) default: L2: scodelem(cdb,e1,&retregs,0,true); // compute left leaf - rretregs = allregs & ~retregs; + rretregs = cgstate.allregs & ~retregs; if (isbyte) rretregs &= BYTEREGS; scodelem(cdb,e2,&rretregs,retregs,true); // get right leaf @@ -2777,7 +2777,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) (sz == REGSIZE || (I64 && sz == 4)) && (!I16 || op == OPlt || op == OPge)) { - assert(*pretregs & (allregs)); + assert(*pretregs & (cgstate.allregs)); codelem(cdb,e1,pretregs,false); reg = findreg(*pretregs); getregs(cdb,mask(reg)); @@ -2814,7 +2814,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) */ genregs(cdb,0xD1,0,reg); // ROL reg,1 reg_t regi; - if (reghasvalue(allregs,1,regi)) + if (reghasvalue(cgstate.allregs,1,regi)) genregs(cdb,0x23,reg,regi); // AND reg,regi else cdb.genc2(0x81,modregrm(3,4,reg),1); // AND reg,1 @@ -2872,7 +2872,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) retregs = idxregm(&cs); if ((cs.Iflags & CFSEG) == CFes) retregs |= mES; // take no chances - rretregs = allregs & ~retregs; + rretregs = cgstate.allregs & ~retregs; if (isbyte) rretregs &= BYTEREGS; scodelem(cdb,e2,&rretregs,retregs,true); @@ -2940,7 +2940,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) { regm_t m; - m = allregs & ~regcon.mvar; + m = cgstate.allregs & ~regcon.mvar; if (isbyte) m &= BYTEREGS; if (m & (m - 1)) // if more than one free register @@ -2964,7 +2964,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) scodelem(cdb,e1,&retregs,0,true); // compute left leaf if (sz == 1) { - reg = findreg(retregs & allregs); // get reg that e1 is in + reg = findreg(retregs & cgstate.allregs); // get reg that e1 is in cs.Irm = modregrm(3,7,reg & 7); if (reg & 8) cs.Irex |= REX_B; @@ -2977,8 +2977,8 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else if (sz <= REGSIZE) { // CMP reg,const - reg = findreg(retregs & allregs); // get reg that e1 is in - rretregs = allregs & ~retregs; + reg = findreg(retregs & cgstate.allregs); // get reg that e1 is in + rretregs = cgstate.allregs & ~retregs; if (cs.IFL2 == FLconst && reghasvalue(rretregs,cs.IEV2.Vint,rreg)) { genregs(cdb,0x3B,reg,rreg); @@ -3056,7 +3056,7 @@ void cdcmp(ref CodeBuilder cdb,elem *e,regm_t *pretregs) scodelem(cdb,e1,&retregs,0,true); // compute left leaf if (sz <= REGSIZE) // CMP reg,EA { - reg = findreg(retregs & allregs); // get reg that e1 is in + reg = findreg(retregs & cgstate.allregs); // get reg that e1 is in uint opsize = cs.Iflags & CFopsize; loadea(cdb,e2,&cs,0x3B ^ isbyte ^ reverse,reg,0,RMload | retregs,0); code_orflag(cdb.last(),opsize); @@ -3300,11 +3300,11 @@ void longcmp(ref CodeBuilder cdb,elem *e,bool jcond,uint fltarg,code *targ) case OPvar: if (!e1.Ecount && e1.Eoper == OPs32_64) { - retregs = allregs; + retregs = cgstate.allregs; scodelem(cdb,e1.E1,&retregs,0,true); freenode(e1); reg = findreg(retregs); - retregs = allregs & ~retregs; + retregs = cgstate.allregs & ~retregs; const msreg = allocreg(cdb,retregs,TYint); genmovreg(cdb,msreg,reg); // MOV msreg,reg cdb.genc2(0xC1,modregrm(3,7,msreg),REGSIZE * 8 - 1); // SAR msreg,31 @@ -3407,7 +3407,7 @@ void cdcnvt(ref CodeBuilder cdb,elem *e, regm_t *pretregs) /* if won't do us much good to transfer back and */ /* forth between 8088 registers and 8087 registers */ - if (OTcall(e.E1.Eoper) && !(*pretregs & allregs)) + if (OTcall(e.E1.Eoper) && !(*pretregs & cgstate.allregs)) { retregs = regmask(e.E1.Ety, e.E1.E1.Ety); if (retregs & (mXMM1 | mXMM0 |mST01 | mST0)) // if return in ST0 @@ -4207,7 +4207,7 @@ void cdbtst(ref CodeBuilder cdb, elem *e, regm_t *pretregs) } else { - retregs = tysize(e1.Ety) == 1 ? BYTEREGS : allregs; + retregs = tysize(e1.Ety) == 1 ? BYTEREGS : cgstate.allregs; codelem(cdb,e1, &retregs, false); reg = findreg(retregs); cs.Irm = modregrm(3,0,reg & 7); @@ -4455,7 +4455,7 @@ void cdbscan(ref CodeBuilder cdb, elem *e, regm_t *pretregs) } else { - regm_t retregs = allregs; + regm_t retregs = cgstate.allregs; codelem(cdb,e.E1, &retregs, false); const reg = findreg(retregs); cs.Irm = modregrm(3,0,reg & 7); @@ -4465,9 +4465,9 @@ void cdbscan(ref CodeBuilder cdb, elem *e, regm_t *pretregs) cs.Irex |= REX_B; } - regm_t retregs = *pretregs & allregs; + regm_t retregs = *pretregs & cgstate.allregs; if (!retregs) - retregs = allregs; + retregs = cgstate.allregs; const reg = allocreg(cdb,retregs, e.Ety); cs.Iop = (e.Eoper == OPbsf) ? 0x0FBC : 0x0FBD; // BSF/BSR reg,EA @@ -4509,7 +4509,7 @@ void cdpopcnt(ref CodeBuilder cdb,elem *e,regm_t *pretregs) } else { - regm_t retregs = allregs; + regm_t retregs = cgstate.allregs; codelem(cdb,e.E1, &retregs, false); const reg = findreg(retregs); cs.Irm = modregrm(3,0,reg & 7); @@ -4519,9 +4519,9 @@ void cdpopcnt(ref CodeBuilder cdb,elem *e,regm_t *pretregs) cs.Irex |= REX_B; } - regm_t retregs = *pretregs & allregs; + regm_t retregs = *pretregs & cgstate.allregs; if (!retregs) - retregs = allregs; + retregs = cgstate.allregs; const reg = allocreg(cdb,retregs, e.Ety); cs.Iop = POPCNT; // POPCNT reg,EA @@ -4584,9 +4584,9 @@ void cdpair(ref CodeBuilder cdb, elem *e, regm_t *pretregs) } else { - retregs &= allregs; + retregs &= cgstate.allregs; if (!retregs) - retregs = allregs; + retregs = cgstate.allregs; regs1 = retregs & mLSW; regs2 = retregs & mMSW; } diff --git a/compiler/src/dmd/backend/code.d b/compiler/src/dmd/backend/code.d index c3bbe5fdd26b..557c52305917 100644 --- a/compiler/src/dmd/backend/code.d +++ b/compiler/src/dmd/backend/code.d @@ -191,6 +191,7 @@ struct CGstate targ_size_t retsize; // size of function return code int dfoidx; // which block we are in + regm_t allregs; // ALLREGS optionally including mBP } public import dmd.backend.nteh;