RFR: 8320347: Emulate vblendvp[sd] on ECore [v2]
Jatin Bhateja
jbhateja at openjdk.org
Wed Nov 22 10:40:08 UTC 2023
On Tue, 21 Nov 2023 21:32:57 GMT, Volodymyr Paprotski <duke at openjdk.org> wrote:
>> Its a member-function pointer, not a regular function pointer.. but `using` function pointer declaration is definitely an improvement I wasn't aware of. Trying to find chapter-and-verse in C++ spec on declaration of member-function pointers and their use with `using`. Will fix.
>
> Keyword `using` is a rather poor search-engine word, couldn't find examples for member-function pointer declaration with the `using` syntax. So had to look at the standard itself. [C++17 draft](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf)
>
> ---
>
> I think properly, its called an `alias-declaration` [dcl.dcl].
>
> alias-declaration:
> using identifier attribute-specifier-seqopt = defining-type-id ;
>
>
> At end of section 11.3.3 [dcl.mptr], seems to imply that function pointer declaration and member-function pointer declarations are different
>
> [ Note: See also 8.3 and 8.5. The type “pointer to member” is distinct from the type “pointer”, that is, a
> pointer to member is declared only by the pointer to member declarator syntax, and never by the pointer
> declarator syntax. There is no “reference-to-member” type in C++. — end note ]
>
> That to me seems to mean that function pointer and member pointer will follow different BNF grammar rules, and might not arrive to both having support for the `using` declaration. I have been trying to find the BNF for it regardless, but its been many years, standard is big, hours of reading later, no closer to a definitive answer that member-function declaration do not support the using syntax.
>
> ---
>
> Trial-and-error, perhaps the compiler would give me some hints as to where to look.. Section 11.1 Type names suggests removing the identifier to get the type:
>
> It is possible to identify uniquely the location in the abstract-declarator where the identifier would appear if
> the construction were a declarator in a declaration. The named type is then the same as the type of the
> hypothetical identifier.
>
> So, I tried syntax similar to what you suggested:
>
> using vblend = void (MacroAssembler::*)(XMMRegister, XMMRegister, XMMRegister, XMMRegister, int, bool, XMMRegister);
>
> Does not work:
>
> src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp:1134:12: error: expected unqualified-id before '=' token
> 1134 | vblend = &MacroAssembler::vblendvpd;
> | ^
> src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp:1156:17: error: expected primary-expression before ')' token
> 1156 | (this->*vblend)(atmp, a, b, mask, vlen_enc, true, btmp);
> ```
> First message is bad, the `&` is required per `8.3.1 Unary operators` section 4 :
>
> A pointer to member is only formed when an explicit & is used and its operand is a qualified-id not enclosed
> in parentheses.
>
> Second message is also bad, per section `8.5 Pointer-to-member operators`, cast, `.*`, `-...
Thanks for giving it a try, let it be like the way it is currently implemented.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16716#discussion_r1401844424
More information about the hotspot-compiler-dev
mailing list