This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, Bernhard Fischer <rep dot dot dot nop at gmail dot com>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, Thomas Koenig <tkoenig at netcologne dot de>, Toon Moene <toon at moene dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 14 Nov 2018 12:56:26 +0100
- Subject: Re: [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics)
- References: <6b852ddd-001c-40d6-383b-0b36f3d13ee7@suse.cz> <CAFiYyc2Q4eXBXBSisaWDE2JH_tS82AnZBPJv1D9fkZnAQpz0CA@mail.gmail.com> <60df9de6-9607-c88a-de0d-1f2c83bf3970@suse.cz> <D6325C52-AE0D-49DB-86A2-F5CBDE6BAC0B@gmail.com> <916e3e10-e020-f4f3-6f8e-c57909c81d55@suse.cz> <CAFiYyc14yjzAojw0o+mJoLvBwobLGhN1ppLKHOt56wan_-ApZw@mail.gmail.com> <20181112163347.4cc3537e@nbbrfq.loc> <CAFiYyc1cczXvCf1v4PPhHVmuvT_W8RuU+8R05vjuJ=_c_nP-6w@mail.gmail.com> <0e9bfe91-eed3-f6e0-9cb6-97c615325fa6@suse.cz> <20181114113527.GP11625@tucnak>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Nov 14, 2018 at 12:35:27PM +0100, Jakub Jelinek wrote:
> > +
> > + When we come here, we have already matched the !GCC$ builtin string. */
> > +match
> > +gfc_match_gcc_builtin (void)
> > +{
> > + char builtin[GFC_MAX_SYMBOL_LEN + 1];
> > +
> > + if (gfc_match_name (builtin) != MATCH_YES)
> > + return MATCH_ERROR;
> > +
> > + gfc_gobble_whitespace ();
> > + if (gfc_match ("attributes") != MATCH_YES)
> > + return MATCH_ERROR;
> > +
> > + gfc_gobble_whitespace ();
> > + if (gfc_match ("omp_simd_notinbranch") != MATCH_YES)
> > + return MATCH_ERROR;
>
> Why so many gfc_match calls? Can't you e.g. just do
> if (gfc_match ("%n attributes simd", builtin) != MATCH_YES)
> return MATCH_ERROR;
>
> int builtin_kind = 0; /* Or whatever, just want to show the parsing here. */
> if (gfc_match ("(notinbranch)") == MATCH_YES)
> builtin_kind = -1;
> else if (gfc_match ("(inbranch)") == MATCH_YES)
> builtin_kind = 1;
>
> The space in gfc_match indicates gfc_gobble_whitespace (), i.e. optionally
> eating whitespace (note, in fixed form white space is optionally eaten
> pretty much always). If you want a mandatory space, there is "% ".
> So it depends in if in fixed form we want to support e.g.
> !GCC$ BUI L TIN SINf ATTRI BUT ESSIMD(NOT IN BRANCH)
> and in free form e.g.
> !gcc$ builtin sinf attributessimd (notinbranch)
> I wouldn't use omp_simd because in C/C++ the attribute is called simd.
One more thing, for fixed form spaces are insignificant generally,
gfc_next_char has:
do
{
c = gfc_next_char_literal (NONSTRING);
}
while (gfc_current_form == FORM_FIXED && gfc_is_whitespace (c));
so a gfc_name in fixed form needs to be separated by something different
from whitespace I'd say. Because in
!gcc$ builtin sinf attribute simd
or
!GCC$ BUILTINSINFATTRIBUTESIMD
you'd get in both cases sinfattributesimd as the builtin's name and nothing
afterwards (so gfc_match would fail).
One possibility is
if (gfc_match ("(%n) attributes simd", name) == MATCH_YES)
where you'd require parens around the builtin's name. Or it could go last
in the syntax, i.e.
!gcc$ builtin attributes simd sinf
!gcc$ builtin attributes simd (notinbranch) sinf
But I think ()s are better.
Jakub