* src/hc08/gen.c (asmopToBool, genIfx): fix for bug #1429722
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 11 May 2006 21:42:48 +0000 (21:42 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 11 May 2006 21:42:48 +0000 (21:42 +0000)
* 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
src/hc08/gen.c

index 433e7b30d6645587e6e6599510edcfadb0d225e2..b2bb74c87b3122651c591c5902c1bdfb199ed91c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-11 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/hc08/gen.c (asmopToBool, genIfx): fix for bug #1429722
+       * src/hc08/gen.c (storeRegToAop): fix for bug #1439894
+
 2006-05-11 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * sim/ucsim/sim.src/memcl.h: added get_decoder() to cl_address_space
index 1c624bdb7d8daa2e65587944bd6403516433c4ea..3b834a005fe12c559119fd6dbaccf862e07f20f9 100644 (file)
@@ -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);