[sledge] Extend Exp.typ to binary and ternary ops

Summary:
Most binary and ternary operations have the same type as their
arguments, so try to compute the type of arguments in these cases.

Reviewed By: kren1

Differential Revision: D15706576

fbshipit-source-id: 4749d6e32
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 99bc7363bf
commit d104f5e518

@ -354,12 +354,22 @@ let pp_t = pp
(** Invariant *)
let typ_of = function
let rec typ_of = function
| Add {typ} | Mul {typ} | Integer {typ} | App {op= Convert {dst= typ}} ->
Some typ
| App {op= App {op= Eq | Dq | Gt | Ge | Lt | Le | Ugt | Uge | Ult | Ule}}
->
Some Typ.bool
| App
{ op=
App
{ op=
Div | Udiv | Rem | Urem | And | Or | Xor | Shl | Lshr | Ashr
; arg= x }
; arg= y } -> (
match typ_of x with Some _ as t -> t | None -> typ_of y )
| App {op= App {op= App {op= Conditional}; arg= thn}; arg= els} -> (
match typ_of thn with Some _ as t -> t | None -> typ_of els )
| _ -> None
let typ = typ_of

Loading…
Cancel
Save