This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [m68k] Ping: Add ffs pattern for ColdFire 528x using the ff1 insn
On Tue, Aug 24, 2004 at 09:07:08PM -0400, Peter Barada wrote:
> 'bfffo'? That instruction only exists on m68k hardware, not ColdFire
> where they have added the 'ff1' instruction;
Obviously.
> At a later date I could add m68k bfffo patterns if I can get access to
> m68k hardware to test them out...
Given that the restricted form of bfffo that we care about has
exactly the same semantics as ff1, this is trivial. I feel
comfortable writing it even without access to hardware.
#define TARGET_HAS_BFFFO (!TARGET_CPU32 && !TARGET_COLDFIRE)
#define TARGET_HAS_FF1 TARGET_528x
#define TARGET_HAS_CLZ (TARGET_HAS_BFFFO || TARGET_HAS_FF1)
(define_expand "clzsi2"
[(set (match_operand:SI 0 "register_operand" "")
(clz:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
"TARGET_HAS_CLZ"
{
if (TARGET_HAS_FF1)
operands[1] = force_reg (SImode, operands[1]);
})
(define_insn "*ff1"
[(set (match_operand:SI 0 "register_operand" "=d")
(clz:SI (match_operand:SI 1 "register_operand" "0")))]
"TARGET_HAS_FF1"
"ff1%.l %0")
;; ??? The only address forms disallowed here are preinc and postdec.
;; We don't currently have predicates or constraints for this, so we
;; fall back all the way to "offsettable".
(define_insn "*bfffo"
[(set (match_operand:SI 0 "register_operand" "=d")
(clz:SI (match_operand:SI 1 "nonimmediate_operand" "od")))]
"TARGET_HAS_BFFFO"
"bfffo %1{%#0,%#0}, %0")
Use TARGET_HAS_CLZ in the CTZ and FFS patterns.
Other comments about your patch:
(1) Your ctzsi2 expander is busted. I don't see the andsi3 pattern
using a PARALLEL, and yet you create one. Simiarly your ffssi2
pattern. You might do well to use expand_simple_binop here
instead of emitting rtl yourself.
(2) CLZ_DEFINED_VALUE_AT_ZERO should be set to return 32.
(3) Changes to longlong.h to take advantage of the new instruction
for coldfire. You should prefer to use __builtin_clz for this
rather than inline assembly. Do not define count_leading_zeros
or count_trailing_zeros unless there's a backing instruction,
since this macro is used as the fallback in libgcc.
r~