123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154(* ------------------------------------------------------------------------ *)openUtilsopenWsizemoduleL=LocationmoduleName=structtypet=stringendtypeuid=Uint63.tletstring_of_uid=Uint63.to_string(* ------------------------------------------------------------------------ *)typebase_ty=|Bool|Int(* Unbounded integer for pexpr *)|Uofwsize(* U(n): unsigned n-bit integer *)[@@derivingcompare,sexp]type'lengty=|Btyofbase_ty|Arrofwsize*'len(* Arr(n,de): array of n-bit integers with dim. *)(* invariant only Const variable can be used in expression *)(* the type of the expression is [Int] *)type'lengety=|ETbool|ETint|ETwordofsignednessoption*wsize|ETarrofwsize*'len(* Arr(n,de): array of n-bit integers with dim. *)(* invariant only Const variable can be used in expression *)(* the type of the expression is [Int] *)letu8=Bty(UU8)letu16=Bty(UU16)letu32=Bty(UU32)letu64=Bty(UU64)letu128=Bty(UU128)letu256=Bty(UU256)lettuws=Bty(Uws)lettbool=BtyBoollettint=BtyIntletetwws=ETword(None,ws)letetwisws=ETword(Somes,ws)letetbool=ETboolletetint=ETintletgty_of_gety(t:'lengety):'lengty=matchtwith|ETbool->tbool|ETint->tint|ETword(_,ws)->tuws|ETarr(ws,len)->Arr(ws,len)letgety_of_gty(t:'lengty):'lengety=matchtwith|Arr(ws,len)->ETarr(ws,len)|Btyt->matchtwith|Bool->etbool|Int->etint|Uws->etwws(* ------------------------------------------------------------------------ *)type'lengvar={v_name:Name.t;v_id:uid;v_kind:v_kind;v_ty:'lengty;v_dloc:L.t;(* location where declared *)v_annot:Annotations.annotations;}(* ------------------------------------------------------------------------ *)moduleGV=structletmkv_namev_kindv_tyv_dlocv_annot=letv_id=Uint63.of_int(Uniq.gen())in{v_name;v_id;v_kind;v_ty;v_dloc;v_annot}letclone?dlocv=mkv.v_namev.v_kindv.v_ty(Option.defaultv.v_dlocdloc)v.v_annotletcomparev1v2=Uint63.comparesv1.v_idv2.v_idletequalv1v2=Uint63.equalv1.v_idv2.v_idlethashv=Uint63.hashv.v_idletis_globv=v.v_kind=Constletis_localv=not(is_globv)end(* ------------------------------------------------------------------------ *)(* Non parametrized variable *)typety=intgtytypevar=intgvarmoduleV=structtypet=varincludeGVend(* Cident *)moduleCident=structtypet=varlettag(x:t)=x.v_idletid_name(x:t):Name.t=x.v_nameletid_kind(x:t):v_kind=x.v_kindletspill_to_mmx(x:t)=matchAnnot.ensure_uniq1"spill_to_mmx"Annot.nonex.v_annotwith|Some()->true|None->falseend(* ------------------------------------------------------------------------ *)(* Function name *)typefunname={fn_name:Name.t;fn_id:uid;}letfunname_tag(f:funname)=f.fn_idmoduleF=structletmkfn_name={fn_name;fn_id=Uint63.of_int(Uniq.gen());}typet=funnameletcomparef1f2=Uint63.comparesf1.fn_idf2.fn_idletequalf1f2=Uint63.equalf1.fn_idf2.fn_idlethashf=Uint63.hashf.fn_idendmoduleSf=Set.Make(F)moduleMf=Map.Make(F)moduleHf=Hash.Make(F)