+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.
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));
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. */
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':
[(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")])