Bidir.IntrinsicsAn implementation of a selection of intrinsics useful for the assembly conversion.
val equal_dir : dir -> dir -> Ppx_deriving_runtime.boolval pp_dir :
Ppx_deriving_runtime.Format.formatter ->
dir ->
Ppx_deriving_runtime.unitval show_dir : dir -> Ppx_deriving_runtime.stringval reorder_one_stmt : dir:dir -> 'a Types.bidir -> 'a Types.bidirReorders the topmost level of the given statement. Does not recurse into sub-statements.
type intrinsic = | BitsToUint of intTypes.value.VBits -> Types.value.VInt. Interprets its argument as an unsigned integer. Intrinsic parameter is BV size.
| BitsToSint of intTypes.value.VBits -> Types.value.VInt. Interprets its argument as a signed integer. Intrinsic parameter is BV size.
| IntToDecimal| Concat of int option listTypes.value.VTup of Types.value.VStr -> Types.value.VStr. Concatenates the given tuple of strings into a single string. Intrinsic parameters are the length of each component of the tuple. At most one length can be None, indicating that component expands to the rest of the string.
| NotIn of Types.value listAny -> Any. Asserts that the given value is not contained in the intrinsic's list of literals. If successful, this acts as the identity function. Otherwise, throws.
*)| InInterval of int * intTypes.value.VInt -> Types.value.VInt. Asserts that the given integer is within the interval (inclusive of bounds).
| Multiply of intTypes.value.VInt -> Types.value.VInt. Multiplies by the given factor. Inverting this succeeds only when the input is a multiple of the factor.
| Add of int| Inv of intrinsicPerforms the inverse of the given intrinsic, i.e., swaps its forwards and backwards directions.
*)Useful intrinsics, though keep in mind that the Bidir type is generic in the allowed intrinsics.
val equal_intrinsic : intrinsic -> intrinsic -> Ppx_deriving_runtime.boolval pp_intrinsic :
Ppx_deriving_runtime.Format.formatter ->
intrinsic ->
Ppx_deriving_runtime.unitval show_intrinsic : intrinsic -> Ppx_deriving_runtime.stringval intrinsic_to_yojson : intrinsic -> Yojson.Safe.tval intrinsic_of_yojson :
Yojson.Safe.t ->
intrinsic Ppx_deriving_yojson_runtime.error_orval pp_dummy_intrinsic : Stdlib.Format.formatter -> 'a -> unittype ('i, 'a) intrinsic_impl = 'i -> dir:dir -> 'a -> 'aAn implementation of an intrinsic, parametrised by the intrinsic type and the value type. Accepts an argument of which direction to operate in.
val make_intrinsic :
((Types.value -> Types.value) * (Types.value -> Types.value)) ->
dir:dir ->
Types.value ->
Types.valueConstructs an intrinsic_impl function from the given forwards and backwards functions. When executing the intrinsic, this helper function ensures that the given functions are inverses.
Types.value conversion functionsval vbits_of_val : Types.value -> stringval vint_of_val : Types.value -> intval vstr_of_val : Types.value -> stringval vtup_of_val : (Types.value -> 'a) list -> Types.value -> 'a listval val_of_vbits : string -> Types.valueval val_of_vint : int -> Types.valueval val_of_vstr : string -> Types.valueval val_of_vtup : ('a -> Types.value) list -> 'a list -> Types.valueThese implement both directions of a number of intrinsics, operating on built-in Ocaml types.
val bits_of_uint : int -> CCInt.t -> stringval bits_of_sint : int -> CCInt.t -> stringval concat_backwards : int option CCList.t -> string -> string listReally weak isomorphisms which are just a pair of forwards and back functions. These are weak because they are really only isomorphic on the image of the forwards function. Even then, they can throw and do other terrible things.
val val_iso_bits : (Types.value -> string) * (string -> Types.value)val val_iso_int : (Types.value -> int) * (int -> Types.value)val val_iso_str : (Types.value -> string) * (string -> Types.value)val val_iso_tup :
((Types.value -> 'a) * ('b -> Types.value)) list ->
(Types.value -> 'a list) * ('b list -> Types.value)val bits_iso_uint : int -> (string -> int) * (CCInt.t -> string)val bits_iso_sint : int -> (string -> int) * (CCInt.t -> string)val concat_strings_iso :
int option CCList.t ->
(string list -> string) * (string -> string list)val run_intrinsics : intrinsic -> dir:dir -> Types.value -> Types.valueAn intrinsic_impl executing the intrinsics specified in intrinsic.