Skip to content

winch(aarch64): Simplify constant handling, part 1/N #10888

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

Merged

Conversation

saulecabrera
Copy link
Member

This commit is the first step toward simplifying constant handling,
particularly for the aarch64 backend.

The main highlights in this patch are:

  • Introduction of ConstantPool implemenetation on top of Cranlift
    primitives. The implemettaion is identical to the existing for x64,
    however, it's abstracted so that it can be easily consumed from any
    existing backend.
  • Usage of the constant pool from aarch64, which simplifies the
    loading of constants, particularly floating point constants.

The main motivation behind this change is to eventually detach the
implicit usage of the scatch register from constant loading as much as
possible, reducing the possibility of subtle bugs (like the one
described in #10829).

Note that I have a work-in-progress branch from where all these
changes are cherry picked from, to make everything easier to review.

A side effect of this change, is the improvement to the code
generation involving floating point constants. Prior to this change,
multiple moves were involved, with this patch, at most 1 move is
required and at worst one load is required.

@saulecabrera saulecabrera requested review from a team as code owners May 31, 2025 20:58
@saulecabrera saulecabrera requested review from abrown and alexcrichton and removed request for a team May 31, 2025 20:58
@saulecabrera saulecabrera changed the title winch(aarch64): implify constant handling, part 1/N winch(aarch64): Simplify constant handling, part 1/N May 31, 2025
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label May 31, 2025
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Nice refactoring 👍

This commit is the first step toward simplifying constant handling,
particularly for the aarch64 backend.

The main highlights in this patch are:

* Introduction of `ConstantPool` implemenetation on top of Cranlift
  primitives. The implemettaion is identical to the existing for x64,
  however, it's abstracted so that it can be easily consumed from any
  existing backend.
* Usage of the constant pool from aarch64, which simplifies the
  loading of constants, particularly floating point constants.

The main motivation behind this change is to _eventually_ detach the
implicit usage of the scatch register from constant loading as much as
possible, reducing the possibility of subtle bugs (like the one
described in bytecodealliance#10829).

Note that I have a work-in-progress branch from where all these
changes are cherry picked from, to make everything easier to review.

A side effect of this change, is the improvement to the code
generation involving floating point constants. Prior to this change,
multiple moves were involved, with this patch, at most 1 move is
required and at worst one load is required.
@saulecabrera saulecabrera force-pushed the winch-aarch64-constant-pool branch from 549c6a5 to 31f3cd6 Compare June 2, 2025 23:22
@saulecabrera saulecabrera enabled auto-merge June 2, 2025 23:28
@saulecabrera saulecabrera added this pull request to the merge queue Jun 2, 2025
Merged via the queue into bytecodealliance:main with commit 2c1e115 Jun 3, 2025
41 checks passed
@saulecabrera saulecabrera deleted the winch-aarch64-constant-pool branch June 3, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants