Skip to content
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

FIX LZCNT semantics to handle the size parameter #516

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

## Bug fixes

- Handle the size parameter in LZCNT semantic
([PR #516](https://github.com/jasmin-lang/jasmin/pull/516);
fixes [#515](https://github.com/jasmin-lang/jasmin/issues/515)).

- Type-checking rejects wrongly casted primitive operators
([PR #489](https://github.com/jasmin-lang/jasmin/pull/488);
fixes [#69](https://github.com/jasmin-lang/jasmin/issues/69)).
Expand Down
8 changes: 4 additions & 4 deletions proofs/compiler/x86_instr_decl.v
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,15 @@ Definition x86_DEC sz (w: word sz) : ex_tpl (b4w_ty sz) :=
(wsigned w - 1)%Z).


Fixpoint leading_zero_aux (n: Z) (k : nat) :=
if (n <? 2^(64 - k))%Z then k
Fixpoint leading_zero_aux (n: Z) (k : nat) (sz : nat) :=
if (n <? 2^(sz - k))%Z then k
else match k with
| 0 => 0
| S k' => leading_zero_aux n k'
| S k' => leading_zero_aux n k' sz
end.

Definition leading_zero sz (w: word sz) : word sz :=
wrepr sz (leading_zero_aux (wunsigned w) sz).
wrepr sz (leading_zero_aux (wunsigned w) sz sz).

Definition x86_LZCNT sz (w: word sz) : ex_tpl (b5w_ty sz) :=
Let _ := check_size_16_64 sz in
Expand Down