Skip to content

Commit

Permalink
Pretyping converts vector suffixes to size suffixes (and warns)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbgl authored and bgregoir committed Dec 12, 2022
1 parent 569b7ca commit e30fb1d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
([PR #290](https://github.com/jasmin-lang/jasmin/pull/290)).
These get extracted to `|<<|` and `|>>|` in EasyCrypt.

- x86 intrinsics that accept a size suffix (e.g., `_128`) also accept, with a
warning, a vector suffix (e.g., `_4u32`)
([PR #303](https://github.com/jasmin-lang/jasmin/pull/303)).

## Bug fixes

- The x86 instructions `VMOVSHDUP` and `VMOVSLDUP` accept a size suffix (`_128`
Expand Down
6 changes: 5 additions & 1 deletion compiler/src/pretyping.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,11 @@ let tt_prim asmOp ws id args =
pr ws (match sz with
| SAw sz -> sz
| SA -> d
| SAv _ | SAvv _ -> rs_tyerror ~loc (PrimNotVector s)
| SAv (s, ve, sz) ->
warning SimplifyVectorSuffix (L.i_loc0 loc) "vector suffix simplified from %s to %a"
(PrintCommon.string_of_velem s sz ve) PrintCommon.pp_wsize sz;
sz
| SAvv _ -> rs_tyerror ~loc (PrimNotVector s)
| SAx _ -> rs_tyerror ~loc (PrimNotX s))
| PrimM pr -> if sz = SA then pr ws else rs_tyerror ~loc (PrimNoSize s)
| PrimV pr -> (match sz with SAv (s, ve, sz) -> pr ws s ve sz | _ -> rs_tyerror ~loc (PrimIsVector s))
Expand Down
1 change: 1 addition & 0 deletions compiler/src/printCommon.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
val pp_string0 : Format.formatter -> char list -> unit
val pp_wsize : Format.formatter -> Wsize.wsize -> unit
val string_of_signess : Wsize.signedness -> string
val string_of_velem : Wsize.signedness -> Wsize.wsize -> Wsize.velem -> string
val string_of_op1 : Expr.sop1 -> string
val string_of_op2 : Expr.sop2 -> string
val pp_opn : 'asm Sopn.asmOp -> Format.formatter -> 'asm Sopn.sopn -> unit
Expand Down
1 change: 1 addition & 0 deletions compiler/src/utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ type warning =
| UseLea
| IntroduceNone
| IntroduceArrayCopy
| SimplifyVectorSuffix
| Always

let warns = ref None
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ type warning =
| ExtraAssignment
| UseLea
| IntroduceNone
| IntroduceArrayCopy
| IntroduceArrayCopy
| SimplifyVectorSuffix
| Always

val nowarning : unit -> unit
Expand Down

0 comments on commit e30fb1d

Please sign in to comment.