123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144(**************************************************************************)(* This file is part of the Codex semantics library. *)(* *)(* Copyright (C) 2013-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)let_name="Collecting";;includeSva_quadrivalent;;moduleIn_bits=Units.In_bits(* Quadrivalent viewed as a set. *)moduleQuadrivalent=structincludeBoolean_Lattice;;letempty=Bottomletaddboolx=matchx,boolwith|Top,_->Top|True,true->True|True,false->Top|False,true->Top|False,false->False|Bottom,false->False|Bottom,true->True;;endmoduleZSet=Lattices.BVSet.ZSet;;moduleBitvector_Lattice=structincludeLattices.Unimplemented.Bitvector_Lattice(structtypet=Lattices.BVSet.tletloc=__LOC__end)includeLattices.BVSet;;letwiden~size~previousx=join~sizepreviousxletis_bottom~sizex=x=ZSet.emptyendmoduleConcrete=Operator.Concrete.Bitvector_Interptypebitvector=Bitvector_Lattice.t[@@@ocaml.warning"-38"]exceptionEmpty=Operator.Concrete.Empty[@@@ocaml.warning"+38"]moduleBitvector_Forward=structletlift1opa=ZSet.fold(funaacc->ZSet.add(opa)acc)aZSet.empty;;letlift2opab=ZSet.fold(funaacc->ZSet.fold(funbacc->matchopabwith|exceptionEmpty->acc|r->ZSet.addracc)bacc)aZSet.empty;;letlift2_predopab=ZSet.fold(funaacc->ZSet.fold(funbacc->Quadrivalent.add(opab)acc)bacc)aQuadrivalent.empty;;letbiconst~sizek=ZSet.singletonkletband~size=lift2(Z.(land));;letbor~size=lift2(Z.(lor));;letbxor~size=lift2(Z.(lxor));;letbiadd~size~flags=lift2(Concrete.biadd~size~flags);;letbisub~size~flags=lift2(Concrete.bisub~size~flags);;letbimul~size~flags=lift2(Concrete.bimul~flags~size);;letbimul_add~size~prod~offset=lift1(funx->Z.(prod*x+offset))letbisdiv~size=lift2(Concrete.bisdiv~size);;letbiudiv~size=lift2(Concrete.biudiv~size);;letbismod~size=lift2(Concrete.bismod~size);;letbiumod~size=lift2(Concrete.biumod~size);;letbuext~size~oldsizex=xletbsext~size~oldsize=letsize=In_bits.to_intsizeandoldsize=In_bits.to_intoldsizeinlift1(funx->Z.extract(Z.signed_extractx0oldsize)0size);;letbshl~size~flags=lift2(Concrete.bshl~size~flags);;letblshr~size=lift2(Concrete.blshr~size);;letbashr~size=lift2(Concrete.bashr~size);;letbconcat~size1~size2=lift2(Concrete.bconcat~size1~size2);;letbextract~size~index~oldsize=lift1(Concrete.bextract~index~size~oldsize);;;;letbeq~size=lift2_pred(Z.equal);;letbiule~size=lift2_pred(Z.leq);;letbisle~size=lift2_pred(Concrete.bisle~size);;let_prettyfmtx=letl=ZSet.elementsx|>List.map(Z.format"%b")inFormat.fprintffmt"[";(Format.pp_print_list~pp_sep:(funfmt()->Format.fprintffmt",")Format.pp_print_string)fmtl;Format.fprintffmt"]"letbofbool~size=function|Bottom->ZSet.empty|True->biconst~sizeZ.one|False->biconst~sizeZ.zero|Top->Bitvector_Lattice.join~size(biconst~sizeZ.zero)(biconst~sizeZ.one);;endmoduleBitvector_Backward=structincludeSva_Assert_False_Transfer_Functions.Bitvector_Backwardend