Skip to content

Commit 73d01af

Browse files
bgregoirvbgl
authored andcommitted
Introduce siXX and uiXX
remove wint annotation after wi2w, this is for printing fix extraction to EC restore main_compiler restore main_compiler restore main_compiler safetyInterpreter safetyInterpreter safetyAbsExpr safetyAbsExpr fix error msg fix extraction of div/mod fix printing of cast to word fix extraction of int_of_word fix signature of functions after wint_int . clean up CHANGELOG CHANGELOG WIword_of_int -> WIwint_of_int fix previous rebase small optimisation in wint_to_int
1 parent e91cdb9 commit 73d01af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4340
-1309
lines changed

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33

44
## New features
55

6+
- Introduction of types siXX and uiXX (XX in [8,16,32,64,128, 256]).
7+
New notation for type uXX/sXX : wXX.
8+
siXX represents signed integer of size XX, i.e in the range [-2^XX/2, 2^XX/2).
9+
uiXX represents unsigned integer of size XX, i.e in the range [0, 2^XX).
10+
Introduction of a new cast operorators:
11+
(sint) e : from wXX/siXX to int, signed interpretation
12+
(uint) e : from wXX/uiXX to int, unsigned interpretation
13+
The previous cast operator (int) e stand for:
14+
(uint) e if e has type wXX/uiXX
15+
(sint) e if e has type siXX
16+
All basic operations on uiXX/siXX perform the corresponding int operation and check
17+
that the result is in the range of uiXX/siXX, if not it is a safety violation.
18+
They can be selected explicitly using notation "e1 +XX(ui/si) e2"
19+
Introduction of new cast operators:
20+
(XXw) e : from siXX/uiXX to wXX
21+
(XXsi) e :
22+
if e has type wXX it the identity
23+
if e has type int ensure that e is in the range of siXX, else it is a safety violation.
24+
(XXui) e :
25+
if e has type wXX it the identity
26+
if e has type int ensure that e is in the range of siXX, else it is a safety violation.
27+
Introduce zquot and zrem operators on int : "e1 /s e2" and "e1 %s e2".
28+
The key feature of this new type are for the extraction to easycrypt.
29+
They are extracted to int, removing the need to deal with modulus 2^XX operations.
30+
([PR #1071](https://github.com/jasmin-lang/jasmin/pull/1071)).
31+
632
- Add support for x86 `VMOVMSKPS` and `VMOVMSKPD` instructions, through the new
733
intrinsics `#MOVEMASK` which also maps to the `VPMOVMSKB` instruction;
834
therefore old intrinsic `#VPMOVMSKB` is deprecated

compiler/entry/commonCLI.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ let parse_and_compile (type reg regx xreg rflag cond asm_op extra_op)
7373
and type rflag = rflag
7474
and type cond = cond
7575
and type asm_op = asm_op
76-
and type extra_op = extra_op) pass file idirs =
76+
and type extra_op = extra_op) ~wi2i pass file idirs =
7777
let _env, pprog, _ast =
7878
try Compile.parse_file Arch.arch_info ~idirs file with
7979
| Annot.AnnotationError (loc, code) ->
@@ -90,6 +90,10 @@ let parse_and_compile (type reg regx xreg rflag cond asm_op extra_op)
9090
hierror ~loc:(Lmore loc) ~kind:"typing error" "%s" code
9191
in
9292

93+
let prog =
94+
if not wi2i then prog
95+
else Compile.do_wint_int (module Arch) prog in
96+
9397
let prog =
9498
if pass <= Compiler.ParamsExpansion then prog
9599
else
@@ -112,3 +116,4 @@ let parse_and_compile (type reg regx xreg rflag cond asm_op extra_op)
112116
| exception E.Found -> !res
113117
in
114118
prog
119+

compiler/entry/commonCLI.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ val parse_and_compile :
1717
and type regx = 'regx
1818
and type rflag = 'rflag
1919
and type xreg = 'xreg) ->
20+
wi2i:bool -> (* true => start by replacing wint operation by int operation *)
2021
Compiler.compiler_step ->
2122
string ->
2223
(string * string) list ->
23-
( unit,
24+
(unit,
2425
( 'reg,
2526
'regx,
2627
'xreg,

compiler/entry/jasmin2ec.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ let parse_and_extract arch call_conv idirs =
3636
let module A = (val get_arch_module arch call_conv) in
3737

3838
let extract model amodel functions array_dir output pass file =
39-
let prog = parse_and_compile (module A) pass file idirs in
40-
39+
let prog = parse_and_compile (module A) ~wi2i:true pass file idirs in
4140
extract_to_file prog arch A.reg_size A.asmOp model amodel functions
4241
array_dir output
4342
in

compiler/entry/jasmin_ct.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ open Utils
66
let parse_and_check arch call_conv idirs =
77
let module A = (val get_arch_module arch call_conv) in
88
let check ~doit infer ct_list speculative pass file =
9-
let prog = parse_and_compile (module A) pass file idirs in
9+
let prog = parse_and_compile (module A) ~wi2i:false pass file idirs in
1010

1111
if speculative then
1212
let prog =

0 commit comments

Comments
 (0)