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

cranelift: Use GPR newtypes extensively in x64 lowering #3798

Merged
merged 1 commit into from
Feb 14, 2022

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Feb 14, 2022

We already defined the Gpr newtype and used it in a few places, and we already
defined the Xmm newtype and used it extensively. This finishes the transition
to using the newtypes extensively in lowering by making use of Gpr in more
places.

Fixes #3685

We already defined the `Gpr` newtype and used it in a few places, and we already
defined the `Xmm` newtype and used it extensively. This finishes the transition
to using the newtypes extensively in lowering by making use of `Gpr` in more
places.

Fixes bytecodealliance#3685
@fitzgen fitzgen requested a review from cfallin February 14, 2022 19:02
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

This looks to have been quite tedious -- thanks for this refactor, it will definitely save us from bugs in the future!

One suggestion below but I'm not strongly attached to it, happy to go either way.

dst_quotient: Writable::from_reg(regs::rax()),
dst_remainder: Writable::from_reg(regs::rdx()),
divisor: GprMem::new(divisor).unwrap(),
dividend: Gpr::new(regs::rax()).unwrap(),
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to make regs::rax() and friends return a Gpr directly, and likewise regs::xmm0() and friends return an Xmm directly? This callsite gets simpler but others maybe gain a .to_reg(), so it's not necessarily any less verbose, but it is a bit more typesafe.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've avoided pushing the newtypes beyond the ISLE-glue boundary thus far. I think it would make sense to have one more PR (maybe I'll get to it while waiting on reviews for my components PRs) where we push the newtypes to all the Inst::add/etc methods and I think pushing that to regs::rax/etc in that same PR would make sense.

But I kinda don't want to do all that right now.

Does that sound good?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that's reasonable, any incremental increase in typed-ness is good but no need to block on any part of it!

@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:x64 Issues related to x64 codegen isle Related to the ISLE domain-specific language labels Feb 14, 2022
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "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.

@fitzgen fitzgen merged commit dc86e7a into bytecodealliance:main Feb 14, 2022
@fitzgen fitzgen deleted the use-gpr-newtypes branch February 14, 2022 20:54
mpardesh pushed a commit to avanhatt/wasmtime that referenced this pull request Mar 17, 2022
…ance#3798)

We already defined the `Gpr` newtype and used it in a few places, and we already
defined the `Xmm` newtype and used it extensively. This finishes the transition
to using the newtypes extensively in lowering by making use of `Gpr` in more
places.

Fixes bytecodealliance#3685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Cranelift: provide Gpr and Xmm newtype wrappers around Reg and use them extensively in ISLE lowering
2 participants