Skip to content
Open
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Lucas Tabary-Maujean
Manuel Barbosa
Maxime Dénès
Miguel Quaresma
Onyeka Obi
Parmida Javadian
Peter Schwabe
Philipp G. Haselwarter
Expand Down
5 changes: 5 additions & 0 deletions changes/02-bugfix/1532-vector-shift-sign.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- The type checker rejects a vector shift whose sign prefix conflicts with the
sign in the vector suffix (for instance `>>s4u32`). The scalar form
(`>>s32u`) was already rejected
([PR #1532](https://github.com/jasmin-lang/jasmin/pull/1532);
fixes [#1441](https://github.com/jasmin-lang/jasmin/issues/1441)).
9 changes: 7 additions & 2 deletions compiler/src/pretyping.ml
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,13 @@ let op_info exn op (s : W.signedness option) (castop:S.castop) ty ws_cmp vs_cmp
in
check_op_w loc op ty s ws_cmp

| CVS(vs,s,ve) ->
let s = tt_sign s in
| CVS(vs,sg,ve) ->
let s1 = tt_sign sg in
let s =
Option.map_default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using map here looks strange. Using Option.may might be clearer.

(fun s -> if s = s1 then s1 else rs_tyerror ~loc (InvalidOperator op))
s1 s
in
let ve, ws = tt_vsize_op loc op vs ve in
check_op_vec loc op vs_cmp (W.wsize_of_velem ve);
OpKV(s, ve, ws)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export
fn toto () -> reg u64 {
reg u128 v;
reg u64 r;
v = 1;
v = v >>s4u32 1;
r = 0;
return r;
}
6 changes: 5 additions & 1 deletion compiler/tests/negative.expected
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,10 @@ fail/typing/x86-64/vector_expr.jazz:

"fail/typing/x86-64/vector_expr.jazz", line 8 (15-16): can not implicitly cast u128 into u256

fail/typing/x86-64/vector_shift_sign_mismatch.jazz:

"fail/typing/x86-64/vector_shift_sign_mismatch.jazz", line 6 (12-16): invalid operator >>s 4u32

fail/typing/x86-64/write_constant_pointer_direct_array.jazz:

"fail/typing/x86-64/write_constant_pointer_direct_array.jazz", line 6 (2-3):
Expand Down Expand Up @@ -1750,7 +1754,7 @@ Allowed args are:

Statistics:
Annots: 4
Pretyping: 49
Pretyping: 50
Parsing: 4
Typing: 5
Compile: 218
3 changes: 3 additions & 0 deletions compiler/tests/success/x86-64/vector_expression.jazz
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ fn toto () -> reg u64 {
x = x <<4s64 32;
x = x >>8s32 32;

x = x >>s8s32 32;
x = x >>u4u64 32;

x >>8s32= 27;

v = #set0_128();
Expand Down