* src/SDCCsymt.c (compStructSize): make bitfields without (un)signed specifier unsigned
[fw/sdcc] / src / SDCCicode.c
index f9e22e60d9f9d99984ee71f583180c6ebc02ef7b..6f8be2731863e2479e27b627f60b5a3ec9e4c30e 100644 (file)
@@ -989,6 +989,34 @@ isOperandInFarSpace (operand * op)
   return (IN_FARSPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
 }
 
+/*-----------------------------------------------------------------*/
+/* isOperandInPagedSpace - return true if operand is in pagedSpace */
+/*-----------------------------------------------------------------*/
+bool
+isOperandInPagedSpace (operand * op)
+{
+  sym_link *etype;
+
+  if (!op)
+    return FALSE;
+
+  if (!IS_SYMOP (op))
+    return FALSE;
+
+  if (!IS_TRUE_SYMOP (op))
+    {
+      if (SPIL_LOC (op))
+        etype = SPIL_LOC (op)->etype;
+      else
+        return FALSE;
+    }
+  else
+    {
+      etype = getSpec (operandType (op));
+    }
+  return (IN_PAGEDSPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
+}
+
 /*------------------------------------------------------------------*/
 /* isOperandInDirSpace - will return true if operand is in dirSpace */
 /*------------------------------------------------------------------*/
@@ -1392,6 +1420,23 @@ operandOperation (operand * left, operand * right,
                                  (i >> 1));
       }
       break;
+    case GETABIT:
+      retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >>
+                                (TYPE_UDWORD)operandLitValue(right)) & 1);
+      break;
+    case GETBYTE:
+      retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >>
+                                (TYPE_UDWORD)operandLitValue(right)) & 0xFF);
+      break;
+    case GETWORD:
+      retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >>
+                                (TYPE_UDWORD)operandLitValue(right)) & 0xFFFF);
+      break;
+
+    case GETHBIT:
+      retval = operandFromLit (((TYPE_UDWORD)operandLitValue(left) >>
+                                ((getSize (let) * 8) - 1)) & 1);
+      break;
 
     case UNARYMINUS:
       retval = operandFromValue (valCastLiteral (type,
@@ -2153,7 +2198,7 @@ geniCodeMultiply (operand * left, operand * right, RESULT_TYPE resultType)
   /* code generated for 1 byte * 1 byte literal = 2 bytes result is more
      efficient in most cases than 2 bytes result = 2 bytes << literal
      if port has 1 byte muldiv */
-  if (p2 && !IS_FLOAT (letype) && !IS_FIXED (letype)
+  if ((p2 > 0) && !IS_FLOAT (letype) && !IS_FIXED (letype)
       && !((resultType == RESULT_TYPE_INT) && (getSize (resType) != getSize (ltype))
            && (port->support.muldiv == 1))
       && strcmp (port->target, "pic16") != 0  /* don't shift for pic */
@@ -2204,8 +2249,8 @@ geniCodeDivision (operand * left, operand * right, RESULT_TYPE resultType)
       !IS_FLOAT (letype) &&
       !IS_FIXED (letype) &&
       IS_UNSIGNED(letype) &&
-      (p2 = powof2 ((TYPE_UDWORD)
-                    floatFromVal (right->operand.valOperand)))) {
+      ((p2 = powof2 ((TYPE_UDWORD)
+                    floatFromVal (right->operand.valOperand))) > 0)) {
     ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */
   }
   else
@@ -2816,6 +2861,7 @@ geniCodeAddressOf (operand * op)
   ADDTOCHAIN (ic);
   return IC_RESULT (ic);
 }
+
 /*-----------------------------------------------------------------*/
 /* setOClass - sets the output class depending on the pointer type */
 /*-----------------------------------------------------------------*/
@@ -4236,15 +4282,6 @@ ast2iCode (ast * tree,int lvl)
 #endif
 
     case '~':
-      {
-        sym_link *ltype = operandType (left);
-        operand *op = geniCodeUnary (geniCodeRValue (left, FALSE), tree->opval.op);
-        if ((SPEC_NOUN(ltype) == V_CHAR) && IS_UNSIGNED(ltype))
-          {
-            setOperandType (op, INTTYPE);
-          }
-        return op;
-      }
     case RRC:
     case RLC:
     case SWAP: