public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Richard Sandiford <richard.sandiford@arm.com>,
	"Kewen.Lin" <linkw@linux.ibm.com>,
	gcc@gcc.gnu.org,  Richard Biener <richard.guenther@gmail.com>,
	 Segher Boessenkool <segher@kernel.crashing.org>,
	Peter Bergner <bergner@linux.ibm.com>,
	 Jeff Law <jlaw@ventanamicro.com>,
	Jakub Jelinek <jakub@redhat.com>,
	 Michael Meissner <meissner@linux.ibm.com>
Subject: Re: RFC: Make builtin types only valid for some target features
Date: Mon, 5 Dec 2022 02:10:53 -0800	[thread overview]
Message-ID: <CA+=Sn1nwmo1sXgx6cGKLCVK+qHQ=HFrQ5FyspvALEUq-BYA-sQ@mail.gmail.com> (raw)
In-Reply-To: <mpt359u2tnf.fsf@arm.com>

On Sun, Dec 4, 2022 at 11:33 PM Richard Sandiford via Gcc
<gcc@gcc.gnu.org> wrote:
>
> "Kewen.Lin" <linkw@linux.ibm.com> writes:
> > Hi,
> >
> > I'm working to find one solution for PR106736, which requires us to
> > make some built-in types only valid for some target features, and
> > emit error messages for the types when the condition isn't satisfied.
> > A straightforward idea is to guard the registry of built-in type under
> > the corresponding target feature.  But as Peter pointed out in the
> > PR, it doesn't work, as these built-in types are used by some built-in
> > functions which are required to be initialized always regardless of
> > target features, in order to support target pragma/attribute.  For
> > the validity checking on the built-in functions, it happens during
> > expanding the built-in functions calls, since till then we already
> > know the exact information on specific target feature.
> >
> > One idea is to support built-in type checking in a similar way, to
> > check if all used type_decl (built-in type) are valid or not somewhere.
> > I hacked to simply check currently expanding gimple stmt is gassign
> > and further check the types of its operands, it did work but checking
> > gassign isn't enough.  Maybe I missed something, there seems not an
> > efficient way for a full check IMHO.
> >
> > So I tried another direction, which was inspired by the existing
> > attribute altivec, to introduce an artificial type attribute and the
> > corresponding macro definition, during attribute handling it can check
> > target option node about target feature for validity.  The advantage
> > is that the checking happens in FE, so it reports error early, and it
> > doesn't need a later full checking on types.  But with some prototyping
> > work, I found one issue that it doesn't support param decl well, since
> > the handling on attributes of function decl happens after that on
> > attributes of param decl, so we aren't able to get exact target feature
> > information when handling the attributes on param decl.  It requires
> > front-end needs to change the parsing order, I guess it's not acceptable?
> > So I planed to give up and return to the previous direction.
> >
> > Does the former idea sound good?  Any comments/suggestions, and other
> > ideas?
> >
> > Thanks a lot in advance!
>
> FWIW, the aarch64 fp move patterns emit the error directly.  They then
> expand an integer-mode move, to provide some error recovery.  (The
> alternative would be to make the error fatal.)
>
> (define_expand "mov<mode>"
>   [(set (match_operand:GPF_TF_F16_MOV 0 "nonimmediate_operand")
>         (match_operand:GPF_TF_F16_MOV 1 "general_operand"))]
>   ""
>   {
>     if (!TARGET_FLOAT)
>       {
>         aarch64_err_no_fpadvsimd (<MODE>mode);
>         machine_mode intmode
>           = int_mode_for_size (GET_MODE_BITSIZE (<MODE>mode), 0).require ();
>         emit_move_insn (gen_lowpart (intmode, operands[0]),
>                         gen_lowpart (intmode, operands[1]));
>         DONE;
>       }
>
> This isn't as user-friendly as catching the error directly in the FE,
> but I think in practice it's going to be very hard to trap all invalid
> uses of a type there.  Also, the user error in these situations is likely
> to be forgetting to enable the right architecture feature, rather than
> accidentally using the wrong type.  So an error about missing architecture
> features is probably good enough in most cases.

I did have a patch which improved the situation for the SVE types to
provide an error message at compile time when SVE is not enabled
but I didn't get any feedback from either the C or C++ front-end folks.
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583786.html

I suspect if that patch gets reviewed by the front-end folks, Kewen
could use the same infrastructure to error out on the types for rs6000
backend.


Thanks,
Andrew Pinski

>
> Thanks,
> Richard

  reply	other threads:[~2022-12-05 10:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  8:47 Kewen.Lin
2022-12-05  7:31 ` Richard Sandiford
2022-12-05 10:10   ` Andrew Pinski [this message]
2022-12-06  1:41     ` Kewen.Lin
2022-12-05 10:22   ` Kewen.Lin
2022-12-05 16:44   ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+=Sn1nwmo1sXgx6cGKLCVK+qHQ=HFrQ5FyspvALEUq-BYA-sQ@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=bergner@linux.ibm.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jlaw@ventanamicro.com \
    --cc=linkw@linux.ibm.com \
    --cc=meissner@linux.ibm.com \
    --cc=richard.guenther@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).