-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add experimental support for fixed arrays #70301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci test |
@swift-ci benchmark |
@swift-ci please build toolchain |
* `createAddressToPointer` * `createLoadBorrow`
* `Context.moduleIsSerialized` * `Context.getBuiltinIntegerType` * `Instruction.move(before:)`
* `alloc_vector`: allocates an uninitialized vector of elements on the stack or in a statically initialized global * `vector`: creates an initialized vector in a statically initialized global
…lySite.isSemanticCall` `Value.isValidGlobalInitValue` was privately used by the ObjectOutliner. Make it a generally usable utility.
So far the semantic annotation was just added to the internal `_getCount` function. But for FixedArray it is also required to add the `@_semantics("array.get_count")` to the public API.
By default it lowers the builtin to an `alloc_vector` with a paired `dealloc_stack`. If the builtin appears in the initializer of a global variable and the vector elements are initialized, a statically initialized global is created where the initializer is a `vector` instruction.
efdd2ce
to
ae27805
Compare
@swift-ci smoke test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This mainly consists of a builtin
_allocateVector
which is lowered to a stack allocated vector (expressed with the new SIL instructionalloc_vector
) or - if used in an initializer of a global variable - to a statically initialized vector in a global.A new pass AllocVectorLowering is doing this transformation.
All this is still experimental and must be enabled with
-enable-experimental-feature FixedArrays
. A lot of pieces are still missing to make this a usable feature, e.g. non-escapable types.I added a prototype of
FixedArray
as a test file. It shows how the builtin can be used to implement fixed arrays or similar data structures.