diff options
| -rw-r--r-- | lib/mono_rewrites.sail | 8 | ||||
| -rw-r--r-- | src/monomorphise.ml | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/mono_rewrites.sail b/lib/mono_rewrites.sail index a72cdd79..144b7ae0 100644 --- a/lib/mono_rewrites.sail +++ b/lib/mono_rewrites.sail @@ -110,3 +110,11 @@ function sext_slice(xs,i,l) = { let xs = (xs & slice_mask(i,l)) >> i in extsv(xs) } + +val UInt_slice : forall 'n, 'n >= 0. + (bits('n), int, int) -> int effect pure + +function UInt_slice(xs,i,l) = { + let xs = (xs & slice_mask(i,l)) >> i in + UInt(xs) +} diff --git a/src/monomorphise.ml b/src/monomorphise.ml index b77b49cf..9f67e93f 100644 --- a/src/monomorphise.ml +++ b/src/monomorphise.ml @@ -2778,6 +2778,15 @@ let rewrite_app env typ (id,args) = | _ -> E_app (id,args) + else if is_id env (Id "UInt") id then + let is_slice = is_id env (Id "slice") in + match args with + | [E_aux (E_app (slice1, [vector1; start1; length1]),_)] + when is_slice slice1 && not (is_constant length1) -> + E_app (mk_id "UInt_slice", [vector1; start1; length1]) + + | _ -> E_app (id,args) + else E_app (id,args) let rewrite_aux = function |
