X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fds390%2Fgen.c;h=e5670acc03530c9791114e466cfdc17316beaeed;hb=353ff1ac97be2a4c6fb07f88607dffaebe20590e;hp=7da0377f61107e3a9192ea2d62b8851fe2514075;hpb=81142f760ed8feb6634a7bc8ef3d5e3c14368c82;p=fw%2Fsdcc diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 7da0377f..e5670acc 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -3017,17 +3017,10 @@ genFunction (iCode * ic) /* save the registers used */ for (i = 0; i < sym->regsUsed->size; i++) { - if (bitVectBitValue (sym->regsUsed, i) || - (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX))) + if (bitVectBitValue (sym->regsUsed, i)) emitcode ("push", "%s", ds390_regWithIdx (i)->dname); } } - else if (ds390_ptrRegReq) - { - emitcode ("push", "%s", ds390_regWithIdx (R0_IDX)->dname); - emitcode ("push", "%s", ds390_regWithIdx (R1_IDX)->dname); - } - } else { @@ -3147,20 +3140,13 @@ genFunction (iCode * ic) /* save the registers used */ for (i = 0; i < sym->regsUsed->size; i++) { - if (bitVectBitValue (sym->regsUsed, i) || - (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX))) + if (bitVectBitValue (sym->regsUsed, i)) { emitcode ("push", "%s", ds390_regWithIdx (i)->dname); _G.nRegsSaved++; } } } - else if (ds390_ptrRegReq) - { - emitcode ("push", "%s", ds390_regWithIdx (R0_IDX)->dname); - emitcode ("push", "%s", ds390_regWithIdx (R1_IDX)->dname); - _G.nRegsSaved += 2; - } } } @@ -3353,17 +3339,10 @@ genEndFunction (iCode * ic) /* save the registers used */ for (i = sym->regsUsed->size; i >= 0; i--) { - if (bitVectBitValue (sym->regsUsed, i) || - (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX))) + if (bitVectBitValue (sym->regsUsed, i)) emitcode ("pop", "%s", ds390_regWithIdx (i)->dname); } } - else if (ds390_ptrRegReq) - { - emitcode ("pop", "%s", ds390_regWithIdx (R1_IDX)->dname); - emitcode ("pop", "%s", ds390_regWithIdx (R0_IDX)->dname); - } - } else { @@ -3453,17 +3432,10 @@ genEndFunction (iCode * ic) /* save the registers used */ for (i = sym->regsUsed->size; i >= 0; i--) { - if (bitVectBitValue (sym->regsUsed, i) || - (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX))) + if (bitVectBitValue (sym->regsUsed, i)) emitcode ("pop", "%s", ds390_regWithIdx (i)->dname); } } - else if (ds390_ptrRegReq) - { - emitcode ("pop", "%s", ds390_regWithIdx (R1_IDX)->dname); - emitcode ("pop", "%s", ds390_regWithIdx (R0_IDX)->dname); - } - } /* if debug then send end of function */ @@ -3492,6 +3464,15 @@ genEndFunction (iCode * ic) && !FUNC_REGBANK(sym->type)) return; + /* There are no push/pops to optimize if not callee-saves or ISR */ + if (!(FUNC_CALLEESAVES (sym->type) || FUNC_ISISR (sym->type))) + return; + + /* If there were stack parameters, we cannot optimize without also */ + /* fixing all of the stack offsets; this is too dificult to consider. */ + if (FUNC_HASSTACKPARM(sym->type)) + return; + /* Compute the registers actually used */ regsUsed = newBitVect (ds390_nRegs); regsUsedPrologue = newBitVect (ds390_nRegs); @@ -3503,7 +3484,7 @@ genEndFunction (iCode * ic) regsUsed = bitVectUnion (regsUsed, port->peep.getRegsWritten(lnp)); if (lnp->ic && lnp->ic->op == FUNCTION && lnp->prev - && lnp->prev->ic && lnp->prev->ic->op != FUNCTION) + && lnp->prev->ic && lnp->prev->ic->op == ENDFUNCTION) break; if (!lnp->prev) break;