* Fixed addrOf bug, more packing for gbz80.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Feb 2000 02:52:29 +0000 (02:52 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Feb 2000 02:52:29 +0000 (02:52 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@126 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/z80/gen.c
src/z80/ralloc.c

index da152c0b2aab2135ddc0eb402cb5bbc67a061370..24a5d2c39f88595fb28729eff11162e1c09ffc9e 100644 (file)
@@ -3400,16 +3400,8 @@ static void genGenPointerGet (operand *left,
        emitcode("ld","%s,%s", ptr, aopGet(AOP(left),0,TRUE));
     else { /* we need to get it byte by byte */
        if (IS_GB) {
-           bool hack = 0;
-           /* PENDING: hack */
-           if (AOP_SIZE(left) == 1) {
-               hack = 1;
-               AOP_SIZE(left) = 2;
-           }
            emitcode("ld", "e,%s ; 1", aopGet(AOP(left), 0, FALSE));
            emitcode("ld", "d,%s ; 2", aopGet(AOP(left), 1, FALSE));
-           if (hack)
-               AOP_SIZE(left) = 1;
        }
        else
            fetchHL(AOP(left));
@@ -3611,31 +3603,34 @@ static void genAddrOf (iCode *ic)
     /* if the operand is on the stack then we 
     need to get the stack offset of this
     variable */
-    if (sym->onStack) {
-        /* if it has an offset  then we need to compute it */
-       if (IS_GB) {
+    if (IS_GB) {
+       if (sym->onStack) {
            emitcode("lda", "hl,%d+%d+%d(sp)", sym->stack, _pushed, _spoffset);
            emitcode("ld", "d,h");
            emitcode("ld", "e,l");
-           aopPut(AOP(IC_RESULT(ic)), "e", 0);
-           aopPut(AOP(IC_RESULT(ic)), "d", 1);
-           goto end;
        }
        else {
-           emitcode("push", "de");
+           emitcode("ld", "de,#%s", sym->rname);
+       }
+       aopPut(AOP(IC_RESULT(ic)), "e", 0);
+       aopPut(AOP(IC_RESULT(ic)), "d", 1);
+    }
+    else {
+       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");
        }
+       else {
+           emitcode("ld", "hl,#%s", sym->rname);
+       }
+       aopPut(AOP(IC_RESULT(ic)), "l", 0);
+       aopPut(AOP(IC_RESULT(ic)), "h", 1);
     }
-    else {
-       emitcode("ld", "hl,#%s", sym->rname);
-    }
-    aopPut(AOP(IC_RESULT(ic)), "l", 0);
-    aopPut(AOP(IC_RESULT(ic)), "h", 1);
-end:
     freeAsmop(IC_RESULT(ic),NULL,ic);
 }
 
@@ -3679,7 +3674,10 @@ static void genAssign (iCode *ic)
 
     if(AOP_TYPE(right) == AOP_LIT)
        lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
-    if((size > 1) &&
+    if (isPair(AOP(result)) && AOP_TYPE(right) == AOP_LIT) {
+       emitcode("ld", "%s,%s", getPairName(AOP(result)), aopGetWord(AOP(right), 0));
+    }
+    else if((size > 1) &&
        (AOP_TYPE(result) != AOP_REG) &&
        (AOP_TYPE(right) == AOP_LIT) &&
        !IS_FLOAT(operandType(right)) &&
index 330de6b4c1a24116aa9fa0afb18f19f660d91d3e..8484a484ad7fe03066e75a798d7b19204e4886c2 100644 (file)
@@ -1299,11 +1299,13 @@ static int packRegsForAssign (iCode *ic,eBBlock *ebp)
            dic = NULL;
            break;
        }
+#if 0
        if (POINTER_SET(dic) && 
            IC_RESULT(dic)->key == IC_RESULT(ic)->key ) {
            dic = NULL ;
            break;
        }
+#endif
     }
     
     if (!dic)
@@ -1750,15 +1752,20 @@ static void packRegsForAccUse (iCode *ic)
 bool opPreservesA(iCode *ic, iCode *uic)
 {
     /* if the usage has only one operand then we can */
-    if (IC_LEFT(ic) == NULL ||
-       IC_RIGHT(ic) == NULL) 
+    if (IC_LEFT(uic) == NULL ||
+       IC_RIGHT(uic) == NULL) 
        return TRUE;
 
+    if (getSize(operandType(IC_RESULT(uic))) > 1) {
+       return FALSE;
+    }
+
     if (uic->op != '=' && 
        !IS_ARITHMETIC_OP(uic) &&
        !IS_BITWISE_OP(uic)    &&
        uic->op != EQ_OP &&
        uic->op != LEFT_OP &&
+       !POINTER_GET(uic) &&
        uic->op != RIGHT_OP ) {
        return FALSE;
     }
@@ -1788,7 +1795,7 @@ bool opPreservesA(iCode *ic, iCode *uic)
 static void packRegsForAccUse2(iCode *ic)
 {
     iCode *uic;
-    
+
     /* if + or - then it has to be one byte result.
        MLH: Ok.
      */
@@ -2038,35 +2045,32 @@ static void packRegisters (eBBlock *ebp)
            !options.model)
            packRegsForOneuse (ic,IC_LEFT(ic),ebp);     
 #endif
-
-       if (!IS_GB) {
-           /* if pointer set & left has a size more than
+       /* if pointer set & left has a size more than
           one and right is not in far space */
-           if (POINTER_SET(ic)                    &&
-               /* MLH: no such thing.
-                  !isOperandInFarSpace(IC_RIGHT(ic)) && */
-               !OP_SYMBOL(IC_RESULT(ic))->remat   &&
-               !IS_OP_RUONLY(IC_RIGHT(ic))        &&
-               getSize(aggrToPtr(operandType(IC_RESULT(ic)),FALSE)) > 1 )
-
-               packRegsForOneuse (ic,IC_RESULT(ic),ebp);
-
-           /* if pointer get */
-           if (POINTER_GET(ic)                    &&
-               /* MLH: dont have far space
-                  !isOperandInFarSpace(IC_RESULT(ic))&& */
-               !OP_SYMBOL(IC_LEFT(ic))->remat     &&
-               !IS_OP_RUONLY(IC_RESULT(ic))         &&
-               getSize(aggrToPtr(operandType(IC_LEFT(ic)),FALSE)) > 1 )
-               packRegsForOneuse (ic,IC_LEFT(ic),ebp);
-       }
-
+       if (POINTER_SET(ic)                    &&
+           /* MLH: no such thing.
+              !isOperandInFarSpace(IC_RIGHT(ic)) && */
+           !OP_SYMBOL(IC_RESULT(ic))->remat   &&
+           !IS_OP_RUONLY(IC_RIGHT(ic))        &&
+           getSize(aggrToPtr(operandType(IC_RESULT(ic)),FALSE)) > 1 )
+           
+           packRegsForOneuse (ic,IC_RESULT(ic),ebp);
+       
+       /* if pointer get */
+       if (POINTER_GET(ic)                    &&
+           /* MLH: dont have far space
+              !isOperandInFarSpace(IC_RESULT(ic))&& */
+           !OP_SYMBOL(IC_LEFT(ic))->remat     &&
+           !IS_OP_RUONLY(IC_RESULT(ic))         &&
+           getSize(aggrToPtr(operandType(IC_LEFT(ic)),FALSE)) > 1 )
+           packRegsForOneuse (ic,IC_LEFT(ic),ebp);
        /* pack registers for accumulator use, when the result of an
           arithmetic or bit wise operation has only one use, that use is
           immediately following the defintion and the using iCode has
           only one operand or has two operands but one is literal & the
           result of that operation is not on stack then we can leave the
           result of this operation in acc:b combination */
+#if 0
 #if 0
        if ((IS_ARITHMETIC_OP(ic) 
             || IS_BITWISE_OP(ic)
@@ -2076,17 +2080,10 @@ static void packRegisters (eBBlock *ebp)
            getSize(operandType(IC_RESULT(ic))) <= 2)
            packRegsForAccUse (ic);
 #else
-       if (!IS_GB) {
-           if ((POINTER_GET(ic) ||
-                IS_ARITHMETIC_OP(ic) ||
-                IS_BITWISE_OP(ic) ||
-                ic->op == LEFT_OP ||
-                ic->op == RIGHT_OP
-                ) &&
-               IS_ITEMP(IC_RESULT(ic)) &&
-               getSize(operandType(IC_RESULT(ic))) == 1)
-               packRegsForAccUse2(ic);
-       }
+       if (IS_ITEMP(IC_RESULT(ic)) &&
+           getSize(operandType(IC_RESULT(ic))) == 1)
+           packRegsForAccUse2(ic);
+#endif
 #endif
     }
 }