Allow use of `consts` in place of immediates in asm blocks
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
## Motivation
https://github.com/FuelLabs/sway-lib-std/pull/46
We should be able to directly use the `const` in the asm block if it is small enough to fit in that immediate size.
## Summary
Currently, immediates are size-checked in the compiler. If an opcode takes a 12-bit immediate, the size of that immediate is checked at compile time. Since we also know the value of `const`s at compile time, we should be able to directly allow the use of `const`s inside of `asm` blocks instead of passing them in. This will require a modification to the grammar and then size checking the const.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the linked sway-lib-std pull request and the compiler's asm grammar and immediate size-checking paths. Trace how compile-time const values are represented in asm, then verify that a const is accepted only when its value fits the opcode's immediate size.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100