Skip to content
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

Make clear that parameter indexes are InstIdxs. #1484

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ltratt
Copy link
Contributor

@ltratt ltratt commented Dec 2, 2024

Previously we used a u32 (why such a big type? dunno!), requiring ParamInst to be packed. By definition a parameter is stored in an SSA variable which, in our context, means it's an InstIdx.

This commit makes this explicit:

  1. Parameters are now indexed by InstIdx.
  2. The vague locidx is now paramidx.
  3. The unnecessary largesse of the params() function returning a slice is hidden by a param() function which returns a single parameter.

This change did spot a bug in a test, so it is useful.

pub(crate) fn params(&self) -> &[yksmp::Location] {
&self.params
/// Return the parameter at a given [InstIdx].
pub(crate) fn param(&self, iidx: InstIdx) -> &yksmp::Location {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about making this InstIdx. My understanding is that an InstIdx is only used to index into the insts vector of the module. Should this not be a new type ParamIdx, as it's indexing into the params vector?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, I originally made it ParamIdx, got almost as far as a PR then.... I realised that the if we have n parameters, the first n instructions must be parameters. It's baked into our system that %0...%n are ParameterInsts, so introducing ParamIdx meant I just ended up with (infallible) conversions to/from InstIdx without really doing much useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@ptersilie ptersilie added this pull request to the merge queue Dec 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2024
Previously we used a `u32` (why such a big type? dunno!), requiring
`ParamInst` to be `packed`. By definition a parameter is stored in an
SSA variable which, in our context, means it's an `InstIdx`.

This commit makes this explicit:

  1. Parameters are now indexed by `InstIdx`.
  2. The vague `locidx` is now `paramidx`.
  3. The unnecessary largesse of the `params()` function returning a
     slice is hidden by a `param()` function which returns a single
     parameter.

This change did spot a bug in a test, so it is useful.
@ltratt
Copy link
Contributor Author

ltratt commented Dec 3, 2024

Force pushed an update which fixes that Clippy warning. Should hopefully merge now.

@ptersilie ptersilie added this pull request to the merge queue Dec 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 3, 2024
@ltratt
Copy link
Contributor Author

ltratt commented Dec 3, 2024

Oops, I didn't actually force push. Now I have. Hopefully it'll merge now!

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.

2 participants