Victor Do Nascimento <victor.donascime...@arm.com> writes: > On 1/5/24 11:10, Richard Sandiford wrote: >> Victor Do Nascimento <victor.donascime...@arm.com> writes: >>> The introduction of further architectural-feature dependent ifuncs >>> for AArch64 makes hard-coding ifunc `_i<n>' suffixes to functions >>> cumbersome to work with. It is awkward to remember which ifunc maps >>> onto which arch feature and makes the code harder to maintain when new >>> ifuncs are added and their suffixes possibly altered. >>> >>> This patch uses pre-processor `#define' statements to map each suffix to >>> a descriptive feature name macro, for example: >>> >>> #define LSE2 _i1 >>> >>> and reconstructs function names with the pre-processor's token >>> concatenation feature, such that for `MACRO(<name>_i<n>)', we would >>> now have `MACRO_FEAT(name, feature)' and in the macro definition body >>> we replace `name` with `name##feature`. >> >> FWIW, another way of doing this would be to have: >> >> #define CORE(NAME) NAME >> #define LSE2(NAME) NAME##_i1 >> >> and use feature(name) instead of name##feature. This has the slight >> advantage of not using ## on empty tokens, and the maybe slightly >> better advantage of not needing the extra forwarding step in: >> >> #define ENTRY_FEAT(name, feat) \ >> ENTRY_FEAT1(name, feat) >> >> #define ENTRY_FEAT1(name, feat) \ >> >> WDYT? >> >> Richard >> > > While from a strictly stylistic point of view, I'm not so keen on the > resulting interface and its 'function call within a function call' look, > e.g. > > ENTRY (LSE2 (libat_compare_exchange_16)) > > and > > ALIAS (LSE128 (libat_compare_exchange_16), \ > LSE2 (libat_compare_exchange_16)) > > on the implementation-side of things, I like the benefits this brings > about. Namely allowing the use of the unaltered original > implementations of the ENTRY, END and ALIAS macros with the > aforementioned advantages of not having to use ## on empty tokens and > abolishing the need for the extra forwarding step. > > I'm happy enough to go with this approach.
I was thinking that the invocations would stay the same. A C example is: #define LSE2(NAME) NAME##_i2 #define ENTRY(NAME, FEAT) void FEAT (NAME) () ENTRY(foo, LSE2) {} https://godbolt.org/z/rdn5dEMPM Thanks, Richard