  This file is part of c4f . 

    Copyright ( c ) 2018 - 2022 C4 Project 

    c4 t itself is licensed under the MIT License . See the LICENSE file in the 
    project root for more information . 

    Parts of c4 t are based on code from the Herdtools7 project 
    (  ) : see the LICENSE.herd file in the 
    project root for more information .

   Copyright (c) 2018-2022 C4 Project

   c4t itself is licensed under the MIT License. See the LICENSE file in the
   project root for more information.

   Parts of c4t are based on code from the Herdtools7 project
   () : see the LICENSE.herd file in the
   project root for more information. *)

(** Utilities for the various expression generators. *)

open Import

val has_ints : Fir.Env.t -> is_atomic:bool -> bool
(** [has_ints env ~is_atomic] is sugar for testing whether [env] has integer
    variables with atomicity [is_atomic]. *)

val has_bools : Fir.Env.t -> is_atomic:bool -> bool
* [ has_bools env ~is_atomic ] is sugar for testing whether [ env ] has Boolean 
     variables with atomicity [ is_atomic ] .
    variables with atomicity [is_atomic]. *)

val with_record :
     'a Q.Generator.t
  -> to_var:('a -> C4f_common.C_id.t)
  -> env:Fir.Env.t
  -> ('a * Fir.Env.Record.t) Q.Generator.t
(** [with_record gen ~to_var ~env] attaches to values generated with [gen] a
    variable record found through [to_var] and [env]. *)

val lift_loadlike :
     'a Q.Generator.t
  -> to_expr:('a -> Fir.Expression.t)
  -> to_var:('a -> Common.C_id.t)
  -> env:Fir.Env.t
  -> (Fir.Expression.t * Fir.Env.Record.t) Q.Generator.t
(** [lift_loadlike gen ~to_expr ~to_var ~env] lifts a loadlike expression
    generator [gen] to one that returns an expression through [to_expr] and a
    variable record through [to_var] and [env]. *)

val gen_kv_refl :
     gen_op:('v -> Fir.Expression.t -> 'a Q.Generator.t)
  -> gen_load:('v * Fir.Env.Record.t) Q.Generator.t
  -> 'a Q.Generator.t
(** [gen_kv_refl ~gen_op ~gen_load] generates expressions of the form
    [h v (kv v)], where [kv v] gets the known value of [v], and [h] is an
    operation generated by [gen_op]. *)

val half : 'a Q.Generator.t -> 'a Q.Generator.t
* [ half x ] runs [ x ] with its size halved .

val ternary :
     gen_if:Fir.Expression.t Q.Generator.t
  -> gen_then:Fir.Expression.t Q.Generator.t
  -> gen_else:Fir.Expression.t Q.Generator.t
  -> Fir.Expression.t Q.Generator.t
(** [ternary ~gen_if ~gen_then ~gen_else] is a wrapper for generating ternary
    expressions. *)

* Utilities for the various expression generators. 
* [has_ints env ~is_atomic] is sugar for testing whether [env] has integer
    variables with atomicity [is_atomic]. 
* [with_record gen ~to_var ~env] attaches to values generated with [gen] a
    variable record found through [to_var] and [env]. 
* [lift_loadlike gen ~to_expr ~to_var ~env] lifts a loadlike expression
    generator [gen] to one that returns an expression through [to_expr] and a
    variable record through [to_var] and [env]. 
* [gen_kv_refl ~gen_op ~gen_load] generates expressions of the form
    [h v (kv v)], where [kv v] gets the known value of [v], and [h] is an
    operation generated by [gen_op]. 
* [ternary ~gen_if ~gen_then ~gen_else] is a wrapper for generating ternary
    expressions. 
  This file is part of c4f . 

    Copyright ( c ) 2018 - 2022 C4 Project 

    c4 t itself is licensed under the MIT License . See the LICENSE file in the 
    project root for more information . 

    Parts of c4 t are based on code from the Herdtools7 project 
    (  ) : see the LICENSE.herd file in the 
    project root for more information .

   Copyright (c) 2018-2022 C4 Project

   c4t itself is licensed under the MIT License. See the LICENSE file in the
   project root for more information.

   Parts of c4t are based on code from the Herdtools7 project
   () : see the LICENSE.herd file in the
   project root for more information. *)


open Import

val has_ints : Fir.Env.t -> is_atomic:bool -> bool

val has_bools : Fir.Env.t -> is_atomic:bool -> bool
* [ has_bools env ~is_atomic ] is sugar for testing whether [ env ] has Boolean 
     variables with atomicity [ is_atomic ] .
    variables with atomicity [is_atomic]. *)

val with_record :
     'a Q.Generator.t
  -> to_var:('a -> C4f_common.C_id.t)
  -> env:Fir.Env.t
  -> ('a * Fir.Env.Record.t) Q.Generator.t

val lift_loadlike :
     'a Q.Generator.t
  -> to_expr:('a -> Fir.Expression.t)
  -> to_var:('a -> Common.C_id.t)
  -> env:Fir.Env.t
  -> (Fir.Expression.t * Fir.Env.Record.t) Q.Generator.t

val gen_kv_refl :
     gen_op:('v -> Fir.Expression.t -> 'a Q.Generator.t)
  -> gen_load:('v * Fir.Env.Record.t) Q.Generator.t
  -> 'a Q.Generator.t

val half : 'a Q.Generator.t -> 'a Q.Generator.t
* [ half x ] runs [ x ] with its size halved .

val ternary :
     gen_if:Fir.Expression.t Q.Generator.t
  -> gen_then:Fir.Expression.t Q.Generator.t
  -> gen_else:Fir.Expression.t Q.Generator.t
  -> Fir.Expression.t Q.Generator.t
