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 committed Dec 2, 2022
1 parent aa8dc73 commit e601ca5
Show file tree
Hide file tree
Showing 5 changed files with 14 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
7 changes: 6 additions & 1 deletion compiler/src/pretyping.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,12 @@ 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) ->
let w = wsize_of_bits ~loc (P.int_of_velem ve * P.int_of_ws sz) in
warning SimplifyVectorSuffix (L.i_loc0 loc) "vector suffix simplified from %s to %a"
(PrintCommon.string_of_velem s sz ve) PrintCommon.pp_wsize w;
w
| 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 e601ca5

Please sign in to comment.