-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IRGen] Lowered open_pack_element. #63363
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
[IRGen] Lowered open_pack_element. #63363
Conversation
2451aee
to
2141a70
Compare
2141a70
to
4128050
Compare
@swift-ci please test |
4128050
to
3fa849e
Compare
@swift-ci please test |
lib/IRGen/GenProto.cpp
Outdated
case GenericRequirement::Kind::Metadata: { | ||
CanGenericTypeParamType ty; | ||
if ((ty = dyn_cast<GenericTypeParamType>(requirement.getTypeParameter())) && | ||
ty->isParameterPack()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might see this kind of requirement for associated types of packs, too, right?
You should have enough information to set the requirement kind as MetadataPack
/ WitnessTablePack
in the first place, and that'll probably make clients of this a lot easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these new kinds in 6a44de2 . Does the static member function GenericRequirement::isPack
added there correctly identify which types are packs?
3fa849e
to
e3daab3
Compare
The mapping from requirement kind to llvm::Type is repeated several places. Pull it into a helper.
Added pack flavors of requirement kinds for metadata and witness tables. Fixes the function signatures for variadic generic functions which previously used %swift.type* for variadic generic parameters--those are lists of metadata and should actually be %swift.type**.
The function emits the metadata for the element of a pack expansion at a specified index. It was previously defined inline in the loop--defined in emitPackExpansionType--which populates a new metadata array with elements derived from a preexisting array. It will be used to emit a single element in the case that only one is needed.
The parameter name to emitPackExpansionElementMetadata matched the preexisting local variable name. Change it to something meaningful to callers. Use a separate commit to make the original extraction more obviously just an extraction.
e3daab3
to
a442245
Compare
@swift-ci please test |
@swift-ci please test macOS platform |
Initial lowering support for the open_pack_element instruction. While lowering,
binds
(@pack_element(...) U_i)
to the typeT(i, %index)
at%index
inPack_i
for alli
of the appropriate shape.Materialize the metadata address for
T(i, %index)
depending on what's already available. In general, compare the %index to the upper bound of each element's range: if it's in range, emit the metadata at%innerIndex := %index - %innerLowerBound
; if it's out of range, jump to the next comparison. From each metadata emission block, jump to a merge point where the result metadata is defined to be the phi of the metadata materialized in each predecessor.Still to do: handle conformances.