Repository navigation
#3047 Gap 2 (§11.7): IndexSpec is the spec's enum; MIR builds the specs, codegen stops laying the record out by hand - #3058
Merged
Merged
Conversation
…cs, codegen stops laying the record out by hand
`IndexSpec` is `Scalar(i64) | Slice(Option[i64], Option[i64], Option[i64]) |
Ellipsis | NewAxis` (lib/std/traits.w), as §11.7 writes it, in place of the
seven-field struct `{kind, start, stop, step, has_start, has_stop, has_step}`.
One owner per fact (D65): Sema reads the `&[IndexSpec]` off the validated
`multi_index` / `multi_index_set` signature and records, per multi-index node,
the `[IndexSpec; n]` the specs are built into and the slice the method takes
(record_multi_index_spec_types). MirLower builds each component as an
`IndexSpec` value (lower_multi_index_specs_slice: Scalar with its bound widened
to i64, Slice with `Some(bound)` / `None` per written bound, Ellipsis, NewAxis),
the values into an array temp, and passes a view of it with the count (and the
value, for a set) to the MULTI_INDEX intrinsics. Codegen forwards the view
through the canonical reference marshalling; mir_build_multi_index_specs_ref,
which laid `{i32, i64, i64, i64, i1, i1, i1}` out by hand to mirror the std
struct, is gone.
Fixtures read the specs by matching them (spec_ss11_7, behav_3047_*). The
spec fixture reads slice bounds through unwrap()/is_none(): `start == Some(2)`
on a view-bound Option is miscompiled today (#3057, reproduced on main).
Contributor
Author
|
Battery green on |
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
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.
#3047 Gap 2:
IndexSpecbecomes the enum §11.7 writes, in place of the seven-field struct.One owner per fact (D65). Codegen used to lay the record out by hand (
mir_build_multi_index_specs_ref:{i32, i64, i64, i64, i1, i1, i1}mirroring the std struct, a second declaration of one layout). Now:&[IndexSpec]off the validatedmulti_index/multi_index_setsignature and records, per multi-index node, the[IndexSpec; n]the specs are built into and the slice the method takes (record_multi_index_spec_types);is_index_spec_slice_ref_typeaccepts the enum.IndexSpecvalue (lower_multi_index_specs_slice:Scalarwith its bound widened toi64,SlicewithSome(bound)orNoneper written bound,Ellipsis,NewAxis), the values into an array temp, and passes a view of it plus the count (plus the value for a set) to theMULTI_INDEXintrinsics.is_ref_param/marshal_ref_addr, as the receiver) and the hand layout is deleted (71 lines).Fixtures.
spec_ss11_7_multi_index_and_dispatch.w,behav_3047_multi_index_d140_no_import.wandbehav_3047_multi_index_prelude_core.wread the specs by matching them. The D140 fixture keepsIndexSpecunnamed in the impl (that is what it tests), so its matches are inline. The spec fixture reads slice bounds throughunwrap()/is_none()becausestart == Some(2)on a view-bound Option is miscompiled today (#3057, reproduced on main's installed compiler, filed with the repro and theicmpline).Iterate tier: the three fixtures,
behav_multi_index.w, the fiveerr_multi_index_*fixtures andtest/hello.wpass under stage1;check src/main.wclean; ceremony census diff ok.