From: michaelh Date: Mon, 6 Mar 2000 04:53:30 +0000 (+0000) Subject: * Minor tuning X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a0a51978211d66c4c85456b317f2f2734162676f;p=fw%2Fsdcc * Minor tuning * Better addrOf * Better plusInc (do sub as well?) * Up to 185 with improved libs. Seems low... git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@167 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/doc/choices.txt b/doc/choices.txt index 080b0cf2..2e48bae1 100644 --- a/doc/choices.txt +++ b/doc/choices.txt @@ -35,4 +35,54 @@ On stack word push inc hl ld d,(hl) 1 = d + 8 + 8 + 4 - 2 = d + 8 + 8 + 8 \ No newline at end of file + 2 = d + 8 + 8 + 8 + +Structure member get: + Normally fetch pair + Then add pair and constant with result in hl + + ld l,c ; 4 + ld h,b ; 4 + inc hl .. ; 6 = 8 + 6n +or + ld l,c ; 4 + ld h,b ; 4 + ld a,#0x06 ; 7 + add a,c ; 4 + ld l,a ; 4 + ld a,#0x00 ; 7 + adc a,b ; 4 + ld h,a ; 4 = 38 +alt: (only when result=hl and left, rigth = pair, const) + ld hl,#const ; 10 + add hl,pair ; 11 = 21 + +So (1) is best for n <= 2, (2) is just bad, (3) is good n > 2 + +How about: + pair = pair + constant: +1: + ld a,#0x08 ; 7 + add a,c ; 4 + ld c,a ; 4 + ld a,#0x00 ; 7 + adc a,b ; 4 + ld b,a ; 4 = 30 +2: + ld hl,#const ; 10 + add hl,pair ; 11 + ld c,l ; 4 + ld b,h ; 4 = 29 +One cycle. If I cache HL later it will throw away the advantage. Choose 1. + +PlusIncr on pairs: +1: + inc pair ; 6 = 6n +2: + ld a,#0x04 ; 7 + add a,c ; 4 + ld c,a ; 4 + ld a,#0x00 ; 7 + adc a,b ; 4 + ld b,a ; 4 = 30 +So n <= 5 (1) is better. diff --git a/src/SDCChasht.h b/src/SDCChasht.h index dcca3f9e..cd00908e 100644 --- a/src/SDCChasht.h +++ b/src/SDCChasht.h @@ -28,6 +28,7 @@ #ifdef _NO_GC +#include #define GC_malloc malloc #define GC_free free #define GC_realloc realloc diff --git a/src/z80/gen.c b/src/z80/gen.c index 4422b297..eff8fc91 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -80,13 +80,15 @@ extern FILE *codeOutFile; set *sendSet = NULL; const char *_shortJP = "jp"; -enum { +typedef enum { PAIR_INVALID, PAIR_BC, PAIR_DE, PAIR_HL, + PAIR_IY, + PAIR_IX, NUM_PAIRS -}; +} PAIR_ID; static struct { const char *name; @@ -96,7 +98,9 @@ static struct { { "??", "?", "?" }, { "bc", "c", "b" }, { "de", "e", "d" }, - { "hl", "l", "h" } + { "hl", "l", "h" }, + { "iy", "iy.l?", "iy.h?" }, + { "ix", "ix.l?", "ix.h?" } }; #define RESULTONSTACK(x) \ @@ -116,17 +120,12 @@ unsigned char SLMask[] = {0xFF ,0xFE, 0xFC, 0xF8, 0xF0, unsigned char SRMask[] = {0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00}; -static int _lastStack = 0; -static int _pushed = 0; -static int _spoffset; - #define LSB 0 #define MSB16 1 #define MSB24 2 #define MSB32 3 /* Stack frame: - IX+4 param0 LH IX+2 ret LH IX+0 ix LH @@ -138,7 +137,13 @@ static struct { AOP_TYPE last_type; const char *lit; int offset; - } HL; + } pairs[NUM_PAIRS]; + struct { + int last; + int pushed; + int offset; + } stack; + int frameId; } _G; static char *aopGet(asmop *aop, int offset, bool bit16); @@ -203,7 +208,7 @@ const char *getPairName(asmop *aop) return NULL; } -static int getPairId(asmop *aop) +static PAIR_ID getPairId(asmop *aop) { if (aop->size == 2) { if (aop->type == AOP_REG) { @@ -238,6 +243,18 @@ bool isPair(asmop *aop) return (getPairId(aop) != PAIR_INVALID); } +bool isPtrPair(asmop *aop) +{ + PAIR_ID pairId = getPairId(aop); + switch (pairId) { + case PAIR_HL: + case PAIR_IY: + case PAIR_IX: + return TRUE; + default: + return FALSE; + } +} /** Push a register pair onto the stack */ void genPairPush(asmop *aop) { @@ -314,7 +331,6 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result) } else { sym->aop = aop = newAsmop(AOP_IY); - emitcode ("ld","iy,#%s ; a", sym->rname); } aop->size = getSize(sym->type); aop->aopu.aop_dir = sym->rname; @@ -591,8 +607,8 @@ dealloc: bool isLitWord(asmop *aop) { - if (aop->size != 2) - return FALSE; + /* if (aop->size != 2) + return FALSE;*/ switch (aop->type) { case AOP_IMMD: case AOP_LIT: @@ -607,15 +623,16 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash) char *s = buffer ; char *rs; +#if 0 if (aop->size != 2 && aop->type != AOP_HL) return NULL; +#endif wassert(offset == 0); /* depending on type */ switch (aop->type) { case AOP_HL: - wassert(IS_GB); - /* Fall through */ + case AOP_IY: case AOP_IMMD: sprintf (s,"%s%s",with_hash ? "#" : "", aop->aopu.aop_immd); ALLOC_ATOMIC(rs,strlen(s)+1); @@ -670,10 +687,16 @@ static void adjustPair(const char *pair, int *pold, int new) } } -static void spillHL(void) +static void spillPair(PAIR_ID pairId) +{ + _G.pairs[pairId].last_type = AOP_INVALID; + _G.pairs[pairId].lit = NULL; +} + +static void spillCached(void) { - _G.HL.last_type = AOP_INVALID; - _G.HL.lit = NULL; + spillPair(PAIR_HL); + spillPair(PAIR_IY); } static bool requiresHL(asmop *aop) @@ -687,7 +710,7 @@ static bool requiresHL(asmop *aop) } } -static void fetchLitPair(int pairId, asmop *left, int offset) +static void fetchLitPair(PAIR_ID pairId, asmop *left, int offset) { const char *l; const char *pair = _pairs[pairId].name; @@ -695,29 +718,29 @@ static void fetchLitPair(int pairId, asmop *left, int offset) wassert(l && pair); if (isPtr(pair)) { - if (_G.HL.lit && !strcmp(_G.HL.lit, l) && abs(_G.HL.offset - offset) < 3) { - adjustPair(pair, &_G.HL.offset, offset); - } - else { - _G.HL.last_type = left->type; - _G.HL.lit = _strdup(l); - _G.HL.offset = offset; - if (offset) - emitcode("ld", "%s,#%s + %d", pair, l, offset); - else - emitcode("ld", "%s,#%s", pair, l); + if (pairId == PAIR_HL || pairId == PAIR_IY) { + if (_G.pairs[pairId].lit && !strcmp(_G.pairs[pairId].lit, l)) { + if (pairId == PAIR_HL && abs(_G.pairs[pairId].offset - offset) < 3) { + adjustPair(pair, &_G.pairs[pairId].offset, offset); + return; + } + if (pairId == PAIR_IY && abs(offset)<127) { + return; + } + } } + _G.pairs[pairId].last_type = left->type; + _G.pairs[pairId].lit = _strdup(l); + _G.pairs[pairId].offset = offset; } - else { - /* Both a lit on the right and a true symbol on the left */ - if (offset) - emitcode("ld", "%s,#%s + %d", pair, l, offset); - else - emitcode("ld", "%s,#%s", pair, l); - } + /* Both a lit on the right and a true symbol on the left */ + if (offset) + emitcode("ld", "%s,#%s + %d", pair, l, offset); + else + emitcode("ld", "%s,#%s", pair, l); } -static void fetchPair(int pairId, asmop *aop) +static void fetchPair(PAIR_ID pairId, asmop *aop) { /* if this is remateriazable */ if (isLitWord(aop)) { @@ -736,7 +759,7 @@ static void fetchPair(int pairId, asmop *aop) } /* PENDING: check? */ if (pairId == PAIR_HL) - spillHL(); + spillPair(PAIR_HL); } } @@ -745,37 +768,40 @@ static void fetchHL(asmop *aop) fetchPair(PAIR_HL, aop); } -static void setupHL(asmop *aop, int offset) +static void setupPair(PAIR_ID pairId, asmop *aop, int offset) { + assert(pairId == PAIR_HL || pairId == PAIR_IY); + switch (aop->type) { + case AOP_IY: case AOP_HL: - emitcode("", ";1"); - fetchLitPair(PAIR_HL, aop, offset); - _G.HL.offset = offset; + fetchLitPair(pairId, aop, offset); + _G.pairs[pairId].offset = offset; break; case AOP_STK: { - /* Doesnt include _pushed */ - int abso = aop->aopu.aop_stk + offset + _spoffset; + /* Doesnt include _G.stack.pushed */ + int abso = aop->aopu.aop_stk + offset + _G.stack.offset; + assert(pairId == PAIR_HL); /* In some cases we can still inc or dec hl */ - if (_G.HL.last_type == AOP_STK && abs(_G.HL.offset - abso) < 3) { - adjustPair("hl", &_G.HL.offset, abso); + if (_G.pairs[pairId].last_type == AOP_STK && abs(_G.pairs[pairId].offset - abso) < 3) { + adjustPair(_pairs[pairId].name, &_G.pairs[pairId].offset, abso); } else { - emitcode("lda", "hl,%d+%d+%d(sp)", aop->aopu.aop_stk+offset, _pushed, _spoffset); + emitcode("lda", "hl,%d+%d+%d(sp)", aop->aopu.aop_stk+offset, _G.stack.pushed, _G.stack.offset); } - _G.HL.offset = abso; + _G.pairs[pairId].offset = abso; break; } default: wassert(0); } - _G.HL.last_type = aop->type; + _G.pairs[pairId].last_type = aop->type; } static void emitLabel(int key) { emitcode("", LABEL_STR ":", key); - spillHL(); + spillCached(); } /*-----------------------------------------------------------------*/ @@ -824,11 +850,13 @@ static char *aopGet(asmop *aop, int offset, bool bit16) case AOP_HL: wassert(IS_GB); emitcode("", ";3"); - setupHL(aop, offset); + setupPair(PAIR_HL, aop, offset); sprintf(s, "(hl)"); return _strdup("(hl)"); case AOP_IY: + wassert(IS_Z80); + setupPair(PAIR_IY, aop, offset); sprintf(s,"%d(iy)", offset); ALLOC_ATOMIC(rs,strlen(s)+1); strcpy(rs,s); @@ -836,11 +864,11 @@ static char *aopGet(asmop *aop, int offset, bool bit16) case AOP_STK: if (IS_GB) { - setupHL(aop, offset); + setupPair(PAIR_HL, aop, offset); sprintf(s, "(hl)"); } else { - sprintf(s,"%d(ix) ; %u", aop->aopu.aop_stk+offset, offset); + sprintf(s,"%d(ix)", aop->aopu.aop_stk+offset); } ALLOC_ATOMIC(rs,strlen(s)+1); strcpy(rs,s); @@ -926,6 +954,7 @@ static void aopPut (asmop *aop, char *s, int offset) case AOP_IY: wassert(!IS_GB); + setupPair(PAIR_IY, aop, offset); if (!canAssignToPtr(s)) { emitcode("ld", "a,%s", s); emitcode("ld", "%d(iy),a", offset); @@ -941,7 +970,7 @@ static void aopPut (asmop *aop, char *s, int offset) s = "a"; } emitcode("", ";2"); - setupHL(aop, offset); + setupPair(PAIR_HL, aop, offset); emitcode("ld", "(hl),%s", s); break; @@ -951,7 +980,7 @@ static void aopPut (asmop *aop, char *s, int offset) emitcode("ld", "a,(hl)"); s = "a"; } - setupHL(aop, offset); + setupPair(PAIR_HL, aop, offset); if (!canAssignToPtr(s)) { emitcode("ld", "a,%s", s); emitcode("ld", "(hl),a"); @@ -1261,7 +1290,7 @@ static void genIpush (iCode *ic) /* push it on the stack */ if (isPair(AOP(IC_LEFT(ic)))) { emitcode("push", getPairName(AOP(IC_LEFT(ic)))); - _pushed += 2; + _G.stack.pushed += 2; } else { offset = size; @@ -1271,7 +1300,7 @@ static void genIpush (iCode *ic) emitcode("ld", "a,%s", l); emitcode("push", "af"); emitcode("inc", "sp"); - _pushed++; + _G.stack.pushed++; } } return ; @@ -1286,15 +1315,15 @@ static void genIpush (iCode *ic) size = AOP_SIZE(IC_LEFT(ic)); if (isPair(AOP(IC_LEFT(ic)))) { - _pushed+=2; + _G.stack.pushed+=2; emitcode("push", "%s", getPairName(AOP(IC_LEFT(ic)))); } else { if (size == 2) { fetchHL(AOP(IC_LEFT(ic))); emitcode("push", "hl ; 2"); - spillHL(); - _pushed += 2; + spillPair(PAIR_HL); + _G.stack.pushed += 2; goto release; } offset = size; @@ -1303,7 +1332,7 @@ static void genIpush (iCode *ic) emitcode("ld", "a,%s", l); emitcode("push", "af"); emitcode("inc", "sp"); - _pushed++; + _G.stack.pushed++; } } release: @@ -1332,7 +1361,7 @@ static void genIpop (iCode *ic) while (size--) { emitcode("dec", "sp"); emitcode("pop", "hl"); - spillHL(); + spillPair(PAIR_HL); aopPut(AOP(IC_LEFT(ic)), "l", offset--); } } @@ -1380,15 +1409,15 @@ static void emitCall (iCode *ic, bool ispcall) } else { symbol *rlbl = newiTempLabel(NULL); - spillHL(); + spillPair(PAIR_HL); emitcode("ld", "hl,#" LABEL_STR, (rlbl->key+100)); emitcode("push", "hl"); - _pushed += 2; + _G.stack.pushed += 2; fetchHL(AOP(IC_LEFT(ic))); emitcode("jp", "(hl)"); emitcode("","%05d$:",(rlbl->key+100)); - _pushed -= 2; + _G.stack.pushed -= 2; } freeAsmop(IC_LEFT(ic),NULL,ic); } @@ -1399,7 +1428,7 @@ static void emitCall (iCode *ic, bool ispcall) OP_SYMBOL(IC_LEFT(ic))->name; emitcode("call", "%s", name); } - spillHL(); + spillCached(); /* if we need assign a result value */ if ((IS_ITEMP(IC_RESULT(ic)) && @@ -1419,12 +1448,12 @@ static void emitCall (iCode *ic, bool ispcall) /* adjust the stack for parameters if required */ if (IC_LEFT(ic)->parmBytes) { int i = IC_LEFT(ic)->parmBytes; - _pushed -= i; + _G.stack.pushed -= i; if (IS_GB) { emitcode("lda", "sp,%d(sp)", i); } else { - spillHL(); + spillCached(); if (i>6) { emitcode("ld", "hl,#%d", i); emitcode("add", "hl,sp"); @@ -1438,7 +1467,7 @@ static void emitCall (iCode *ic, bool ispcall) if (i) emitcode("inc", "sp"); } - spillHL(); + spillCached(); } } @@ -1519,7 +1548,7 @@ static void genFunction (iCode *ic) emitcode("add", "ix,sp"); } - _lastStack = sym->stack; + _G.stack.last = sym->stack; if (sym->stack) { if (IS_GB) { @@ -1531,7 +1560,7 @@ static void genFunction (iCode *ic) emitcode("ld", "sp,hl"); } } - _spoffset = sym->stack; + _G.stack.offset = sym->stack; } /*-----------------------------------------------------------------*/ @@ -1568,8 +1597,8 @@ static void genEndFunction (iCode *ic) emitcode("pop", "de"); } else { - if (_spoffset) { - emitcode("ld", "hl,#%d", _spoffset); + if (_G.stack.offset) { + emitcode("ld", "hl,#%d", _G.stack.offset); emitcode("add", "hl,sp"); emitcode("ld", "sp,hl"); } @@ -1580,8 +1609,8 @@ static void genEndFunction (iCode *ic) emitcode(".dw", "%s", sym->rname); emitcode("", "__%s_end:", sym->rname); } - _pushed = 0; - _spoffset = 0; + _G.stack.pushed = 0; + _G.stack.offset = 0; } /*-----------------------------------------------------------------*/ @@ -1658,7 +1687,8 @@ static bool genPlusIncr (iCode *ic) { unsigned int icount ; unsigned int size = getDataSize(IC_RESULT(ic)); - + PAIR_ID resultId = getPairId(AOP(IC_RESULT(ic))); + /* will try to generate an increment */ /* if the right side is not a literal we cannot */ @@ -1668,27 +1698,38 @@ static bool genPlusIncr (iCode *ic) emitcode("", "; genPlusIncr"); icount = floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit); - /* If result is a pair */ - if (isPair(AOP(IC_RESULT(ic))) && isLitWord(AOP(IC_LEFT(ic)))) { - fetchLitPair(getPairId(AOP(IC_RESULT(ic))), AOP(IC_LEFT(ic)), icount); + if (resultId != PAIR_INVALID) { + if (isLitWord(AOP(IC_LEFT(ic)))) { + fetchLitPair(getPairId(AOP(IC_RESULT(ic))), AOP(IC_LEFT(ic)), icount); + return TRUE; + } + if (isPair(AOP(IC_LEFT(ic))) && resultId == PAIR_HL && icount > 2) { + fetchPair(resultId, AOP(IC_RIGHT(ic))); + emitcode("add", "hl,%s", getPairName(AOP(IC_LEFT(ic)))); + return TRUE; + } + if (icount > 5) + return FALSE; + /* Inc a pair */ + if (!sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic)))) { + if (icount > 2) + return FALSE; + movLeft2Result(IC_LEFT(ic), 0, IC_RESULT(ic), 0, 0); + movLeft2Result(IC_LEFT(ic), 1, IC_RESULT(ic), 1, 0); + } + while (icount--) { + emitcode("inc", "%s", getPairName(AOP(IC_RESULT(ic)))); + } return TRUE; } /* if the literal value of the right hand side is greater than 4 then it is not worth it */ if (icount > 4) - return FALSE ; + return FALSE; - /* Inc a pair */ - if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) && - isPair(AOP(IC_RESULT(ic)))) { - while (icount--) { - emitcode("inc", "%s", getPairName(AOP(IC_RESULT(ic)))); - } - return TRUE; - } /* if increment 16 bits in register */ if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) && (size > 1) && @@ -1705,15 +1746,6 @@ static bool genPlusIncr (iCode *ic) return TRUE; } - /* If result is a pair */ - if (isPair(AOP(IC_RESULT(ic)))) { - movLeft2Result(IC_LEFT(ic), 0, IC_RESULT(ic), 0, 0); - movLeft2Result(IC_LEFT(ic), 1, IC_RESULT(ic), 1, 0); - while (icount--) - emitcode("inc", "%s", getPairName(AOP(IC_RESULT(ic)))); - return TRUE; - } - /* if the sizes are greater than 1 then we cannot */ if (AOP_SIZE(IC_RESULT(ic)) > 1 || AOP_SIZE(IC_LEFT(ic)) > 1 ) @@ -1815,6 +1847,14 @@ static void genPlus (iCode *ic) } } + if (isPair(AOP(IC_RIGHT(ic))) && getPairId(AOP(IC_RESULT(ic))) == PAIR_HL) { + /* Fetch into HL then do the add */ + spillPair(PAIR_HL); + fetchPair(PAIR_HL, AOP(IC_LEFT(ic))); + emitcode("add", "hl,%s", getPairName(AOP(IC_RIGHT(ic)))); + goto release; + } + while(size--) { if (AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) { MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE)); @@ -3530,11 +3570,18 @@ static void genGenPointerGet (operand *left, aopOp(left,ic,FALSE); aopOp(result,ic,FALSE); - - if (isPair(AOP(left)) && (AOP_SIZE(result)==1)) { + + if (isPair(AOP(left)) && AOP_SIZE(result)==1) { /* Just do it */ - emitcode("ld", "a,(%s)", getPairName(AOP(left))); - aopPut(AOP(result),"a", 0); + if (isPtrPair(AOP(left))) + { + sprintf(buffer, "(%s)", getPairName(AOP(left))); + aopPut(AOP(result), buffer, 0); + } + else { + emitcode("ld", "a,(%s)", getPairName(AOP(left))); + aopPut(AOP(result),"a", 0); + } freeAsmop(left,NULL,ic); goto release; } @@ -3607,7 +3654,7 @@ static void genGenPointerSet (operand *right, { int size, offset ; link *retype = getSpec(operandType(right)); - int pairId = PAIR_HL; + PAIR_ID pairId = PAIR_HL; aopOp(result,ic,FALSE); aopOp(right,ic,FALSE); @@ -3733,8 +3780,8 @@ static void genAddrOf (iCode *ic) variable */ if (IS_GB) { if (sym->onStack) { - spillHL(); - emitcode("lda", "hl,%d+%d+%d(sp)", sym->stack, _pushed, _spoffset); + spillCached(); + emitcode("lda", "hl,%d+%d+%d(sp)", sym->stack, _G.stack.pushed, _G.stack.offset); emitcode("ld", "d,h"); emitcode("ld", "e,l"); } @@ -3745,15 +3792,11 @@ static void genAddrOf (iCode *ic) aopPut(AOP(IC_RESULT(ic)), "d", 1); } else { - spillHL(); + spillCached(); if (sym->onStack) { /* if it has an offset then we need to compute it */ - emitcode("push", "de"); - emitcode("push", "ix"); - emitcode("pop", "hl"); - emitcode("ld", "de,#%d", sym->stack); - emitcode("add", "hl,de"); - emitcode("pop", "de"); + emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset); + emitcode("add", "hl,sp"); } else { emitcode("ld", "hl,#%s", sym->rname); @@ -3874,7 +3917,7 @@ static void genJumpTab (iCode *ic) emitcode("ld", "e,%s", l); emitcode("ld", "d,#0"); jtab = newiTempLabel(NULL); - spillHL(); + spillCached(); emitcode("ld", "hl,#" LABEL_STR, jtab->key+100); emitcode("add", "hl,de"); emitcode("add", "hl,de"); diff --git a/src/z80/peeph-z80.def b/src/z80/peeph-z80.def index 8b137891..44a07dfb 100644 --- a/src/z80/peeph-z80.def +++ b/src/z80/peeph-z80.def @@ -1 +1,17 @@ - +replace restart { + or a,%1(%2) + or a,a + jp nz,%3 +} by { + or a,%1(%2) + ; Removed redundent OR + jp nz,%3 +} +replace restart { + ld a,%1(%2) + bit %3,a + jp %4,%5 +} by { + bit %3,%1(%2) + jp %4,%5 +} diff --git a/src/z80/peeph.def b/src/z80/peeph.def index 63f57e35..4ef4a4b7 100644 --- a/src/z80/peeph.def +++ b/src/z80/peeph.def @@ -54,11 +54,11 @@ replace restart { %1: } replace restart { -%1: - jp %2 - jp %3 + ld a,%1 + or a,%2 + or a,a } by { - ; Weird Rule 7 -%1: - jp %2 + ; Rule 8 + ld a,%1 + or a,%2 } diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index d0309b8e..ec0a4864 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -1773,9 +1773,9 @@ bool opPreservesA(iCode *ic, iCode *uic) !IS_BITWISE_OP(uic) && uic->op != '=' && uic->op != EQ_OP && + !POINTER_GET(uic) && /* uic->op != LEFT_OP && - !POINTER_GET(uic) && uic->op != RIGHT_OP &&*/ 1 ) { @@ -1812,6 +1812,7 @@ static void packRegsForAccUse2(iCode *ic) /* Filter out all but those 'good' commands */ if ( + !POINTER_GET(ic) && ic->op != '+' && !IS_BITWISE_OP(ic) && ic->op != '=' && diff --git a/src/z80/z80.h b/src/z80/z80.h index 31116900..631d9cce 100644 --- a/src/z80/z80.h +++ b/src/z80/z80.h @@ -21,4 +21,5 @@ extern Z80_OPTS z80_opts; #define wassert(a) wassertl(a,"code generator internal error") #define IS_GB (z80_opts.sub == SUB_GBZ80) +#define IS_Z80 (z80_opts.sub == SUB_Z80) diff --git a/support/tests/dhrystone/Makefile b/support/tests/dhrystone/Makefile index 3efa4734..1eba231c 100644 --- a/support/tests/dhrystone/Makefile +++ b/support/tests/dhrystone/Makefile @@ -5,7 +5,7 @@ PORT = gb CC = /home/michaelh/projects/gbdk-support/lcc/lcc # -DNOENUM is here to make the results more predictable -CFLAGS = -v --prefix=/home/michaelh/projects/gbdk-current/ +CFLAGS = -Wl-m -mz80/consolez80 -v --prefix=/home/michaelh/projects/gbdk-current/ CFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM LIBDIR = /home/michaelh/projects/gbdk-lib/build/ LD = link-$(PROC)