From: epetrich Date: Thu, 16 Sep 2004 07:10:57 +0000 (+0000) Subject: * src/hc08/main.c, X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=06b95666e210afed625cfbe73489873b7b1bef82;p=fw%2Fsdcc * src/hc08/main.c, * src/hc08/gen.c (genJumpTable): more efficient jump table, supports preservation of HX * src/hc08/gen.c (pullRegs): fixed order of HX & XA pairs * src/mcs51/ralloc.c (packRegisters): removed the patch applied on 2004-09-12; it was buggy git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3498 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ec46032e..ac6a8335 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-09-16 Erik Petrich + + * src/hc08/main.c, + * src/hc08/gen.c (genJumpTable): more efficient jump table, supports + preservation of HX + * src/hc08/gen.c (pullRegs): fixed order of HX & XA pairs + * src/mcs51/ralloc.c (packRegisters): removed the patch applied + on 2004-09-12; it was buggy + 2004-09-15 Bernhard Held * src/SDCCsymt.h: removed RESULT_CHECK diff --git a/src/hc08/gen.c b/src/hc08/gen.c index 2938ece6..75a1f85c 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -411,18 +411,18 @@ pullReg (regs *reg) updateCFA(); break; case HX_IDX: - emitcode ("pulx", ""); + emitcode ("pulh", ""); _G.stackPushes--; updateCFA(); - emitcode ("pulh", ""); + emitcode ("pulx", ""); _G.stackPushes--; updateCFA(); break; case XA_IDX: - emitcode ("pula", ""); + emitcode ("pulx", ""); _G.stackPushes--; updateCFA(); - emitcode ("pulx", ""); + emitcode ("pula", ""); _G.stackPushes--; updateCFA(); break; @@ -7665,32 +7665,59 @@ static void genJumpTab (iCode * ic) { symbol *jtab; -// char *l; - + symbol *jtablo = newiTempLabel (NULL); + symbol *jtabhi = newiTempLabel (NULL); + D(emitcode ("; genJumpTab","")); aopOp (IC_JTCOND (ic), ic, FALSE); - /* get the condition into accumulator */ - loadRegFromAop (hc08_reg_a, AOP (IC_JTCOND (ic)), 0); - freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE); - /* multiply by three */ - pushReg (hc08_reg_a, FALSE); - emitcode ("lsla", ""); - emitcode ("add","1,s"); - transferRegReg (hc08_reg_a, hc08_reg_x, TRUE); - loadRegFromConst (hc08_reg_h, zero); - pullReg (hc08_reg_a); + + if (hc08_reg_x->isFree && hc08_reg_x->isFree) + { + /* get the condition into x */ + loadRegFromAop (hc08_reg_x, AOP (IC_JTCOND (ic)), 0); + freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE); + loadRegFromConst (hc08_reg_h, zero); + + emitcode ("lda", "%05d$,x", jtabhi->key + 100); + emitcode ("ldx", "%05d$,x", jtablo->key + 100); + transferRegReg (hc08_reg_a, hc08_reg_h, TRUE); + emitcode ("jmp", ",x"); + + hc08_dirtyReg (hc08_reg_a, TRUE); + hc08_dirtyReg (hc08_reg_hx, TRUE); + } + else + { + adjustStack(-2); + pushReg(hc08_reg_hx, TRUE); + + /* get the condition into x */ + loadRegFromAop (hc08_reg_x, AOP (IC_JTCOND (ic)), 0); + freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE); + loadRegFromConst (hc08_reg_h, zero); + + emitcode ("lda", "%05d$,x", jtabhi->key + 100); + emitcode ("sta", "3,s"); + emitcode ("lda", "%05d$,x", jtablo->key + 100); + emitcode ("sta", "4,s"); + + pullReg(hc08_reg_hx); + emitcode ("rts", ""); + _G.stackPushes += 2; + updateCFA(); + } - jtab = newiTempLabel (NULL); - emitcode ("jmp", "%05d$,x", jtab->key + 100); - emitcode ("", "%05d$:", jtab->key + 100); /* now generate the jump labels */ + emitLabel (jtablo); + for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab; + jtab = setNextItem (IC_JTLABELS (ic))) + emitcode (".db", "%05d$", jtab->key + 100); + emitLabel (jtabhi); for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab; jtab = setNextItem (IC_JTLABELS (ic))) - emitcode ("jmp", "%05d$", jtab->key + 100); + emitcode (".db", ">%05d$", jtab->key + 100); - hc08_dirtyReg (hc08_reg_a, TRUE); - hc08_dirtyReg (hc08_reg_hx, TRUE); } /*-----------------------------------------------------------------*/ diff --git a/src/hc08/main.c b/src/hc08/main.c index f586fc63..f5efd860 100644 --- a/src/hc08/main.c +++ b/src/hc08/main.c @@ -464,12 +464,12 @@ PORT hc08_port = }, }, { - 255/3, /* maxCount */ - 3, /* sizeofElement */ + 256, /* maxCount */ + 2, /* sizeofElement */ {8,16,32}, /* sizeofMatchJump[] */ {8,16,32}, /* sizeofRangeCompare[] */ 5, /* sizeofSubtract */ - 11, /* sizeofDispatch */ + 10, /* sizeofDispatch */ }, "_", _hc08_init, diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 0c9ada1d..0d4181a2 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -2808,46 +2808,6 @@ packRegisters (eBBlock ** ebpp, int blockno) for (ic = ebp->sch; ic; ic = ic->next) { - /* Fix for bug #979599: */ - /* P0 &= ~1; */ - - /* Look for two subsequent iCodes with */ - /* iTemp := _c; */ - /* _c = iTemp & op; */ - /* and replace them by */ - /* _c = _c & op; */ - if ((ic->op == BITWISEAND || ic->op == '|' || ic->op == '^') && - /* avoid trouble with unary '&' */ - IC_RIGHT (ic) && - ic->prev && - ic->prev->op == '=' && - IS_ITEMP (IC_LEFT (ic)) && - IC_LEFT (ic) == IC_RESULT (ic->prev) && - isOperandEqual (IC_RESULT(ic), IC_RIGHT(ic->prev))) - { - int key = ic->prev->key; - - bitVectUnSetBit (OP_SYMBOL (IC_RESULT (ic->prev))->defs, key); - ReplaceOpWithCheaperOp (&IC_LEFT (ic), IC_RESULT (ic)); - if (/*IS_ITEMP (IC_RESULT (ic->prev)) && */ - OP_SYMBOL (IC_RESULT (ic->prev))->liveFrom > ic->seq) - { - OP_SYMBOL (IC_RESULT (ic->prev))->liveFrom = ic->seq; - } - // TODO: and the other way round? - - /* delete from liverange table also - delete from all the points in between and the new one */ - bitVectUnSetBit (ic->prev->rlive, IC_RESULT (ic->prev)->key); - bitVectSetBit (ic->prev->rlive, IC_RESULT (ic)->key); - bitVectUnSetBit (ic->rlive, IC_RESULT (ic->prev)->key); - bitVectSetBit (ic->rlive, IC_RESULT (ic)->key); - - remiCodeFromeBBlock (ebp, ic->prev); - // bitVectUnSetBit (OP_SYMBOL (IC_RESULT (ic))->defs, ic->key); - hTabDeleteItem (&iCodehTab, key, ic->prev, DELETE_ITEM, NULL); - // OP_DEFS (IC_RESULT (ic->prev)) = bitVectSetBit (OP_DEFS (IC_RESULT (ic->prev)), ic->prev->key); - } /* if this is an itemp & result of an address of a true sym then mark this as rematerialisable */