123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484(****************************************************************************)(* 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_numtypetext=stringtypel=|Unknown|Uniqueofint*l|Generatedofl|Hintofstring*l*l|RangeofLexing.position*Lexing.position(** We put the attribute data type in it's own module, so other
modules can import it unqualified. The parse AST and the main AST
share this type, so modules that wouldn't normally import this
module will want to use it. *)moduleAttribute_data=structtypeattribute_data_aux=|AD_objectof(string*attribute_data)list|AD_listofattribute_datalist|AD_numofBig_int.num|AD_stringofstring|AD_boolofbool(** JSON-style data structure for attributes *)andattribute_data=AD_auxofattribute_data_aux*lendopenAttribute_datatype'aannot=l*'atypeextern={pure:bool;bindings:(string*string)list}exceptionParse_error_locnofl*stringtypex=text(* identifier *)typeix=text(* infix identifier *)typekind_aux=|(* base kind *)K_type(* kind of types *)|K_int(* kind of natural number size expressions *)|K_order(* kind of vector order specifications *)|K_bool(* kind of constraints *)typekind=K_auxofkind_aux*ltypekid_aux=(* identifiers with kind, ticked to differentiate from program variables *)|Varofxtypeid_aux=(* Identifier *)|Idofx|Operatorofx(* remove infix status *)typekid=Kid_auxofkid_aux*ltypeid=Id_auxofid_aux*ltype'ainfix_token=IT_primaryof'a|IT_opofid|IT_prefixofidtypelit_aux=|(* Literal constant *)L_unit(* $() : _$ *)|L_zero(* $_ : _$ *)|L_one(* $_ : _$ *)|L_true(* $_ : _$ *)|L_false(* $_ : _$ *)|L_numofBig_int.num(* natural number constant *)|L_hexofstring(* bit vector constant, C-style *)|L_binofstring(* bit vector constant, C-style *)|L_undef(* undefined value *)|L_stringofstring(* string constant *)|L_realofstringtypelit=L_auxoflit_aux*ltypeatyp_aux=(* expressions of all kinds, to be translated to types, nats, orders, and effects after parsing *)|ATyp_idofid(* identifier *)|ATyp_varofkid(* ticked variable *)|ATyp_litoflit(* literal *)|ATyp_nsetofBig_int.numlist(* set type *)|ATyp_inofatyp*atyp(* set type *)|ATyp_timesofatyp*atyp(* product *)|ATyp_sumofatyp*atyp(* sum *)|ATyp_minusofatyp*atyp(* subtraction *)|ATyp_expofatyp(* exponential *)|ATyp_negofatyp(* Internal (but not M as I want a datatype constructor) negative nexp *)|ATyp_infixof(atypinfix_token*Lexing.position*Lexing.position)list|ATyp_inc(* increasing *)|ATyp_dec(* decreasing *)|ATyp_setofidlist(* effect set *)|ATyp_fnofatyp*atyp*atyp(* Function type, last atyp is an effect *)|ATyp_bidirofatyp*atyp*atyp(* Mapping type, last atyp is an effect *)|ATyp_wild|ATyp_tupleofatyplist(* Tuple type *)|ATyp_appofid*atyplist(* type constructor application *)|ATyp_ifofatyp*atyp*atyp|ATyp_existofkinded_idlist*atyp*atyp|ATyp_parensofatypandatyp=ATyp_auxofatyp_aux*landkinded_id_aux=(* optionally kind-annotated identifier *)|KOpt_kindofstringoption*kidlist*kindoption*intoption(* kind-annotated variable *)andkinded_id=KOpt_auxofkinded_id_aux*ltypequant_item_aux=(* Either a kinded identifier or a nexp constraint for a typquant *)|QI_idofkinded_id(* An optionally kinded identifier *)|QI_constraintofatyp(* A constraint for this type *)typequant_item=QI_auxofquant_item_aux*ltypetypquant_aux=(* type quantifiers and constraints *)|TypQ_tqofquant_itemlist|TypQ_no_forall(* sugar, omitting quantifier and constraints *)typetypquant=TypQ_auxoftypquant_aux*ltypetypschm_aux=(* type scheme *)|TypSchm_tsoftypquant*atyptypetypschm=TypSchm_auxoftypschm_aux*ltypepat_aux=(* Pattern *)|P_litoflit(* literal constant pattern *)|P_wild(* wildcard - always matches *)|P_typofatyp*pat(* typed pattern *)|P_idofid(* identifier *)|P_varofpat*atyp(* bind pat to type variable *)|P_appofid*patlist(* union constructor pattern *)|P_vectorofpatlist(* vector pattern *)|P_vector_concatofpatlist(* concatenated vector pattern *)|P_vector_subrangeofid*Big_int.num*Big_int.num|P_tupleofpatlist(* tuple pattern *)|P_listofpatlist(* list pattern *)|P_consofpat*pat(* cons pattern *)|P_string_appendofpatlist(* string append pattern, x ^^ y *)|P_structoffpatlist(* struct pattern *)|P_attributeofstring*attribute_dataoption*patandpat=P_auxofpat_aux*landfpat_aux=(* Field pattern *)|FP_fieldofid*pat|FP_wildandfpat=FP_auxoffpat_aux*ltypeloop=While|Untiltypeif_loc={if_loc:l;then_loc:l;else_loc:loption}typemeasure_aux=(* optional termination measure for a loop *)|Measure_none|Measure_someofexpandmeasure=Measure_auxofmeasure_aux*landexp_aux=(* Expression *)|E_blockofexplist(* block (parsing conflict with structs?) *)|E_idofid(* identifier *)|E_refofid|E_derefofexp|E_litoflit(* literal constant *)|E_typofatyp*exp(* cast *)|E_appofid*explist(* function application *)|E_app_infixofexp*id*exp(* infix function application *)|E_infixof(expinfix_token*Lexing.position*Lexing.position)list|E_tupleofexplist(* tuple *)|E_ifofexp*exp*exp*if_loc(* conditional *)|E_loopofloop*measure*exp*exp|E_forofid*exp*exp*exp*atyp*exp(* loop *)|E_vectorofexplist(* vector (indexed from 0) *)|E_vector_accessofexp*exp(* vector access *)|E_vector_subrangeofexp*exp*exp(* subvector extraction *)|E_vector_updateofexp*exp*exp(* vector functional update *)|E_vector_update_subrangeofexp*exp*exp*exp(* vector subrange update (with vector) *)|E_vector_appendofexp*exp(* vector concatenation *)|E_listofexplist(* list *)|E_consofexp*exp(* cons *)|E_structofexplist(* struct *)|E_struct_updateofexp*explist(* functional update of struct *)|E_fieldofexp*id(* field projection from struct *)|E_matchofexp*pexplist(* pattern matching *)|E_letofletbind*exp(* let expression *)|E_assignofexp*exp(* imperative assignment *)|E_sizeofofatyp|E_constraintofatyp|E_exitofexp|E_throwofexp|E_tryofexp*pexplist|E_returnofexp|E_assertofexp*exp|E_varofexp*exp*exp|E_attributeofstring*attribute_dataoption*exp|E_internal_pletofpat*exp*exp|E_internal_returnofexp|E_internal_assumeofatyp*expandexp=E_auxofexp_aux*landopt_default_aux=|(* Optional default value for indexed vectors, to define a default value for any unspecified positions in a sparse map *)Def_val_empty|Def_val_decofexpandopt_default=Def_val_auxofopt_default_aux*landpexp_aux=(* Pattern match *)|Pat_expofpat*exp|Pat_whenofpat*exp*expandpexp=Pat_auxofpexp_aux*landletbind_aux=(* Let binding *)|LB_valofpat*exp(* value binding, implicit type (pat must be total) *)andletbind=LB_auxofletbind_aux*ltypetannot_opt_aux=|(* Optional type annotation for functions *)Typ_annot_opt_none|Typ_annot_opt_someoftypquant*atyptypetypschm_opt_aux=TypSchm_opt_none|TypSchm_opt_someoftypschmtypetypschm_opt=TypSchm_opt_auxoftypschm_opt_aux*ltypeeffect_opt_aux=|(* Optional effect annotation for functions *)Effect_opt_none(* sugar for empty effect set *)|Effect_opt_effectofatyptyperec_opt_aux=|(* Optional recursive annotation for functions *)Rec_none(* no termination measure *)|Rec_measureofpat*exp(* recursive with termination measure *)typefuncl=FCL_auxoffuncl_aux*landfuncl_aux=(* Function clause *)|FCL_privateoffuncl|FCL_attributeofstring*attribute_dataoption*funcl|FCL_docofstring*funcl|FCL_funclofid*pexptypetype_union=Tu_auxoftype_union_aux*landtype_union_aux=(* Type union constructors *)|Tu_privateoftype_union|Tu_attributeofstring*attribute_dataoption*type_union|Tu_docofstring*type_union|Tu_ty_idofatyp*id|Tu_ty_anon_recof(atyp*id)list*idtypetannot_opt=Typ_annot_opt_auxoftannot_opt_aux*ltypeeffect_opt=Effect_opt_auxofeffect_opt_aux*ltyperec_opt=Rec_auxofrec_opt_aux*ltypesubst_aux=(* instantiation substitution *)|IS_typofkid*atyp(* instantiate a type variable with a type *)|IS_idofid*id(* instantiate an identifier with another identifier *)typesubst=IS_auxofsubst_aux*ltypeindex_range_aux=(* index specification, for bitfields in register types *)|BF_singleofatyp(* single index *)|BF_rangeofatyp*atyp(* index range *)|BF_concatofindex_range*index_range(* concatenation of index ranges *)andindex_range=BF_auxofindex_range_aux*ltypedefault_typing_spec_aux=(* Default kinding or typing assumption, and default order for literal vectors and vector shorthands *)|DT_orderofkind*atyptypempat_aux=(* Mapping pattern. Mostly the same as normal patterns but only constructible parts *)|MP_litoflit|MP_idofid|MP_appofid*mpatlist|MP_vectorofmpatlist|MP_vector_concatofmpatlist|MP_vector_subrangeofid*Big_int.num*Big_int.num|MP_tupleofmpatlist|MP_listofmpatlist|MP_consofmpat*mpat|MP_string_appendofmpatlist|MP_typofmpat*atyp|MP_asofmpat*id|MP_structof(id*mpat)listandmpat=MP_auxofmpat_aux*ltypempexp_aux=MPat_patofmpat|MPat_whenofmpat*exptypempexp=MPat_auxofmpexp_aux*ltypemapcl=MCL_auxofmapcl_aux*landmapcl_aux=(* mapping clause (bidirectional pattern-match) *)|MCL_attributeofstring*attribute_dataoption*mapcl|MCL_docofstring*mapcl|MCL_bidirofmpexp*mpexp|MCL_forwards_deprecatedofmpexp*exp|MCL_forwardsofpexp|MCL_backwardsofpexptypemapdef_aux=(* mapping definition (bidirectional pattern-match function) *)|MD_mappingofid*typschm_opt*mapcllisttypemapdef=MD_auxofmapdef_aux*ltypeoutcome_spec_aux=(* outcome declaration *)|OV_outcomeofid*typschm*kinded_idlisttypeoutcome_spec=OV_auxofoutcome_spec_aux*ltypefundef_aux=(* Function definition *)|FD_functionofrec_opt*tannot_opt*effect_opt*funcllisttypetype_def_aux=(* Type definition body *)|TD_abbrevofid*typquant*kindoption*atyp(* type abbreviation *)|TD_recordofid*typquant*(atyp*id)list(* struct type definition *)|TD_variantofid*typquant*type_unionlist(* union type definition *)|TD_enumofid*(id*atyp)list*(id*expoption)list(* enumeration type definition *)|TD_abstractofid*kind|TD_bitfieldofid*atyp*(id*index_range)list(* register mutable bitfield type definition *)typeval_spec_aux=(* Value type specification *)|VS_val_specoftypschm*id*externoptiontypedec_spec_aux=(* Register declarations *)|DEC_regofatyp*id*expoptiontypescattered_def_aux=(* Function and type union definitions that can be spread across
a file. Each one must end in $_$ *)|SD_functionofrec_opt*tannot_opt*effect_opt*id(* scattered function definition header *)|SD_funcloffuncl(* scattered function definition clause *)|SD_enumofid(* scattered enumeration definition header *)|SD_enumclofid*id(* scattered enumeration member clause *)|SD_variantofid*typquant(* scattered union definition header *)|SD_unionclofid*type_union(* scattered union definition member *)|SD_mappingofid*tannot_opt|SD_mapclofid*mapcl|SD_endofid(* scattered definition end *)typedefault_typing_spec=DT_auxofdefault_typing_spec_aux*ltypefundef=FD_auxoffundef_aux*ltypetype_def=TD_auxoftype_def_aux*ltypeval_spec=VS_auxofval_spec_aux*ltypedec_spec=DEC_auxofdec_spec_aux*ltypeloop_measure=Loopofloop*exptypescattered_def=SD_auxofscattered_def_aux*ltypeprec=Infix|InfixL|InfixRtypefixity_token=prec*Big_int.num*stringtypedef_aux=(* Top-level definition *)|DEF_typeoftype_def(* type definition *)|DEF_constraintofatyp(* global constraint *)|DEF_fundefoffundef(* function definition *)|DEF_mapdefofmapdef(* mapping definition *)|DEF_imploffuncl(* impl definition *)|DEF_letofletbind(* value definition *)|DEF_overloadofid*idlist(* operator overload specifications *)|DEF_fixityofprec*Big_int.num*id(* fixity declaration *)|DEF_valofval_spec(* top-level type constraint *)|DEF_outcomeofoutcome_spec*deflist(* top-level outcome definition *)|DEF_instantiationofid*substlist(* instantiation *)|DEF_defaultofdefault_typing_spec(* default kind and type assumptions *)|DEF_scatteredofscattered_def(* scattered definition *)|DEF_measureofid*pat*exp(* separate termination measure declaration *)|DEF_loop_measuresofid*loop_measurelist(* separate termination measure declaration *)|DEF_registerofdec_spec(* register declaration *)|DEF_pragmaofstring*string*int|DEF_privateofdef|DEF_attributeofstring*attribute_dataoption*def|DEF_docofstring*def|DEF_internal_mutrecoffundeflistanddef=DEF_auxofdef_aux*ltypelexp_aux=(* lvalue expression, can't occur out of the parser *)|LE_idofid(* identifier *)|LE_memofid*explist|LE_vectoroflexp*exp(* vector element *)|LE_vector_rangeoflexp*exp*exp(* subvector *)|LE_vector_concatoflexplist|LE_fieldoflexp*id(* struct field *)andlexp=LE_auxoflexp_aux*ltypedefs=(* Definition sequence *)|Defsof(string*deflist)list