0xMiden / 0xMiden/compiler

Fix `felt!` macro to use `Felt::from_u64_unchecked` (instead of `from_u32`)

Open
#361 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
115
Forks
84
Avg merge
1d 8h
Merged PRs (30d)
15

Description

### What
As discovered in #357, we parse `u64` constants as two `i32` parts on the stack, which makes translating `from_u64_unchecked` calls to `bitcast` op non-optimal. So, temporarily, in #357 I switched for `felt!` macro to use `Felt::from_u32`.

### How
The easiest way is to `peek` into the next translated op in the frontend, and if it's a `Felt::from_u64_unchecked` call translate `u64` constant as one `u64` value on the stack. Alternative would be to allow to alter `n` previous translated ops, i.e. convert `push.i32.i32` to `push.u64`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.