Hey, On Wed, 5 Jun 2024, David Brown wrote:
> The ideal here would be to have some way to tell gcc that a given > function has the semantics of a different function. For example, a > programmer might have several implementations of "memcpy" that are > optimised for different purposes based on the size or alignment of the > arguments. Maybe some of these are written with inline assembly or work > in a completely different way (I've used DMA on a microcontroller for > the purpose). If you could tell the compiler that the semantic > behaviour and results were the same as standard memcpy(), that could > lead to optimisations. > > Then you could declare your "isinf" function with > __attribute__((semantics_of(__builtin_isinf))). > > And the feature could be used in any situation where you can write a > function in a simple, easy-to-analyse version and a more efficient but > opaque version. Hmm, that actually sounds like a useful feature. There are some details to care for, like what to do with arguments: e.g. do they need to have the same types as the referred builtin, only compatible ones, or even just convertible ones, and suchlike, but yeah, that sounds nice. Ciao, Michael.