Cranelift: add _imm_s/_imm_u instruction builder helpers#13583
Open
aniasse wants to merge 1 commit into
Open
Conversation
Replaces the single `_imm` builder method, whose sign/zero-extension was decided by a hardcoded list of "historical" opcodes, with explicit `_imm_s` (sign-extend) and `_imm_u` (zero-extend) variants. The bare `_imm` method stays for back-compat but is now deprecated. Migrates internal callers to the explicit variants. Fixes bytecodealliance#13529.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13529. Follow-up to the discussion in #13527.
Today the generated
<inst>_immbuilder picks sign- vs zero-extension froma hardcoded list of opcodes in
build_imm_const, which is easy to trip on.This adds explicit
<inst>_imm_s(sign-extend) and<inst>_imm_u(zero-extend) variants instead, and
build_imm_constnow takes a plainsigned: bool. The extension only matters fori128; below that the maskedimmediate is the same either way.
<inst>_immstays for back-compat but is now#[deprecated]in favor of theexplicit ones. I migrated the ~100 in-tree callers over by their historical
signedness — that part is a no-op (nothing internal uses these on
i128),which is why the diff is big but boring.
Skipped the
SImm128/UImm128newtype idea for now since the_s/_unames already carry the signedness — can do it as a follow-up if you want.
Tested with the cranelift-codegen/frontend suites and the filetests, plus a
new unit test for the
i128extension behavior.