- {
- int i = 0;
-
- bitVectUnSetBit (_G.regAssigned, sym->key);
-
- /* if the result of this one needs registers
- and does not have it then assign it right
- away */
- if (IC_RESULT (ic) &&
- !(SKIP_IC2 (ic) || /* not a special icode */
- ic->op == JUMPTABLE ||
- ic->op == IFX ||
- ic->op == IPUSH ||
- ic->op == IPOP ||
- ic->op == RETURN ||
- POINTER_SET (ic)) &&
- (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */
- result->liveTo > ic->seq && /* and will live beyond this */
- result->liveTo <= ebp->lSeq && /* does not go beyond this block */
- result->regType == sym->regType && /* same register types */
- result->nRegs && /* which needs registers */
- !result->isspilt && /* and does not already have them */
- !result->remat &&
- !bitVectBitValue (_G.regAssigned, result->key) &&
- /* the number of free regs + number of regs in this LR
- can accomodate the what result Needs */
- ((nfreeRegsType (result->regType) +
- sym->nRegs) >= result->nRegs)
- )
- {
-
- for (i = 0; i < result->nRegs; i++)
- if (i < sym->nRegs)
- result->regs[i] = sym->regs[i];
- else
- result->regs[i] = getRegGpr (ic, ebp, result);
-
- _G.regAssigned = bitVectSetBit (_G.regAssigned, result->key);
- _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, result->key);
-
- }
-
- /* free the remaining */
- for (; i < sym->nRegs; i++)
- {
- if (psym)
- {
- if (!symHasReg (psym, sym->regs[i]))
- freeReg (sym->regs[i]);
- }
- else
- freeReg (sym->regs[i]);
- }
- }
+ {
+ int i = 0;
+
+ bitVectUnSetBit (_G.regAssigned, sym->key);
+
+ /* if the result of this one needs registers
+ and does not have it then assign it right
+ away */
+ if (IC_RESULT (ic) &&
+ !(SKIP_IC2 (ic) || /* not a special icode */
+ ic->op == JUMPTABLE ||
+ ic->op == IFX ||
+ ic->op == IPUSH ||
+ ic->op == IPOP ||
+ ic->op == RETURN ||
+ POINTER_SET (ic)) &&
+ (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */
+ result->liveTo > ic->seq && /* and will live beyond this */
+ result->liveTo <= ebp->lSeq && /* does not go beyond this block */
+ result->regType == sym->regType && /* same register types */
+ result->nRegs && /* which needs registers */
+ !result->isspilt && /* and does not already have them */
+ !result->remat &&
+ !bitVectBitValue (_G.regAssigned, result->key) &&
+ /* the number of free regs + number of regs in this LR
+ can accomodate the what result Needs */
+ ((nfreeRegsType (result->regType) +
+ sym->nRegs) >= result->nRegs)
+ )
+ {
+
+ for (i = 0; i < result->nRegs; i++)
+ if (i < sym->nRegs)
+ result->regs[i] = sym->regs[i];
+ else
+ result->regs[i] = getRegGpr (ic, ebp, result);
+
+ _G.regAssigned = bitVectSetBit (_G.regAssigned, result->key);
+ _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, result->key);
+
+ }
+
+ /* free the remaining */
+ for (; i < sym->nRegs; i++)
+ {
+ if (psym)
+ {
+ if (!symHasReg (psym, sym->regs[i]))
+ freeReg (sym->regs[i]);
+ }
+ else
+ freeReg (sym->regs[i]);
+ }
+ }
- for (i = 0 ; i < unused->size ; i++ ) {
-
- /* if unused */
- if (bitVectBitValue(unused,i)) {
-
- /* if assigned to registers */
- if (bitVectBitValue(_G.regAssigned,i)) {
- symbol *sym;
- int j;
-
- sym = hTabItemWithKey(liveRanges,i);
- /* remove it from regassigned & mark the
- register free */
- bitVectUnSetBit(_G.regAssigned,i);
- for (j = 0 ; j < sym->nRegs; j++)
- freeReg(sym->regs[j]);
- } else {
- /* not assigned to registers : remove from set*/
- bitVectUnSetBit(unused,i);
- }
- }
- }
+ for (i = 0 ; i < unused->size ; i++ ) {
+
+ /* if unused */
+ if (bitVectBitValue(unused,i)) {
+
+ /* if assigned to registers */
+ if (bitVectBitValue(_G.regAssigned,i)) {
+ symbol *sym;
+ int j;
+
+ sym = hTabItemWithKey(liveRanges,i);
+ /* remove it from regassigned & mark the
+ register free */
+ bitVectUnSetBit(_G.regAssigned,i);
+ for (j = 0 ; j < sym->nRegs; j++)
+ freeReg(sym->regs[j]);
+ } else {
+ /* not assigned to registers : remove from set*/
+ bitVectUnSetBit(unused,i);
+ }
+ }
+ }
- {
-
- /* if this is an ipop that means some live
- range will have to be assigned again */
- if (ic->op == IPOP)
- reassignLR (IC_LEFT (ic));
-
- /* if result is present && is a true symbol */
- if (IC_RESULT (ic) && ic->op != IFX &&
- IS_TRUE_SYMOP (IC_RESULT (ic)))
- OP_SYMBOL (IC_RESULT (ic))->allocreq++;
-
- /* take away registers from live
- ranges that end at this instruction */
- deassignLRs (ic, ebbs[i]);
-
- /* some don't need registers */
- if (SKIP_IC2 (ic) ||
- ic->op == JUMPTABLE ||
- ic->op == IFX ||
- ic->op == IPUSH ||
- ic->op == IPOP ||
- (IC_RESULT (ic) && POINTER_SET (ic)))
- continue;
-
- /* now we need to allocate registers
- only for the result */
- if (IC_RESULT (ic))
- {
- symbol *sym = OP_SYMBOL (IC_RESULT (ic));
- bitVect *spillable;
- int willCS;
- int j;
- int ptrRegSet = 0;
-
- /* if it does not need or is spilt
- or is already assigned to registers
- or will not live beyond this instructions */
- if (!sym->nRegs ||
- sym->isspilt ||
- bitVectBitValue (_G.regAssigned, sym->key) ||
- sym->liveTo <= ic->seq)
- continue;
-
- /* if some liverange has been spilt at the block level
- and this one live beyond this block then spil this
- to be safe */
- if (_G.blockSpil && sym->liveTo > ebbs[i]->lSeq)
- {
- spillThis (sym);
- continue;
- }
- /* if trying to allocate this will cause
- a spill and there is nothing to spill
- or this one is rematerializable then
- spill this one */
- willCS = willCauseSpill (sym->nRegs, sym->regType);
- spillable = computeSpillable (ic);
- if (sym->remat ||
- (willCS && bitVectIsZero (spillable)))
- {
-
- spillThis (sym);
- continue;
-
- }
-
- /* If the live range preceeds the point of definition
- then ideally we must take into account registers that
- have been allocated after sym->liveFrom but freed
- before ic->seq. This is complicated, so spill this
- symbol instead and let fillGaps handle the allocation. */
- if (sym->liveFrom < ic->seq)
- {
- spillThis (sym);
- continue;
- }
-
- /* if it has a spillocation & is used less than
- all other live ranges then spill this */
- if (willCS) {
- if (sym->usl.spillLoc) {
- symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
- allLRs, ebbs[i], ic));
- if (leastUsed && leastUsed->used > sym->used) {
- spillThis (sym);
- continue;
- }
- } else {
- /* if none of the liveRanges have a spillLocation then better
- to spill this one than anything else already assigned to registers */
- if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
- /* if this is local to this block then we might find a block spil */
- if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
- spillThis (sym);
- continue;
- }
- }
- }
- }
-
- /* if we need ptr regs for the right side
- then mark it */
- if (POINTER_GET (ic) && IS_SYMOP (IC_LEFT (ic))
- && getSize (OP_SYMBOL (IC_LEFT (ic))->type)
- <= (unsigned) PTRSIZE)
- {
- ds390_ptrRegReq++;
- ptrRegSet = 1;
- }
- /* else we assign registers to it */
- _G.regAssigned = bitVectSetBit (_G.regAssigned, sym->key);
- _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, sym->key);
-
- for (j = 0; j < sym->nRegs; j++)
- {
- if (sym->regType == REG_PTR)
- sym->regs[j] = getRegPtr (ic, ebbs[i], sym);
- else
- sym->regs[j] = getRegGpr (ic, ebbs[i], sym);
-
- /* if the allocation falied which means
- this was spilt then break */
- if (!sym->regs[j])
- break;
- }
-
+ {
+
+ /* if this is an ipop that means some live
+ range will have to be assigned again */
+ if (ic->op == IPOP)
+ reassignLR (IC_LEFT (ic));
+
+ /* if result is present && is a true symbol */
+ if (IC_RESULT (ic) && ic->op != IFX &&
+ IS_TRUE_SYMOP (IC_RESULT (ic)))
+ OP_SYMBOL (IC_RESULT (ic))->allocreq++;
+
+ /* take away registers from live
+ ranges that end at this instruction */
+ deassignLRs (ic, ebbs[i]);
+
+ /* some don't need registers */
+ if (SKIP_IC2 (ic) ||
+ ic->op == JUMPTABLE ||
+ ic->op == IFX ||
+ ic->op == IPUSH ||
+ ic->op == IPOP ||
+ (IC_RESULT (ic) && POINTER_SET (ic)))
+ continue;
+
+ /* now we need to allocate registers
+ only for the result */
+ if (IC_RESULT (ic))
+ {
+ symbol *sym = OP_SYMBOL (IC_RESULT (ic));
+ bitVect *spillable;
+ int willCS;
+ int j;
+ int ptrRegSet = 0;
+
+ /* if it does not need or is spilt
+ or is already assigned to registers
+ or will not live beyond this instructions */
+ if (!sym->nRegs ||
+ sym->isspilt ||
+ bitVectBitValue (_G.regAssigned, sym->key) ||
+ sym->liveTo <= ic->seq)
+ continue;
+
+ /* if some liverange has been spilt at the block level
+ and this one live beyond this block then spil this
+ to be safe */
+ if (_G.blockSpil && sym->liveTo > ebbs[i]->lSeq)
+ {
+ spillThis (sym);
+ continue;
+ }
+ /* if trying to allocate this will cause
+ a spill and there is nothing to spill
+ or this one is rematerializable then
+ spill this one */
+ willCS = willCauseSpill (sym->nRegs, sym->regType);
+ spillable = computeSpillable (ic);
+ if (sym->remat ||
+ (willCS && bitVectIsZero (spillable)))
+ {
+
+ spillThis (sym);
+ continue;
+
+ }
+
+ /* If the live range preceeds the point of definition
+ then ideally we must take into account registers that
+ have been allocated after sym->liveFrom but freed
+ before ic->seq. This is complicated, so spill this
+ symbol instead and let fillGaps handle the allocation. */
+ if (sym->liveFrom < ic->seq)
+ {
+ spillThis (sym);
+ continue;
+ }
+
+ /* if it has a spillocation & is used less than
+ all other live ranges then spill this */
+ if (willCS) {
+ if (sym->usl.spillLoc) {
+ symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
+ allLRs, ebbs[i], ic));
+ if (leastUsed && leastUsed->used > sym->used) {
+ spillThis (sym);
+ continue;
+ }
+ } else {
+ /* if none of the liveRanges have a spillLocation then better
+ to spill this one than anything else already assigned to registers */
+ if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
+ /* if this is local to this block then we might find a block spil */
+ if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
+ spillThis (sym);
+ continue;
+ }
+ }
+ }
+ }
+
+ /* if we need ptr regs for the right side
+ then mark it */
+ if (POINTER_GET (ic) && IS_SYMOP (IC_LEFT (ic))
+ && getSize (OP_SYMBOL (IC_LEFT (ic))->type)
+ <= (unsigned) PTRSIZE)
+ {
+ ds390_ptrRegReq++;
+ ptrRegSet = 1;
+ }
+ /* else we assign registers to it */
+ _G.regAssigned = bitVectSetBit (_G.regAssigned, sym->key);
+ _G.totRegAssigned = bitVectSetBit (_G.totRegAssigned, sym->key);
+
+ for (j = 0; j < sym->nRegs; j++)
+ {
+ if (sym->regType == REG_PTR)
+ sym->regs[j] = getRegPtr (ic, ebbs[i], sym);
+ else
+ sym->regs[j] = getRegGpr (ic, ebbs[i], sym);
+
+ /* if the allocation falied which means
+ this was spilt then break */
+ if (!sym->regs[j])
+ break;
+ }
+
- iCode *ic;
-
- if (ebbs[i]->noPath &&
- (ebbs[i]->entryLabel != entryLabel &&
- ebbs[i]->entryLabel != returnLabel))
- continue;
-
- for (ic = ebbs[i]->sch; ic; ic = ic->next)
- {
- if (SKIP_IC2 (ic))
- continue;
-
- if (ic->op == IFX)
- {
- verifyRegsAssigned (IC_COND (ic), ic);
- continue;
- }
-
- if (ic->op == JUMPTABLE)
- {
- verifyRegsAssigned (IC_JTCOND (ic), ic);
- continue;
- }
-
- verifyRegsAssigned (IC_RESULT (ic), ic);
- verifyRegsAssigned (IC_LEFT (ic), ic);
- verifyRegsAssigned (IC_RIGHT (ic), ic);
+ iCode *ic;
+
+ if (ebbs[i]->noPath &&
+ (ebbs[i]->entryLabel != entryLabel &&
+ ebbs[i]->entryLabel != returnLabel))
+ continue;
+
+ for (ic = ebbs[i]->sch; ic; ic = ic->next)
+ {
+ if (SKIP_IC2 (ic))
+ continue;
+
+ if (ic->op == IFX)
+ {
+ verifyRegsAssigned (IC_COND (ic), ic);
+ continue;
+ }
+
+ if (ic->op == JUMPTABLE)
+ {
+ verifyRegsAssigned (IC_JTCOND (ic), ic);
+ continue;
+ }
+
+ verifyRegsAssigned (IC_RESULT (ic), ic);
+ verifyRegsAssigned (IC_LEFT (ic), ic);
+ verifyRegsAssigned (IC_RIGHT (ic), ic);
- change = 0;
-
- for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
- sym = hTabNextItem(liveRanges,&key)) {
- int size = getSize(sym->type);
-
- if (sym->liveFrom == sym->liveTo) continue;
-
- if (sym->uptr && sym->dptr==0 && !sym->ruonly &&
- size < 4 && size > 1) {
-
- if (packRegsDPTRuse(operandFromSymbol(sym))) {
-
- /* if this was ssigned to registers then */
- if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
- /* take it out of the register assigned set */
- bitVectUnSetBit(_G.totRegAssigned,sym->key);
- } else if (sym->usl.spillLoc) {
- sym->usl.spillLoc->allocreq--;
- sym->usl.spillLoc = NULL;
- }
-
- sym->nRegs = 0;
- sym->isspilt = sym->spillA = 0;
- continue ;
- }
-
- /* try assigning other dptrs */
- if (sym->dptr == 0 && packRegsDPTRnuse(operandFromSymbol(sym),1) && !getenv("DPTRnDISABLE")) {
- /* if this was ssigned to registers then */
- if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
- /* take it out of the register assigned set */
- bitVectUnSetBit(_G.totRegAssigned,sym->key);
- } else if (sym->usl.spillLoc) {
- sym->usl.spillLoc->allocreq--;
- sym->usl.spillLoc = NULL;
- }
- sym->nRegs = 0;
- sym->isspilt = sym->spillA = 0;
- }
- }
- }
-
- /* look for livernages that was spilt by the allocator */
- for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
- sym = hTabNextItem(liveRanges,&key)) {
-
- int i;
- int pdone = 0;
-
- if (!sym->spillA || !sym->clashes || sym->remat) continue ;
- if (!sym->uses || !sym->defs) continue ;
- /* find the liveRanges this one clashes with, that are
- still assigned to registers & mark the registers as used*/
- for ( i = 0 ; i < sym->clashes->size ; i ++) {
- int k;
- symbol *clr;
-
- if (bitVectBitValue(sym->clashes,i) == 0 || /* those that clash with this */
- bitVectBitValue(_G.totRegAssigned,i) == 0) /* and are still assigned to registers */
- continue ;
-
- clr = hTabItemWithKey(liveRanges,i);
- assert(clr);
-
- /* mark these registers as used */
- for (k = 0 ; k < clr->nRegs ; k++ )
- useReg(clr->regs[k]);
- }
-
- if (willCauseSpill(sym->nRegs,sym->regType)) {
- /* NOPE :( clear all registers & and continue */
- freeAllRegs();
- continue ;
- }
-
- /* THERE IS HOPE !!!! */
- for (i=0; i < sym->nRegs ; i++ ) {
- if (sym->regType == REG_PTR)
- sym->regs[i] = getRegPtrNoSpil ();
- else
- sym->regs[i] = getRegGprNoSpil ();
- }
-
- /* For all its definitions check if the registers
- allocated needs positioning NOTE: we can position
- only ONCE if more than One positioning required
- then give up.
- We may need to perform the checks twice; once to
- position the registers as needed, the second to
- verify any register repositioning is still
- compatible.
+ change = 0;
+
+ for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
+ sym = hTabNextItem(liveRanges,&key)) {
+ int size = getSize(sym->type);
+
+ if (sym->liveFrom == sym->liveTo) continue;
+
+ if (sym->uptr && sym->dptr==0 && !sym->ruonly &&
+ size < 4 && size > 1) {
+
+ if (packRegsDPTRuse(operandFromSymbol(sym))) {
+
+ /* if this was assigned to registers then */
+ if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
+ /* take it out of the register assigned set */
+ bitVectUnSetBit(_G.totRegAssigned,sym->key);
+ } else if (sym->usl.spillLoc) {
+ sym->usl.spillLoc->allocreq--;
+ sym->usl.spillLoc = NULL;
+ }
+
+ sym->nRegs = 0;
+ sym->isspilt = sym->spillA = 0;
+ continue ;
+ }
+
+ /* try assigning other dptrs */
+ if (sym->dptr == 0 && packRegsDPTRnuse(operandFromSymbol(sym),1) && !getenv("DPTRnDISABLE")) {
+ /* if this was ssigned to registers then */
+ if (bitVectBitValue(_G.totRegAssigned,sym->key)) {
+ /* take it out of the register assigned set */
+ bitVectUnSetBit(_G.totRegAssigned,sym->key);
+ } else if (sym->usl.spillLoc) {
+ sym->usl.spillLoc->allocreq--;
+ sym->usl.spillLoc = NULL;
+ }
+ sym->nRegs = 0;
+ sym->isspilt = sym->spillA = 0;
+ }
+ }
+ }
+
+ /* look for livernages that was spilt by the allocator */
+ for (sym = hTabFirstItem(liveRanges,&key) ; sym ;
+ sym = hTabNextItem(liveRanges,&key)) {
+
+ int i;
+ int pdone = 0;
+
+ if (!sym->spillA || !sym->clashes || sym->remat) continue ;
+ if (!sym->uses || !sym->defs) continue ;
+ /* find the liveRanges this one clashes with, that are
+ still assigned to registers & mark the registers as used*/
+ for ( i = 0 ; i < sym->clashes->size ; i ++) {
+ int k;
+ symbol *clr;
+
+ if (bitVectBitValue(sym->clashes,i) == 0 || /* those that clash with this */
+ bitVectBitValue(_G.totRegAssigned,i) == 0) /* and are still assigned to registers */
+ continue ;
+
+ clr = hTabItemWithKey(liveRanges,i);
+ assert(clr);
+
+ /* mark these registers as used */
+ for (k = 0 ; k < clr->nRegs ; k++ )
+ useReg(clr->regs[k]);
+ }
+
+ if (willCauseSpill(sym->nRegs,sym->regType)) {
+ /* NOPE :( clear all registers & and continue */
+ freeAllRegs();
+ continue ;
+ }
+
+ /* THERE IS HOPE !!!! */
+ for (i=0; i < sym->nRegs ; i++ ) {
+ if (sym->regType == REG_PTR)
+ sym->regs[i] = getRegPtrNoSpil ();
+ else
+ sym->regs[i] = getRegGprNoSpil ();
+ }
+
+ /* For all its definitions check if the registers
+ allocated needs positioning NOTE: we can position
+ only ONCE if more than One positioning required
+ then give up.
+ We may need to perform the checks twice; once to
+ position the registers as needed, the second to
+ verify any register repositioning is still
+ compatible.
- if (IS_SYMOP(IC_LEFT(ic)) &&
- bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_LEFT(ic))->key)) {
- pdone += (positionRegs(sym,OP_SYMBOL(IC_LEFT(ic)))>0);
- }
- if (IS_SYMOP(IC_RIGHT(ic)) &&
- bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RIGHT(ic))->key)) {
- pdone += (positionRegs(sym,OP_SYMBOL(IC_RIGHT(ic)))>0);
- }
- if (pdone > 1) break;
- }
- }
- for (i = 0 ; i < sym->uses->size ; i++ ) {
- if (bitVectBitValue(sym->uses,i)) {
- iCode *ic;
- if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
- if (SKIP_IC(ic)) continue;
- if (POINTER_SET(ic) || POINTER_GET(ic)) continue ;
-
- /* if result is assigned to registers */
- if (IS_SYMOP(IC_RESULT(ic)) &&
- bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
- pdone += (positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)))>0);
- }
- if (pdone > 1) break;
- }
- }
+ if (IS_SYMOP(IC_LEFT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_LEFT(ic))->key)) {
+ pdone += (positionRegs(sym,OP_SYMBOL(IC_LEFT(ic)))>0);
+ }
+ if (IS_SYMOP(IC_RIGHT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RIGHT(ic))->key)) {
+ pdone += (positionRegs(sym,OP_SYMBOL(IC_RIGHT(ic)))>0);
+ }
+ if (pdone > 1) break;
+ }
+ }
+ for (i = 0 ; i < sym->uses->size ; i++ ) {
+ if (bitVectBitValue(sym->uses,i)) {
+ iCode *ic;
+ if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+ if (SKIP_IC(ic)) continue;
+ if (POINTER_SET(ic) || POINTER_GET(ic)) continue ;
+
+ /* if result is assigned to registers */
+ if (IS_SYMOP(IC_RESULT(ic)) &&
+ bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
+ pdone += (positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)))>0);
+ }
+ if (pdone > 1) break;
+ }
+ }
- {
-
- int j;
-
- if (SKIP_IC2 (ic) || !ic->rlive)
- continue;
-
- /* first mark the registers used in this
- instruction */
- ic->rUsed = regsUsedIniCode (ic);
- _G.funcrUsed = bitVectUnion (_G.funcrUsed, ic->rUsed);
-
- /* now create the register mask for those
- registers that are in use : this is a
- super set of ic->rUsed */
- ic->rMask = newBitVect (ds390_nRegs + 1);
-
- /* for all live Ranges alive at this point */
- for (j = 1; j < ic->rlive->size; j++)
- {
- symbol *sym;
- int k;
-
- /* if not alive then continue */
- if (!bitVectBitValue (ic->rlive, j))
- continue;
-
- /* find the live range we are interested in */
- if (!(sym = hTabItemWithKey (liveRanges, j)))
- {
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "createRegMask cannot find live range");
- exit (0);
- }
+ {
+
+ int j;
+
+ if (SKIP_IC2 (ic) || !ic->rlive)
+ continue;
+
+ /* first mark the registers used in this
+ instruction */
+ ic->rUsed = regsUsedIniCode (ic);
+ _G.funcrUsed = bitVectUnion (_G.funcrUsed, ic->rUsed);
+
+ /* now create the register mask for those
+ registers that are in use : this is a
+ super set of ic->rUsed */
+ ic->rMask = newBitVect (ds390_nRegs + 1);
+
+ /* for all live Ranges alive at this point */
+ for (j = 1; j < ic->rlive->size; j++)
+ {
+ symbol *sym;
+ int k;
+
+ /* if not alive then continue */
+ if (!bitVectBitValue (ic->rlive, j))
+ continue;
+
+ /* find the live range we are interested in */
+ if (!(sym = hTabItemWithKey (liveRanges, j)))
+ {
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "createRegMask cannot find live range");
+ fprintf(stderr, "\tmissing live range: key=%d\n", j);
+ exit (0);
+ }
- {
-
- /* if the type is marked as a conditional */
- if (sym->regType == REG_CND)
- continue;
-
- /* if used in return only then we don't
- need registers */
- if (sym->ruonly || sym->accuse)
- {
- if (IS_AGGREGATE (sym->type) || sym->isptr)
- sym->type = aggrToPtr (sym->type, FALSE);
- continue;
- }
-
- /* if the symbol has only one definition &
- that definition is a get_pointer */
- if (bitVectnBitsOn (sym->defs) == 1 &&
- (ic = hTabItemWithKey (iCodehTab,
- bitVectFirstBit (sym->defs))) &&
- POINTER_GET (ic) &&
- !IS_BITVAR (sym->etype) &&
- (aggrToPtrDclType (operandType (IC_LEFT (ic)), FALSE) == POINTER))
- {
-
- if (ptrPseudoSymSafe (sym, ic))
- {
- ptrPseudoSymConvert (sym, ic, rematStr (OP_SYMBOL (IC_LEFT (ic))));
- continue;
- }
-
- /* if in data space or idata space then try to
- allocate pointer register */
-
- }
-
- /* if not then we require registers */
- sym->nRegs = ((IS_AGGREGATE (sym->type) || sym->isptr) ?
- getSize (sym->type = aggrToPtr (sym->type, FALSE)) :
- getSize (sym->type));
-
- if (sym->nRegs > 4)
- {
- fprintf (stderr, "allocated more than 4 or 0 registers for type ");
- printTypeChain (sym->type, stderr);
- fprintf (stderr, "\n");
- }
-
- /* determine the type of register required */
- if (sym->nRegs == 1 &&
- IS_PTR (sym->type) &&
- sym->uptr)
- sym->regType = REG_PTR;
- else
- sym->regType = REG_GPR;
-
- }
+ {
+
+ /* if the type is marked as a conditional */
+ if (sym->regType == REG_CND)
+ continue;
+
+ /* if used in return only then we don't
+ need registers */
+ if (sym->ruonly || sym->accuse)
+ {
+ if (IS_AGGREGATE (sym->type) || sym->isptr)
+ sym->type = aggrToPtr (sym->type, FALSE);
+ continue;
+ }
+
+ /* if the symbol has only one definition &
+ that definition is a get_pointer */
+ if (bitVectnBitsOn (sym->defs) == 1 &&
+ (ic = hTabItemWithKey (iCodehTab,
+ bitVectFirstBit (sym->defs))) &&
+ POINTER_GET (ic) &&
+ !IS_BITVAR (sym->etype) &&
+ (aggrToPtrDclType (operandType (IC_LEFT (ic)), FALSE) == POINTER))
+ {
+
+ if (ptrPseudoSymSafe (sym, ic))
+ {
+ ptrPseudoSymConvert (sym, ic, rematStr (OP_SYMBOL (IC_LEFT (ic))));
+ continue;
+ }
+
+ /* if in data space or idata space then try to
+ allocate pointer register */
+
+ }
+
+ /* if not then we require registers */
+ sym->nRegs = ((IS_AGGREGATE (sym->type) || sym->isptr) ?
+ getSize (sym->type = aggrToPtr (sym->type, FALSE)) :
+ getSize (sym->type));
+
+ if (sym->nRegs > 4)
+ {
+ fprintf (stderr, "allocated more than 4 or 0 registers for type ");
+ printTypeChain (sym->type, stderr);
+ fprintf (stderr, "\n");
+ }
+
+ /* determine the type of register required */
+ if (sym->nRegs == 1 &&
+ IS_PTR (sym->type) &&
+ sym->uptr)
+ sym->regType = REG_PTR;
+ else
+ sym->regType = REG_GPR;
+
+ }
- )
- {
-
- /* we are interested only if defined in far space */
- /* or in stack space in case of + & - */
-
- /* if assigned to a non-symbol then return
- FALSE */
- if (!IS_SYMOP (IC_RIGHT (dic)))
- return NULL;
-
- /* if the symbol is in far space then
- we should not */
- if (isOperandInFarSpace (IC_RIGHT (dic)))
- return NULL;
-
- /* for + & - operations make sure that
- if it is on the stack it is the same
- as one of the three operands */
- if ((ic->op == '+' || ic->op == '-') &&
- OP_SYMBOL (IC_RIGHT (dic))->onStack)
- {
-
- if (IC_RESULT (ic)->key != IC_RIGHT (dic)->key &&
- IC_LEFT (ic)->key != IC_RIGHT (dic)->key &&
- IC_RIGHT (ic)->key != IC_RIGHT (dic)->key)
- return NULL;
- }
+ )
+ {
+
+ /* we are interested only if defined in far space */
+ /* or in stack space in case of + & - */
+
+ /* if assigned to a non-symbol then return
+ FALSE */
+ if (!IS_SYMOP (IC_RIGHT (dic)))
+ return NULL;
+
+ /* if the symbol is in far space then
+ we should not */
+ if (isOperandInFarSpace (IC_RIGHT (dic)))
+ return NULL;
+
+ /* for + & - operations make sure that
+ if it is on the stack it is the same
+ as one of the three operands */
+ if ((ic->op == '+' || ic->op == '-') &&
+ OP_SYMBOL (IC_RIGHT (dic))->onStack)
+ {
+
+ if (IC_RESULT (ic)->key != IC_RIGHT (dic)->key &&
+ IC_LEFT (ic)->key != IC_RIGHT (dic)->key &&
+ IC_RIGHT (ic)->key != IC_RIGHT (dic)->key)
+ return NULL;
+ }
- ic = hTabNextItem(iCodeSeqhTab,&key)) {
- int nfs =0;
-
- if (ic->op == CALL || ic->op == PCALL) return 0;
-
- /* single operand icode are ok */
- if (ic->op == IFX || ic->op == IPUSH)
- continue ;
-
- if (ic->op == SEND ) {
- if (ic->argreg != 1 ) return 0;
- else continue ;
- }
- /* two special cases first */
- if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) && /* pointer get */
- !OP_SYMBOL(IC_LEFT(ic))->ruonly && /* with result in far space */
- (isOperandInFarSpace(IC_RESULT(ic)) &&
- !isOperandInReg(IC_RESULT(ic)))) {
- return 0;
- }
-
- if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) && /* pointer set */
- !OP_SYMBOL(IC_RESULT(ic))->ruonly && /* with right in far space */
- (isOperandInFarSpace(IC_RIGHT(ic)) &&
- !isOperandInReg(IC_RIGHT(ic)))) {
- return 0;
- }
-
- if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) && /* if symbol operand */
- !isOperandEqual(IC_RESULT(ic),op) && /* not the same as this */
- ((isOperandInFarSpace(IC_RESULT(ic)) || /* in farspace or */
- OP_SYMBOL(IC_RESULT(ic))->onStack) && /* on the stack */
- !isOperandInReg(IC_RESULT(ic)))) { /* and not in register */
- nfs++;
- }
- /* same for left */
- if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) && /* if symbol operand */
- !isOperandEqual(IC_LEFT(ic),op) && /* not the same as this */
- ((isOperandInFarSpace(IC_LEFT(ic)) || /* in farspace or */
- OP_SYMBOL(IC_LEFT(ic))->onStack) && /* on the stack */
- !isOperandInReg(IC_LEFT(ic)))) { /* and not in register */
- nfs++;
- }
- /* same for right */
- if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) && /* if symbol operand */
- !isOperandEqual(IC_RIGHT(ic),op) && /* not the same as this */
- ((isOperandInFarSpace(IC_RIGHT(ic)) || /* in farspace or */
- OP_SYMBOL(IC_RIGHT(ic))->onStack) && /* on the stack */
- !isOperandInReg(IC_RIGHT(ic)))) { /* and not in register */
- nfs++;
- }
-
- // Check that no other ops in this range have been assigned to dptr1.
- // I don't understand why this is not caught by the first check, above.
- // But it isn't always, see bug 769624.
- if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
- (OP_SYMBOL(IC_RESULT(ic))->dptr == 1))
- {
- //fprintf(stderr, "dptr1 already in use in live range #1\n");
- return 0;
- }
-
- if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
- (OP_SYMBOL(IC_LEFT(ic))->dptr == 1))
- {
- //fprintf(stderr, "dptr1 already in use in live range # 2\n");
- return 0;
- }
-
- if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
- (OP_SYMBOL(IC_RIGHT(ic))->dptr == 1))
- {
- //fprintf(stderr, "dptr1 already in use in live range # 3\n");
- return 0;
- }
-
- if (nfs && IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
- OP_SYMBOL(IC_RESULT(ic))->ruonly) return 0;
-
- if (nfs > 1) return 0;
+ ic = hTabNextItem(iCodeSeqhTab,&key)) {
+ int nfs =0;
+
+ if (ic->op == CALL || ic->op == PCALL) return 0;
+
+ /* single operand icode are ok */
+ if (ic->op == IFX || ic->op == IPUSH)
+ continue ;
+
+ if (ic->op == SEND ) {
+ if (ic->argreg != 1 ) return 0;
+ else continue ;
+ }
+ /* two special cases first */
+ if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) && /* pointer get */
+ !OP_SYMBOL(IC_LEFT(ic))->ruonly && /* with result in far space */
+ (isOperandInFarSpace(IC_RESULT(ic)) &&
+ !isOperandInReg(IC_RESULT(ic)))) {
+ return 0;
+ }
+
+ if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) && /* pointer set */
+ !OP_SYMBOL(IC_RESULT(ic))->ruonly && /* with right in far space */
+ (isOperandInFarSpace(IC_RIGHT(ic)) &&
+ !isOperandInReg(IC_RIGHT(ic)))) {
+ return 0;
+ }
+
+ if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) && /* if symbol operand */
+ !isOperandEqual(IC_RESULT(ic),op) && /* not the same as this */
+ ((isOperandInFarSpace(IC_RESULT(ic)) || /* in farspace or */
+ OP_SYMBOL(IC_RESULT(ic))->onStack) && /* on the stack */
+ !isOperandInReg(IC_RESULT(ic)))) { /* and not in register */
+ nfs++;
+ }
+ /* same for left */
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) && /* if symbol operand */
+ !isOperandEqual(IC_LEFT(ic),op) && /* not the same as this */
+ ((isOperandInFarSpace(IC_LEFT(ic)) || /* in farspace or */
+ OP_SYMBOL(IC_LEFT(ic))->onStack) && /* on the stack */
+ !isOperandInReg(IC_LEFT(ic)))) { /* and not in register */
+ nfs++;
+ }
+ /* same for right */
+ if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) && /* if symbol operand */
+ !isOperandEqual(IC_RIGHT(ic),op) && /* not the same as this */
+ ((isOperandInFarSpace(IC_RIGHT(ic)) || /* in farspace or */
+ OP_SYMBOL(IC_RIGHT(ic))->onStack) && /* on the stack */
+ !isOperandInReg(IC_RIGHT(ic)))) { /* and not in register */
+ nfs++;
+ }
+
+ // Check that no other ops in this range have been assigned to dptr1.
+ // I don't understand why this is not caught by the first check, above.
+ // But it isn't always, see bug 769624.
+ if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
+ (OP_SYMBOL(IC_RESULT(ic))->dptr == 1))
+ {
+ //fprintf(stderr, "dptr1 already in use in live range #1\n");
+ return 0;
+ }
+
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
+ (OP_SYMBOL(IC_LEFT(ic))->dptr == 1))
+ {
+ //fprintf(stderr, "dptr1 already in use in live range # 2\n");
+ return 0;
+ }
+
+ if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
+ (OP_SYMBOL(IC_RIGHT(ic))->dptr == 1))
+ {
+ //fprintf(stderr, "dptr1 already in use in live range # 3\n");
+ return 0;
+ }
+
+ if (nfs && IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
+ OP_SYMBOL(IC_RESULT(ic))->ruonly) return 0;
+
+ if (nfs > 1) return 0;
- ic = hTabNextItem(iCodeSeqhTab,&key)) {
-
- if (SKIP_IC3(ic)) continue;
-
- /* if PCALL cannot be sure give up */
- if (ic->op == PCALL) return NULL;
-
- /* if SEND & not the first parameter then giveup */
- if (ic->op == SEND && ic->argreg != 1 &&
- ((isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) ||
- isOperandEqual(op,IC_LEFT(ic)))) return NULL;
-
- /* if CALL then make sure it is VOID || return value not used
- or the return value is assigned to this one */
- if (ic->op == CALL) {
- if (OP_SYMBOL(IC_RESULT(ic))->liveTo ==
- OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ;
- etype = getSpec(type = operandType(IC_RESULT(ic)));
- if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic)))
- continue ;
- return NULL ;
- }
-
- /* special case of add with a [remat] */
- if (ic->op == '+' &&
- OP_SYMBOL(IC_LEFT(ic))->remat &&
- (isOperandInFarSpace(IC_RIGHT(ic)) &&
- !isOperandInReg(IC_RIGHT(ic)))) return NULL ;
-
- /* special cases */
- /* pointerGet */
- if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) &&
- getSize(operandType(IC_LEFT(ic))) > 1 ) return NULL ;
-
- /* pointerSet */
- if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) &&
- getSize(operandType(IC_RESULT(ic))) > 1 ) return NULL;
-
- /* conditionals can destroy 'b' - make sure B wont
- be used in this one*/
- if ((IS_CONDITIONAL(ic) || ic->op == '*' || ic->op == '/' ||
- ic->op == LEFT_OP || ic->op == RIGHT_OP ) &&
- getSize(operandType(op)) > 3) return NULL;
-
- /* if this is a cast to a bigger type */
- if (ic->op==CAST) {
- if (!IS_PTR(OP_SYM_TYPE(IC_RESULT(ic))) &&
- getSize(OP_SYM_TYPE(IC_RESULT(ic))) >
- getSize(OP_SYM_TYPE(IC_RIGHT(ic)))) {
- return 0;
- }
- }
-
- /* general case */
- if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
- !isOperandEqual(IC_RESULT(ic),op) &&
- ( ( ( isOperandInFarSpace(IC_RESULT(ic)) || OP_SYMBOL(IC_RESULT(ic))->onStack) &&
- !isOperandInReg(IC_RESULT(ic))) ||
- OP_SYMBOL(IC_RESULT(ic))->ruonly)) return NULL;
-
- if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
- !isOperandEqual(IC_RIGHT(ic),op) &&
- (OP_SYMBOL(IC_RIGHT(ic))->liveTo >= ic->seq ||
- IS_TRUE_SYMOP(IC_RIGHT(ic)) ||
- OP_SYMBOL(IC_RIGHT(ic))->ruonly) &&
- ( ( isOperandInFarSpace(IC_RIGHT(ic)) || OP_SYMBOL(IC_RIGHT(ic))->onStack) &&
- !isOperandInReg(IC_RIGHT(ic))) ) return NULL;
-
- if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
- !isOperandEqual(IC_LEFT(ic),op) &&
- (OP_SYMBOL(IC_LEFT(ic))->liveTo >= ic->seq ||
- IS_TRUE_SYMOP(IC_LEFT(ic)) ||
- OP_SYMBOL(IC_LEFT(ic))->ruonly) &&
- ( ( isOperandInFarSpace(IC_LEFT(ic)) || OP_SYMBOL(IC_LEFT(ic))->onStack) &&
- !isOperandInReg(IC_LEFT(ic))) ) return NULL;
-
- if (IC_LEFT(ic) && IC_RIGHT(ic) &&
- IS_ITEMP(IC_LEFT(ic)) && IS_ITEMP(IC_RIGHT(ic)) &&
- (isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) &&
- (isOperandInFarSpace(IC_RIGHT(ic)) && !isOperandInReg(IC_RIGHT(ic))))
- return NULL;
+ ic = hTabNextItem(iCodeSeqhTab,&key)) {
+
+ if (SKIP_IC3(ic)) continue;
+
+ /* if PCALL cannot be sure give up */
+ if (ic->op == PCALL) return NULL;
+
+ /* if SEND & not the first parameter then giveup */
+ if (ic->op == SEND && ic->argreg != 1 &&
+ ((isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) ||
+ isOperandEqual(op,IC_LEFT(ic)))) return NULL;
+
+ /* if CALL then make sure it is VOID || return value not used
+ or the return value is assigned to this one */
+ if (ic->op == CALL) {
+ if (OP_SYMBOL(IC_RESULT(ic))->liveTo ==
+ OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ;
+ etype = getSpec(type = operandType(IC_RESULT(ic)));
+ if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic)))
+ continue ;
+ return NULL ;
+ }
+
+ /* special case of add with a [remat] */
+ if (ic->op == '+' &&
+ OP_SYMBOL(IC_LEFT(ic))->remat &&
+ (isOperandInFarSpace(IC_RIGHT(ic)) &&
+ !isOperandInReg(IC_RIGHT(ic)))) return NULL ;
+
+ /* special cases */
+ /* pointerGet */
+ if (POINTER_GET(ic) && !isOperandEqual(IC_LEFT(ic),op) &&
+ getSize(operandType(IC_LEFT(ic))) > 1 ) return NULL ;
+
+ /* pointerSet */
+ if (POINTER_SET(ic) && !isOperandEqual(IC_RESULT(ic),op) &&
+ getSize(operandType(IC_RESULT(ic))) > 1 ) return NULL;
+
+ /* conditionals can destroy 'b' - make sure B wont
+ be used in this one*/
+ if ((IS_CONDITIONAL(ic) || ic->op == '*' || ic->op == '/' ||
+ ic->op == LEFT_OP || ic->op == RIGHT_OP ) &&
+ getSize(operandType(op)) > 3) return NULL;
+
+ /* if this is a cast to a bigger type */
+ if (ic->op==CAST) {
+ if (!IS_PTR(OP_SYM_TYPE(IC_RESULT(ic))) &&
+ getSize(OP_SYM_TYPE(IC_RESULT(ic))) >
+ getSize(OP_SYM_TYPE(IC_RIGHT(ic)))) {
+ return 0;
+ }
+ }
+
+ /* general case */
+ if (IC_RESULT(ic) && IS_SYMOP(IC_RESULT(ic)) &&
+ !isOperandEqual(IC_RESULT(ic),op) &&
+ ( ( ( isOperandInFarSpace(IC_RESULT(ic)) || OP_SYMBOL(IC_RESULT(ic))->onStack) &&
+ !isOperandInReg(IC_RESULT(ic))) ||
+ OP_SYMBOL(IC_RESULT(ic))->ruonly)) return NULL;
+
+ if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) &&
+ !isOperandEqual(IC_RIGHT(ic),op) &&
+ (OP_SYMBOL(IC_RIGHT(ic))->liveTo >= ic->seq ||
+ IS_TRUE_SYMOP(IC_RIGHT(ic)) ||
+ OP_SYMBOL(IC_RIGHT(ic))->ruonly) &&
+ ( ( isOperandInFarSpace(IC_RIGHT(ic)) || OP_SYMBOL(IC_RIGHT(ic))->onStack) &&
+ !isOperandInReg(IC_RIGHT(ic))) ) return NULL;
+
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) &&
+ !isOperandEqual(IC_LEFT(ic),op) &&
+ (OP_SYMBOL(IC_LEFT(ic))->liveTo >= ic->seq ||
+ IS_TRUE_SYMOP(IC_LEFT(ic)) ||
+ OP_SYMBOL(IC_LEFT(ic))->ruonly) &&
+ ( ( isOperandInFarSpace(IC_LEFT(ic)) || OP_SYMBOL(IC_LEFT(ic))->onStack) &&
+ !isOperandInReg(IC_LEFT(ic))) ) return NULL;
+
+ if (IC_LEFT(ic) && IC_RIGHT(ic) &&
+ IS_ITEMP(IC_LEFT(ic)) && IS_ITEMP(IC_RIGHT(ic)) &&
+ (isOperandInFarSpace(IC_LEFT(ic)) && !isOperandInReg(IC_LEFT(ic))) &&
+ (isOperandInFarSpace(IC_RIGHT(ic)) && !isOperandInReg(IC_RIGHT(ic))))
+ return NULL;
- IS_ITEMP (IC_RESULT (ic)) &&
- IS_TRUE_SYMOP (IC_LEFT (ic)) &&
- bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
- !OP_SYMBOL (IC_LEFT (ic))->onStack)
- {
-
- OP_SYMBOL (IC_RESULT (ic))->remat = 1;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
-
- }
-
- /* if this is an itemp & used as a pointer
- & assigned to a literal then remat */
- if (IS_ASSIGN_ICODE(ic) &&
- IS_ITEMP(IC_RESULT(ic)) &&
- bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
- isOperandLiteral(IC_RIGHT(ic)))
- {
- OP_SYMBOL (IC_RESULT (ic))->remat = 1;
- OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
- }
+ IS_ITEMP (IC_RESULT (ic)) &&
+ IS_TRUE_SYMOP (IC_LEFT (ic)) &&
+ bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
+ !OP_SYMBOL (IC_LEFT (ic))->onStack)
+ {
+
+ OP_SYMBOL (IC_RESULT (ic))->remat = 1;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
+ OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+
+ }
+
+ /* if this is an itemp & used as a pointer
+ & assigned to a literal then remat */
+ if (IS_ASSIGN_ICODE(ic) &&
+ IS_ITEMP(IC_RESULT(ic)) &&
+ bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 &&
+ isOperandLiteral(IC_RIGHT(ic)))
+ {
+ OP_SYMBOL (IC_RESULT (ic))->remat = 1;
+ OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
+ OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+ }
- {
- /* if we are using a symbol on the stack
- then we should say ds390_ptrRegReq */
- if (options.useXstack && ic->parmPush
- && (ic->op == IPUSH || ic->op == IPOP))
- ds390_ptrRegReq++;
- if (ic->op == IFX && IS_SYMOP (IC_COND (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_COND (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_COND (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_COND (ic))->etype) == idata));
- else if (ic->op == JUMPTABLE && IS_SYMOP (IC_JTCOND (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_JTCOND (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_JTCOND (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_JTCOND (ic))->etype) == idata));
- else
- {
- if (IS_SYMOP (IC_LEFT (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_LEFT (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_LEFT (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_LEFT (ic))->etype) == idata));
- if (IS_SYMOP (IC_RIGHT (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_RIGHT (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_RIGHT (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_RIGHT (ic))->etype) == idata));
- if (IS_SYMOP (IC_RESULT (ic)))
- ds390_ptrRegReq += ((OP_SYMBOL (IC_RESULT (ic))->onStack ? !options.stack10bit : 0) +
- OP_SYMBOL (IC_RESULT (ic))->iaccess +
- (SPEC_OCLS(OP_SYMBOL (IC_RESULT (ic))->etype) == idata));
- }
- }
+ {
+ /* if we are using a symbol on the stack
+ then we should say ds390_ptrRegReq */
+ if (options.useXstack && ic->parmPush
+ && (ic->op == IPUSH || ic->op == IPOP))
+ ds390_ptrRegReq++;
+ if (ic->op == IFX && IS_SYMOP (IC_COND (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_COND (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_COND (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_COND (ic))->etype) == idata));
+ else if (ic->op == JUMPTABLE && IS_SYMOP (IC_JTCOND (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_JTCOND (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_JTCOND (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_JTCOND (ic))->etype) == idata));
+ else
+ {
+ if (IS_SYMOP (IC_LEFT (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_LEFT (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_LEFT (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_LEFT (ic))->etype) == idata));
+ if (IS_SYMOP (IC_RIGHT (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_RIGHT (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_RIGHT (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_RIGHT (ic))->etype) == idata));
+ if (IS_SYMOP (IC_RESULT (ic)))
+ ds390_ptrRegReq += ((OP_SYMBOL (IC_RESULT (ic))->onStack ? !options.stack10bit : 0) +
+ OP_SYMBOL (IC_RESULT (ic))->iaccess +
+ (SPEC_OCLS(OP_SYMBOL (IC_RESULT (ic))->etype) == idata));
+ }
+ }
- {
- sym_link *fromType = operandType (IC_RIGHT (ic));
- sym_link *toType = operandType (IC_LEFT (ic));
-
- if (IS_INTEGRAL (fromType) && IS_INTEGRAL (toType) &&
- getSize (fromType) != getSize (toType) &&
- SPEC_USIGN (fromType) == SPEC_USIGN (toType))
- {
-
- iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
- if (dic)
- {
- if (IS_ARITHMETIC_OP (dic))
- {
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
- IC_RESULT (dic) = IC_RESULT (ic);
- remiCodeFromeBBlock (ebp, ic);
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
- hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
- OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
- ic = ic->prev;
- }
- else
- OP_SYMBOL (IC_RIGHT (ic))->ruonly = 0;
- }
- }
- else
- {
-
- /* if the type from and type to are the same
- then if this is the only use then packit */
- if (compareType (operandType (IC_RIGHT (ic)),
- operandType (IC_LEFT (ic))) == 1)
- {
- iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
- if (dic)
- {
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
- IC_RESULT (dic) = IC_RESULT (ic);
- remiCodeFromeBBlock (ebp, ic);
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
- hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
- OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
- ic = ic->prev;
- }
- }
- }
- }
-
- /* pack for PUSH
+ {
+ sym_link *fromType = operandType (IC_RIGHT (ic));
+ sym_link *toType = operandType (IC_LEFT (ic));
+
+ if (IS_INTEGRAL (fromType) && IS_INTEGRAL (toType) &&
+ getSize (fromType) != getSize (toType) &&
+ SPEC_USIGN (fromType) == SPEC_USIGN (toType))
+ {
+
+ iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
+ if (dic)
+ {
+ if (IS_ARITHMETIC_OP (dic))
+ {
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
+ IC_RESULT (dic) = IC_RESULT (ic);
+ remiCodeFromeBBlock (ebp, ic);
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
+ OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+ ic = ic->prev;
+ }
+ else
+ OP_SYMBOL (IC_RIGHT (ic))->ruonly = 0;
+ }
+ }
+ else
+ {
+
+ /* if the type from and type to are the same
+ then if this is the only use then packit */
+ if (compareType (operandType (IC_RIGHT (ic)),
+ operandType (IC_LEFT (ic))) == 1)
+ {
+ iCode *dic = packRegsDPTRuse (IC_RIGHT (ic));
+ if (dic)
+ {
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ IC_RESULT (dic) = IC_RESULT (ic);
+ remiCodeFromeBBlock (ebp, ic);
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
+ OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+ ic = ic->prev;
+ }
+ }
+ }
+ }
+
+ /* pack for PUSH