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

Add fixed_nonallocatable constraints when appropriate #5253

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Nov 11, 2022

Plumb the set of allocatable registers through the OperandCollector and use it validate uses of fixed-nonallocatable registers, like %rsp on x86_64.

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen isle Related to the ISLE domain-specific language labels Nov 11, 2022
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:area:machinst", "cranelift:area:x64", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@elliottt elliottt force-pushed the trevor/add-fixed-nonallocatable-operands branch from 629819a to 77e36b4 Compare November 11, 2022 04:32
@elliottt elliottt marked this pull request as ready for review November 11, 2022 05:49
@elliottt elliottt requested a review from fitzgen November 14, 2022 22:19
@elliottt elliottt force-pushed the trevor/add-fixed-nonallocatable-operands branch from 3a71d79 to f0e84a9 Compare November 14, 2022 23:46
@elliottt elliottt marked this pull request as draft November 15, 2022 00:10
Comment on lines 145 to 155
pub struct Lower<'func, I: VCodeInst> {
pub struct Lower<'func, 'env, I: VCodeInst> {
/// The function to lower.
f: &'func Function,

/// Machine-independent flags.
flags: crate::settings::Flags,

/// The MachineEnv used when allocating registers.
machine_env: &'env MachineEnv,

Copy link
Member

Choose a reason for hiding this comment

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

Did you try reusing 'func here by chance and find that a new lifetime was actually necessary to get the code to compile? This is pretty invasive and adds a third(!!) lifetime to the IsleContext so if it isn't actually necessary it would be nice to skip.

Copy link
Member Author

@elliottt elliottt Nov 15, 2022

Choose a reason for hiding this comment

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

I didn't try that, as I was assuming that the two structures would have different lifetimes. I'll give that a try, and see if anything breaks.

Copy link
Member Author

Choose a reason for hiding this comment

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

That worked, thanks for pointing this out!

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that I'm thinking about this, we don't need the actual MachineEnv plumbed through, just the PRegSet that's used in the OperandCollector. Moving the creation of the PRegSet to Lower::new removes the MachineEnv reference, and only iterates it once instead of for each instruction.

@elliottt elliottt force-pushed the trevor/add-fixed-nonallocatable-operands branch from f0e84a9 to 0280ba7 Compare November 15, 2022 17:02
@elliottt elliottt marked this pull request as ready for review November 15, 2022 19:07
@elliottt elliottt merged commit a007e02 into bytecodealliance:main Nov 15, 2022
jameysharp added a commit to jameysharp/wasmtime that referenced this pull request May 13, 2024
Consumption of non-allocatable operands was added in bytecodealliance#5253 and bytecodealliance#5132,
and removed in bytecodealliance#8524 and following PRs. Now they are not only ignored by
regalloc2, but the placeholders that it leaves in the allocation results
are also ignored by Cranelift. So let's stop adding them to the operands
list entirely.
github-merge-queue bot pushed a commit that referenced this pull request May 14, 2024
Consumption of non-allocatable operands was added in #5253 and #5132,
and removed in #8524 and following PRs. Now they are not only ignored by
regalloc2, but the placeholders that it leaves in the allocation results
are also ignored by Cranelift. So let's stop adding them to the operands
list entirely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants