123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803(****************************************************************************)(* 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"). *)(* *)(* Redistribution and use in source and binary forms, with or without *)(* modification, are permitted provided that the following conditions *)(* are met: *)(* 1. Redistributions of source code must retain the above copyright *)(* notice, this list of conditions and the following disclaimer. *)(* 2. Redistributions in binary form must reproduce the above copyright *)(* notice, this list of conditions and the following disclaimer in *)(* the documentation and/or other materials provided with the *)(* distribution. *)(* *)(* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' *)(* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *)(* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *)(* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR *)(* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *)(* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *)(* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *)(* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *)(* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *)(* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *)(* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *)(* SUCH DAMAGE. *)(****************************************************************************)moduleBig_int=Nat_big_nummoduleStringMap=Map.Make(String)letprint_chan=refstdoutletprint_redirected=reffalseletoutput_redirectchan=print_chan:=chan;print_redirected:=trueletoutput_close()=if!print_redirectedthenclose_out!print_chanelse()letoutputstr=output_string!print_chanstr;flush!print_chanletoutput_endlinestr=output_string!print_chan(str^"\n");flush!print_chantypevalue=|V_vectorofvaluelist|V_listofvaluelist|V_intofBig_int.num|V_realofRational.t|V_boolofbool|V_bitofSail_lib.bit|V_tupleofvaluelist|V_unit|V_stringofstring|V_refofstring|V_ctorofstring*valuelist|V_recordofvalueStringMap.t(* When constant folding we disable reading registers, so a register
read will return a V_attempted_read value. If we try to do
anything with this value, we'll get an exception - but if all we
do is return it then we can replace the expression we are folding
with a direct register read. *)|V_attempted_readofstringletcoerce_bit=functionV_bitb->b|_->assertfalseletis_bit=functionV_bit_->true|_->falseletrecstring_of_value=function|V_vectorvswhenList.for_allis_bitvs->Sail_lib.string_of_bits(List.mapcoerce_bitvs)|V_vectorvs->"["^Util.string_of_list", "string_of_valuevs^"]"|V_booltrue->"true"|V_boolfalse->"false"|V_bitSail_lib.B0->"bitzero"|V_bitSail_lib.B1->"bitone"|V_intn->Big_int.to_stringn|V_tuplevals->"("^Util.string_of_list", "string_of_valuevals^")"|V_listvals->"[|"^Util.string_of_list", "string_of_valuevals^"|]"|V_unit->"()"|V_stringstr->"\""^str^"\""|V_refstr->"ref "^str|V_realr->Sail_lib.string_of_realr|V_ctor(str,vals)->str^"("^Util.string_of_list", "string_of_valuevals^")"|V_recordrecord->"{"^Util.string_of_list", "(fun(field,v)->field^"="^string_of_valuev)(StringMap.bindingsrecord)^"}"|V_attempted_read_->assertfalseletreceq_valuev1v2=match(v1,v2)with|V_vectorv1s,V_vectorv2swhenList.lengthv1s=List.lengthv2s->List.for_all2eq_valuev1sv2s|V_listv1s,V_listv2swhenList.lengthv1s=List.lengthv2s->List.for_all2eq_valuev1sv2s|V_intn,V_intm->Big_int.equalnm|V_realn,V_realm->Rational.equalnm|V_boolb1,V_boolb2->b1=b2|V_bitb1,V_bitb2->b1=b2|V_tuplev1s,V_tuplev2swhenList.lengthv1s=List.lengthv2s->List.for_all2eq_valuev1sv2s|V_unit,V_unit->true|V_stringstr1,V_stringstr2->str1=str2|V_refstr1,V_refstr2->str1=str2|V_ctor(name1,fields1),V_ctor(name2,fields2)whenList.lengthfields1=List.lengthfields2->name1=name2&&List.for_all2eq_valuefields1fields2|V_recordfields1,V_recordfields2->StringMap.equaleq_valuefields1fields2|_,_->falseletcoerce_ctor=functionV_ctor(str,vals)->(str,vals)|_->assertfalseletcoerce_bool=functionV_boolb->b|_->assertfalseletcoerce_record=functionV_recordrecord->record|_->assertfalseletand_bool=function[v1;v2]->V_bool(coerce_boolv1&&coerce_boolv2)|_->assertfalseletor_bool=function[v1;v2]->V_bool(coerce_boolv1||coerce_boolv2)|_->assertfalselettuple_value(vs:valuelist):value=V_tuplevsletmk_vector(bits:Sail_lib.bitlist):value=V_vector(List.map(funbit->V_bitbit)bits)letcoerce_bit=functionV_bitb->b|_->assertfalseletcoerce_tuple=functionV_tuplevs->vs|_->assertfalseletcoerce_list=functionV_listvs->vs|_->assertfalseletcoerce_listlike=functionV_tuplevs->vs|V_listvs->vs|V_unit->[]|_->assertfalseletcoerce_int=functionV_inti->i|_->assertfalseletcoerce_real=functionV_realr->r|_->assertfalseletcoerce_cons=functionV_list(v::vs)->Some(v,vs)|V_list[]->None|_->assertfalseletcoerce_gv=functionV_vectorvs->vs|_->assertfalseletcoerce_bv=functionV_vectorvs->List.mapcoerce_bitvs|_->assertfalseletcoerce_string=functionV_stringstr->str|_->assertfalseletcoerce_ref=functionV_refstr->str|_->assertfalseletunit_value=V_unitletvalue_eq_int=function|[v1;v2]->V_bool(Sail_lib.eq_int(coerce_intv1,coerce_intv2))|_->failwith"value eq_int"letvalue_eq_bool=function|[v1;v2]->V_bool(Sail_lib.eq_bool(coerce_boolv1,coerce_boolv2))|_->failwith"value eq_bool"letvalue_lteq=function|[v1;v2]->V_bool(Sail_lib.lteq(coerce_intv1,coerce_intv2))|_->failwith"value lteq"letvalue_gteq=function|[v1;v2]->V_bool(Sail_lib.gteq(coerce_intv1,coerce_intv2))|_->failwith"value gteq"letvalue_lt=function[v1;v2]->V_bool(Sail_lib.lt(coerce_intv1,coerce_intv2))|_->failwith"value lt"letvalue_gt=function[v1;v2]->V_bool(Sail_lib.gt(coerce_intv1,coerce_intv2))|_->failwith"value gt"letvalue_eq_list=function|[v1;v2]->V_bool(Sail_lib.eq_list(coerce_bvv1,coerce_bvv2))|_->failwith"value eq_list"letvalue_eq_string=function|[v1;v2]->V_bool(Sail_lib.eq_string(coerce_stringv1,coerce_stringv2))|_->failwith"value eq_string"letvalue_string_startswith=function|[v1;v2]->V_bool(Sail_lib.string_startswith(coerce_stringv1,coerce_stringv2))|_->failwith"value string_startswith"letvalue_string_drop=function|[v1;v2]->V_string(Sail_lib.string_drop(coerce_stringv1,coerce_intv2))|_->failwith"value string_drop"letvalue_string_take=function|[v1;v2]->V_string(Sail_lib.string_take(coerce_stringv1,coerce_intv2))|_->failwith"value string_take"letvalue_string_length=function|[v]->V_int(coerce_stringv|>Sail_lib.string_length)|_->failwith"value string_length"letvalue_eq_bit=function|[v1;v2]->V_bool(Sail_lib.eq_bit(coerce_bitv1,coerce_bitv2))|_->failwith"value eq_bit"letvalue_length=function[v]->V_int(coerce_gvv|>List.length|>Big_int.of_int)|_->failwith"value length"letvalue_subrange=function|[v1;v2;v3]->mk_vector(Sail_lib.subrange(coerce_bvv1,coerce_intv2,coerce_intv3))|_->failwith"value subrange"letvalue_access=function[v1;v2]->Sail_lib.access(coerce_gvv1,coerce_intv2)|_->failwith"value access"letvalue_update=function|[v1;v2;v3]->V_vector(Sail_lib.update(coerce_gvv1,coerce_intv2,v3))|_->failwith"value update"letvalue_update_subrange=function|[v1;v2;v3;v4]->mk_vector(Sail_lib.update_subrange(coerce_bvv1,coerce_intv2,coerce_intv3,coerce_bvv4))|_->failwith"value update_subrange"letvalue_append=function[v1;v2]->V_vector(coerce_gvv1@coerce_gvv2)|_->failwith"value append"letvalue_append_list=function|[v1;v2]->V_list(coerce_listv1@coerce_listv2)|_->failwith"value_append_list"letvalue_slice=function|[v1;v2;v3]->V_vector(Sail_lib.slice(coerce_gvv1,coerce_intv2,coerce_intv3))|_->failwith"value slice"letvalue_not=function[v]->V_bool(not(coerce_boolv))|_->failwith"value not"letvalue_not_vec=function[v]->mk_vector(Sail_lib.not_vec(coerce_bvv))|_->failwith"value not_vec"letvalue_and_vec=function|[v1;v2]->mk_vector(Sail_lib.and_vec(coerce_bvv1,coerce_bvv2))|_->failwith"value not_vec"letvalue_or_vec=function|[v1;v2]->mk_vector(Sail_lib.or_vec(coerce_bvv1,coerce_bvv2))|_->failwith"value not_vec"letvalue_xor_vec=function|[v1;v2]->mk_vector(Sail_lib.xor_vec(coerce_bvv1,coerce_bvv2))|_->failwith"value xor_vec"letvalue_uint=function[v]->V_int(Sail_lib.uint(coerce_bvv))|_->failwith"value uint"letvalue_sint=function[v]->V_int(Sail_lib.sint(coerce_bvv))|_->failwith"value sint"letvalue_get_slice_int=function|[v1;v2;v3]->mk_vector(Sail_lib.get_slice_int(coerce_intv1,coerce_intv2,coerce_intv3))|_->failwith"value get_slice_int"letvalue_set_slice_int=function|[v1;v2;v3;v4]->V_int(Sail_lib.set_slice_int(coerce_intv1,coerce_intv2,coerce_intv3,coerce_bvv4))|_->failwith"value set_slice_int"letvalue_set_slice=function|[v1;v2;v3;v4;v5]->mk_vector(Sail_lib.set_slice(coerce_intv1,coerce_intv2,coerce_bvv3,coerce_intv4,coerce_bvv5))|_->failwith"value set_slice"letvalue_hex_slice=function|[v1;v2;v3]->mk_vector(Sail_lib.hex_slice(coerce_stringv1,coerce_intv2,coerce_intv3))|_->failwith"value hex_slice"letvalue_add_int=function|[v1;v2]->V_int(Sail_lib.add_int(coerce_intv1,coerce_intv2))|_->failwith"value add"letvalue_sub_int=function|[v1;v2]->V_int(Sail_lib.sub_int(coerce_intv1,coerce_intv2))|_->failwith"value sub"letvalue_sub_nat=function|[v1;v2]->V_int(Sail_lib.sub_nat(coerce_intv1,coerce_intv2))|_->failwith"value sub_nat"letvalue_negate=function[v1]->V_int(Sail_lib.negate(coerce_intv1))|_->failwith"value negate"letvalue_pow2=function[v1]->V_int(Sail_lib.pow2(coerce_intv1))|_->failwith"value pow2"letvalue_int_power=function|[v1;v2]->V_int(Sail_lib.int_power(coerce_intv1,coerce_intv2))|_->failwith"value int_power"letvalue_mult=function|[v1;v2]->V_int(Sail_lib.mult(coerce_intv1,coerce_intv2))|_->failwith"value mult"letvalue_tdiv_int=function|[v1;v2]->V_int(Sail_lib.tdiv_int(coerce_intv1,coerce_intv2))|_->failwith"value tdiv_int"letvalue_tmod_int=function|[v1;v2]->V_int(Sail_lib.tmod_int(coerce_intv1,coerce_intv2))|_->failwith"value tmod_int"letvalue_quotient=function|[v1;v2]->V_int(Sail_lib.quotient(coerce_intv1,coerce_intv2))|_->failwith"value quotient"letvalue_modulus=function|[v1;v2]->V_int(Sail_lib.modulus(coerce_intv1,coerce_intv2))|_->failwith"value modulus"letvalue_abs_int=function[v]->V_int(Big_int.abs(coerce_intv))|_->failwith"value abs_int"letvalue_add_vec_int=function|[v1;v2]->mk_vector(Sail_lib.add_vec_int(coerce_bvv1,coerce_intv2))|_->failwith"value add_vec_int"letvalue_sub_vec_int=function|[v1;v2]->mk_vector(Sail_lib.sub_vec_int(coerce_bvv1,coerce_intv2))|_->failwith"value sub_vec_int"letvalue_add_vec=function|[v1;v2]->mk_vector(Sail_lib.add_vec(coerce_bvv1,coerce_bvv2))|_->failwith"value add_vec"letvalue_sub_vec=function|[v1;v2]->mk_vector(Sail_lib.sub_vec(coerce_bvv1,coerce_bvv2))|_->failwith"value sub_vec"letvalue_shl_int=function|[v1;v2]->V_int(Sail_lib.shl_int(coerce_intv1,coerce_intv2))|_->failwith"value shl_int"letvalue_shr_int=function|[v1;v2]->V_int(Sail_lib.shr_int(coerce_intv1,coerce_intv2))|_->failwith"value shr_int"letvalue_max_int=function|[v1;v2]->V_int(Sail_lib.max_int(coerce_intv1,coerce_intv2))|_->failwith"value max_int"letvalue_min_int=function|[v1;v2]->V_int(Sail_lib.min_int(coerce_intv1,coerce_intv2))|_->failwith"value min_int"letvalue_replicate_bits=function|[v1;v2]->mk_vector(Sail_lib.replicate_bits(coerce_bvv1,coerce_intv2))|_->failwith"value replicate_bits"letvalue_count_leading_zeros=function|[v1]->V_int(Sail_lib.count_leading_zeros(coerce_bvv1))|_->failwith"value count_leading_zeros"letis_ctor=functionV_ctor_->true|_->falseletvalue_sign_extend=function|[v1;v2]->mk_vector(Sail_lib.sign_extend(coerce_bvv1,coerce_intv2))|_->failwith"value sign_extend"letvalue_zero_extend=function|[v1;v2]->mk_vector(Sail_lib.zero_extend(coerce_bvv1,coerce_intv2))|_->failwith"value zero_extend"letvalue_zeros=function[v]->mk_vector(Sail_lib.zeros(coerce_intv))|_->failwith"value zeros"letvalue_ones=function[v]->mk_vector(Sail_lib.ones(coerce_intv))|_->failwith"value ones"letvalue_shiftl=function|[v1;v2]->mk_vector(Sail_lib.shiftl(coerce_bvv1,coerce_intv2))|_->failwith"value shiftl"letvalue_shiftr=function|[v1;v2]->mk_vector(Sail_lib.shiftr(coerce_bvv1,coerce_intv2))|_->failwith"value shiftr"letvalue_arith_shiftr=function|[v1;v2]->mk_vector(Sail_lib.arith_shiftr(coerce_bvv1,coerce_intv2))|_->failwith"value arith_shiftr"letvalue_shift_bits_left=function|[v1;v2]->mk_vector(Sail_lib.shift_bits_left(coerce_bvv1,coerce_bvv2))|_->failwith"value shift_bits_left"letvalue_shift_bits_right=function|[v1;v2]->mk_vector(Sail_lib.shift_bits_right(coerce_bvv1,coerce_bvv2))|_->failwith"value shift_bits_right"letvalue_vector_truncate=function|[v1;v2]->mk_vector(Sail_lib.vector_truncate(coerce_bvv1,coerce_intv2))|_->failwith"value vector_truncate"letvalue_vector_truncateLSB=function|[v1;v2]->mk_vector(Sail_lib.vector_truncateLSB(coerce_bvv1,coerce_intv2))|_->failwith"value vector_truncateLSB"letvalue_eq_anything=function[v1;v2]->V_bool(eq_valuev1v2)|_->failwith"value eq_anything"letvalue_print=function|[V_stringstr]->outputstr;V_unit|[v]->output(string_of_valuev|>Util.red|>Util.clear);V_unit|_->assertfalseletvalue_print_endline=function|[V_stringstr]->output_endlinestr;V_unit|[v]->output_endline(string_of_valuev|>Util.red|>Util.clear);V_unit|_->assertfalseletvalue_internal_pick=function[v1]->List.hd(coerce_listlikev1)|_->failwith"value internal_pick"letvalue_undefined_vector=function|[v1;v2]->V_vector(Sail_lib.undefined_vector(coerce_intv1,v2))|_->failwith"value undefined_vector"letvalue_undefined_list=function[_]->V_list[]|_->failwith"value undefined_list"letvalue_undefined_bitvector=function|[v]->V_vector(Sail_lib.undefined_vector(coerce_intv,V_bitSail_lib.B0))|_->failwith"value undefined_bitvector"letvalue_read_ram=function|[v1;v2;v3;v4]->mk_vector(Sail_lib.read_ram(coerce_intv1,coerce_intv2,coerce_bvv3,coerce_bvv4))|_->failwith"value read_ram"letvalue_write_ram=function|[v1;v2;v3;v4;v5]->letb=Sail_lib.write_ram(coerce_intv1,coerce_intv2,coerce_bvv3,coerce_bvv4,coerce_bvv5)inV_boolb|_->failwith"value write_ram"letvalue_load_raw=function|[v1;v2]->Sail_lib.load_raw(coerce_bvv1,coerce_stringv2);V_unit|_->failwith"value load_raw"letvalue_putchar=function|[v]->output_char!print_chan(char_of_int(Big_int.to_int(coerce_intv)));flush!print_chan;V_unit|_->failwith"value putchar"letvalue_dec_str=function[n]->V_string(string_of_valuen)|_->failwith"value print_int"letvalue_print_bits=function|[msg;bits]->output_endline(coerce_stringmsg^string_of_valuebits);V_unit|_->failwith"value print_bits"letvalue_print_int=function|[msg;n]->output_endline(coerce_stringmsg^string_of_valuen);V_unit|_->failwith"value print_int"letvalue_print_string=function|[msg;str]->output_endline(coerce_stringmsg^coerce_stringstr);V_unit|_->failwith"value print_string"letvalue_prerr_bits=function|[msg;bits]->prerr_endline(coerce_stringmsg^string_of_valuebits);V_unit|_->failwith"value prerr_bits"letvalue_prerr_int=function|[msg;n]->prerr_endline(coerce_stringmsg^string_of_valuen);V_unit|_->failwith"value prerr_int"letvalue_prerr_string=function|[msg;str]->output_endline(coerce_stringmsg^coerce_stringstr);V_unit|_->failwith"value print_string"letvalue_concat_str=function|[v1;v2]->V_string(Sail_lib.concat_str(coerce_stringv1,coerce_stringv2))|_->failwith"value concat_str"letvalue_to_real=function[v]->V_real(Sail_lib.to_real(coerce_intv))|_->failwith"value to_real"letvalue_print_real=function|[v1;v2]->output_endline(coerce_stringv1^string_of_valuev2);V_unit|_->failwith"value print_real"letvalue_random_real=function[_]->V_real(Sail_lib.random_real())|_->failwith"value random_real"letvalue_sqrt_real=function[v]->V_real(Sail_lib.sqrt_real(coerce_realv))|_->failwith"value sqrt_real"letvalue_quotient_real=function|[v1;v2]->V_real(Sail_lib.quotient_real(coerce_realv1,coerce_realv2))|_->failwith"value quotient_real"letvalue_round_up=function[v]->V_int(Sail_lib.round_up(coerce_realv))|_->failwith"value round_up"letvalue_round_down=function[v]->V_int(Sail_lib.round_down(coerce_realv))|_->failwith"value round_down"letvalue_quot_round_zero=function|[v1;v2]->V_int(Sail_lib.quot_round_zero(coerce_intv1,coerce_intv2))|_->failwith"value quot_round_zero"letvalue_rem_round_zero=function|[v1;v2]->V_int(Sail_lib.rem_round_zero(coerce_intv1,coerce_intv2))|_->failwith"value rem_round_zero"letvalue_add_real=function|[v1;v2]->V_real(Sail_lib.add_real(coerce_realv1,coerce_realv2))|_->failwith"value add_real"letvalue_sub_real=function|[v1;v2]->V_real(Sail_lib.sub_real(coerce_realv1,coerce_realv2))|_->failwith"value sub_real"letvalue_mult_real=function|[v1;v2]->V_real(Sail_lib.mult_real(coerce_realv1,coerce_realv2))|_->failwith"value mult_real"letvalue_div_real=function|[v1;v2]->V_real(Sail_lib.div_real(coerce_realv1,coerce_realv2))|_->failwith"value div_real"letvalue_abs_real=function[v]->V_real(Sail_lib.abs_real(coerce_realv))|_->failwith"value abs_real"letvalue_eq_real=function|[v1;v2]->V_bool(Sail_lib.eq_real(coerce_realv1,coerce_realv2))|_->failwith"value eq_real"letvalue_lt_real=function|[v1;v2]->V_bool(Sail_lib.lt_real(coerce_realv1,coerce_realv2))|_->failwith"value lt_real"letvalue_gt_real=function|[v1;v2]->V_bool(Sail_lib.gt_real(coerce_realv1,coerce_realv2))|_->failwith"value gt_real"letvalue_lteq_real=function|[v1;v2]->V_bool(Sail_lib.lteq_real(coerce_realv1,coerce_realv2))|_->failwith"value lteq_real"letvalue_gteq_real=function|[v1;v2]->V_bool(Sail_lib.gteq_real(coerce_realv1,coerce_realv2))|_->failwith"value gteq_real"letvalue_string_append=function|[v1;v2]->V_string(Sail_lib.string_append(coerce_stringv1,coerce_stringv2))|_->failwith"value string_append"letvalue_decimal_string_of_bits=function|[v]->V_string(Sail_lib.decimal_string_of_bits(coerce_bvv))|_->failwith"value decimal_string_of_bits"letvalue_hex_str=function[v]->V_string(Sail_lib.hex_str(coerce_intv))|_->failwith"value hex_str"letvalue_hex_str_upper=function|[v]->V_string(Sail_lib.hex_str_upper(coerce_intv))|_->failwith"value hex_str_upper"letvalue_valid_hex_bits=function|[v1;v2]->V_bool(Sail_lib.valid_hex_bits(coerce_intv1,coerce_stringv2))|_->failwith"value valid_hex_bits"letvalue_parse_hex_bits=function|[v1;v2]->mk_vector(Sail_lib.parse_hex_bits(coerce_intv1,coerce_stringv2))|_->failwith"value parse_hex_bits"letvalue_emulator_read_mem=function|[v1;v2;v3]->mk_vector(Sail_lib.emulator_read_mem(coerce_intv1,coerce_bvv2,coerce_intv3))|_->failwith"value emulator_read_mem"letvalue_emulator_read_mem_ifetch=function|[v1;v2;v3]->mk_vector(Sail_lib.emulator_read_mem_ifetch(coerce_intv1,coerce_bvv2,coerce_intv3))|_->failwith"value emulator_read_mem_ifetch"letvalue_emulator_read_mem_exclusive=function|[v1;v2;v3]->mk_vector(Sail_lib.emulator_read_mem_exclusive(coerce_intv1,coerce_bvv2,coerce_intv3))|_->failwith"value emulator_read_mem_exclusive"letvalue_emulator_write_mem=function|[v1;v2;v3;v4]->V_bool(Sail_lib.emulator_write_mem(coerce_intv1,coerce_bvv2,coerce_intv3,coerce_bvv4))|_->failwith"value emulator_write_mem"letvalue_emulator_write_mem_exclusive=function|[v1;v2;v3;v4]->V_bool(Sail_lib.emulator_write_mem_exclusive(coerce_intv1,coerce_bvv2,coerce_intv3,coerce_bvv4))|_->failwith"value emulator_write_mem_exclusive"letvalue_emulator_read_tag=function|[v1;v2]->V_bool(Sail_lib.emulator_read_tag(coerce_intv1,coerce_bvv2))|_->failwith"value emulator_read_tag"letvalue_emulator_write_tag=function|[v1;v2;v3]->Sail_lib.emulator_write_tag(coerce_intv1,coerce_bvv2,coerce_boolv3);V_unit|_->failwith"value emulator_write_tag"letvalue_cycle_count_=Sail_lib.cycle_count();V_unitletvalue_get_cycle_count_=V_int(Sail_lib.get_cycle_count())letprimops=ref(List.fold_left(funr(x,y)->StringMap.addxyr)StringMap.empty[("and_bool",and_bool);("or_bool",or_bool);("print",value_print);("prerr",funvs->prerr_string(string_of_value(List.hdvs));V_unit);("dec_str",value_dec_str);("print_endline",value_print_endline);("prerr_endline",funvs->prerr_endline(string_of_value(List.hdvs));V_unit);("putchar",value_putchar);("string_of_int",funvs->V_string(string_of_value(List.hdvs)));("string_of_bits",funvs->V_string(string_of_value(List.hdvs)));("decimal_string_of_bits",value_decimal_string_of_bits);("print_bits",value_print_bits);("print_int",value_print_int);("print_string",value_print_string);("prerr_bits",value_print_bits);("prerr_int",value_print_int);("prerr_string",value_prerr_string);("concat_str",value_concat_str);("eq_int",value_eq_int);("lteq",value_lteq);("gteq",value_gteq);("lt",value_lt);("gt",value_gt);("eq_list",value_eq_list);("eq_bool",value_eq_bool);("eq_string",value_eq_string);("string_startswith",value_string_startswith);("string_drop",value_string_drop);("string_take",value_string_take);("string_length",value_string_length);("eq_bit",value_eq_bit);("eq_anything",value_eq_anything);("length",value_length);("subrange",value_subrange);("access",value_access);("update",value_update);("update_subrange",value_update_subrange);("slice",value_slice);("append",value_append);("append_list",value_append_list);("not",value_not);("not_vec",value_not_vec);("and_vec",value_and_vec);("or_vec",value_or_vec);("xor_vec",value_xor_vec);("uint",value_uint);("sint",value_sint);("get_slice_int",value_get_slice_int);("set_slice_int",value_set_slice_int);("set_slice",value_set_slice);("hex_slice",value_hex_slice);("zero_extend",value_zero_extend);("sign_extend",value_sign_extend);("zeros",value_zeros);("ones",value_ones);("shiftr",value_shiftr);("shiftl",value_shiftl);("arith_shiftr",value_arith_shiftr);("shift_bits_left",value_shift_bits_left);("shift_bits_right",value_shift_bits_right);("add_int",value_add_int);("sub_int",value_sub_int);("sub_nat",value_sub_nat);("div_int",value_quotient);("tdiv_int",value_tdiv_int);("tmod_int",value_tmod_int);("mult_int",value_mult);("mult",value_mult);("quotient",value_quotient);("modulus",value_modulus);("negate",value_negate);("pow2",value_pow2);("int_power",value_int_power);("shr_int",value_shr_int);("shl_int",value_shl_int);("max_int",value_max_int);("min_int",value_min_int);("abs_int",value_abs_int);("add_vec_int",value_add_vec_int);("sub_vec_int",value_sub_vec_int);("add_vec",value_add_vec);("sub_vec",value_sub_vec);("vector_truncate",value_vector_truncate);("vector_truncateLSB",value_vector_truncateLSB);("read_ram",value_read_ram);("write_ram",value_write_ram);("emulator_read_mem",value_emulator_read_mem);("emulator_read_mem_ifetch",value_emulator_read_mem);("emulator_read_mem_exclusive",value_emulator_read_mem);("emulator_write_mem",value_emulator_write_mem);("emulator_write_mem_exclusive",value_emulator_write_mem);("emulator_read_tag",value_emulator_read_tag);("emulator_write_tag",value_emulator_write_tag);("cycle_count",value_cycle_count);("get_cycle_count",value_get_cycle_count);("trace_memory_read",fun_->V_unit);("trace_memory_write",fun_->V_unit);("get_time_ns",fun_->V_int(Sail_lib.get_time_ns()));("load_raw",value_load_raw);("to_real",value_to_real);("eq_real",value_eq_real);("lt_real",value_lt_real);("gt_real",value_gt_real);("lteq_real",value_lteq_real);("gteq_real",value_gteq_real);("add_real",value_add_real);("sub_real",value_sub_real);("mult_real",value_mult_real);("round_up",value_round_up);("round_down",value_round_down);("quot_round_zero",value_quot_round_zero);("rem_round_zero",value_rem_round_zero);("quotient_real",value_quotient_real);("abs_real",value_abs_real);("div_real",value_div_real);("sqrt_real",value_sqrt_real);("print_real",value_print_real);("random_real",value_random_real);("undefined_unit",fun_->V_unit);("undefined_bit",fun_->V_bitSail_lib.B0);("undefined_int",fun_->V_intBig_int.zero);("undefined_nat",fun_->V_intBig_int.zero);("undefined_bool",fun_->V_boolfalse);("undefined_bitvector",value_undefined_bitvector);("undefined_vector",value_undefined_vector);("undefined_list",value_undefined_list);("undefined_string",fun_->V_string"");("internal_pick",value_internal_pick);("replicate_bits",value_replicate_bits);("count_leading_zeros",value_count_leading_zeros);("Elf_loader.elf_entry",fun_->V_int!Elf_loader.opt_elf_entry);("Elf_loader.elf_tohost",fun_->V_int!Elf_loader.opt_elf_tohost);("string_append",value_string_append);("string_length",value_string_length);("string_startswith",value_string_startswith);("string_drop",value_string_drop);("hex_str",value_hex_str);("hex_str_upper",value_hex_str_upper);("parse_hex_bits",value_parse_hex_bits);("valid_hex_bits",value_valid_hex_bits);("skip",fun_->V_unit);])letadd_primopnameimpl=primops:=StringMap.addnameimpl!primops