diff options
| author | Brian Campbell | 2018-01-26 17:52:16 +0000 |
|---|---|---|
| committer | Brian Campbell | 2018-01-26 18:32:20 +0000 |
| commit | 481f492ecc3179f5ea8293dab45c3712871c219e (patch) | |
| tree | e725b5bba459a47597264ef65f72606390945bf3 | |
| parent | 36e95d3af78bf8b6e11b1939e605a735285e3183 (diff) | |
One more mono rewrite
| -rw-r--r-- | lib/mono_rewrites.sail | 7 | ||||
| -rw-r--r-- | src/monomorphise.ml | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/mono_rewrites.sail b/lib/mono_rewrites.sail index fd1d1b23..a69dc379 100644 --- a/lib/mono_rewrites.sail +++ b/lib/mono_rewrites.sail @@ -122,3 +122,10 @@ function UInt_slice(xs,i,l) = { let xs = (xs & slice_mask(i,l)) >> i in UInt(xs) } + +val zext_ones : forall 'n, 'n >= 0. int -> bits('n) effect pure + +function zext_ones(m) = { + let v : bits('n) = extsv(0b1) in + v >> ('n - m) +} diff --git a/src/monomorphise.ml b/src/monomorphise.ml index cd2c419f..745b40e4 100644 --- a/src/monomorphise.ml +++ b/src/monomorphise.ml @@ -3075,6 +3075,10 @@ let rewrite_app env typ (id,args) = when is_slice slice1 && not (is_constant length1) -> E_app (mk_id "zext_slice", [vector1; start1; length1]) + | [E_aux (E_app (ones, [len1]),_); + _ (* unnecessary ZeroExtend length *)] -> + E_app (mk_id "zext_ones", [len1]) + | _ -> E_app (id,args) else if is_id env (Id "SignExtend") id then |
