@@ -209,6 +209,7 @@ module type CircuitInterface = sig
209
209
val decompose : int -> int -> cbitstring cfun -> (cbitstring cfun ) list * (int * int )
210
210
val permute : int -> (int -> int ) -> cbitstring cfun -> cbitstring cfun
211
211
val align_inputs : circuit -> (int * int ) option list -> circuit
212
+ val circuit_slice : circuit -> int -> int -> circuit
212
213
213
214
(* Wraps the backend call to deal with args/inputs *)
214
215
module CircuitSpec : sig
@@ -1621,6 +1622,21 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
1621
1622
| `CTuple (r , ws ) -> (`CTuple (Backend. applys aligner r, ws), inps)
1622
1623
| `CBool b -> (`CBool (Backend. apply aligner b), inps)
1623
1624
1625
+ let circuit_slice ((c , inps ): circuit ) (sz : width ) (offset : int ) =
1626
+ match c with
1627
+ | `CArray (r , w ) when sz mod w = 0 && offset mod w = 0 -> `CArray (Backend. slice r offset sz, w), inps
1628
+ | `CArray (r , w ) ->
1629
+ Format. eprintf " Flattening array to bitstring in order to slice@." ;
1630
+ `CBitstring (Backend. slice r offset sz), inps
1631
+ | `CBitstring r ->
1632
+ `CBitstring (Backend. slice r offset sz), inps
1633
+ | `CTuple (r , szs ) ->
1634
+ Format. eprintf " Cannot slice tuple circuit@." ;
1635
+ assert false
1636
+ | `CBool b ->
1637
+ Format. eprintf " Cannot slice boolean circuit@." ;
1638
+ assert false
1639
+
1624
1640
let split_renamer (n : count ) (in_w : width ) (inp : cinp ) : (cinp array) * (Backend.inp -> cbool_type option) =
1625
1641
match inp with
1626
1642
| {type_ = `CIBitstring w ; id} when w mod in_w = 0 ->
@@ -1940,6 +1956,7 @@ let circuit_of_form
1940
1956
else
1941
1957
let hyps, circ = match (EcEnv.Op. by_path pth env).op_kind with
1942
1958
| OB_oper (Some (OP_Plain f )) ->
1959
+ Format. eprintf " [BDEP] Opening definition of function at path %s" (EcPath. tostring pth);
1943
1960
doit cache hyps f
1944
1961
| _ when pth = EcCoreLib.CI_Witness. p_witness ->
1945
1962
assert false ;
@@ -1963,6 +1980,7 @@ let circuit_of_form
1963
1980
begin match f with
1964
1981
| {f_node = Fop (pth , _ )} when op_is_parametric_base env pth ->
1965
1982
let hyps, args = List. fold_left_map (arg_of_form) hyps fs in
1983
+ Format. eprintf " Processed args for form %a@." EcPrinting. (pp_form (PPEnv. ofenv env)) f_;
1966
1984
hyps, circuit_of_op_with_args env pth args
1967
1985
1968
1986
(* For dealing with iter cases: *)
@@ -2304,7 +2322,8 @@ let circuit_has_uninitialized = circuit_has_uninitialized
2304
2322
let circuit_aggregate_inps =
2305
2323
circuit_aggregate_inputs
2306
2324
2307
- let circuit_slice (c : circuit ) (sz : int ) (offset : int ) = assert false
2325
+ let circuit_slice (c : circuit ) (sz : int ) (offset : int ) =
2326
+ circuit_slice c sz offset
2308
2327
2309
2328
(* FIXME: this should use ids instead of strings *)
2310
2329
let circuit_align_inputs =
0 commit comments