This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Using mode and code macros in *.md files
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: James E Wilson <wilson at specifixinc dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 08 Aug 2004 07:39:49 +0100
- Subject: Re: RFC: Using mode and code macros in *.md files
- References: <87vffux323.fsf@redhat.com> <411574A9.4000704@specifixinc.com>
Thanks for the feedback.
James E Wilson <wilson@specifixinc.com> writes:
> My first question would be how this affects debugging gcc. Being able
> to match rtl insns to the md pattern for them is important. These
> macros obscure the connection. If I have a insn that has been
> recognized, and claims to match the slesi pattern, then I will be
> confused if I can't find such a pattern. How am I supposed to know to
> look for the s<floatcond><mode> pattern instead? The port maintainer
> would know this, but someone else wouldn't. Maybe it would help to
> print md file line numbers instead of or in addition to pattern names
> when dumping rtl.
Sound like a good idea.
> If I have an insn that hasn't been recognized, then I have a similar but
> slightly different problem. If I try grepping for the operator (le:SI I
> am not going to find it. How I am supposed to know to search for
> (<floatcond>:<mode> instead?
I can see that could be a problem. I guess it depends on the habits
of the coder.
FWIW, I tend to use '\ble\b' (within emacs) when searching for an
operator name, and the first hit for that would be the macro definition.
(I mostly use '\b' because I can never remember which re syntaxes use
'(' as a grouping operator and which use '\(').
>> For example, code macros allow us to combine 7 of the c.cond.fmt patterns:
>
> You can already do this via match_operator. Just define a predicate
> that accepts the 7 comparison codes you care about, and you can write a
> single pattern to patch all 7. This gives a somewhat different affect
> though, as your macro approach gives 7 patterns whereas we only have one
> pattern if we use match_operator.
For matching, yes, but the point is that these are named patterns.
OK, so at the moment, only gen_slt_sf() is actually used (by one
of the reload patterns), but match_operator gives a less friendly
gen_*() interface. If you have:
(set (match_operand:SF 0 "register_operand" "=f")
(match_operator:SF 1 "float_cmp_operator"
[(match_operand:SF 2 "register_operand" "f")
(match_operand:SF 2 "register_operand" "f")]))
then the gen_*() function will have four arguments. From memory,
arguments 2 and 3 are ignored, and you need to pass gen_rtx_LT (...)
for argument 1.
In practice, we'd probably end up adding a new expander specifically for
"slt_sf", or perhaps just synthesising it directly using gen_rtx_*()
functions.
> We should consider whether we need or want two different mechanisms that
> do the same thing.
Well, match_operator is a bit more general, in that it can (if necessary)
match codes with different formats. I don't know how important that is
in practice.
Richard