Skip to content

[SOL] Use mov32 to load and zero extend immediate in V2+ #166

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
merged 3 commits into from
Jul 27, 2025

Conversation

LucasSte
Copy link
Collaborator

Problem

For SBPFv2 onwards, we can use mov32 reg, imm to load and sign extend immediate values, without the pair hor64/mo32. This is particularly useful for numbers between u32::MAX >> 1 and u32::MAX.

Solution

Create a new instruction to represent a load with zero extend. Since it has the same opcode as all the other use cases for mov32, it needs a new decoder namespace, so that LLVM knows which instruction the opcode refers to when disassembling a file.

PS: In the disassembler, we do not care which of the defined mov32 reg, imm the instruction we are reading is assigned to. All of them have the same syntax and semantic.

@LucasSte LucasSte requested a review from Lichtso July 25, 2025 20:57
@LucasSte LucasSte marked this pull request as ready for review July 25, 2025 20:57
@LucasSte LucasSte changed the title [SOL] Use mov32 to load an zero extend immediate in V2+ [SOL] Use mov32 to load and zero extend immediate in V2+ Jul 25, 2025
@LucasSte LucasSte merged commit 5a49caa into anza-xyz:solana-rustc/19.1-2024-12-03 Jul 27, 2025
15 checks passed
@LucasSte LucasSte deleted the n-load branch July 27, 2025 20:09
LucasSte added a commit to LucasSte/llvm-project that referenced this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants