Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file nl_flow.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110(****************************************************************************)(* Sail *)(* *)(* Sail and the Sail architecture models here, comprising all files and *)(* directories except the ASL-derived Sail code in the aarch64 directory, *)(* are subject to the BSD two-clause licence below. *)(* *)(* The ASL derived parts of the ARMv8.3 specification in *)(* aarch64/no_vector and aarch64/full are copyright ARM Ltd. *)(* *)(* Copyright (c) 2013-2021 *)(* Kathyrn Gray *)(* Shaked Flur *)(* Stephen Kell *)(* Gabriel Kerneis *)(* Robert Norton-Wright *)(* Christopher Pulte *)(* Peter Sewell *)(* Alasdair Armstrong *)(* Brian Campbell *)(* Thomas Bauereiss *)(* Anthony Fox *)(* Jon French *)(* Dominic Mulligan *)(* Stephen Kell *)(* Mark Wassell *)(* Alastair Reid (Arm Ltd) *)(* *)(* All rights reserved. *)(* *)(* This work was partially supported by EPSRC grant EP/K008528/1 <a *)(* href="http://www.cl.cam.ac.uk/users/pes20/rems">REMS: Rigorous *)(* Engineering for Mainstream Systems</a>, an ARM iCASE award, EPSRC IAA *)(* KTF funding, and donations from Arm. This project has received *)(* funding from the European Research Council (ERC) under the European *)(* Union’s Horizon 2020 research and innovation programme (grant *)(* agreement No 789108, ELVER). *)(* *)(* This software was developed by SRI International and the University of *)(* Cambridge Computer Laboratory (Department of Computer Science and *)(* Technology) under DARPA/AFRL contracts FA8650-18-C-7809 ("CIFV") *)(* and FA8750-10-C-0237 ("CTSRD"). *)(* *)(* SPDX-License-Identifier: BSD-2-Clause *)(****************************************************************************)openAstopenAst_utilletopt_nl_flow=reffalseletrecescapes(E_aux(aux,_))=matchauxwith|E_throw_->true|E_block[]->false|E_blockexps->escapes(List.hd(List.revexps))|_->falseletis_bitvector_literal(L_aux(aux,_))=matchauxwithL_bin_|L_hex_->true|_->falseletbitvector_unsigned(L_aux(aux,_))=letopenSail_libinmatchauxwith|L_binbin->uint(Semantics.bitlist_of_bin_litbin)|L_hexhex->uint(Semantics.bitlist_of_hex_lithex)|_->assertfalseletrecpat_id(P_aux(aux,_))=matchauxwithP_idid->Someid|P_as(_,id)->Someid|P_var(pat,_)->pat_idpat|_->Noneletadd_assertcond(E_aux(aux,(l,uannot))asexp)=letmsg=mk_lit_exp(L_string"")inletassertion=locate(fun_->gen_locl)(mk_exp(E_assert(cond,msg)))inmatchauxwith|E_blockexps->E_aux(E_block(assertion::exps),(l,empty_uannot))|_->E_aux(E_block(assertion::[exp]),(l,uannot))(* If we know that x != bitv, then after any let y = unsigned(x) we
will also know that y != unsigned(bitv) *)letmodify_unsignedidvalue(E_aux(aux,annot)asexp)=matchauxwith|E_let((LB_aux(LB_val(pat,E_aux(E_app(f,[E_aux(E_idid',_)]),_)),_)aslb),exp')when(string_of_idf="unsigned"||string_of_idf="UInt")&&Id.compareidid'=0->beginmatchpat_idpatwith|None->exp|Someuid->E_aux(E_let(lb,add_assert(mk_infix_exp(mk_exp(E_iduid))(mk_operator"!=")(mk_lit_exp(L_numvalue)))exp'),annot)end|_->expletis_equals=functionId_aux(Operator"==",_)->true|_->falseletanalyze'exps=matchexpswith|E_aux(E_if(cond,then_exp,_),_)::_whenescapesthen_exp->beginmatchcondwith|E_aux(E_app(op,[E_aux(E_idid,_);E_aux(E_litlit,_)]),_)|E_aux(E_app(op,[E_aux(E_litlit,_);E_aux(E_idid,_)]),_)whenis_equalsop&&is_bitvector_literallit->letvalue=bitvector_unsignedlitinList.map(modify_unsignedidvalue)exps|_->expsend|_->expsletanalyzeexps=if!opt_nl_flowthenanalyze'expselseexps