* src/hc08/gen.c: --no-gen-comments (RFE #1493816) for hc08
[fw/sdcc] / src / hc08 / gen.c
index 8c93b380c85b1083471488e31910cd8b5eb77e86..e00a0b263f1b29fe92b706904c842a1ee341da42 100644 (file)
@@ -28,8 +28,7 @@
 -------------------------------------------------------------------------*/
 
 /* Use the D macro for basic (unobtrusive) debugging messages */
-//#define D(x)
-#define D(x) x
+#define D(x) do if (!options.noGenComments) {x;} while(0)
 /* Use the DD macro for detailed debugging messages */
 #define DD(x)
 //#define DD(x) x
@@ -1621,6 +1620,7 @@ operandsEqu (operand * op1, operand * op2)
   if (sym1 == sym2)
     return TRUE;
 
+  /* if they have the same rname */
   if (sym1->rname[0] && sym2->rname[0]
       && strcmp (sym1->rname, sym2->rname) == 0)
     return TRUE;
@@ -4229,8 +4229,9 @@ negatedCmp (int opcode)
   return EQ_OP; /* shouldn't happen, but need to return something */
 }
 
-/* compile only if the debugging macro D is enabled */
-#if (D(1) -0)
+/*------------------------------------------------------------------*/
+/* nameCmp : helper function for human readable debug output        */
+/*------------------------------------------------------------------*/
 static char *
 nameCmp (int opcode)
 {
@@ -4252,7 +4253,6 @@ nameCmp (int opcode)
       return "invalid";
     }
 }
-#endif
 
 /*------------------------------------------------------------------*/
 /* branchInstCmp : returns the conditional branch instruction that  */
@@ -5702,7 +5702,7 @@ genSwap (iCode * ic)
       hc08_freeReg (hc08_reg_a);
       break;
     case 2: /* swap bytes in a word */
-      if (operandsEqu (left, result))
+      if (operandsEqu (left, result) || sameRegs (AOP (left), AOP (result)))
         {
           loadRegFromAop (hc08_reg_a, AOP (left), 0);
           hc08_useReg (hc08_reg_a);