On Tue, Dec 17, 2019 at 11:15:29AM -0600, Segher Boessenkool wrote:
> Hi!
>
> On Wed, Dec 11, 2019 at 07:29:05PM -0500, Michael Meissner wrote:
> > +(define_memory_constraint "em"
> > + "A memory operand that does not contain a prefixed address."
> > + (and (match_code "mem")
> > + (match_operand 0 "non_prefixed_memory")))
> > +
> > +(define_memory_constraint "ep"
> > + "A memory operand that does contains a prefixed address."
> > + (and (match_code "mem")
> > + (match_operand 0 "prefixed_memory")))
>
> "does contain". Or maybe just say "with a non-prefixed address" and
> "with a prefixed address"?
Ok.
> > +;; Return true if the operand is a valid memory address that does not use a
> > +;; prefixed address.
> > +(define_predicate "non_prefixed_memory"
> > + (match_code "mem")
> > +{
> > + enum insn_form iform
> > + = address_to_insn_form (XEXP (op, 0), mode, NON_PREFIXED_DEFAULT);
> > +
> > + return (iform != INSN_FORM_BAD
> > + && iform != INSN_FORM_PREFIXED_NUMERIC
> > + && iform != INSN_FORM_PCREL_LOCAL
> > + && iform != INSN_FORM_PCREL_EXTERNAL);
> > +})
>
> Why can this not use just !address_is_prefixed? Why is an
> INSN_FORM_PCREL_EXTERNAL address neither prefixed nor non-prefixed? What
> does "BAD" mean, really? Should that ever happen, should that not ICE?
You can't just invert !address_is_prefixed, because it would all things that
may not be valid memory addresses.
So we could just do:
{
/* If the operand is not a valid memory operand even if it is not prefixed,
do not return true. */
if (!memory_operand (op, mode))
return false;
return !address_is_prefixed (XEXP (op, 0), mode, NON_PREFIXED_DEFAULT);
}
It is important that the predicate not return true if the operand is NOT a
valid memory address. If you allow non-valid memory addresses, the register
allocator will create things like:
(mem:MODE (plus:DI (reg:DI x)
(plus:DI (reg:DI y)
(const_int z))))
Or some such -- I forget the exact sequence it created. A later pass would
then choke with bad insn.
INSN_FORM_BAD just means that the operand is not valid as a memory address.
> It is very confusing if any valid memory is neither "prefixed_memory" nor
> "non_prefixed_memory"!
The point was to make sure the memory is valid. Once it is a valid memory
address, then just a simple !address_is_prefixed will work.
> > --- gcc/doc/md.texi (revision 279182)
> > +++ gcc/doc/md.texi (working copy)
> > @@ -3373,6 +3373,12 @@ asm ("st %1,%0" : "=m<>" (mem) : "r" (va
> >
> > is not.
> >
> > +@item em
> > +A memory operand that does not contain a prefixed address.
> > +
> > +@item ep
> > +A memory operand that does contains a prefixed address.
>
> Same comments as above.
Ok.
--
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: [email protected], phone: +1 (978) 899-4797