From e1c85b66cee001ea68bca916f6fc45547ee6b7ab Mon Sep 17 00:00:00 2001 From: epetrich Date: Thu, 11 May 2006 21:42:48 +0000 Subject: [PATCH] * src/hc08/gen.c (asmopToBool, genIfx): fix for bug #1429722 * src/hc08/gen.c (storeRegToAop): fix for bug #1439894 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4168 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/hc08/gen.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 433e7b30..b2bb74c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-11 Erik Petrich + + * src/hc08/gen.c (asmopToBool, genIfx): fix for bug #1429722 + * src/hc08/gen.c (storeRegToAop): fix for bug #1439894 + 2006-05-11 Maarten Brock * sim/ucsim/sim.src/memcl.h: added get_decoder() to cl_address_space diff --git a/src/hc08/gen.c b/src/hc08/gen.c index 1c624bdb..3b834a00 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -839,7 +839,10 @@ storeRegToAop (regs *reg, asmop *aop, int loffset) if (aop->type == AOP_DUMMY) return; - + + if (aop->type == AOP_CRY) /* This can only happen if IFX was optimized */ + return; /* away, so just toss the result */ + switch (regidx) { case A_IDX: @@ -2169,6 +2172,14 @@ asmopToBool (asmop *aop, bool resultInA) flagsonly = FALSE; } break; + case AOP_LIT: + /* Higher levels should optimize this case away but let's be safe */ + if ((unsigned long) floatFromVal (aop->aopu.aop_lit)) + loadRegFromConst (hc08_reg_a, one); + else + loadRegFromConst (hc08_reg_a, zero); + hc08_freeReg(hc08_reg_a); + break; default: if (size==1) { @@ -7695,6 +7706,30 @@ genIfx (iCode * ic, iCode * popIc) aopOp (cond, ic, FALSE); + /* If the condition is a literal, we can just do an unconditional */ + /* branch or no branch */ + if (AOP_TYPE (cond) == AOP_LIT) + { + unsigned long lit = (unsigned long) floatFromVal (AOP (cond)->aopu.aop_lit); + freeAsmop (cond, NULL, ic, TRUE); + + /* if there was something to be popped then do it */ + if (popIc) + genIpop (popIc); + if (lit) + { + if (IC_TRUE (ic)) + emitBranch ("jmp", IC_TRUE (ic)); + } + else + { + if (IC_FALSE (ic)) + emitBranch ("jmp", IC_FALSE (ic)); + } + ic->generated = 1; + return; + } + /* get the value into acc */ if (AOP_TYPE (cond) != AOP_CRY) asmopToBool (AOP (cond), FALSE); -- 2.30.2