diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2002-05-29 14:20:40 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2002-05-29 14:20:40 +0000 |
commit | 4d4d89e28392eeff561fa945f8e7403199897acb (patch) | |
tree | c95dfc89a53c8bd88c74c797b7f54daf5301b373 /gcc | |
parent | abd6ddecb5724117c0ea2108a5cd42ab405ab288 (diff) | |
download | gcc-4d4d89e28392eeff561fa945f8e7403199897acb.zip gcc-4d4d89e28392eeff561fa945f8e7403199897acb.tar.gz gcc-4d4d89e28392eeff561fa945f8e7403199897acb.tar.bz2 |
h8300-protos.h: Remove the prototype for o_operand.
* 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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/config/h8300/h8300-protos.h | 3 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.c | 49 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.md | 55 |
4 files changed, 72 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index df4027f..c1d0a26 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h index 9a70284..d02c082 100644 --- a/gcc/config/h8300/h8300-protos.h +++ b/gcc/config/h8300/h8300-protos.h @@ -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)); diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index bb78d4b..0258c68 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -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': diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md index 1359a01..6ae6d6f 100644 --- a/gcc/config/h8300/h8300.md +++ b/gcc/config/h8300/h8300.md @@ -1007,7 +1007,8 @@ [(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" @@ -1036,23 +1037,19 @@ (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); @@ -1082,21 +1079,10 @@ (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")]) @@ -1135,21 +1121,10 @@ (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")]) |