From 018c7384999aa0b14c735529d7a5fa89ff171c54 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 24 Mar 2021 14:16:11 -0700 Subject: [PATCH] [sledge] Make type arg of Exp.conditional non-optional Reviewed By: jvillard Differential Revision: D27262514 fbshipit-source-id: bcd35096f --- sledge/cli/frontend.ml | 2 +- sledge/src/llair/exp.ml | 3 +-- sledge/src/llair/exp.mli | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sledge/cli/frontend.ml b/sledge/cli/frontend.ml index 25fa28bc2..e070d7d91 100644 --- a/sledge/cli/frontend.ml +++ b/sledge/cli/frontend.ml @@ -660,7 +660,7 @@ and xlate_opcode : x -> Llvm.llvalue -> Llvm.Opcode.t -> Inst.t list * Exp.t let pre_0, cnd = xlate_rand 0 in let pre_1, thn = xlate_rand 1 in let pre_2, els = xlate_rand 2 in - (pre_0 @ pre_1 @ pre_2, Exp.conditional ~typ ~cnd ~thn ~els) + (pre_0 @ pre_1 @ pre_2, Exp.conditional typ ~cnd ~thn ~els) | ExtractElement | InsertElement -> ( let typ = let lltyp = Llvm.type_of (Llvm.operand llv 0) in diff --git a/sledge/src/llair/exp.ml b/sledge/src/llair/exp.ml index b553a14cf..6e34c1d4b 100644 --- a/sledge/src/llair/exp.ml +++ b/sledge/src/llair/exp.ml @@ -431,8 +431,7 @@ let ashr = binary Ashr (* if-then-else *) -let conditional ?typ ~cnd ~thn ~els = - let typ = match typ with Some typ -> typ | None -> typ_of thn in +let conditional typ ~cnd ~thn ~els = Ap3 (Conditional, typ, cnd, thn, els) |> check invariant (* sequences *) diff --git a/sledge/src/llair/exp.mli b/sledge/src/llair/exp.mli index 830c9bbaa..9dfa66cd6 100644 --- a/sledge/src/llair/exp.mli +++ b/sledge/src/llair/exp.mli @@ -223,7 +223,7 @@ val lshr : ?typ:Typ.t -> t -> t -> t val ashr : ?typ:Typ.t -> t -> t -> t (* if-then-else *) -val conditional : ?typ:Typ.t -> cnd:t -> thn:t -> els:t -> t +val conditional : Typ.t -> cnd:t -> thn:t -> els:t -> t (* sequences *) val splat : Typ.t -> t -> t