-2001-11-25 Bernhard Held <bernhard@bernhardheld.de>
+2001-11-25 Michael Hope <michaelh@juju.net.nz>
+ * support/regression/tests/bug-485362.c: Added.
+
+ * support/regression/tests/simplefloat.c (testDivNearOne): Added.
+
+ * src/z80/gen.c (aopOp): Fixed case where left and result are in the same spill loc and they have different sizes.
+ * src/z80/peeph.def: Added rules for optimising two byte compares on the same thing, and to optimise two ptr assign.
+
+ * src/z80/gen.c (aopDump): Added a dump function.
+
+2001-11-25 Bernhard Held <bernhard@bernhardheld.de>
* sim/ucsim/s51.src/glob.cc: DS390 SFRs and bits added.
* sim/ucsim/s51.src/port.cc: Port 4 and 5 added.
static const char *aopGet (asmop * aop, int offset, bool bit16);
+static const char *aopNames[] = {
+ "AOP_INVALID",
+ "AOP_LIT",
+ "AOP_REG",
+ "AOP_DIR",
+ "AOP_SFR",
+ "AOP_STK",
+ "AOP_IMMD",
+ "AOP_STR",
+ "AOP_CRY",
+ "AOP_IY",
+ "AOP_HL",
+ "AOP_ACC",
+ "AOP_HLREG",
+ "AOP_SIMPLELIT",
+ "AOP_EXSTK",
+ "AOP_PAIRPT"
+};
+
static PAIR_ID
_getTempPairId(void)
{
}
}
+static void
+aopDump(const char *plabel, asmop *aop)
+{
+ emitDebug("; Dump of %s: type %s size %u", plabel, aopNames[aop->type], aop->size);
+ switch (aop->type)
+ {
+ case AOP_STK:
+ emitDebug("; aop_stk %d", aop->aopu.aop_stk);
+ break;
+ default:
+ /* No information. */
+ }
+}
+
static void
_moveA(const char *moveFrom)
{
/* if already has one */
if (sym->aop)
- return sym->aop;
+ {
+ return sym->aop;
+ }
/* Assign depending on the storage class */
if (sym->onStack || sym->iaccess)
/* if already has a asmop then continue */
if (op->aop)
- return;
+ {
+ return;
+ }
/* if the underlying symbol has a aop */
if (IS_SYMOP (op) && OP_SYMBOL (op)->aop)
}
/* else spill location */
- sym->aop = op->aop = aop =
+ op->aop = aop =
aopForSym (ic, sym->usl.spillLoc, result, requires_a);
+ wassertl (aop->size >= getSize (sym->type), "Operand doesn't fit in the spill location");
aop->size = getSize (sym->type);
+ /* PENDING: HACK. Can have different sizes in the same AOP. */
+ sym->usl.spillLoc->aop = NULL;
return;
}
{
/* Doesnt include _G.stack.pushed */
int abso = aop->aopu.aop_stk + offset + _G.stack.offset;
+
if (aop->aopu.aop_stk > 0)
{
abso += _G.stack.param_offset;
operand *left, *result;
left = IC_LEFT (ic);
result = IC_RESULT (ic);
+
aopOp (left, ic, FALSE, FALSE);
aopOp (result, ic, FALSE, FALSE);
else
{
emit2 ("rlc a");
- /* PENDING: For re-target. */
- emit2 ("and a,#1");
+ emit2 ("and a,!one");
outAcc (result);
}
aopPut (AOP (result), at, offset);
offset++;
}
+
+ freeAsmop (left, NULL, ic);
goto release;
}
--- /dev/null
+/** Simple set of tests for floating pt.
+ */
+#include <testfwk.h>
+
+void
+testCmp(void)
+{
+ volatile float left, right;
+
+ left = 5;
+ right = 13;
+ ASSERT(left + right == 18);
+ ASSERT(left + right <= 18);
+ ASSERT(left + right >= 18);
+ ASSERT(left + right > 17.9);
+ ASSERT(left + right < 18.1);
+}
+
+void
+testDiv(void)
+{
+ volatile float left, right;
+
+ left = 17;
+ right = 343;
+
+ ASSERT(left/right == (17.0/343.0));
+ ASSERT(right/left == (343.0/17.0));
+
+ right = 17;
+ ASSERT(left/right == 1.0);
+}
+
+void
+testDivNearOne(void)
+{
+ volatile float left, right, result;
+
+ left = 12392.4;
+ right = 12392.4;
+ result = left / right;
+
+ if (result > 0.999999)
+ {
+ /* Fine */
+ }
+ else
+ {
+ FAIL();
+ }
+ if (result < 1.00001)
+ {
+ /* Fine */
+ }
+ else
+ {
+ FAIL();
+ }
+ if (result > 0.999999 && result < 1.00001)
+ {
+ /* Fine */
+ }
+ else
+ {
+ FAIL();
+ }
+}