diff --git a/sledge/src/llair/exp.ml b/sledge/src/llair/exp.ml index a20c0a2eb..da2b44f39 100644 --- a/sledge/src/llair/exp.ml +++ b/sledge/src/llair/exp.ml @@ -1227,6 +1227,11 @@ let struct_rec key = let convert ?(signed = false) ~dst ~src exp = app1 (Convert {signed; dst; src}) exp +let size_of t = + Option.bind (Typ.prim_bit_size_of t) ~f:(fun n -> + if n % 8 = 0 then Some (integer (Z.of_int (n / 8)) Typ.siz) else None + ) + (** Transform *) let map e ~f = diff --git a/sledge/src/llair/exp.mli b/sledge/src/llair/exp.mli index ecbae388f..82f61b4d1 100644 --- a/sledge/src/llair/exp.mli +++ b/sledge/src/llair/exp.mli @@ -186,6 +186,7 @@ val struct_rec : stack overflow. *) val convert : ?signed:bool -> dst:Typ.t -> src:Typ.t -> t -> t +val size_of : Typ.t -> t option (** Access *)