On Fri, 28 Oct 2022 15:35:45 +0100 Dave Love via Fortran <fortran@gcc.gnu.org> wrote:
> Assuming there's no technical reason not to, can someone say what would > be involved in adding relevant attributes (at least function ones) like > those for C? I'm thinking particularly of target_clones, but others > probably make sense. Well we already have !GCC$ ATTRIBUTES attribute-list :: var-name [, var-name] ... See https://gcc.gnu.org/onlinedocs/gfortran/ATTRIBUTES-directive.html > > I don't know my way around, but I had a quick look, and it at least > wouldn't be as straightforward as I hoped. See gcc/fortran/decl.cc gfc_match_gcc_* For example the CDECL attribute probably comes close to target_clones: subroutine mysub1() !GCC$ ATTRIBUTES CDECL :: mysub1 ! body of mysub1 here For target_clones you would most likely need a slightly different parser for you need the user to specify the actual target_clones somehow. You would probably make a suggestion and discuss the proposal here. Ideally the syntax would be the same as in C. Finally you would have to lower the target_clones, not sure offhand who creates the ifunc dispatcher, the frontend or the middle-end. There is expand_target_clones in gcc/multiple_target.cc that probably comes into play. So yes, that seems to create the ifuncs if i read that correctly. Hence the implementation in the frontend should not be all too complicated, it seems. To your initial remark about a technical reason not to support it i would point you to what Tobias said to me some time ago and which i certainly told other people more than once, too: https://patchwork.ozlabs.org/comment/958570/ ---8<--- In general, I prefer to stick to standard methods (which are portable) and think that those user knobs often make things slower than faster (as they tend to stay for years, even after the hard- ware as moved on - or they are even inserted blindly). ---8<--- In former times, you would compile your library multiple times and provide a distinct, optimized version for each of the CPUs. Maybe that would work for you equally well, without target_clones? HTH