h8300-protos.h: Remove the prototype for o_operand.
authorKazu Hirata <kazu@cs.umass.edu>
Wed, 29 May 2002 14:20:40 +0000 (14:20 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Wed, 29 May 2002 14:20:40 +0000 (14:20 +0000)
* config/h8300/h8300-protos.h: Remove the prototype for
o_operand.
Add prototypes for single_one_operand and single_zero_operand.
* config/h8300/h8300.c (o_operand): Remove.
(single_one_operand): New.
(single_zero_operand): Likewise.
(print_operand): For 'V' operand, and the operand with 0xff.
For 'V' and 'W' operands, do not and the bit position with 7.
* config/h8300/h8300.md (various anonymous patterns): Replace
use of exact_log2 with single_one_operand/single_zero_operand.

From-SVN: r53994

gcc/ChangeLog
gcc/config/h8300/h8300-protos.h
gcc/config/h8300/h8300.c
gcc/config/h8300/h8300.md

index df4027ffcda1e10e471d2bd3141d07c8f8210c1f..c1d0a26e81256025818723b0d7142312c29489d6 100644 (file)
@@ -1,3 +1,16 @@
+2002-05-29  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * config/h8300/h8300-protos.h: Remove the prototype for
+       o_operand.
+       Add prototypes for single_one_operand and single_zero_operand.
+       * config/h8300/h8300.c (o_operand): Remove.
+       (single_one_operand): New.
+       (single_zero_operand): Likewise.
+       (print_operand): For 'V' operand, and the operand with 0xff.
+       For 'V' and 'W' operands, do not and the bit position with 7.
+       * config/h8300/h8300.md (various anonymous patterns): Replace
+       use of exact_log2 with single_one_operand/single_zero_operand.
+
 2002-05-29  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * config/s390/linux.h (MD_FALLBACK_FRAME_STATE_FOR): New.
index 9a70284d806a2b167f5b31d20ed64ad34564e4fd..d02c082f8be3494fa5cf9cf206996c3ab76dd51e 100644 (file)
@@ -48,7 +48,8 @@ extern void split_adds_subs PARAMS ((enum machine_mode, rtx[]));
 
 extern int general_operand_src PARAMS ((rtx, enum machine_mode));
 extern int general_operand_dst PARAMS ((rtx, enum machine_mode));
-extern int o_operand PARAMS ((rtx, enum machine_mode));
+extern int single_one_operand PARAMS ((rtx, enum machine_mode));
+extern int single_zero_operand PARAMS ((rtx, enum machine_mode));
 extern int call_insn_operand PARAMS ((rtx, enum machine_mode));
 extern int two_insn_adds_subs_operand PARAMS ((rtx, enum machine_mode));
 extern int small_call_insn_operand PARAMS ((rtx, enum machine_mode));
index bb78d4bb34f99810ca4dd4cba985b1dfdb80dcdd..0258c68a9be808146eefaab80e478fade98aab45 100644 (file)
@@ -569,15 +569,50 @@ general_operand_dst (op, mode)
   return general_operand (op, mode);
 }
 
-/* Return true if OP is a const valid for a bit clear instruction.  */
+/* Return true if OP is a constant that contains only one 1 in its
+   binary representation.  */
 
 int
-o_operand (operand, mode)
+single_one_operand (operand, mode)
      rtx operand;
      enum machine_mode mode ATTRIBUTE_UNUSED;
 {
-  return (GET_CODE (operand) == CONST_INT
-         && CONST_OK_FOR_O (INTVAL (operand)));
+  if (GET_CODE (operand) == CONST_INT)
+    {
+      /* We really need to do this masking because 0x80 in QImode is
+        represented as -128 for example.  */
+      unsigned HOST_WIDE_INT mask =
+       ((unsigned HOST_WIDE_INT) 1 << GET_MODE_BITSIZE (mode)) - 1;
+      unsigned HOST_WIDE_INT value = INTVAL (operand);
+
+      if (exact_log2 (value & mask) >= 0)
+       return 1;
+    }
+
+  return 0;
+}
+
+/* Return true if OP is a constant that contains only one 0 in its
+   binary representation.  */
+
+int
+single_zero_operand (operand, mode)
+     rtx operand;
+     enum machine_mode mode ATTRIBUTE_UNUSED;
+{
+  if (GET_CODE (operand) == CONST_INT)
+    {
+      /* We really need to do this masking because 0x80 in QImode is
+        represented as -128 for example.  */
+      unsigned HOST_WIDE_INT mask =
+       ((unsigned HOST_WIDE_INT) 1 << GET_MODE_BITSIZE (mode)) - 1;
+      unsigned HOST_WIDE_INT value = INTVAL (operand);
+
+      if (exact_log2 (~value & mask) >= 0)
+       return 1;
+    }
+
+  return 0;
 }
 
 /* Return true if OP is a valid call operand.  */
@@ -1030,16 +1065,16 @@ print_operand (file, x, code)
        goto def;
       break;
     case 'V':
-      bitint = exact_log2 (INTVAL (x));
+      bitint = exact_log2 (INTVAL (x) & 0xff);
       if (bitint == -1)
        abort ();
-      fprintf (file, "#%d", bitint & 7);
+      fprintf (file, "#%d", bitint);
       break;
     case 'W':
       bitint = exact_log2 ((~INTVAL (x)) & 0xff);
       if (bitint == -1)
        abort ();
-      fprintf (file, "#%d", bitint & 7);
+      fprintf (file, "#%d", bitint);
       break;
     case 'R':
     case 'X':
index 1359a01ad78c87c573d931f747730c7261aa5fcf..6ae6d6f01e681e7a8a253a30ca92a22b058111ed 100644 (file)
   [(set (match_operand:QI 0 "bit_operand" "=r,U")
        (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
                (match_operand:QI 2 "nonmemory_operand" "rn,O")))]
-  "register_operand (operands[0], QImode) || o_operand (operands[2], QImode)"
+  "register_operand (operands[0], QImode)
+   || single_zero_operand (operands[2], QImode)"
   "@
    and %X2,%X0
    bclr        %W2,%R0"
 (define_insn "*andorqi3"
   [(set (match_operand:QI 0 "register_operand" "=r")
        (ior:QI (and:QI (match_operand:QI 2 "register_operand" "r")
-                       (match_operand:QI 3 "const_int_operand" "n"))
+                       (match_operand:QI 3 "single_one_operand" "n"))
                (match_operand:QI 1 "register_operand" "0")))]
-  "exact_log2 (INTVAL (operands[3]) & 0xff) != -1"
-  "*
-{
-  operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
-  return \"bld\\t%V3,%X2\;bst\\t%V3,%X0\";
-}"
+  ""
+  "bld\\t%V3,%X2\;bst\\t%V3,%X0"
   [(set_attr "length" "4")
    (set_attr "cc" "clobber")])
 
 (define_insn "*andorhi3"
   [(set (match_operand:HI 0 "register_operand" "=r")
        (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
-                       (match_operand:HI 3 "const_int_operand" "n"))
+                       (match_operand:HI 3 "single_one_operand" "n"))
        (match_operand:HI 1 "register_operand" "0")))]
-  "exact_log2 (INTVAL (operands[3]) & 0xffff) != -1"
+  ""
   "*
 {
   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
        (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
                (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
   "register_operand (operands[0], QImode)
-   || (GET_CODE (operands[2]) == CONST_INT
-       && exact_log2 (INTVAL (operands[2]) & 0xff) != -1)"
-  "*
-{
-  switch (which_alternative)
-    {
-    case 0:
-      return \"or\t%X2,%X0\";
-    case 1:
-      operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
-      return \"bset\t%V2,%R0\";
-    default:
-      abort ();
-    }
-}"
+   || single_one_operand (operands[2], QImode)"
+  "@
+   or\\t%X2,%X0
+   bset\\t%V2,%R0"
   [(set_attr "length" "2,8")
    (set_attr "adjust_length" "no")
    (set_attr "cc" "set_znv,none_0hit")])
        (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
                (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
   "register_operand (operands[0], QImode)
-   || (GET_CODE (operands[2]) == CONST_INT
-       && exact_log2 (INTVAL (operands[2]) & 0xff) != -1)"
-  "*
-{
-  switch (which_alternative)
-    {
-    case 0:
-      return \"xor\t%X2,%X0\";
-    case 1:
-      operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
-      return \"bnot\t%V2,%R0\";
-    default:
-      abort ();
-    }
-}"
+   || single_one_operand (operands[2], QImode)"
+  "@
+   xor\\t%X2,%X0
+   bnot\\t%V2,%R0"
   [(set_attr "length" "2,8")
    (set_attr "adjust_length" "no")
    (set_attr "cc" "set_znv,none_0hit")])