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

refactor: retrieve immediates in new backend #2251

Merged
merged 4 commits into from
Oct 7, 2020

Conversation

abrown
Copy link
Collaborator

@abrown abrown commented Oct 1, 2020

@cfallin, here is what I came up with after we discussed this last week. This change:

  • moves DataValue into cranelift-codegen so that I can use it as a value wrapper
  • gives InstructionData the ability to find immediate values in the format structures
  • reworks LowerCtx::get_immediate to grab the value from the instruction (and the DataFlowGraph for vector immediates)

I felt like this approach provides the new backend a more abstract view of immediates instead of munging directly in the InstructionData but I didn't perform the refactor on the rest of the places the new backend grabs immediates because I wanted to get some feedback first.

@abrown abrown requested a review from cfallin October 1, 2020 17:43
@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 labels Oct 1, 2020
@github-actions
Copy link

github-actions bot commented Oct 1, 2020

Subscribe to Label Action

cc @bnjbvr

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

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

  • bnjbvr: cranelift

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

Learn more.

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.

Looks fine overall, but see below re: consolidating two matches into one by giving the helper a borrow to the immediates array...

cranelift/codegen/src/ir/instructions.rs Outdated Show resolved Hide resolved
cranelift/codegen/src/ir/instructions.rs Outdated Show resolved Hide resolved
@abrown abrown force-pushed the access-immediates branch 3 times, most recently from e78d0bb to 9b8c84b Compare October 1, 2020 20:42
This is no change to functionality; the move is necessary in order to return InstructionData immediates in a structure way (see next commit).
This change abstracts away (from the perspective of the new backend) how immediate values are stored in InstructionData. It gathers large immediates from necessary places (e.g. constant pool) and delegates to `InstructionData::imm_value` for the rest. This refactor only touches original users of `LowerCtx::get_immediate` but a future change could do the same for any place the new backend is accessing InstructionData directly to retrieve immediates.
abrown added a commit to abrown/wasmtime that referenced this pull request Oct 7, 2020
As discussed in bytecodealliance#2251, in order to be very confident that NaN signaling bits are correctly handled by the compiler, this switches `DataValue` to use Cranelift's `Ieee32` and `Ieee64` structures. This makes it a bit more inconvenient to interpreter Cranelift FP operations but this should change to something like `rustc_apfloat` in the future.
As discussed in bytecodealliance#2251, in order to be very confident that NaN signaling bits are correctly handled by the compiler, this switches `DataValue` to use Cranelift's `Ieee32` and `Ieee64` structures. This makes it a bit more inconvenient to interpreter Cranelift FP operations but this should change to something like `rustc_apfloat` in the future.
@abrown abrown merged commit 3778fa0 into bytecodealliance:main Oct 7, 2020
cfallin pushed a commit that referenced this pull request Nov 30, 2020
As discussed in #2251, in order to be very confident that NaN signaling bits are correctly handled by the compiler, this switches `DataValue` to use Cranelift's `Ieee32` and `Ieee64` structures. This makes it a bit more inconvenient to interpreter Cranelift FP operations but this should change to something like `rustc_apfloat` in the future.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants