Skip to content

Conversation

compnerd
Copy link
Member

Rather than use a function, use a templated structure with a constant
expression to metaprogram the alignment of the type. NFC.

Adjust the templating for the SIMD vector types. Use the reserved
spelling for the clang extension, and rename the types. NFC.

The meat of this change is the explicit template specialization for the
float 3 vector and double 3 vector. Since they are going to be emitted
as float 4 vector underneath everything, we can simply treat them the
same. This has a benefit of allowing us to share the same
specialization of the witness tables. Additionally, it works around a
bug in clang where we cannot correctly decorate the extended type with
Microsoft's ABI (which is a separate issue). Since this saves some
bytes, this is still beneficial.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

Rather than use a function, use a templated structure with a constant
expression to metaprogram the alignment of the type.  NFC.

Adjust the templating for the SIMD vector types.  Use the reserved
spelling for the clang extension, and rename the types.  NFC.

The meat of this change is the explicit template specialization for the
float 3 vector and double 3 vector.  Since they are going to be emitted
as float 4 vector underneath everything, we can simply treat them the
same.  This has a benefit of allowing us to share the same
specialization of the witness tables.  Additionally, it works around a
bug in clang where we cannot correctly decorate the extended type with
Microsoft's ABI (which is a separate issue).  Since this saves some
bytes, this is still beneficial.
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd compnerd requested a review from DougGregor October 28, 2018 09:07
@compnerd
Copy link
Member Author

@DougGregor - I want to get your opinion on the trick here of aliasing the float-3 and double-3 vectors. I believe that this should be safe, but I'm not 100% sure. If you think that this is too clever for its own good (maybe we want to do something special in the future?), I'm happy to see this go. I tracked down the clang mangling issue and will fix that separately.

@compnerd
Copy link
Member Author

CC: @rjmccall @jckarter - since this does technically impact ABI

@jckarter
Copy link
Contributor

@DougGregor and I were recently discussing doing away with "known metadata" for builtin vectors altogether and using an accessor function to generate metadata for them on demand. That might obviate the need for this, but this seems fine for the time being.

@compnerd compnerd merged commit 9f7ee56 into swiftlang:master Oct 29, 2018
@compnerd compnerd deleted the metadata branch October 29, 2018 21:47
@DougGregor
Copy link
Member

Yeah, this is an improvement over my approach, but we'll also look into an opaque accessor function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants