/* bitwise operations are considered optimizable
under the following conditions (Jean-Louis VERN)
- x & lit <== jwk: should be x && lit
+ x & lit
bit & bit
bit & x
bit ^ bit
bit ^ x
- x ^ lit <== jwk: should be x ^^ lit
- x | lit <== jwk: should be x || lit
+ x ^ lit
+ x | lit
bit | bit
bit | x
*/
- if ( /* jwk IS_LITERAL (rtype) || */
+ if ( IS_LITERAL (rtype) ||
(IS_BITVAR (ltype) && IN_BITSPACE (SPEC_OCLS (ltype))))
return TRUE;
else
}
}
+#if 0
/* if the condition of an if instruction
is defined in the previous instruction then
mark the itemp as a conditional */
OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
continue;
}
+#else
+ /* if the condition of an if instruction
+ is defined in the previous instruction and
+ this is the only usage then
+ mark the itemp as a conditional */
+ if ((IS_CONDITIONAL (ic) ||
+ (IS_BITWISE_OP(ic) && isBitwiseOptimizable (ic))) &&
+ ic->next && ic->next->op == IFX &&
+ bitVectnBitsOn (OP_USES(IC_RESULT(ic)))==1 &&
+ isOperandEqual (IC_RESULT (ic), IC_COND (ic->next)) &&
+ OP_SYMBOL (IC_RESULT (ic))->liveTo <= ic->next->seq)
+ {
+ OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
+ continue;
+ }
+#endif
/* reduce for support function calls */
if (ic->supportRtn || ic->op == '+' || ic->op == '-')
return aop;
}
-static void
-genSetDPTR (int n)
-{
- if (!n)
- {
- emitcode (";", "Select standard DPTR");
- emitcode ("mov", "dps, #0x00");
- }
- else
- {
- emitcode (";", "Select alternate DPTR");
- emitcode ("mov", "dps, #0x01");
- }
-}
-
/*-----------------------------------------------------------------*/
/* pointerCode - returns the code for a pointer type */
/*-----------------------------------------------------------------*/
return rs;
case AOP_DPTR:
- case AOP_DPTR2:
-
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR (1);
- }
-
while (offset > aop->coff)
{
emitcode ("inc", "dptr");
{
emitcode ("movx", "a,@dptr");
}
-
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR (0);
- }
-
return (dname ? "acc" : "a");
break;
case AOP_DPTR:
- case AOP_DPTR2:
-
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR (1);
- }
-
if (aop->code)
{
werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
MOVA (s);
emitcode ("movx", "@dptr,a");
-
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR (0);
- }
break;
case AOP_R0:
static void
reAdjustPreg (asmop * aop)
{
- aop->coff = 0;
if ((aop->coff==0) || aop->size <= 1)
return;
emitcode ("dec", "%s", aop->aopu.aop_ptr->name);
break;
case AOP_DPTR:
- case AOP_DPTR2:
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR (1);
- }
while (aop->coff--)
{
emitcode ("lcall", "__decdptr");
}
-
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR (0);
- }
break;
-
}
-
+ aop->coff = 0;
}
#define AOP(op) op->aop
AOP_TYPE(x) == AOP_R0))
#define AOP_NEEDSACC(x) (AOP(x) && (AOP_TYPE(x) == AOP_CRY || \
- AOP_TYPE(x) == AOP_DPTR || AOP_TYPE(x) == AOP_DPTR2 || \
- AOP(x)->paged))
+ AOP_TYPE(x) == AOP_DPTR || AOP(x)->paged))
#define AOP_INPREG(x) (x && (x->type == AOP_REG && \
(x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \
int bytelit = 0;
char buffer[10];
+ catchMe();
aopOp ((left = IC_LEFT (ic)), ic, FALSE);
aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
aopOp ((result = IC_RESULT (ic)), ic, TRUE);
aopOp (right, ic, FALSE);
/* special case both in far space */
- if ((AOP_TYPE (right) == AOP_DPTR ||
- AOP_TYPE (right) == AOP_DPTR2) &&
+ if (AOP_TYPE (right) == AOP_DPTR &&
IS_TRUE_SYMOP (result) &&
isOperandInFarSpace (result))
{
{
AOP_LIT = 1,
AOP_REG, AOP_DIR,
- AOP_DPTR, AOP_DPTR2, AOP_R0, AOP_R1,
+ AOP_DPTR, AOP_R0, AOP_R1,
AOP_STK, AOP_IMMD, AOP_STR,
AOP_CRY, AOP_ACC
};
isBitwiseOptimizable (iCode * ic)
{
sym_link *ltype = getSpec (operandType (IC_LEFT (ic)));
+ sym_link *rtype = getSpec (operandType (IC_RIGHT (ic)));
/* bitwise operations are considered optimizable
under the following conditions (Jean-Louis VERN)
+ x & lit
bit & bit
bit & x
bit ^ bit
bit ^ x
+ x ^ lit
+ x | lit
bit | bit
bit | x
- */
- if ((IS_BITVAR (ltype) && IN_BITSPACE (SPEC_OCLS (ltype))))
+ */
+ if (IS_LITERAL(rtype) ||
+ (IS_BITVAR (ltype) && IN_BITSPACE (SPEC_OCLS (ltype))))
return TRUE;
else
return FALSE;
}
}
+#if 0
/* if the condition of an if instruction
is defined in the previous instruction then
mark the itemp as a conditional */
OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
continue;
}
+#else
+ /* if the condition of an if instruction
+ is defined in the previous instruction and
+ this is the only usage then
+ mark the itemp as a conditional */
+ if ((IS_CONDITIONAL (ic) ||
+ (IS_BITWISE_OP(ic) && isBitwiseOptimizable (ic))) &&
+ ic->next && ic->next->op == IFX &&
+ bitVectnBitsOn (OP_USES(IC_RESULT(ic)))==1 &&
+ isOperandEqual (IC_RESULT (ic), IC_COND (ic->next)) &&
+ OP_SYMBOL (IC_RESULT (ic))->liveTo <= ic->next->seq)
+ {
+ OP_SYMBOL (IC_RESULT (ic))->regType = REG_CND;
+ continue;
+ }
+#endif
/* reduce for support function calls */
if (ic->supportRtn || ic->op == '+' || ic->op == '-')