Skip to content
Snippets Groups Projects
Commit 964091d1 authored by Thibaut Benjamin's avatar Thibaut Benjamin Committed by Julien Signoles
Browse files

[e-acsl] refactor Gmp: add Z.cmp

parent b36bded7
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,22 @@ module Z = struct
in
e,env
let cmp ~loc name t_opt bop env kf e1 e2 =
let _, e, env = Env.new_var
~loc
env
kf
t_opt
~name
Cil.intType
(fun v _ ->
[ Smart_stmt.rtl_call ~loc
~result:(Cil.var v)
~prefix:""
"__gmpz_cmp"
[ e1; e2 ] ])
in
Cil.new_exp ~loc (BinOp(bop, e, Cil.zero ~loc, Cil.intType)), env
end
module Q = struct
......
......@@ -15,9 +15,14 @@ module Z : sig
val binop:
loc:location -> term option -> binop -> Env.t -> kernel_function ->
exp -> exp -> exp * Env.t
(** Applies [binop] to the given expressions. The optional term
indicates whether the comparison has a correspondance in the logic. *)
(** Applies [binop] to the given expressions. The optional term
indicates whether the comparison has a correspondance in the logic. *)
val cmp:
loc:location -> string -> term option -> binop -> Env.t ->
kernel_function -> exp -> exp -> exp * Env.t
(** Compares two expressions according to the given [binop]. The optional term
indicates whether the comparison has a correspondance in the logic. *)
end
......
......@@ -205,22 +205,7 @@ let comparison_to_exp
match ity with
| C_integer _ | C_float _ | Nan ->
Cil.mkBinOp ~loc bop e1 e2, env
| Gmpz ->
let _, e, env = Env.new_var
~loc
env
kf
t_opt
~name
Cil.intType
(fun v _ ->
[ Smart_stmt.rtl_call ~loc
~result:(Cil.var v)
~prefix:""
"__gmpz_cmp"
[ e1; e2 ] ])
in
Cil.new_exp ~loc (BinOp(bop, e, Cil.zero ~loc, Cil.intType)), env
| Gmpz -> Gmp_gen.Z.cmp ~loc name t_opt bop env kf e1 e2
| Rational -> Gmp_gen.Q.cmp ~loc t_opt bop env kf e1 e2
| Real -> Error.not_yet "comparison involving real numbers"
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment