This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Restricting arguments to intrinsic functions
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: Charles Baylis <charles dot baylis at linaro dot org>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 23 Oct 2014 20:12:12 +0200
- Subject: Re: Restricting arguments to intrinsic functions
- Authentication-results: sourceware.org; auth=none
- References: <CADnVucA8f3zHOY_UaFvxNAR-j3D7EDvTPiYpoLEUNJL+8TYZzw at mail dot gmail dot com> <CA+=Sn1nsyQXz5BJ9SqCNmDTBLvuqUuzzmWmXJhnxTt8PUp-8Wg at mail dot gmail dot com> <CA+=Sn1=B3iuVtdUeZs6rGz=ZWGav-aCt7Ad3y=mDjjB3U5LPaQ at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Oct 23, 2014 at 11:06:24AM -0700, Andrew Pinski wrote:
> On Thu, Oct 23, 2014 at 11:00 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> > On Thu, Oct 23, 2014 at 10:52 AM, Charles Baylis
> > <charles.baylis@linaro.org> wrote:
> >> Hi
> >>
> >> ( tl;dr: How do I handle intrinsic or builtin functions where there
> >> are restrictions on the arguments which can't be represented in a C
> >> function prototype? Do other ports have this problem, how do they
> >> solve it? Language extension for C++98 to provide static_assert?)
> >
> > The attribute __artificial__ .
>
> Long example:
> extern __inline void __attribute__((__gnu_inline__, __always_inline__,
> __artificial__))
> _mm_stream_sd (double * __P, __m128d __Y)
> {
> __builtin_ia32_movntsd (__P, (__v2df) __Y);
> }
>
> Don't use static inline either because it is not valid thing to do
> from a template in C++98.
And the argument checking (compile time constant, what range etc.) can be
done either when expanding the builtin, or when folding it (there are
target hooks for both generic and gimple foldings of builtin), you can
report it in either of those (and fold to constant or similar if there are
errors).
Jakub