Skip to content
Snippets Groups Projects
Commit bd647334 authored by Basile Desloges's avatar Basile Desloges
Browse files

[eacsl:codegen] Add support for bitwise AND, OR and XOR when using GMP parameters

parent 4afbcfd4
No related branches found
No related tags found
No related merge requests found
...@@ -57,8 +57,11 @@ let name_of_mpz_arith_bop = function ...@@ -57,8 +57,11 @@ let name_of_mpz_arith_bop = function
| Mult -> "__gmpz_mul" | Mult -> "__gmpz_mul"
| Div -> "__gmpz_tdiv_q" | Div -> "__gmpz_tdiv_q"
| Mod -> "__gmpz_tdiv_r" | Mod -> "__gmpz_tdiv_r"
| Lt | Gt | Le | Ge | Eq | Ne | BAnd | BXor | BOr | LAnd | LOr | BAnd -> "__gmpz_and"
| Shiftlt | Shiftrt | PlusPI | IndexPI | MinusPI | MinusPP -> assert false | BOr -> "__gmpz_ior"
| BXor -> "__gmpz_xor"
| Lt | Gt | Le | Ge | Eq | Ne | LAnd | LOr | Shiftlt | Shiftrt | PlusPI
| IndexPI | MinusPI | MinusPP -> assert false
(* Type of a string that represents a number. (* Type of a string that represents a number.
Used when a string is required to encode a constant number because it is not Used when a string is required to encode a constant number because it is not
...@@ -426,7 +429,15 @@ and context_insensitive_term_to_exp kf env t = ...@@ -426,7 +429,15 @@ and context_insensitive_term_to_exp kf env t =
let e1, env = term_to_exp kf env t1 in let e1, env = term_to_exp kf env t1 in
let e2, env = term_to_exp kf env t2 in let e2, env = term_to_exp kf env t2 in
if Gmp_types.Z.is_t ty then if Gmp_types.Z.is_t ty then
not_yet env "bitwise operator on arbitrary precision" let mk_stmts _v e =
let name = name_of_mpz_arith_bop bop in
let instr = Constructor.mk_lib_call ~loc name [ e; e1; e2 ] in
[ instr ]
in
let name = Misc.name_of_binop bop in
let t = Some t in
let _, e, env = Env.new_var_and_mpz_init ~loc ~name env kf t mk_stmts in
e, env, C_number, ""
else begin else begin
assert (Logic_typing.is_integral_type t.term_type); assert (Logic_typing.is_integral_type t.term_type);
Cil.new_exp ~loc (BinOp(bop, e1, e2, ty)), env, C_number, "" Cil.new_exp ~loc (BinOp(bop, e1, e2, ty)), env, C_number, ""
......
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