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!

BR,
Kewen

Reply via email to