<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" encoding="UTF-8" href="iform.xsl" version="1.0"?>
<!DOCTYPE instructionsection PUBLIC "-//ARM//DTD instructionsection //EN" "sharedps.dtd">
<!-- Copyright (c) 2010-2022 Arm Limited or its affiliates. All rights reserved. -->
<!-- This document is Non-Confidential. This document may only be used and distributed in accordance with the terms of the agreement entered into by Arm and the party that Arm delivered this document to. -->

<instructionsection id="shared_pseudocode" title="AArch32 Instruction Summary -- Shared Pseudocode" type="pseudocode">
  <heading>Shared Pseudocode Functions</heading>
  <desc>
    <brief>This page displays common pseudocode functions shared by many pages</brief>
  </desc>
  <ps_section howmany="1677">
    <ps name="aarch32/at/AArch32.AT" mylink="aarch32.at.AArch32.AT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.AT()
// ============
// Perform address translation as per AT instructions.

<anchor link="AArch32.AT.4" hover="function: AArch32.AT(bits(32) vaddress, TranslationStage stage_in, bits(2) el, ATAccess ataccess)">AArch32.AT</anchor>(bits(32) vaddress, <a link="TranslationStage" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage</a> stage_in, bits(2) el, <a link="ATAccess" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess</a> ataccess)
    <a link="TranslationStage" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage</a> stage = stage_in;
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss;
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime;
    boolean eae;

    // ATS1Hx instructions
    if el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        regime = <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>;
        eae = TRUE;
        ss = <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;

    // ATS1Cxx instructions
    elsif stage == <a link="TranslationStage_1" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_1</a> || (stage == <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a> &amp;&amp; !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>)) then
        stage = <a link="TranslationStage_1" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_1</a>;
        ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);
        regime = if ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> else <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
        eae = TTBCR.EAE == '1';

    // ATS12NSOxx instructions
    else
        regime = <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
        eae = if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then TTBCR_NS.EAE == '1' else TTBCR.EAE == '1';
        ss = <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc;
    <a link="SDFType" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</a> sdftype;
    boolean aligned = TRUE;
    bit supersection = '0';

    boolean write = ataccess IN {<a link="ATAccess_WritePAN" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_WritePAN</a>, <a link="ATAccess_Write" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_Write</a>};
    boolean pan   = ataccess IN {<a link="ATAccess_WritePAN" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_WritePAN</a>, <a link="ATAccess_ReadPAN" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_ReadPAN</a>};
    accdesc = <a link="impl-shared.CreateAccDescAT.4" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescAT(SecurityState ss, bits(2) el, boolean write, boolean pan)">CreateAccDescAT</a>(ss, el, write, pan);

    // Prepare fault fields in case a fault is detected
    fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);

    if eae then
        (fault, addrdesc) = <a link="AArch32.S1TranslateLD.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1TranslateLD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateLD</a>(fault, regime, vaddress, aligned, accdesc);
    else
        (fault, addrdesc, sdftype) = <a link="AArch32.S1TranslateSD.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor, SDFType) AArch32.S1TranslateSD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateSD</a>(fault, regime, vaddress, aligned,
                                                           accdesc);
        supersection = if sdftype == <a link="SDFType_Supersection" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Supersection</a> then '1' else '0';

    // ATS12NSOxx instructions
    if stage == <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a> &amp;&amp; fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        (fault, addrdesc) = <a link="AArch32.S2Translate.4" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean aligned, AccessDescriptor accdesc)">AArch32.S2Translate</a>(fault, addrdesc, aligned, accdesc);

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        // Take exception on External abort or when a fault occurs on translation table walk
        if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) || (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; fault.s2fs1walk) then
            PAR = bits(64) UNKNOWN;
            <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(vaddress, fault);

    addrdesc.fault = fault;

    if (eae || (stage == <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a> &amp;&amp; (HCR.VM == '1' || HCR.DC == '1'))
            || (stage == <a link="TranslationStage_1" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_1</a> &amp;&amp; el != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>)) then
        <a link="AArch32.EncodePARLD.2" file="shared_pseudocode.xml" hover="function: AArch32.EncodePARLD(AddressDescriptor addrdesc, SecurityState ss)">AArch32.EncodePARLD</a>(addrdesc, ss);
    else
        <a link="AArch32.EncodePARSD.3" file="shared_pseudocode.xml" hover="function: AArch32.EncodePARSD(AddressDescriptor addrdesc_in, bit supersection, SecurityState ss)">AArch32.EncodePARSD</a>(addrdesc, supersection, ss);
    return;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.EncodePARLD" mylink="aarch32.at.AArch32.EncodePARLD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EncodePARLD()
// =====================
// Returns 64-bit format PAR on address translation instruction.

<anchor link="AArch32.EncodePARLD.2" hover="function: AArch32.EncodePARLD(AddressDescriptor addrdesc, SecurityState ss)">AArch32.EncodePARLD</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)

    if !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(addrdesc) then
        bit ns;
        if ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
            ns = bit UNKNOWN;
        elsif addrdesc.paddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
            ns = '0';
        else
            ns = '1';
        PAR.F      = '0';
        PAR.SH     = <a link="impl-shared.ReportedPARShareability.1" file="shared_pseudocode.xml" hover="function: bits(2) ReportedPARShareability(bits(2) sh)">ReportedPARShareability</a>(<a link="impl-shared.PAREncodeShareability.1" file="shared_pseudocode.xml" hover="function: bits(2) PAREncodeShareability(MemoryAttributes memattrs)">PAREncodeShareability</a>(addrdesc.memattrs));
        PAR.NS     = ns;
        PAR&lt;10&gt;    = bit IMPLEMENTATION_DEFINED "Non-Faulting PAR";               // IMPDEF
        PAR.LPAE   = '1';
        PAR.PA     = addrdesc.paddress.address&lt;39:12&gt;;
        PAR.ATTR   = <a link="impl-shared.ReportedPARAttrs.1" file="shared_pseudocode.xml" hover="function: bits(8) ReportedPARAttrs(bits(8) parattrs)">ReportedPARAttrs</a>(<a link="impl-shared.EncodePARAttrs.1" file="shared_pseudocode.xml" hover="function: bits(8) EncodePARAttrs(MemoryAttributes memattrs)">EncodePARAttrs</a>(addrdesc.memattrs));
    else
        PAR.F      = '1';
        PAR.FST    = <a link="AArch32.PARFaultStatusLD.1" file="shared_pseudocode.xml" hover="function: bits(6) AArch32.PARFaultStatusLD(FaultRecord fault)">AArch32.PARFaultStatusLD</a>(addrdesc.fault);
        PAR.S2WLK  = if addrdesc.fault.s2fs1walk then '1' else '0';
        PAR.FSTAGE = if addrdesc.fault.secondstage then '1' else '0';
        PAR.LPAE   = '1';
        PAR&lt;63:48&gt; = bits(16) IMPLEMENTATION_DEFINED "Faulting PAR";              // IMPDEF
    return;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.EncodePARSD" mylink="aarch32.at.AArch32.EncodePARSD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EncodePARSD()
// =====================
// Returns 32-bit format PAR on address translation instruction.

<anchor link="AArch32.EncodePARSD.3" hover="function: AArch32.EncodePARSD(AddressDescriptor addrdesc_in, bit supersection, SecurityState ss)">AArch32.EncodePARSD</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc_in, bit supersection, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc = addrdesc_in;
    if !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(addrdesc) then
        if (addrdesc.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> ||
                (addrdesc.memattrs.inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp;
                 addrdesc.memattrs.outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>)) then
            addrdesc.memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        bit ns;
        if ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
            ns = bit UNKNOWN;
        elsif addrdesc.paddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
            ns = '0';
        else
            ns = '1';
        bits(2) sh = if addrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then '01' else '00';
        PAR.F      = '0';
        PAR.SS     = supersection;
        PAR.Outer  = <a link="AArch32.ReportedOuterAttrs.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch32.ReportedOuterAttrs(bits(2) attrs)">AArch32.ReportedOuterAttrs</a>(<a link="AArch32.PAROuterAttrs.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch32.PAROuterAttrs(MemoryAttributes memattrs)">AArch32.PAROuterAttrs</a>(addrdesc.memattrs));
        PAR.Inner  = <a link="AArch32.ReportedInnerAttrs.1" file="shared_pseudocode.xml" hover="function: bits(3) AArch32.ReportedInnerAttrs(bits(3) attrs)">AArch32.ReportedInnerAttrs</a>(<a link="AArch32.PARInnerAttrs.1" file="shared_pseudocode.xml" hover="function: bits(3) AArch32.PARInnerAttrs(MemoryAttributes memattrs)">AArch32.PARInnerAttrs</a>(addrdesc.memattrs));
        PAR.SH     = <a link="impl-shared.ReportedPARShareability.1" file="shared_pseudocode.xml" hover="function: bits(2) ReportedPARShareability(bits(2) sh)">ReportedPARShareability</a>(sh);
        PAR&lt;8&gt;     = bit IMPLEMENTATION_DEFINED "Non-Faulting PAR";               // IMPDEF
        PAR.NS     = ns;
        PAR.NOS    = if addrdesc.memattrs.shareability == <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> then '0' else '1';
        PAR.LPAE   = '0';
        PAR.PA     = addrdesc.paddress.address&lt;39:12&gt;;
    else
        PAR.F      = '1';
        PAR.FST    = <a link="AArch32.PARFaultStatusSD.1" file="shared_pseudocode.xml" hover="function: bits(6) AArch32.PARFaultStatusSD(FaultRecord fault)">AArch32.PARFaultStatusSD</a>(addrdesc.fault);
        PAR.LPAE   = '0';
        PAR&lt;31:16&gt; = bits(16) IMPLEMENTATION_DEFINED "Faulting PAR";              // IMPDEF
    return;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.PARFaultStatusLD" mylink="aarch32.at.AArch32.PARFaultStatusLD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PARFaultStatusLD()
// ==========================
// Fault status field decoding of 64-bit PAR

bits(6) <anchor link="AArch32.PARFaultStatusLD.1" hover="function: bits(6) AArch32.PARFaultStatusLD(FaultRecord fault)">AArch32.PARFaultStatusLD</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    bits(6) syndrome;

    if fault.statuscode == <a link="Fault_Domain" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Domain</a> then
        // Report Domain fault
        assert fault.level IN {1,2};
        syndrome&lt;1:0&gt; = if fault.level == 1 then '01' else '10';
        syndrome&lt;5:2&gt; = '1111';
    else
        syndrome = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level);
    return syndrome;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.PARFaultStatusSD" mylink="aarch32.at.AArch32.PARFaultStatusSD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PARFaultStatusSD()
// ==========================
// Fault status field decoding of 32-bit PAR.

bits(6) <anchor link="AArch32.PARFaultStatusSD.1" hover="function: bits(6) AArch32.PARFaultStatusSD(FaultRecord fault)">AArch32.PARFaultStatusSD</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    bits(6) syndrome;

    syndrome&lt;5&gt; = if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then fault.extflag else '0';
    syndrome&lt;4:0&gt; = <a link="impl-aarch32.EncodeSDFSC.2" file="shared_pseudocode.xml" hover="function: bits(5) EncodeSDFSC(Fault statuscode, integer level)">EncodeSDFSC</a>(fault.statuscode, fault.level);
    return syndrome;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.PARInnerAttrs" mylink="aarch32.at.AArch32.PARInnerAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PARInnerAttrs()
// =======================
// Convert orthogonal attributes and hints to 32-bit PAR Inner field.

bits(3) <anchor link="AArch32.PARInnerAttrs.1" hover="function: bits(3) AArch32.PARInnerAttrs(MemoryAttributes memattrs)">AArch32.PARInnerAttrs</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    bits(3) result;

    if memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
        if memattrs.device == <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a> then
            result = '001'; // Non-cacheable
        elsif memattrs.device == <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a> then
            result = '011'; // Non-cacheable
    else
        <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> inner = memattrs.inner;
        if inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
            result = '000'; // Non-cacheable
        elsif inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp; inner.hints&lt;0&gt; == '1' then
            result = '101'; // Write-Back, Write-Allocate
        elsif inner.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> then
            result = '110'; // Write-Through
        elsif inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp; inner.hints&lt;0&gt; == '0' then
            result = '111'; // Write-Back, no Write-Allocate
    return result;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.PAROuterAttrs" mylink="aarch32.at.AArch32.PAROuterAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PAROuterAttrs()
// =======================
// Convert orthogonal attributes and hints to 32-bit PAR Outer field.

bits(2) <anchor link="AArch32.PAROuterAttrs.1" hover="function: bits(2) AArch32.PAROuterAttrs(MemoryAttributes memattrs)">AArch32.PAROuterAttrs</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    bits(2) result;

    if memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
        result = bits(2) UNKNOWN;
    else
        <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> outer = memattrs.outer;
        if outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
            result = '00'; // Non-cacheable
        elsif outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp; outer.hints&lt;0&gt; == '1' then
            result = '01'; // Write-Back, Write-Allocate
        elsif outer.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> &amp;&amp; outer.hints&lt;0&gt; == '0' then
            result = '10'; // Write-Through, no Write-Allocate
        elsif outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp; outer.hints&lt;0&gt; == '0' then
            result = '11'; // Write-Back, no Write-Allocate
    return result;</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.ReportedInnerAttrs" mylink="aarch32.at.AArch32.ReportedInnerAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ReportedInnerAttrs()
// ============================
// The value returned in this field can be the resulting attribute, as determined by any permitted
// implementation choices and any applicable configuration bits, instead of the value that appears
// in the translation table descriptor.

bits(3) <anchor link="AArch32.ReportedInnerAttrs.1" hover="function: bits(3) AArch32.ReportedInnerAttrs(bits(3) attrs)">AArch32.ReportedInnerAttrs</anchor>(bits(3) attrs);</pstext>
    </ps>
    <ps name="aarch32/at/AArch32.ReportedOuterAttrs" mylink="aarch32.at.AArch32.ReportedOuterAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ReportedOuterAttrs()
// ============================
// The value returned in this field can be the resulting attribute, as determined by any permitted
// implementation choices and any applicable configuration bits, instead of the value that appears
// in the translation table descriptor.

bits(2) <anchor link="AArch32.ReportedOuterAttrs.1" hover="function: bits(2) AArch32.ReportedOuterAttrs(bits(2) attrs)">AArch32.ReportedOuterAttrs</anchor>(bits(2) attrs);</pstext>
    </ps>
    <ps name="aarch32/dc/AArch32.DC" mylink="aarch32.dc.AArch32.DC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DC()
// ============
// Perform Data Cache Operation.

<anchor link="AArch32.DC.3" hover="function: AArch32.DC(bits(32) regval, CacheOp cacheop, CacheOpScope opscope)">AArch32.DC</anchor>(bits(32) regval, <a link="CacheOp" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp</a> cacheop, <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    <a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache;

    cache.acctype   = <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>;
    cache.cacheop   = cacheop;
    cache.opscope   = opscope;
    cache.cachetype = <a link="CacheType_Data" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data</a>;
    cache.security  = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);

    if opscope == <a link="CacheOpScope_SetWay" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_SetWay</a> then
        cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        (cache.set, cache.way, cache.level) = <a link="impl-shared.DecodeSW.2" file="shared_pseudocode.xml" hover="function: (integer, integer, integer) DecodeSW(bits(64) regval, CacheType cachetype)">DecodeSW</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(regval, 64), <a link="CacheType_Data" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data</a>);

        if (cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
            ((!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (HCR_EL2.SWIO == '1' || HCR_EL2.&lt;DC,VM&gt; != '00')) ||
              (<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (HCR.SWIO == '1' || HCR.&lt;DC,VM&gt; != '00')))) then
            cache.cacheop = <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a>;
        <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
        return;

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
            cache.is_vmid_valid = TRUE;
            cache.vmid          = VMID[];
        else
            cache.is_vmid_valid = FALSE;
    else
        cache.is_vmid_valid = FALSE;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        cache.is_asid_valid = TRUE;
        cache.asid          = <a link="impl-shared.ASID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) ASID[]">ASID</a>[];
    else
        cache.is_asid_valid = FALSE;

    need_translate = <a link="impl-shared.DCInstNeedsTranslation.1" file="shared_pseudocode.xml" hover="function: boolean DCInstNeedsTranslation(CacheOpScope opscope)">DCInstNeedsTranslation</a>(opscope);
    vaddress = regval;

    size = 0;        // by default no watchpoint address
    if cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> then
        size = integer IMPLEMENTATION_DEFINED "Data Cache Invalidate Watchpoint Size";
        assert size &gt;= 4*(2^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(CTR_EL0.DminLine))) &amp;&amp; size &lt;= 2048;
        assert <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(size&lt;32:0&gt; AND (size-1)&lt;32:0&gt;) == 0; // size is power of 2
        vaddress = <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(regval, size);

    cache.translated = need_translate;
    cache.vaddress   = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress, 64);

    if need_translate then
        boolean aligned = TRUE;
        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescDC.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescDC(CacheRecord cache)">CreateAccDescDC</a>(cache);
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch32.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</a>(vaddress, accdesc, aligned, size);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
            <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(regval, memaddrdesc.fault);

        cache.paddress = memaddrdesc.paddress;
        if opscope == <a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a> then
            cache.shareability = memaddrdesc.memattrs.shareability;
        else
            cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
    else
        cache.shareability = <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> UNKNOWN;
        cache.paddress     = <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> UNKNOWN;

    if (cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
            ((!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR_EL2.&lt;DC,VM&gt; != '00') ||
              (<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR.&lt;DC,VM&gt; != '00'))) then
        cache.cacheop = <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a>;

    <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
    return;</pstext>
    </ps>
    <ps name="aarch32/debug/VCRMatch/AArch32.VCRMatch" mylink="aarch32.debug.VCRMatch.AArch32.VCRMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.VCRMatch()
// ==================

boolean <anchor link="AArch32.VCRMatch.1" hover="function: boolean AArch32.VCRMatch(bits(32) vaddress)">AArch32.VCRMatch</anchor>(bits(32) vaddress)

    boolean match;
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; PSTATE.EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        // Each bit position in this string corresponds to a bit in DBGVCR and an exception vector.
        match_word = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);

        ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
        if vaddress&lt;31:5&gt; == <a link="impl-aarch32.ExcVectorBase.0" file="shared_pseudocode.xml" hover="function: bits(32) ExcVectorBase()">ExcVectorBase</a>()&lt;31:5&gt; then
            if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
                match_word&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;4:2&gt;) + 24&gt; = '1';     // Non-secure vectors
            else
                match_word&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;4:2&gt;) + 0&gt; = '1';      // Secure vectors (or no EL3)

        if (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; vaddress&lt;31:5&gt; == MVBAR&lt;31:5&gt; &amp;&amp;
            ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then
            match_word&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;4:2&gt;) + 8&gt; = '1';          // Monitor vectors

        // Mask out bits not corresponding to vectors.
        bits(32) mask;
        if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            mask = '00000000':'00000000':'00000000':'11011110'; // DBGVCR[31:8] are RES0
        elsif !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            mask = '11011110':'00000000':'00000000':'11011110'; // DBGVCR[15:8] are RES0
        else
            mask = '11011110':'00000000':'11011100':'11011110';

        match_word = match_word AND DBGVCR AND mask;
        match = !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(match_word);

        // Check for UNPREDICTABLE case - match on Prefetch Abort and Data Abort vectors
        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(match_word&lt;28:27,12:11,4:3&gt;) &amp;&amp; <a link="impl-shared.DebugTarget.0" file="shared_pseudocode.xml" hover="function: bits(2) DebugTarget()">DebugTarget</a>() == PSTATE.EL then
            match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_VCMATCHDAPA" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_VCMATCHDAPA</a>);

        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(vaddress&lt;1:0&gt;) &amp;&amp; match then
            match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_VCMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_VCMATCHHALF</a>);
    else
        match = FALSE;

    return match;</pstext>
    </ps>
    <ps name="aarch32/debug/authentication/AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled" mylink="aarch32.debug.authentication.AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled()
// ========================================================

boolean <anchor link="AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled.0" hover="function: boolean AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled()">AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled</anchor>()
    // The definition of this function is IMPLEMENTATION DEFINED.
    // In the recommended interface, AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled returns
    // the state of the (DBGEN AND SPIDEN) signal.
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.NonSecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean NonSecureOnlyImplementation()">NonSecureOnlyImplementation</a>() then return FALSE;
    return DBGEN == HIGH &amp;&amp; SPIDEN == HIGH;</pstext>
    </ps>
    <ps name="aarch32/debug/breakpoint/AArch32.BreakpointMatch" mylink="aarch32.debug.breakpoint.AArch32.BreakpointMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.BreakpointMatch()
// =========================
// Breakpoint matching in an AArch32 translation regime.

(boolean,boolean) <anchor link="AArch32.BreakpointMatch.4" hover="function: (boolean,boolean) AArch32.BreakpointMatch(integer n, bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.BreakpointMatch</anchor>(integer n, bits(32) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                          integer size)
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    assert n &lt; <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>();

    enabled    = DBGBCR[n].E == '1';
    isbreakpnt = TRUE;
    linked     = DBGBCR[n].BT IN {'0x01'};
    linked_to  = FALSE;

    state_match = <a link="AArch32.StateMatch.7" file="shared_pseudocode.xml" hover="function: boolean AArch32.StateMatch(bits(2) ssc_in,  bit hmc_in, bits(2) pxc_in, boolean linked_in, bits(4) lbn, boolean isbreakpnt, AccessDescriptor accdesc)">AArch32.StateMatch</a>(DBGBCR[n].SSC, DBGBCR[n].HMC, DBGBCR[n].PMC,
                                     linked, DBGBCR[n].LBN, isbreakpnt,  accdesc);
    (value_match, value_mismatch) = <a link="AArch32.BreakpointValueMatch.3" file="shared_pseudocode.xml" hover="function: (boolean, boolean) AArch32.BreakpointValueMatch(integer n_in, bits(32) vaddress, boolean linked_to)">AArch32.BreakpointValueMatch</a>(n, vaddress, linked_to);

    if size == 4 then                    // Check second halfword
        // If the breakpoint address and BAS of an Address breakpoint match the address of the
        // second halfword of an instruction, but not the address of the first halfword, it is
        // CONSTRAINED UNPREDICTABLE whether or not this breakpoint generates a Breakpoint debug
        // event.
        (match_i, mismatch_i) = <a link="AArch32.BreakpointValueMatch.3" file="shared_pseudocode.xml" hover="function: (boolean, boolean) AArch32.BreakpointValueMatch(integer n_in, bits(32) vaddress, boolean linked_to)">AArch32.BreakpointValueMatch</a>(n, vaddress + 2, linked_to);

        if !value_match &amp;&amp; match_i then
            value_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMATCHHALF</a>);

        if value_mismatch &amp;&amp; !mismatch_i then
            value_mismatch = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPMISMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMISMATCHHALF</a>);

    if vaddress&lt;1&gt; == '1' &amp;&amp; DBGBCR[n].BAS == '1111' then
        // The above notwithstanding, if DBGBCR[n].BAS == '1111', then it is CONSTRAINED
        // UNPREDICTABLE whether or not a Breakpoint debug event is generated for an instruction
        // at the address DBGBVR[n]+2.
        if value_match then
            value_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMATCHHALF</a>);

        if !value_mismatch then
            value_mismatch = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPMISMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMISMATCHHALF</a>);

    match    = value_match &amp;&amp; state_match &amp;&amp; enabled;
    mismatch = value_mismatch &amp;&amp; state_match &amp;&amp; enabled;

    return (match, mismatch);</pstext>
    </ps>
    <ps name="aarch32/debug/breakpoint/AArch32.BreakpointValueMatch" mylink="aarch32.debug.breakpoint.AArch32.BreakpointValueMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.BreakpointValueMatch()
// ==============================
// The first result is whether an Address Match or Context breakpoint is programmed on the
// instruction at "address". The second result is whether an Address Mismatch breakpoint is
// programmed on the instruction, that is, whether the instruction should be stepped.

(boolean, boolean) <anchor link="AArch32.BreakpointValueMatch.3" hover="function: (boolean, boolean) AArch32.BreakpointValueMatch(integer n_in, bits(32) vaddress, boolean linked_to)">AArch32.BreakpointValueMatch</anchor>(integer n_in, bits(32) vaddress, boolean linked_to)

    // "n" is the identity of the breakpoint unit to match against.
    // "vaddress" is the current instruction address, ignored if linked_to is TRUE and for Context
    //   matching breakpoints.
    // "linked_to" is TRUE if this is a call from StateMatch for linking.
    integer n = n_in;

    // If a non-existent breakpoint then it is CONSTRAINED UNPREDICTABLE whether this gives
    // no match or the breakpoint is mapped to another UNKNOWN implemented breakpoint.
    if n &gt;= <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() then
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, n) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(0, <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - 1,
                                               <a link="Unpredictable_BPNOTIMPL" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPNOTIMPL</a>);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then return (FALSE, FALSE);

    // If this breakpoint is not enabled, it cannot generate a match. (This could also happen on a
    // call from StateMatch for linking).
    if DBGBCR[n].E == '0' then return (FALSE, FALSE);

    context_aware = (n &gt;= (<a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - <a link="impl-shared.NumContextAwareBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumContextAwareBreakpointsImplemented()">NumContextAwareBreakpointsImplemented</a>()));

    // If BT is set to a reserved type, behaves either as disabled or as a not-reserved type.
    dbgtype = DBGBCR[n].BT;

    if ((dbgtype IN {'011x','11xx'} &amp;&amp; !<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; !<a link="impl-shared.HaveV82Debug.0" file="shared_pseudocode.xml" hover="function: boolean HaveV82Debug()">HaveV82Debug</a>()) || // Context matching
          (dbgtype IN {'010x'} &amp;&amp; <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>()) ||             // Address mismatch
          (!(dbgtype IN {'0x0x'}) &amp;&amp; !context_aware) ||                          // Context matching
          (dbgtype IN {'1xxx'} &amp;&amp; !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>))) then                            // EL2 extension
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, dbgtype) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESBPTYPE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESBPTYPE</a>, 4);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then return (FALSE, FALSE);
        // Otherwise the value returned by ConstrainUnpredictableBits must be a not-reserved value

    // Determine what to compare against.
    match_addr = (dbgtype IN {'0x0x'});
    mismatch   = (dbgtype IN {'010x'});
    match_vmid = (dbgtype IN {'10xx'});
    match_cid1 = (dbgtype IN {'xx1x'});
    match_cid2 = (dbgtype IN {'11xx'});
    linked     = (dbgtype IN {'xxx1'});

    // If this is a call from StateMatch, return FALSE if the breakpoint is not programmed for a
    // VMID and/or context ID match, of if not context-aware. The above assertions mean that the
    // code can just test for match_addr == TRUE to confirm all these things.
    if linked_to &amp;&amp; (!linked || match_addr) then return (FALSE, FALSE);

    // If called from BreakpointMatch return FALSE for Linked context ID and/or VMID matches.
    if !linked_to &amp;&amp; linked &amp;&amp; !match_addr then return (FALSE, FALSE);

    boolean bvr_match  = FALSE;
    boolean bxvr_match = FALSE;

    // Do the comparison.
    if match_addr then
        integer byte = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;1:0&gt;);
        assert byte IN {0,2};                     // "vaddress" is halfword aligned

        boolean byte_select_match = (DBGBCR[n].BAS&lt;byte&gt; == '1');
        integer top = 31;
        bvr_match = (vaddress&lt;top:2&gt; == DBGBVR[n]&lt;top:2&gt;) &amp;&amp; byte_select_match;

    elsif match_cid1 then
        bvr_match = (PSTATE.EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; CONTEXTIDR == DBGBVR[n]&lt;31:0&gt;);

    if match_vmid then
        bits(16) vmid;
        bits(16) bvr_vmid;

        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR.VMID, 16);
            bvr_vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(DBGBXVR[n]&lt;7:0&gt;, 16);
        elsif !<a link="impl-shared.Have16bitVMID.0" file="shared_pseudocode.xml" hover="function: boolean Have16bitVMID()">Have16bitVMID</a>() || VTCR_EL2.VS == '0' then
            vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR_EL2.VMID&lt;7:0&gt;, 16);
            bvr_vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(DBGBXVR[n]&lt;7:0&gt;, 16);
        else
            vmid = VTTBR_EL2.VMID;
            bvr_vmid = DBGBXVR[n]&lt;15:0&gt;;

        bxvr_match = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; vmid == bvr_vmid);

    elsif match_cid2 then
        bxvr_match = (PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp;
                      DBGBXVR[n]&lt;31:0&gt; == CONTEXTIDR_EL2&lt;31:0&gt;);

    bvr_match_valid  = (match_addr || match_cid1);
    bxvr_match_valid = (match_vmid || match_cid2);

    match = (!bxvr_match_valid || bxvr_match) &amp;&amp; (!bvr_match_valid || bvr_match);

    return (match &amp;&amp; !mismatch, !match &amp;&amp; mismatch);</pstext>
    </ps>
    <ps name="aarch32/debug/breakpoint/AArch32.StateMatch" mylink="aarch32.debug.breakpoint.AArch32.StateMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.StateMatch()
// ====================
// Determine whether a breakpoint or watchpoint is enabled in the current mode and state.

boolean <anchor link="AArch32.StateMatch.7" hover="function: boolean AArch32.StateMatch(bits(2) ssc_in,  bit hmc_in, bits(2) pxc_in, boolean linked_in, bits(4) lbn, boolean isbreakpnt, AccessDescriptor accdesc)">AArch32.StateMatch</anchor>(bits(2) ssc_in,  bit hmc_in, bits(2) pxc_in, boolean linked_in,
                           bits(4) lbn, boolean isbreakpnt, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    // "ssc_in","hmc_in","pxc_in" are the control fields from the DBGBCR[n] or DBGWCR[n] register.
    // "linked_in" is TRUE if this is a linked breakpoint/watchpoint type.
    // "lbn" is the linked breakpoint number from the DBGBCR[n] or DBGWCR[n] register.
    // "isbreakpnt" is TRUE for breakpoints, FALSE for watchpoints.
    // "accdesc" describes the properties of the access being matched.
    bits(2) ssc    = ssc_in;
    bit hmc        = hmc_in;
    bits(2) pxc    = pxc_in;
    boolean linked = linked_in;

    // If parameters are set to a reserved type, behaves as either disabled or a defined type
    <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
    // SSCE value discarded as there is no SSCE bit in AArch32.
    (c, ssc, -, hmc, pxc) = <a link="impl-shared.CheckValidStateMatch.5" file="shared_pseudocode.xml" hover="function: (Constraint, bits(2), bit, bit, bits(2)) CheckValidStateMatch(bits(2) ssc_in, bit ssce_in, bit hmc_in, bits(2) pxc_in, boolean isbreakpnt)">CheckValidStateMatch</a>(ssc, '0', hmc, pxc, isbreakpnt);
    if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then return FALSE;
    // Otherwise the hmc,ssc,pxc values are either valid or the values returned by
    // CheckValidStateMatch are valid.

    pl2_match = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; ((hmc == '1' &amp;&amp; (ssc:pxc != '1000')) || ssc == '11');
    pl1_match = pxc&lt;0&gt; == '1';
    pl0_match = pxc&lt;1&gt; == '1';
    ssu_match = isbreakpnt &amp;&amp; hmc == '0' &amp;&amp; pxc == '00' &amp;&amp; ssc != '11';

    boolean priv_match;
    if ssu_match then
        priv_match = PSTATE.M IN {<a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>,<a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>,<a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>};
    else
        case accdesc.el of
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> priv_match = pl1_match;           // EL3 and EL1 are both PL1
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> priv_match = pl2_match;
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> priv_match = pl1_match;
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> priv_match = pl0_match;

    // Security state match
    boolean ss_match;
    case ssc of
        when '00' ss_match = TRUE;                                     // Both
        when '01' ss_match = accdesc.ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;               // Non-secure only
        when '10' ss_match = accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;                  // Secure only
        when '11' ss_match = (hmc == '1' || accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>);  // HMC=1 -&gt; Both,
                                                                       // HMC=0 -&gt; Secure only

    boolean linked_match = FALSE;

    if linked then
        // "lbn" must be an enabled context-aware breakpoint unit. If it is not context-aware then
        // it is CONSTRAINED UNPREDICTABLE whether this gives no match, gives a match without
        // linking, or lbn is mapped to some UNKNOWN breakpoint that is context-aware.
        integer int_lbn = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(lbn);
        first_ctx_cmp = <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - <a link="impl-shared.NumContextAwareBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumContextAwareBreakpointsImplemented()">NumContextAwareBreakpointsImplemented</a>();
        last_ctx_cmp = <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - 1;

        if (int_lbn &lt; first_ctx_cmp || int_lbn &gt; last_ctx_cmp) then
            (c, int_lbn) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(first_ctx_cmp, last_ctx_cmp,
                                                         <a link="Unpredictable_BPNOTCTXCMP" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPNOTCTXCMP</a>);
            assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};

            case c of
                when <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>  return FALSE;      // Disabled
                when <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>      linked = FALSE;    // No linking
                // Otherwise ConstrainUnpredictableInteger returned a context-aware breakpoint

        vaddress  = bits(32) UNKNOWN;
        linked_to = TRUE;
        (linked_match,-) = <a link="AArch32.BreakpointValueMatch.3" file="shared_pseudocode.xml" hover="function: (boolean, boolean) AArch32.BreakpointValueMatch(integer n_in, bits(32) vaddress, boolean linked_to)">AArch32.BreakpointValueMatch</a>(int_lbn, vaddress, linked_to);

    return priv_match &amp;&amp; ss_match &amp;&amp; (!linked || linked_match);</pstext>
    </ps>
    <ps name="aarch32/debug/enables/AArch32.GenerateDebugExceptions" mylink="aarch32.debug.enables.AArch32.GenerateDebugExceptions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GenerateDebugExceptions()
// =================================

boolean <anchor link="AArch32.GenerateDebugExceptions.0" hover="function: boolean AArch32.GenerateDebugExceptions()">AArch32.GenerateDebugExceptions</anchor>()
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    return <a link="AArch32.GenerateDebugExceptionsFrom.2" file="shared_pseudocode.xml" hover="function: boolean AArch32.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state)">AArch32.GenerateDebugExceptionsFrom</a>(PSTATE.EL, ss);</pstext>
    </ps>
    <ps name="aarch32/debug/enables/AArch32.GenerateDebugExceptionsFrom" mylink="aarch32.debug.enables.AArch32.GenerateDebugExceptionsFrom" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GenerateDebugExceptionsFrom()
// =====================================

boolean <anchor link="AArch32.GenerateDebugExceptionsFrom.2" hover="function: boolean AArch32.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state)">AArch32.GenerateDebugExceptionsFrom</anchor>(bits(2) from_el, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> from_state)

    if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.DebugTargetFrom.1" file="shared_pseudocode.xml" hover="function: bits(2) DebugTargetFrom(SecurityState from_state)">DebugTargetFrom</a>(from_state)) then
        mask = '0';    // No PSTATE.D in AArch32 state
        return <a link="AArch64.GenerateDebugExceptionsFrom.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state, bit mask)">AArch64.GenerateDebugExceptionsFrom</a>(from_el, from_state, mask);

    if DBGOSLSR.OSLK == '1' || <a link="impl-shared.DoubleLockStatus.0" file="shared_pseudocode.xml" hover="function: boolean DoubleLockStatus()">DoubleLockStatus</a>() || <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        return FALSE;

    boolean enabled;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; from_state == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        assert from_el != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;    // Secure EL2 always uses AArch64
        if <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>() then
            // Implies that EL3 and EL2 both using AArch64
            enabled = MDCR_EL3.SDD == '0';
        else
            spd = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SDCR.SPD else MDCR_EL3.SPD32;
            if spd&lt;1&gt; == '1' then
                enabled = spd&lt;0&gt; == '1';
            else
                // SPD == 0b01 is reserved, but behaves the same as 0b00.
                enabled = <a link="AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled()">AArch32.SelfHostedSecurePrivilegedInvasiveDebugEnabled</a>();
        if from_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then enabled = enabled || SDER.SUIDEN == '1';
    else
        enabled = from_el != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    return enabled;</pstext>
    </ps>
    <ps name="aarch32/debug/pmu/AArch32.ClearEventCounters" mylink="aarch32.debug.pmu.AArch32.ClearEventCounters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ClearEventCounters()
// ============================
// Zero all the event counters.

<anchor link="AArch32.ClearEventCounters.0" hover="function: AArch32.ClearEventCounters()">AArch32.ClearEventCounters</anchor>()
    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        // Force the counter to be cleared as a 64-bit counter.
        <a link="AArch64.ClearEventCounters.0" file="shared_pseudocode.xml" hover="function: AArch64.ClearEventCounters()">AArch64.ClearEventCounters</a>();
        return;

    integer counters = <a link="AArch32.GetNumEventCountersAccessible.0" file="shared_pseudocode.xml" hover="function: integer AArch32.GetNumEventCountersAccessible()">AArch32.GetNumEventCountersAccessible</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            PMEVCNTR[idx] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);</pstext>
    </ps>
    <ps name="aarch32/debug/pmu/AArch32.GetNumEventCountersAccessible" mylink="aarch32.debug.pmu.AArch32.GetNumEventCountersAccessible" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GetNumEventCountersAccessible()
// =======================================
// Return the number of event counters that can be accessed at the current Exception level.

integer <anchor link="AArch32.GetNumEventCountersAccessible.0" hover="function: integer AArch32.GetNumEventCountersAccessible()">AArch32.GetNumEventCountersAccessible</anchor>()
    integer n;
    integer total_counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();
    // Software can reserve some counters for EL2
    if PSTATE.EL IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then MDCR_EL2.HPMN else HDCR.HPMN);
        if n &gt; total_counters || (!<a link="impl-shared.HaveFeatHPMN0.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatHPMN0()">HaveFeatHPMN0</a>() &amp;&amp; n == 0) then
            (-, n) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(0, total_counters,
                                                   <a link="Unpredictable_PMUEVENTCOUNTER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_PMUEVENTCOUNTER</a>);
    else
        n = total_counters;

    return n;</pstext>
    </ps>
    <ps name="aarch32/debug/pmu/AArch32.IncrementCycleCounter" mylink="aarch32.debug.pmu.AArch32.IncrementCycleCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.IncrementCycleCounter()
// ===============================
// Increment the cycle counter and possibly set overflow bits.

<anchor link="AArch32.IncrementCycleCounter.0" hover="function: AArch32.IncrementCycleCounter()">AArch32.IncrementCycleCounter</anchor>()
    if (<a link="impl-shared.CountPMUEvents.1" file="shared_pseudocode.xml" hover="function: boolean CountPMUEvents(integer idx)">CountPMUEvents</a>(<a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>) &amp;&amp;
        (PMCR.LC == '1' || PMCR.D == '0' || <a link="impl-shared.HasElapsed64Cycles.0" file="shared_pseudocode.xml" hover="function: boolean HasElapsed64Cycles()">HasElapsed64Cycles</a>())) then
        integer old_value = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMCCNTR);
        integer new_value = old_value + 1;
        PMCCNTR = new_value&lt;63:0&gt;;

        integer ovflw = if PMCR.LC == '1' then 64 else 32;

        if old_value&lt;64:ovflw&gt; != new_value&lt;64:ovflw&gt; then
            PMOVSSET.C = '1';
            PMOVSR.C = '1';</pstext>
    </ps>
    <ps name="aarch32/debug/pmu/AArch32.IncrementEventCounter" mylink="aarch32.debug.pmu.AArch32.IncrementEventCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.IncrementEventCounter()
// ===============================
// Increment the specified event counter by the specified amount.

<anchor link="AArch32.IncrementEventCounter.2" hover="function: AArch32.IncrementEventCounter(integer idx, integer increment)">AArch32.IncrementEventCounter</anchor>(integer idx, integer increment)
    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        // Force the counter to be incremented as a 64-bit counter.
        <a link="AArch64.IncrementEventCounter.2" file="shared_pseudocode.xml" hover="function: AArch64.IncrementEventCounter(integer idx, integer increment)">AArch64.IncrementEventCounter</a>(idx, increment);
        return;

    // In this model, event counters in an AArch32-only implementation are 32 bits and
    // the LP bits are RES0 in this model, even if FEAT_PMUv3p5 is implemented.
    integer old_value;
    integer new_value;
    integer ovflw;
    bit lp;
    old_value = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMEVCNTR[idx]);
    new_value = old_value + <a link="impl-shared.PMUCountValue.2" file="shared_pseudocode.xml" hover="function: integer PMUCountValue(integer n, integer Vb)">PMUCountValue</a>(idx, increment);

    PMEVCNTR[idx] = new_value&lt;31:0&gt;;
    ovflw = 32;

    if old_value&lt;64:ovflw&gt; != new_value&lt;64:ovflw&gt; then
        PMOVSSET&lt;idx&gt; = '1';
        PMOVSR&lt;idx&gt; = '1';
        // Check for the CHAIN event from an even counter
        if idx&lt;0&gt; == '0' &amp;&amp; idx + 1 &lt; <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>() then
            <a link="impl-shared.PMUEvent.3" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event, integer increment, integer idx)">PMUEvent</a>(PMU_EVENT_CHAIN, 1, idx + 1);</pstext>
    </ps>
    <ps name="aarch32/debug/pmu/AArch32.PMUCycle" mylink="aarch32.debug.pmu.AArch32.PMUCycle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PMUCycle()
// ==================
// Called at the end of each cycle to increment event counters and
// check for PMU overflow. In pseudocode, a cycle ends after the
// execution of the operational pseudocode.

<anchor link="AArch32.PMUCycle.0" hover="function: AArch32.PMUCycle()">AArch32.PMUCycle</anchor>()
    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        <a link="AArch64.PMUCycle.0" file="shared_pseudocode.xml" hover="function: AArch64.PMUCycle()">AArch64.PMUCycle</a>();
        return;

    if !<a link="impl-shared.HavePMUv3.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3()">HavePMUv3</a>() then
        return;

    <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_CPU_CYCLES);

    integer counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            if <a link="impl-shared.CountPMUEvents.1" file="shared_pseudocode.xml" hover="function: boolean CountPMUEvents(integer idx)">CountPMUEvents</a>(idx) then
                integer accumulated = PMUEventAccumulator[idx];
                <a link="AArch32.IncrementEventCounter.2" file="shared_pseudocode.xml" hover="function: AArch32.IncrementEventCounter(integer idx, integer increment)">AArch32.IncrementEventCounter</a>(idx, accumulated);
            PMUEventAccumulator[idx] = 0;

    <a link="AArch32.IncrementCycleCounter.0" file="shared_pseudocode.xml" hover="function: AArch32.IncrementCycleCounter()">AArch32.IncrementCycleCounter</a>();
    <a link="impl-shared.CheckForPMUOverflow.0" file="shared_pseudocode.xml" hover="function: CheckForPMUOverflow()">CheckForPMUOverflow</a>();</pstext>
    </ps>
    <ps name="aarch32/debug/pmu/AArch32.PMUSwIncrement" mylink="aarch32.debug.pmu.AArch32.PMUSwIncrement" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PMUSwIncrement()
// ========================
// Generate PMU Events on a write to PMSWINC.

<anchor link="AArch32.PMUSwIncrement.1" hover="function: AArch32.PMUSwIncrement(bits(32) sw_incr)">AArch32.PMUSwIncrement</anchor>(bits(32) sw_incr)
    integer counters = <a link="AArch32.GetNumEventCountersAccessible.0" file="shared_pseudocode.xml" hover="function: integer AArch32.GetNumEventCountersAccessible()">AArch32.GetNumEventCountersAccessible</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            if sw_incr&lt;idx&gt; == '1' then
                <a link="impl-shared.PMUEvent.3" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event, integer increment, integer idx)">PMUEvent</a>(PMU_EVENT_SW_INCR, 1, idx);</pstext>
    </ps>
    <ps name="aarch32/debug/takeexceptiondbg/AArch32.EnterHypModeInDebugState" mylink="aarch32.debug.takeexceptiondbg.AArch32.EnterHypModeInDebugState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EnterHypModeInDebugState()
// ==================================
// Take an exception in Debug state to Hyp mode.

<anchor link="AArch32.EnterHypModeInDebugState.1" hover="function: AArch32.EnterHypModeInDebugState(ExceptionRecord exception)">AArch32.EnterHypModeInDebugState</anchor>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception)
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    <a link="AArch32.ReportHypEntry.1" file="shared_pseudocode.xml" hover="function: AArch32.ReportHypEntry(ExceptionRecord exception)">AArch32.ReportHypEntry</a>(exception);
    <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>);
    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = bits(32) UNKNOWN;
    ELR_hyp = bits(32) UNKNOWN;
    // In Debug state, the PE always execute T32 instructions when in AArch32 state, and
    // PSTATE.{SS,A,I,F} are not observable so behave as UNKNOWN.
    PSTATE.T = '1';                             // PSTATE.J is RES0
    PSTATE.&lt;SS,A,I,F&gt; = bits(4) UNKNOWN;
    DLR = bits(32) UNKNOWN;
    DSPSR = bits(32) UNKNOWN;
    PSTATE.E = HSCTLR.EE;
    PSTATE.IL = '0';
    PSTATE.IT = '00000000';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = bit UNKNOWN;
    EDSCR.ERR = '1';
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch32/debug/takeexceptiondbg/AArch32.EnterModeInDebugState" mylink="aarch32.debug.takeexceptiondbg.AArch32.EnterModeInDebugState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EnterModeInDebugState()
// ===============================
// Take an exception in Debug state to a mode other than Monitor and Hyp mode.

<anchor link="AArch32.EnterModeInDebugState.1" hover="function: AArch32.EnterModeInDebugState(bits(5) target_mode)">AArch32.EnterModeInDebugState</anchor>(bits(5) target_mode)
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; PSTATE.EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then SCR.NS = '0';
    <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(target_mode);
    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = bits(32) UNKNOWN;
    <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[14] = bits(32) UNKNOWN;
    // In Debug state, the PE always execute T32 instructions when in AArch32 state, and
    // PSTATE.{SS,A,I,F} are not observable so behave as UNKNOWN.
    PSTATE.T = '1';                             // PSTATE.J is RES0
    PSTATE.&lt;SS,A,I,F&gt; = bits(4) UNKNOWN;
    DLR = bits(32) UNKNOWN;
    DSPSR = bits(32) UNKNOWN;
    PSTATE.E = SCTLR.EE;
    PSTATE.IL = '0';
    PSTATE.IT = '00000000';
    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; SCTLR.SPAN == '0' then PSTATE.PAN = '1';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = bit UNKNOWN;
    EDSCR.ERR = '1';
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                        // Update EDSCR processor state flags.

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch32/debug/takeexceptiondbg/AArch32.EnterMonitorModeInDebugState" mylink="aarch32.debug.takeexceptiondbg.AArch32.EnterMonitorModeInDebugState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EnterMonitorModeInDebugState()
// ======================================
// Take an exception in Debug state to Monitor mode.

<anchor link="AArch32.EnterMonitorModeInDebugState.0" hover="function: AArch32.EnterMonitorModeInDebugState()">AArch32.EnterMonitorModeInDebugState</anchor>()
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    from_secure = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
    if PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then SCR.NS = '0';
    <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>);
    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = bits(32) UNKNOWN;
    <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[14] = bits(32) UNKNOWN;
    // In Debug state, the PE always execute T32 instructions when in AArch32 state, and
    // PSTATE.{SS,A,I,F} are not observable so behave as UNKNOWN.
    PSTATE.T = '1';                             // PSTATE.J is RES0
    PSTATE.&lt;SS,A,I,F&gt; = bits(4) UNKNOWN;
    PSTATE.E = SCTLR.EE;
    PSTATE.IL = '0';
    PSTATE.IT = '00000000';
    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() then
        if !from_secure then
            PSTATE.PAN = '0';
        elsif SCTLR.SPAN == '0' then
            PSTATE.PAN = '1';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = bit UNKNOWN;
    DLR = bits(32) UNKNOWN;
    DSPSR = bits(32) UNKNOWN;
    EDSCR.ERR = '1';
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                        // Update EDSCR processor state flags.

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch32/debug/watchpoint/AArch32.WatchpointByteMatch" mylink="aarch32.debug.watchpoint.AArch32.WatchpointByteMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.WatchpointByteMatch()
// =============================

boolean <anchor link="AArch32.WatchpointByteMatch.2" hover="function: boolean AArch32.WatchpointByteMatch(integer n, bits(32) vaddress)">AArch32.WatchpointByteMatch</anchor>(integer n, bits(32) vaddress)

    integer top = 31;
    bottom = if DBGWVR[n]&lt;2&gt; == '1' then 2 else 3;            // Word or doubleword
    byte_select_match = (DBGWCR[n].BAS&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;bottom-1:0&gt;)&gt; != '0');
    mask = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(DBGWCR[n].MASK);

    // If DBGWCR[n].MASK is non-zero value and DBGWCR[n].BAS is not set to '11111111', or
    // DBGWCR[n].BAS specifies a non-contiguous set of bytes behavior is CONSTRAINED
    // UNPREDICTABLE.
    if mask &gt; 0 &amp;&amp; !<a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(DBGWCR[n].BAS) then
        byte_select_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_WPMASKANDBAS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPMASKANDBAS</a>);
    else
        LSB = (DBGWCR[n].BAS AND NOT(DBGWCR[n].BAS - 1));  MSB = (DBGWCR[n].BAS + LSB);
        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(MSB AND (MSB - 1)) then                     // Not contiguous
            byte_select_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_WPBASCONTIGUOUS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPBASCONTIGUOUS</a>);
            bottom = 3;                                        // For the whole doubleword

    // If the address mask is set to a reserved value, the behavior is CONSTRAINED UNPREDICTABLE.
    if mask &gt; 0 &amp;&amp; mask &lt;= 2 then
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, mask) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(3, 31, <a link="Unpredictable_RESWPMASK" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESWPMASK</a>);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        case c of
            when <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>  return FALSE;            // Disabled
            when <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>      mask = 0;                // No masking
            // Otherwise the value returned by ConstrainUnpredictableInteger is a not-reserved value

    boolean WVR_match;
    if mask &gt; bottom then
        WVR_match = (vaddress&lt;top:mask&gt; == DBGWVR[n]&lt;top:mask&gt;);
        // If masked bits of DBGWVR_EL1[n] are not zero, the behavior is CONSTRAINED UNPREDICTABLE.
        if WVR_match &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(DBGWVR[n]&lt;mask-1:bottom&gt;) then
            WVR_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_WPMASKEDBITS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPMASKEDBITS</a>);
    else
        WVR_match = vaddress&lt;top:bottom&gt; == DBGWVR[n]&lt;top:bottom&gt;;

    return WVR_match &amp;&amp; byte_select_match;</pstext>
    </ps>
    <ps name="aarch32/debug/watchpoint/AArch32.WatchpointMatch" mylink="aarch32.debug.watchpoint.AArch32.WatchpointMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.WatchpointMatch()
// =========================
// Watchpoint matching in an AArch32 translation regime.

boolean <anchor link="AArch32.WatchpointMatch.4" hover="function: boolean AArch32.WatchpointMatch(integer n, bits(32) vaddress, integer size, AccessDescriptor accdesc)">AArch32.WatchpointMatch</anchor>(integer n, bits(32) vaddress, integer size,
                                <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    assert n &lt; <a link="impl-shared.NumWatchpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumWatchpointsImplemented()">NumWatchpointsImplemented</a>();

    enabled = DBGWCR[n].E == '1';
    linked = DBGWCR[n].WT == '1';
    isbreakpnt = FALSE;

    state_match = <a link="AArch32.StateMatch.7" file="shared_pseudocode.xml" hover="function: boolean AArch32.StateMatch(bits(2) ssc_in,  bit hmc_in, bits(2) pxc_in, boolean linked_in, bits(4) lbn, boolean isbreakpnt, AccessDescriptor accdesc)">AArch32.StateMatch</a>(DBGWCR[n].SSC, DBGWCR[n].HMC, DBGWCR[n].PAC,
                                     linked, DBGWCR[n].LBN, isbreakpnt, accdesc);

    boolean ls_match;
    case DBGWCR[n].LSC&lt;1:0&gt; of
        when '00' ls_match = FALSE;
        when '01' ls_match = accdesc.read;
        when '10' ls_match = accdesc.write || accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>;
        when '11' ls_match = TRUE;

    value_match = FALSE;
    for byte = 0 to size - 1
        value_match = value_match || <a link="AArch32.WatchpointByteMatch.2" file="shared_pseudocode.xml" hover="function: boolean AArch32.WatchpointByteMatch(integer n, bits(32) vaddress)">AArch32.WatchpointByteMatch</a>(n, vaddress + byte);

    return value_match &amp;&amp; state_match &amp;&amp; ls_match &amp;&amp; enabled;</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.Abort" mylink="aarch32.exceptions.aborts.AArch32.Abort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.Abort()
// ===============
// Abort and Debug exception handling in an AArch32 translation regime.

<anchor link="AArch32.Abort.2" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</anchor>(bits(32) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)

    // Check if routed to AArch64 state
    route_to_aarch64 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        route_to_aarch64 = (HCR_EL2.TGE == '1' || <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault) ||
                            (<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; HCR_EL2.TEA == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault)) ||
                            (<a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) &amp;&amp; MDCR_EL2.TDE == '1'));

    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        route_to_aarch64 = <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault);

    if route_to_aarch64 then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress,  64), fault);
    elsif fault.access.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        <a link="AArch32.TakePrefetchAbortException.2" file="shared_pseudocode.xml" hover="function: AArch32.TakePrefetchAbortException(bits(32) vaddress, FaultRecord fault)">AArch32.TakePrefetchAbortException</a>(vaddress, fault);
    else
        <a link="AArch32.TakeDataAbortException.2" file="shared_pseudocode.xml" hover="function: AArch32.TakeDataAbortException(bits(32) vaddress, FaultRecord fault)">AArch32.TakeDataAbortException</a>(vaddress, fault);</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.AbortSyndrome" mylink="aarch32.exceptions.aborts.AArch32.AbortSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.AbortSyndrome()
// =======================
// Creates an exception syndrome record for Abort  exceptions
// taken to Hyp mode
// from an AArch32 translation regime.

ExceptionRecord <anchor link="AArch32.AbortSyndrome.4" hover="function: ExceptionRecord AArch32.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(32) vaddress, bits(2) target_el)">AArch32.AbortSyndrome</anchor>(<a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault,
                                      bits(32) vaddress, bits(2) target_el)
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(exceptype);

    d_side = exceptype == <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>;

    exception.syndrome = <a link="AArch32.FaultSyndrome.2" file="shared_pseudocode.xml" hover="function: bits(25) AArch32.FaultSyndrome(boolean d_side, FaultRecord fault)">AArch32.FaultSyndrome</a>(d_side, fault);
    exception.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress, 64);

    if <a link="impl-shared.IPAValid.1" file="shared_pseudocode.xml" hover="function: boolean IPAValid(FaultRecord fault)">IPAValid</a>(fault) then
        exception.ipavalid = TRUE;
        exception.NS = if fault.ipaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then '1' else '0';
        exception.ipaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(fault.ipaddress.address,  56);
    else
        exception.ipavalid = FALSE;

    return exception;</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.CheckPCAlignment" mylink="aarch32.exceptions.aborts.AArch32.CheckPCAlignment" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckPCAlignment()
// ==========================

<anchor link="AArch32.CheckPCAlignment.0" hover="function: AArch32.CheckPCAlignment()">AArch32.CheckPCAlignment</anchor>()
    bits(32) pc = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);

    if (<a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> &amp;&amp; pc&lt;1&gt; == '1') || pc&lt;0&gt; == '1' then
        if <a link="AArch32.GeneralExceptionsToAArch64.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GeneralExceptionsToAArch64()">AArch32.GeneralExceptionsToAArch64</a>() then <a link="AArch64.PCAlignmentFault.0" file="shared_pseudocode.xml" hover="function: AArch64.PCAlignmentFault()">AArch64.PCAlignmentFault</a>();

        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescIFetch.0" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescIFetch()">CreateAccDescIFetch</a>();
        <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
        // Generate an Alignment fault Prefetch Abort exception
        fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(pc, fault);</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.CommonFaultStatus" mylink="aarch32.exceptions.aborts.AArch32.CommonFaultStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CommonFaultStatus()
// ===========================
// Return the common part of the fault status on reporting a Data
// or Prefetch Abort.

bits(32) <anchor link="AArch32.CommonFaultStatus.2" hover="function: bits(32) AArch32.CommonFaultStatus(FaultRecord fault, boolean long_format)">AArch32.CommonFaultStatus</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault, boolean long_format)
    bits(32) target = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; <a link="impl-shared.IsAsyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsAsyncAbort(Fault statuscode)">IsAsyncAbort</a>(fault) then
        <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errstate = <a link="AArch32.PEErrorState.1" file="shared_pseudocode.xml" hover="function: ErrorState AArch32.PEErrorState(FaultRecord fault)">AArch32.PEErrorState</a>(fault);
        target&lt;15:14&gt; = <a link="AArch32.EncodeAsyncErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch32.EncodeAsyncErrorSyndrome(ErrorState errorstate)">AArch32.EncodeAsyncErrorSyndrome</a>(errstate);   // AET
    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then target&lt;12&gt; = fault.extflag;        // ExT
    target&lt;9&gt; = if long_format then '1' else '0';                     // LPAE
    if long_format then                                               // Long-descriptor format
        target&lt;5:0&gt;    = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level);  // STATUS
    else                                                              // Short-descriptor format
        target&lt;10,3:0&gt; = <a link="impl-aarch32.EncodeSDFSC.2" file="shared_pseudocode.xml" hover="function: bits(5) EncodeSDFSC(Fault statuscode, integer level)">EncodeSDFSC</a>(fault.statuscode, fault.level);  // FS
    return target;</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.ReportDataAbort" mylink="aarch32.exceptions.aborts.AArch32.ReportDataAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ReportDataAbort()
// =========================
// Report syndrome information for aborts taken to modes other than Hyp mode.

<anchor link="AArch32.ReportDataAbort.3" hover="function: AArch32.ReportDataAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportDataAbort</anchor>(boolean route_to_monitor, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault,
                        bits(32) vaddress)
    long_format = FALSE;
    if route_to_monitor &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        long_format = ((TTBCR_S.EAE == '1') ||
                       (<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) &amp;&amp; ((PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || TTBCR.EAE == '1') ||
                        (fault.secondstage &amp;&amp; (boolean IMPLEMENTATION_DEFINED
                                               "Report abort using Long-descriptor format")))));
    else
        long_format = TTBCR.EAE == '1';
    bits(32) syndrome = <a link="AArch32.CommonFaultStatus.2" file="shared_pseudocode.xml" hover="function: bits(32) AArch32.CommonFaultStatus(FaultRecord fault, boolean long_format)">AArch32.CommonFaultStatus</a>(fault, long_format);

    // bits of syndrome that are not common to I and D side
    if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
        syndrome&lt;13&gt; = '1';                              // CM
        syndrome&lt;11&gt; = '1';                              // WnR
    else
        syndrome&lt;11&gt; = if fault.write then '1' else '0'; // WnR

    if !long_format then
        syndrome&lt;7:4&gt; = fault.domain;                    // Domain

    if fault.access.acctype == <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a> then
        bits(32) i_syndrome;
        if (!long_format &amp;&amp;
            boolean IMPLEMENTATION_DEFINED "Report I-cache maintenance fault in IFSR") then
            i_syndrome = syndrome;
            syndrome&lt;10,3:0&gt; = <a link="impl-aarch32.EncodeSDFSC.2" file="shared_pseudocode.xml" hover="function: bits(5) EncodeSDFSC(Fault statuscode, integer level)">EncodeSDFSC</a>(<a link="Fault_ICacheMaint" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_ICacheMaint</a>, 1);
        else
            i_syndrome = bits(32) UNKNOWN;
        if route_to_monitor then
            IFSR_S = i_syndrome;
        else
            IFSR = i_syndrome;

    if route_to_monitor then
        DFSR_S = syndrome;
        DFAR_S = vaddress;
    else
        DFSR = syndrome;
        DFAR = vaddress;

    return;</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.ReportPrefetchAbort" mylink="aarch32.exceptions.aborts.AArch32.ReportPrefetchAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ReportPrefetchAbort()
// =============================
// Report syndrome information for aborts taken to modes other than Hyp mode.

<anchor link="AArch32.ReportPrefetchAbort.3" hover="function: AArch32.ReportPrefetchAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportPrefetchAbort</anchor>(boolean route_to_monitor, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault, bits(32) vaddress)
    // The encoding used in the IFSR can be Long-descriptor format or Short-descriptor format.
    // Normally, the current translation table format determines the format. For an abort from
    // Non-secure state to Monitor mode, the IFSR uses the Long-descriptor format if any of the
    // following applies:
    // * The Secure TTBCR.EAE is set to 1.
    // * It is taken from Hyp mode.
    // * It is taken from EL1 or EL0, and the Non-secure TTBCR.EAE is set to 1.
    long_format = FALSE;
    if route_to_monitor &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        long_format = TTBCR_S.EAE == '1' || PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || TTBCR.EAE == '1';
    else
        long_format = TTBCR.EAE == '1';

    bits(32) fsr = <a link="AArch32.CommonFaultStatus.2" file="shared_pseudocode.xml" hover="function: bits(32) AArch32.CommonFaultStatus(FaultRecord fault, boolean long_format)">AArch32.CommonFaultStatus</a>(fault, long_format);

    if route_to_monitor then
        IFSR_S = fsr;
        IFAR_S = vaddress;
    else
        IFSR = fsr;
        IFAR = vaddress;

    return;</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.TakeDataAbortException" mylink="aarch32.exceptions.aborts.AArch32.TakeDataAbortException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeDataAbortException()
// ================================

<anchor link="AArch32.TakeDataAbortException.2" hover="function: AArch32.TakeDataAbortException(bits(32) vaddress, FaultRecord fault)">AArch32.TakeDataAbortException</anchor>(bits(32) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    route_to_monitor = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault);
    route_to_hyp = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp;
                    (HCR.TGE == '1' ||
                     (<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; HCR2.TEA == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault)) ||
                     (<a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) &amp;&amp; HDCR.TDE == '1') ||
                     <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault)));

    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x10;
    lr_offset = 8;

    if <a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) then DBGDSCRext.MOE = fault.debugmoe;
    if route_to_monitor then
        <a link="AArch32.ReportDataAbort.3" file="shared_pseudocode.xml" hover="function: AArch32.ReportDataAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportDataAbort</a>(route_to_monitor, fault, vaddress);
        <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
        exception = <a link="AArch32.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch32.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(32) vaddress, bits(2) target_el)">AArch32.AbortSyndrome</a>(<a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>, fault, vaddress, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
        else
            <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);
    else
        <a link="AArch32.ReportDataAbort.3" file="shared_pseudocode.xml" hover="function: AArch32.ReportDataAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportDataAbort</a>(route_to_monitor, fault, vaddress);
        <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/aborts/AArch32.TakePrefetchAbortException" mylink="aarch32.exceptions.aborts.AArch32.TakePrefetchAbortException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakePrefetchAbortException()
// ====================================

<anchor link="AArch32.TakePrefetchAbortException.2" hover="function: AArch32.TakePrefetchAbortException(bits(32) vaddress, FaultRecord fault)">AArch32.TakePrefetchAbortException</anchor>(bits(32) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    route_to_monitor = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault);

    route_to_hyp = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp;
                    (HCR.TGE == '1' ||
                     (<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; HCR2.TEA == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault)) ||
                     (<a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) &amp;&amp; HDCR.TDE == '1') ||
                     <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault)));

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x0C;
    lr_offset = 4;

    if <a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) then DBGDSCRext.MOE = fault.debugmoe;
    if route_to_monitor then
        <a link="AArch32.ReportPrefetchAbort.3" file="shared_pseudocode.xml" hover="function: AArch32.ReportPrefetchAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportPrefetchAbort</a>(route_to_monitor, fault, vaddress);
        <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
        if fault.statuscode == <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a> then             // PC Alignment fault
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>);
            exception.vaddress = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
        else
            exception = <a link="AArch32.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch32.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(32) vaddress, bits(2) target_el)">AArch32.AbortSyndrome</a>(<a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>, fault, vaddress, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
        else
            <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);
    else
        <a link="AArch32.ReportPrefetchAbort.3" file="shared_pseudocode.xml" hover="function: AArch32.ReportPrefetchAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportPrefetchAbort</a>(route_to_monitor, fault, vaddress);
        <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/async/AArch32.TakePhysicalFIQException" mylink="aarch32.exceptions.async.AArch32.TakePhysicalFIQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakePhysicalFIQException()
// ==================================

<anchor link="AArch32.TakePhysicalFIQException.0" hover="function: AArch32.TakePhysicalFIQException()">AArch32.TakePhysicalFIQException</anchor>()

    // Check if routed to AArch64 state
    route_to_aarch64 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        route_to_aarch64 = HCR_EL2.TGE == '1' || (HCR_EL2.FMO == '1' &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>());

    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        route_to_aarch64 = SCR_EL3.FIQ == '1';

    if route_to_aarch64 then <a link="AArch64.TakePhysicalFIQException.0" file="shared_pseudocode.xml" hover="function: AArch64.TakePhysicalFIQException()">AArch64.TakePhysicalFIQException</a>();
    route_to_monitor = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR.FIQ == '1';
    route_to_hyp = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR.TGE == '1' || HCR.FMO == '1'));
    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x1C;
    lr_offset = 4;
    if route_to_monitor then
        <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>);
        <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/async/AArch32.TakePhysicalIRQException" mylink="aarch32.exceptions.async.AArch32.TakePhysicalIRQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakePhysicalIRQException()
// ==================================
// Take an enabled physical IRQ exception.

<anchor link="AArch32.TakePhysicalIRQException.0" hover="function: AArch32.TakePhysicalIRQException()">AArch32.TakePhysicalIRQException</anchor>()

    // Check if routed to AArch64 state
    route_to_aarch64 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        route_to_aarch64 = HCR_EL2.TGE == '1' || (HCR_EL2.IMO == '1' &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>());
    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        route_to_aarch64 = SCR_EL3.IRQ == '1';

    if route_to_aarch64 then <a link="AArch64.TakePhysicalIRQException.0" file="shared_pseudocode.xml" hover="function: AArch64.TakePhysicalIRQException()">AArch64.TakePhysicalIRQException</a>();

    route_to_monitor = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR.IRQ == '1';
    route_to_hyp = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR.TGE == '1' || HCR.IMO == '1'));
    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x18;
    lr_offset = 4;
    if route_to_monitor then
        <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>);
        <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/async/AArch32.TakePhysicalSErrorException" mylink="aarch32.exceptions.async.AArch32.TakePhysicalSErrorException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakePhysicalSErrorException()
// =====================================

<anchor link="AArch32.TakePhysicalSErrorException.1" hover="function: AArch32.TakePhysicalSErrorException(boolean implicit_esb)">AArch32.TakePhysicalSErrorException</anchor>(boolean implicit_esb)
    // Check if routed to AArch64 state
    route_to_aarch64 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        route_to_aarch64 = (HCR_EL2.TGE == '1' || (!<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; HCR_EL2.AMO == '1'));
    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        route_to_aarch64 = <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1';

    if route_to_aarch64 then
        <a link="AArch64.TakePhysicalSErrorException.1" file="shared_pseudocode.xml" hover="function: AArch64.TakePhysicalSErrorException(boolean implicit_esb)">AArch64.TakePhysicalSErrorException</a>(implicit_esb);

    route_to_monitor = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR.EA == '1';
    route_to_hyp = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR.TGE == '1' || HCR.AMO == '1'));
    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x10;
    lr_offset = 8;

    bits(2) target_el;
    if route_to_monitor then
        target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.GetPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: FaultRecord GetPendingPhysicalSError()">GetPendingPhysicalSError</a>();
    vaddress = bits(32) UNKNOWN;
    exception = <a link="AArch32.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch32.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(32) vaddress, bits(2) target_el)">AArch32.AbortSyndrome</a>(<a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>, fault, vaddress, target_el);

    if <a link="impl-shared.IsSErrorEdgeTriggered.0" file="shared_pseudocode.xml" hover="function: boolean IsSErrorEdgeTriggered()">IsSErrorEdgeTriggered</a>() then
        <a link="impl-shared.ClearPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: ClearPendingPhysicalSError()">ClearPendingPhysicalSError</a>();
    case target_el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            <a link="AArch32.ReportDataAbort.3" file="shared_pseudocode.xml" hover="function: AArch32.ReportDataAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportDataAbort</a>(route_to_monitor, fault, vaddress);
            <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
                <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
            else
                <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            <a link="AArch32.ReportDataAbort.3" file="shared_pseudocode.xml" hover="function: AArch32.ReportDataAbort(boolean route_to_monitor, FaultRecord fault, bits(32) vaddress)">AArch32.ReportDataAbort</a>(route_to_monitor, fault, vaddress);
            <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, preferred_exception_return, lr_offset, vect_offset);
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/async/AArch32.TakeVirtualFIQException" mylink="aarch32.exceptions.async.AArch32.TakeVirtualFIQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeVirtualFIQException()
// =================================

<anchor link="AArch32.TakeVirtualFIQException.0" hover="function: AArch32.TakeVirtualFIQException()">AArch32.TakeVirtualFIQException</anchor>()
    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then  // Virtual IRQ enabled if TGE==0 and FMO==1
        assert HCR.TGE == '0' &amp;&amp; HCR.FMO == '1';
    else
        assert HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.FMO == '1';
    // Check if routed to AArch64 state
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then <a link="AArch64.TakeVirtualFIQException.0" file="shared_pseudocode.xml" hover="function: AArch64.TakeVirtualFIQException()">AArch64.TakeVirtualFIQException</a>();

    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x1C;
    lr_offset = 4;

    <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/async/AArch32.TakeVirtualIRQException" mylink="aarch32.exceptions.async.AArch32.TakeVirtualIRQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeVirtualIRQException()
// =================================

<anchor link="AArch32.TakeVirtualIRQException.0" hover="function: AArch32.TakeVirtualIRQException()">AArch32.TakeVirtualIRQException</anchor>()
    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then   // Virtual IRQs enabled if TGE==0 and IMO==1
        assert HCR.TGE == '0' &amp;&amp; HCR.IMO == '1';
    else
        assert HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.IMO == '1';

    // Check if routed to AArch64 state
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then <a link="AArch64.TakeVirtualIRQException.0" file="shared_pseudocode.xml" hover="function: AArch64.TakeVirtualIRQException()">AArch64.TakeVirtualIRQException</a>();

    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x18;
    lr_offset = 4;

    <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/async/AArch32.TakeVirtualSErrorException" mylink="aarch32.exceptions.async.AArch32.TakeVirtualSErrorException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeVirtualSErrorException()
// ====================================

<anchor link="AArch32.TakeVirtualSErrorException.0" hover="function: AArch32.TakeVirtualSErrorException()">AArch32.TakeVirtualSErrorException</anchor>()

    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then   // Virtual SError enabled if TGE==0 and AMO==1
        assert HCR.TGE == '0' &amp;&amp; HCR.AMO == '1';
    else
        assert HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.AMO == '1';
    // Check if routed to AArch64 state
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then <a link="AArch64.TakeVirtualSErrorException.0" file="shared_pseudocode.xml" hover="function: AArch64.TakeVirtualSErrorException()">AArch64.TakeVirtualSErrorException</a>();
    route_to_monitor = FALSE;

    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x10;
    lr_offset = 8;

    vaddress = bits(32) UNKNOWN;
    parity = FALSE;
    <a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> fault = <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>;
    integer level = integer UNKNOWN;
    bits(32) fsr = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() then
        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            fsr&lt;15:14&gt; =  VDFSR.AET;
            fsr&lt;12&gt; =  VDFSR.ExT;
        else
            fsr&lt;15:14&gt; =  VSESR_EL2.AET;
            fsr&lt;12&gt; =  VSESR_EL2.ExT;
    else
        fsr&lt;12&gt; = bit IMPLEMENTATION_DEFINED "Virtual External abort type";
    if TTBCR.EAE == '1' then // Long-descriptor format
        fsr&lt;9&gt; = '1';
        fsr&lt;5:0&gt; = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault, level);
    else                     // Short-descriptor format
        fsr&lt;9&gt; = '0';
        fsr&lt;10,3:0&gt; = <a link="impl-aarch32.EncodeSDFSC.2" file="shared_pseudocode.xml" hover="function: bits(5) EncodeSDFSC(Fault statuscode, integer level)">EncodeSDFSC</a>(fault, level);
    DFSR = fsr;
    DFAR = bits(32) UNKNOWN;
    <a link="impl-shared.ClearPendingVirtualSError.0" file="shared_pseudocode.xml" hover="function: ClearPendingVirtualSError()">ClearPendingVirtualSError</a>();
    <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/debug/AArch32.SoftwareBreakpoint" mylink="aarch32.exceptions.debug.AArch32.SoftwareBreakpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SoftwareBreakpoint()
// ============================

<anchor link="AArch32.SoftwareBreakpoint.1" hover="function: AArch32.SoftwareBreakpoint(bits(16) immediate)">AArch32.SoftwareBreakpoint</anchor>(bits(16) immediate)

    if (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp;
        (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1')) || !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        <a link="AArch64.SoftwareBreakpoint.1" file="shared_pseudocode.xml" hover="function: AArch64.SoftwareBreakpoint(bits(16) immediate)">AArch64.SoftwareBreakpoint</a>(immediate);

    accdesc  = <a link="impl-shared.CreateAccDescIFetch.0" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescIFetch()">CreateAccDescIFetch</a>();
    fault    = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
    vaddress = bits(32) UNKNOWN;

    fault.statuscode = <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;
    fault.debugmoe   = <a link="DebugException_BKPT" file="shared_pseudocode.xml" hover="constant bits(4) DebugException_BKPT = '0011'">DebugException_BKPT</a>;

    <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(vaddress, fault);</pstext>
    </ps>
    <ps name="aarch32/exceptions/debug/DebugException" mylink="aarch32.exceptions.debug.DebugException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(4) <anchor link="DebugException_Breakpoint" hover="constant bits(4) DebugException_Breakpoint = '0001'">DebugException_Breakpoint</anchor>  = '0001';
constant bits(4) <anchor link="DebugException_BKPT" hover="constant bits(4) DebugException_BKPT = '0011'">DebugException_BKPT</anchor>        = '0011';
constant bits(4) <anchor link="DebugException_VectorCatch" hover="constant bits(4) DebugException_VectorCatch = '0101'">DebugException_VectorCatch</anchor> = '0101';
constant bits(4) <anchor link="DebugException_Watchpoint" hover="constant bits(4) DebugException_Watchpoint = '1010'">DebugException_Watchpoint</anchor>  = '1010';</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/AArch32.CheckAdvSIMDOrFPRegisterTraps" mylink="aarch32.exceptions.exceptions.AArch32.CheckAdvSIMDOrFPRegisterTraps" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckAdvSIMDOrFPRegisterTraps()
// =======================================
// Check if an instruction that accesses an Advanced SIMD and
// floating-point System register is trapped by an appropriate HCR.TIDx
// ID group trap control.

<anchor link="AArch32.CheckAdvSIMDOrFPRegisterTraps.1" hover="function: AArch32.CheckAdvSIMDOrFPRegisterTraps(bits(4) reg)">AArch32.CheckAdvSIMDOrFPRegisterTraps</anchor>(bits(4) reg)

    if PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        tid0 = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then HCR.TID0 else HCR_EL2.TID0;
        tid3 = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then HCR.TID3 else HCR_EL2.TID3;

        if ((tid0 == '1' &amp;&amp; reg == '0000') ||                            // FPSID
              (tid3 == '1' &amp;&amp; reg IN {'0101', '0110', '0111'})) then     // MVFRx
            if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
                <a link="AArch32.SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch32.SystemAccessTrap(bits(5) mode, integer ec)">AArch32.SystemAccessTrap</a>(<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>, 0x8);
            else
                <a link="AArch64.AArch32SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, 0x8);</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/AArch32.ExceptionClass" mylink="aarch32.exceptions.exceptions.AArch32.ExceptionClass" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ExceptionClass()
// ========================
// Returns the Exception Class and Instruction Length fields to be reported in HSR

(integer,bit) <anchor link="AArch32.ExceptionClass.1" hover="function: (integer,bit) AArch32.ExceptionClass(Exception exceptype)">AArch32.ExceptionClass</anchor>(<a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype)

    il_is_valid = TRUE;
    integer ec;
    case exceptype of
        when <a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>         ec = 0x00; il_is_valid = FALSE;
        when <a link="Exception_WFxTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_WFxTrap</a>               ec = 0x01;
        when <a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>            ec = 0x03;
        when <a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>           ec = 0x04;
        when <a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>            ec = 0x05;
        when <a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a>            ec = 0x06;
        when <a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>   ec = 0x07;
        when <a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>              ec = 0x08;
        when <a link="Exception_PACTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACTrap</a>               ec = 0x09;
        when <a link="Exception_TSTARTAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_TSTARTAccessTrap</a>      ec = 0x1B;
        when <a link="Exception_GPC" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GPC</a>                   ec = 0x1E;
        when <a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>           ec = 0x0C;
        when <a link="Exception_BranchTarget" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_BranchTarget</a>          ec = 0x0D;
        when <a link="Exception_IllegalState" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</a>          ec = 0x0E; il_is_valid = FALSE;
        when <a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>        ec = 0x11;
        when <a link="Exception_HypervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_HypervisorCall</a>        ec = 0x12;
        when <a link="Exception_MonitorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</a>           ec = 0x13;
        when <a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>      ec = 0x20; il_is_valid = FALSE;
        when <a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>           ec = 0x22; il_is_valid = FALSE;
        when <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>             ec = 0x24;
        when <a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a>          ec = 0x25;
        when <a link="Exception_FPTrappedException" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPTrappedException</a>    ec = 0x28;
        otherwise                            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    if ec IN {0x20,0x24} &amp;&amp; PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        ec = ec + 1;
    bit il;
    if il_is_valid then
        il = if <a link="impl-shared.ThisInstrLength.0" file="shared_pseudocode.xml" hover="function: integer ThisInstrLength()">ThisInstrLength</a>() == 32 then '1' else '0';
    else
        il = '1';

    return (ec,il);</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/AArch32.GeneralExceptionsToAArch64" mylink="aarch32.exceptions.exceptions.AArch32.GeneralExceptionsToAArch64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GeneralExceptionsToAArch64()
// ====================================
// Returns TRUE if exceptions normally routed to EL1 are being handled at an Exception
// level using AArch64, because either EL1 is using AArch64 or TGE is in force and EL2
// is using AArch64.

boolean <anchor link="AArch32.GeneralExceptionsToAArch64.0" hover="function: boolean AArch32.GeneralExceptionsToAArch64()">AArch32.GeneralExceptionsToAArch64</anchor>()
    return ((PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) ||
            (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR_EL2.TGE == '1'));</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/AArch32.ReportHypEntry" mylink="aarch32.exceptions.exceptions.AArch32.ReportHypEntry" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ReportHypEntry()
// ========================
// Report syndrome information to Hyp mode registers.

<anchor link="AArch32.ReportHypEntry.1" hover="function: AArch32.ReportHypEntry(ExceptionRecord exception)">AArch32.ReportHypEntry</anchor>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception)

    <a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype = exception.exceptype;

    (ec,il) = <a link="AArch32.ExceptionClass.1" file="shared_pseudocode.xml" hover="function: (integer,bit) AArch32.ExceptionClass(Exception exceptype)">AArch32.ExceptionClass</a>(exceptype);
    iss  = exception.syndrome;
    iss2 = exception.syndrome2;

    // IL is not valid for Data Abort exceptions without valid instruction syndrome information
    if ec IN {0x24,0x25} &amp;&amp; iss&lt;24&gt; == '0' then
        il = '1';

    HSR = ec&lt;5:0&gt;:il:iss;

    if exceptype IN {<a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>, <a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>} then
        HIFAR = exception.vaddress&lt;31:0&gt;;
        HDFAR = bits(32) UNKNOWN;
    elsif exceptype == <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a> then
        HIFAR = bits(32) UNKNOWN;
        HDFAR = exception.vaddress&lt;31:0&gt;;

    if exception.ipavalid then
        HPFAR&lt;31:4&gt; = exception.ipaddress&lt;39:12&gt;;
    else
        HPFAR&lt;31:4&gt; = bits(28) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/AArch32.ResetControlRegisters" mylink="aarch32.exceptions.exceptions.AArch32.ResetControlRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ResetControlRegisters()
// ===============================
// Resets System registers and memory-mapped control registers that have architecturally-defined
// reset values to those values.

<anchor link="AArch32.ResetControlRegisters.1" hover="function: AArch32.ResetControlRegisters(boolean cold_reset)">AArch32.ResetControlRegisters</anchor>(boolean cold_reset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/AArch32.TakeReset" mylink="aarch32.exceptions.exceptions.AArch32.TakeReset" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeReset()
// ===================
// Reset into AArch32 state

<anchor link="AArch32.TakeReset.1" hover="function: AArch32.TakeReset(boolean cold_reset)">AArch32.TakeReset</anchor>(boolean cold_reset)
    assert !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>();

    // Enter the highest implemented Exception level in AArch32 state
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>);
        SCR.NS = '0';                     // Secure state
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>);
    else
        <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>);

    // Reset System registers in the coproc=0b111x encoding space
    // and other system components
    <a link="AArch32.ResetControlRegisters.1" file="shared_pseudocode.xml" hover="function: AArch32.ResetControlRegisters(boolean cold_reset)">AArch32.ResetControlRegisters</a>(cold_reset);
    FPEXC.EN = '0';

    // Reset all other PSTATE fields, including instruction set and endianness according to the
    // SCTLR values produced by the above call to ResetControlRegisters()
    PSTATE.&lt;A,I,F&gt; = '111';             // All asynchronous exceptions masked
    PSTATE.IT = '00000000';             // IT block state reset
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        PSTATE.T = HSCTLR.TE;           // Instruction set: TE=0:A32, TE=1:T32. PSTATE.J is RES0.
        PSTATE.E = HSCTLR.EE;           // Endianness: EE=0: little-endian, EE=1: big-endian.
    else
        PSTATE.T = SCTLR.TE;            // Instruction set: TE=0:A32, TE=1:T32. PSTATE.J is RES0.
        PSTATE.E = SCTLR.EE;            // Endianness: EE=0: little-endian, EE=1: big-endian.
    PSTATE.IL = '0';                    // Clear Illegal Execution state bit

    // All registers, bits and fields not reset by the above pseudocode or by the BranchTo() call
    // below are UNKNOWN bitstrings after reset. In particular, the return information registers
    // R14 or ELR_hyp and SPSR have UNKNOWN values, so that it
    // is impossible to return from a reset in an architecturally defined way.
    <a link="AArch32.ResetGeneralRegisters.0" file="shared_pseudocode.xml" hover="function: AArch32.ResetGeneralRegisters()">AArch32.ResetGeneralRegisters</a>();
    <a link="AArch32.ResetSIMDFPRegisters.0" file="shared_pseudocode.xml" hover="function: AArch32.ResetSIMDFPRegisters()">AArch32.ResetSIMDFPRegisters</a>();
    <a link="AArch32.ResetSpecialRegisters.0" file="shared_pseudocode.xml" hover="function: AArch32.ResetSpecialRegisters()">AArch32.ResetSpecialRegisters</a>();
    <a link="impl-shared.ResetExternalDebugRegisters.1" file="shared_pseudocode.xml" hover="function: ResetExternalDebugRegisters(boolean cold_reset)">ResetExternalDebugRegisters</a>(cold_reset);

    bits(32) rv;                      // IMPLEMENTATION DEFINED reset vector

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if MVBAR&lt;0&gt; == '1' then           // Reset vector in MVBAR
            rv = MVBAR&lt;31:1&gt;:'0';
        else
            rv = bits(32) IMPLEMENTATION_DEFINED "reset vector address";
    else
        rv = RVBAR&lt;31:1&gt;:'0';

    // The reset vector must be correctly aligned
    assert rv&lt;0&gt; == '0' &amp;&amp; (PSTATE.T == '1' || rv&lt;1&gt; == '0');

    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(rv, <a link="BranchType_RESET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RESET</a>, branch_conditional);</pstext>
    </ps>
    <ps name="aarch32/exceptions/exceptions/ExcVectorBase" mylink="aarch32.exceptions.exceptions.ExcVectorBase" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExcVectorBase()
// ===============

bits(32) <anchor link="impl-aarch32.ExcVectorBase.0" hover="function: bits(32) ExcVectorBase()">ExcVectorBase</anchor>()
    if SCTLR.V == '1' then  // Hivecs selected, base = 0xFFFF0000
        return <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(16):<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    else
        return VBAR&lt;31:5&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(5);</pstext>
    </ps>
    <ps name="aarch32/exceptions/ieeefp/AArch32.FPTrappedException" mylink="aarch32.exceptions.ieeefp.AArch32.FPTrappedException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.FPTrappedException()
// ============================

<anchor link="AArch32.FPTrappedException.1" hover="function: AArch32.FPTrappedException(bits(8) accumulated_exceptions)">AArch32.FPTrappedException</anchor>(bits(8) accumulated_exceptions)
    if <a link="AArch32.GeneralExceptionsToAArch64.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GeneralExceptionsToAArch64()">AArch32.GeneralExceptionsToAArch64</a>() then
        is_ase = FALSE;
        element = 0;
        <a link="AArch64.FPTrappedException.2" file="shared_pseudocode.xml" hover="function: AArch64.FPTrappedException(boolean is_ase, bits(8) accumulated_exceptions)">AArch64.FPTrappedException</a>(is_ase, accumulated_exceptions);
    FPEXC.DEX    = '1';
    FPEXC.TFV    = '1';
    FPEXC&lt;7,4:0&gt; = accumulated_exceptions&lt;7,4:0&gt;;                  // IDF,IXF,UFF,OFF,DZF,IOF
    FPEXC&lt;10:8&gt;  = '111';                                          // VECITR is RES1

    <a link="AArch32.TakeUndefInstrException.0" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException()">AArch32.TakeUndefInstrException</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/syscalls/AArch32.CallHypervisor" mylink="aarch32.exceptions.syscalls.AArch32.CallHypervisor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CallHypervisor()
// ========================
// Performs a HVC call

<anchor link="AArch32.CallHypervisor.1" hover="function: AArch32.CallHypervisor(bits(16) immediate)">AArch32.CallHypervisor</anchor>(bits(16) immediate)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        <a link="AArch64.CallHypervisor.1" file="shared_pseudocode.xml" hover="function: AArch64.CallHypervisor(bits(16) immediate)">AArch64.CallHypervisor</a>(immediate);
    else
        <a link="AArch32.TakeHVCException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHVCException(bits(16) immediate)">AArch32.TakeHVCException</a>(immediate);</pstext>
    </ps>
    <ps name="aarch32/exceptions/syscalls/AArch32.CallSupervisor" mylink="aarch32.exceptions.syscalls.AArch32.CallSupervisor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CallSupervisor()
// ========================
// Calls the Supervisor

<anchor link="AArch32.CallSupervisor.1" hover="function: AArch32.CallSupervisor(bits(16) immediate_in)">AArch32.CallSupervisor</anchor>(bits(16) immediate_in)
    bits(16) immediate = immediate_in;
    if <a link="AArch32.CurrentCond.0" file="shared_pseudocode.xml" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</a>() != '1110' then
        immediate = bits(16) UNKNOWN;
    if <a link="AArch32.GeneralExceptionsToAArch64.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GeneralExceptionsToAArch64()">AArch32.GeneralExceptionsToAArch64</a>() then
        <a link="AArch64.CallSupervisor.1" file="shared_pseudocode.xml" hover="function: AArch64.CallSupervisor(bits(16) immediate_in)">AArch64.CallSupervisor</a>(immediate);
    else
        <a link="AArch32.TakeSVCException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeSVCException(bits(16) immediate)">AArch32.TakeSVCException</a>(immediate);</pstext>
    </ps>
    <ps name="aarch32/exceptions/syscalls/AArch32.TakeHVCException" mylink="aarch32.exceptions.syscalls.AArch32.TakeHVCException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeHVCException()
// ==========================

<anchor link="AArch32.TakeHVCException.1" hover="function: AArch32.TakeHVCException(bits(16) immediate)">AArch32.TakeHVCException</anchor>(bits(16) immediate)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    <a link="AArch32.ITAdvance.0" file="shared_pseudocode.xml" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</a>();
    <a link="impl-shared.SSAdvance.0" file="shared_pseudocode.xml" hover="function: SSAdvance()">SSAdvance</a>();
    bits(32) preferred_exception_return = <a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(32);
    vect_offset = 0x08;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_HypervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_HypervisorCall</a>);
    exception.syndrome&lt;15:0&gt; = immediate;

    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);</pstext>
    </ps>
    <ps name="aarch32/exceptions/syscalls/AArch32.TakeSMCException" mylink="aarch32.exceptions.syscalls.AArch32.TakeSMCException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeSMCException()
// ==========================

<anchor link="AArch32.TakeSMCException.0" hover="function: AArch32.TakeSMCException()">AArch32.TakeSMCException</anchor>()
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    <a link="AArch32.ITAdvance.0" file="shared_pseudocode.xml" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</a>();
    <a link="impl-shared.SSAdvance.0" file="shared_pseudocode.xml" hover="function: SSAdvance()">SSAdvance</a>();
    bits(32) preferred_exception_return = <a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(32);
    vect_offset = 0x08;
    lr_offset = 0;

    <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/syscalls/AArch32.TakeSVCException" mylink="aarch32.exceptions.syscalls.AArch32.TakeSVCException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeSVCException()
// ==========================

<anchor link="AArch32.TakeSVCException.1" hover="function: AArch32.TakeSVCException(bits(16) immediate)">AArch32.TakeSVCException</anchor>(bits(16) immediate)

    <a link="AArch32.ITAdvance.0" file="shared_pseudocode.xml" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</a>();
    <a link="impl-shared.SSAdvance.0" file="shared_pseudocode.xml" hover="function: SSAdvance()">SSAdvance</a>();
    route_to_hyp = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR.TGE == '1';

    bits(32) preferred_exception_return = <a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(32);
    vect_offset = 0x08;
    lr_offset = 0;

    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>);
        exception.syndrome&lt;15:0&gt; = immediate;
        if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
        else
            <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);
    else
        <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/takeexception/AArch32.EnterHypMode" mylink="aarch32.exceptions.takeexception.AArch32.EnterHypMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EnterHypMode()
// ======================
// Take an exception to Hyp mode.

<anchor link="AArch32.EnterHypMode.3" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</anchor>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception, bits(32) preferred_exception_return,
                     integer vect_offset)
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        <a link="AArch32.EnterHypModeInDebugState.1" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypModeInDebugState(ExceptionRecord exception)">AArch32.EnterHypModeInDebugState</a>(exception);
        return;
    bits(32) spsr = <a link="impl-shared.GetPSRFromPSTATE.2" file="shared_pseudocode.xml" hover="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N)">GetPSRFromPSTATE</a>(<a link="AArch32_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch32_NonDebugState</a>, 32);
    if !(exception.exceptype IN {<a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>, <a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>}) then
        <a link="AArch32.ReportHypEntry.1" file="shared_pseudocode.xml" hover="function: AArch32.ReportHypEntry(ExceptionRecord exception)">AArch32.ReportHypEntry</a>(exception);
    <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>);
    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = spsr;
    ELR_hyp = preferred_exception_return;
    PSTATE.T = HSCTLR.TE;                       // PSTATE.J is RES0
    PSTATE.SS = '0';
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].EA == '0' then PSTATE.A = '1';
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].IRQ == '0' then PSTATE.I = '1';
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].FIQ == '0' then PSTATE.F = '1';
    PSTATE.E = HSCTLR.EE;
    PSTATE.IL = '0';
    PSTATE.IT = '00000000';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = HSCTLR.DSSBS;
    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(HVBAR&lt;31:5&gt;:vect_offset&lt;4:0&gt;, <a link="BranchType_EXCEPTION" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_EXCEPTION</a>, branch_conditional);

    <a link="impl-shared.CheckExceptionCatch.1" file="shared_pseudocode.xml" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</a>(TRUE);                  // Check for debug event on exception entry

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/takeexception/AArch32.EnterMode" mylink="aarch32.exceptions.takeexception.AArch32.EnterMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EnterMode()
// ===================
// Take an exception to a mode other than Monitor and Hyp mode.

<anchor link="AArch32.EnterMode.4" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</anchor>(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset,
                  integer vect_offset)
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; PSTATE.EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        <a link="AArch32.EnterModeInDebugState.1" file="shared_pseudocode.xml" hover="function: AArch32.EnterModeInDebugState(bits(5) target_mode)">AArch32.EnterModeInDebugState</a>(target_mode);
        return;
    bits(32) spsr = <a link="impl-shared.GetPSRFromPSTATE.2" file="shared_pseudocode.xml" hover="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N)">GetPSRFromPSTATE</a>(<a link="AArch32_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch32_NonDebugState</a>, 32);
    if PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then SCR.NS = '0';
    <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(target_mode);
    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = spsr;
    <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[14] = preferred_exception_return + lr_offset;
    PSTATE.T = SCTLR.TE;                        // PSTATE.J is RES0
    PSTATE.SS = '0';
    if target_mode == <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a> then
        PSTATE.&lt;A,I,F&gt; = '111';
    elsif target_mode IN {<a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>} then
        PSTATE.&lt;A,I&gt; = '11';
    else
        PSTATE.I = '1';
    PSTATE.E = SCTLR.EE;
    PSTATE.IL = '0';
    PSTATE.IT = '00000000';
    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; SCTLR.SPAN == '0' then PSTATE.PAN = '1';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = SCTLR.DSSBS;
    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(<a link="impl-aarch32.ExcVectorBase.0" file="shared_pseudocode.xml" hover="function: bits(32) ExcVectorBase()">ExcVectorBase</a>()&lt;31:5&gt;:vect_offset&lt;4:0&gt;, <a link="BranchType_EXCEPTION" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_EXCEPTION</a>, branch_conditional);

    <a link="impl-shared.CheckExceptionCatch.1" file="shared_pseudocode.xml" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</a>(TRUE);                  // Check for debug event on exception entry

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/takeexception/AArch32.EnterMonitorMode" mylink="aarch32.exceptions.takeexception.AArch32.EnterMonitorMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EnterMonitorMode()
// ==========================
// Take an exception to Monitor mode.

<anchor link="AArch32.EnterMonitorMode.3" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</anchor>(bits(32) preferred_exception_return, integer lr_offset,
                         integer vect_offset)
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    from_secure = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        <a link="AArch32.EnterMonitorModeInDebugState.0" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorModeInDebugState()">AArch32.EnterMonitorModeInDebugState</a>();
        return;
    bits(32) spsr = <a link="impl-shared.GetPSRFromPSTATE.2" file="shared_pseudocode.xml" hover="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N)">GetPSRFromPSTATE</a>(<a link="AArch32_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch32_NonDebugState</a>, 32);
    if PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then SCR.NS = '0';
    <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>);
    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = spsr;
    <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[14] = preferred_exception_return + lr_offset;
    PSTATE.T = SCTLR.TE;                        // PSTATE.J is RES0
    PSTATE.SS = '0';
    PSTATE.&lt;A,I,F&gt; = '111';
    PSTATE.E = SCTLR.EE;
    PSTATE.IL = '0';
    PSTATE.IT = '00000000';
    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() then
        if !from_secure then
            PSTATE.PAN = '0';
        elsif SCTLR.SPAN == '0' then
            PSTATE.PAN = '1';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = SCTLR.DSSBS;
    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(MVBAR&lt;31:5&gt;:vect_offset&lt;4:0&gt;, <a link="BranchType_EXCEPTION" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_EXCEPTION</a>, branch_conditional);

    <a link="impl-shared.CheckExceptionCatch.1" file="shared_pseudocode.xml" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</a>(TRUE);                  // Check for debug event on exception entry

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckAdvSIMDOrFPEnabled" mylink="aarch32.exceptions.traps.AArch32.CheckAdvSIMDOrFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckAdvSIMDOrFPEnabled()
// =================================
// Check against CPACR, FPEXC, HCPTR, NSACR, and CPTR_EL3.

<anchor link="AArch32.CheckAdvSIMDOrFPEnabled.2" hover="function: AArch32.CheckAdvSIMDOrFPEnabled(boolean fpexc_check, boolean advsimd)">AArch32.CheckAdvSIMDOrFPEnabled</anchor>(boolean fpexc_check, boolean advsimd)
    if (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp;
          (!<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() || (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR_EL2.TGE == '0'))) then
        // The PE behaves as if FPEXC.EN is 1
        <a link="AArch64.CheckFPEnabled.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPEnabled()">AArch64.CheckFPEnabled</a>();
        <a link="AArch64.CheckFPAdvSIMDEnabled.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPAdvSIMDEnabled()">AArch64.CheckFPAdvSIMDEnabled</a>();
    elsif (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
             !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR_EL2.TGE == '1' &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) then
        if fpexc_check &amp;&amp; HCR_EL2.RW == '0' then
            fpexc_en = bits(1) IMPLEMENTATION_DEFINED "FPEXC.EN value when TGE==1 and RW==0";
            if fpexc_en == '0' then UNDEFINED;
        <a link="AArch64.CheckFPEnabled.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPEnabled()">AArch64.CheckFPEnabled</a>();
    else
        cpacr_asedis = CPACR.ASEDIS;
        cpacr_cp10 = CPACR.cp10;

        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
            // Check if access disabled in NSACR
            if NSACR.NSASEDIS == '1' then cpacr_asedis = '1';
            if NSACR.cp10 == '0' then cpacr_cp10 = '00';

        if PSTATE.EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            // Check if Advanced SIMD disabled in CPACR
            if advsimd &amp;&amp; cpacr_asedis == '1' then UNDEFINED;

            // Check if access disabled in CPACR
            boolean disabled;
            case cpacr_cp10 of
                when '00' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
                when '10' disabled = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_RESCPACR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESCPACR</a>);
                when '11' disabled = FALSE;
            if disabled then UNDEFINED;

        // If required, check FPEXC enabled bit.
        if fpexc_check &amp;&amp; FPEXC.EN == '0' then UNDEFINED;

        <a link="AArch32.CheckFPAdvSIMDTrap.1" file="shared_pseudocode.xml" hover="function: AArch32.CheckFPAdvSIMDTrap(boolean advsimd)">AArch32.CheckFPAdvSIMDTrap</a>(advsimd);    // Also check against HCPTR and CPTR_EL3</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckFPAdvSIMDTrap" mylink="aarch32.exceptions.traps.AArch32.CheckFPAdvSIMDTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckFPAdvSIMDTrap()
// ============================
// Check against CPTR_EL2 and CPTR_EL3.

<anchor link="AArch32.CheckFPAdvSIMDTrap.1" hover="function: AArch32.CheckFPAdvSIMDTrap(boolean advsimd)">AArch32.CheckFPAdvSIMDTrap</anchor>(boolean advsimd)
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        <a link="AArch64.CheckFPAdvSIMDTrap.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPAdvSIMDTrap()">AArch64.CheckFPAdvSIMDTrap</a>();
    else
        if (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp;
            CPTR_EL3.TFP == '1' &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>()) then
            UNDEFINED;

        ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; ss != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
            hcptr_tase = HCPTR.TASE;
            hcptr_cp10 = HCPTR.TCP10;

            if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
                // Check if access disabled in NSACR
                if NSACR.NSASEDIS == '1' then hcptr_tase = '1';
                if NSACR.cp10 == '0' then hcptr_cp10 = '1';

            // Check if access disabled in HCPTR
            if (advsimd &amp;&amp; hcptr_tase == '1') || hcptr_cp10 == '1' then
                exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>);
                exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();

                if advsimd then
                    exception.syndrome&lt;5&gt; = '1';
                else
                    exception.syndrome&lt;5&gt; = '0';
                    exception.syndrome&lt;3:0&gt; = '1010';         // coproc field, always 0xA

                if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
                    <a link="AArch32.TakeUndefInstrException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException(ExceptionRecord exception)">AArch32.TakeUndefInstrException</a>(exception);
                else
                    <a link="AArch32.TakeHypTrapException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</a>(exception);

        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            // Check if access disabled in CPTR_EL3
            if CPTR_EL3.TFP == '1' then
                if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
                    UNDEFINED;
                else
                    <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckForSMCUndefOrTrap" mylink="aarch32.exceptions.traps.AArch32.CheckForSMCUndefOrTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckForSMCUndefOrTrap()
// ================================
// Check for UNDEFINED or trap on SMC instruction

<anchor link="AArch32.CheckForSMCUndefOrTrap.0" hover="function: AArch32.CheckForSMCUndefOrTrap()">AArch32.CheckForSMCUndefOrTrap</anchor>()
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        UNDEFINED;

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        <a link="AArch64.CheckForSMCUndefOrTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.CheckForSMCUndefOrTrap(bits(16) imm)">AArch64.CheckForSMCUndefOrTrap</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16));
    else
        route_to_hyp = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; HCR.TSC == '1';
        if route_to_hyp then
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_MonitorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</a>);
            <a link="AArch32.TakeHypTrapException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</a>(exception);</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckForSVCTrap" mylink="aarch32.exceptions.traps.AArch32.CheckForSVCTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckForSVCTrap()
// =========================
// Check for trap on SVC instruction

<anchor link="AArch32.CheckForSVCTrap.1" hover="function: AArch32.CheckForSVCTrap(bits(16) immediate)">AArch32.CheckForSVCTrap</anchor>(bits(16) immediate)
    if <a link="impl-shared.HaveFGTExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveFGTExt()">HaveFGTExt</a>() then
        route_to_el2 = FALSE;
        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            route_to_el2 = (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HFGITR_EL2.SVC_EL0 == '1' &amp;&amp;
                           (HCR_EL2.&lt;E2H, TGE&gt; != '11' &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || SCR_EL3.FGTEn == '1')));

        if route_to_el2 then
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>);
            exception.syndrome&lt;15:0&gt; = immediate;
            exception.trappedsyscallinst = TRUE;
            bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
            vect_offset = 0x0;

            <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckForWFxTrap" mylink="aarch32.exceptions.traps.AArch32.CheckForWFxTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckForWFxTrap()
// =========================
// Check for trap on WFE or WFI instruction

<anchor link="AArch32.CheckForWFxTrap.2" hover="function: AArch32.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch32.CheckForWFxTrap</anchor>(bits(2) target_el, <a link="WFxType" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType</a> wfxtype)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el);

    // Check for routing to AArch64
    if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(target_el) then
        <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(target_el, wfxtype);
        return;

    boolean is_wfe = wfxtype == <a link="WFxType_WFE" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFE</a>;
    boolean trap;
    case target_el of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            trap = (if is_wfe then SCTLR.nTWE else SCTLR.nTWI) == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            trap = (if is_wfe then HCR.TWE else HCR.TWI) == '1';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            trap = (if is_wfe then SCR.TWE else SCR.TWI) == '1';

    if trap then
        if target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR_EL2.TGE == '1' then
            <a link="AArch64.WFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.WFxTrap(WFxType wfxtype, bits(2) target_el)">AArch64.WFxTrap</a>(wfxtype, target_el);

        if target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            <a link="AArch32.TakeMonitorTrapException.0" file="shared_pseudocode.xml" hover="function: AArch32.TakeMonitorTrapException()">AArch32.TakeMonitorTrapException</a>();
        elsif target_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_WFxTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_WFxTrap</a>);
            exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();

            case wfxtype of
                when <a link="WFxType_WFI" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFI</a>
                    exception.syndrome&lt;0&gt; = '0';
                when <a link="WFxType_WFE" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFE</a>
                    exception.syndrome&lt;0&gt; = '1';

            <a link="AArch32.TakeHypTrapException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</a>(exception);
        else
            <a link="AArch32.TakeUndefInstrException.0" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException()">AArch32.TakeUndefInstrException</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckITEnabled" mylink="aarch32.exceptions.traps.AArch32.CheckITEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckITEnabled()
// ========================
// Check whether the T32 IT instruction is disabled.

<anchor link="AArch32.CheckITEnabled.1" hover="function: AArch32.CheckITEnabled(bits(4) mask)">AArch32.CheckITEnabled</anchor>(bits(4) mask)
    bit it_disabled;
    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        it_disabled = HSCTLR.ITD;
    else
        it_disabled = (if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then SCTLR.ITD else SCTLR[].ITD);
    if it_disabled == '1' then
        if mask != '1000' then UNDEFINED;

        accdesc = <a link="impl-shared.CreateAccDescIFetch.0" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescIFetch()">CreateAccDescIFetch</a>();
        aligned = TRUE;
        // Otherwise whether the IT block is allowed depends on hw1 of the next instruction.
        next_instr = <a link="AArch32.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch32.MemSingle</a>[<a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(32), 2, accdesc, aligned];

        if next_instr IN {'11xxxxxxxxxxxxxx', '1011xxxxxxxxxxxx', '10100xxxxxxxxxxx',
                          '01001xxxxxxxxxxx', '010001xxx1111xxx', '010001xx1xxxx111'} then
            // It is IMPLEMENTATION DEFINED whether the Undefined Instruction exception is
            // taken on the IT instruction or the next instruction. This is not reflected in
            // the pseudocode, which always takes the exception on the IT instruction. This
            // also does not take into account cases where the next instruction is UNPREDICTABLE.
            UNDEFINED;

    return;</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckIllegalState" mylink="aarch32.exceptions.traps.AArch32.CheckIllegalState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckIllegalState()
// ===========================
// Check PSTATE.IL bit and generate Illegal Execution state exception if set.

<anchor link="AArch32.CheckIllegalState.0" hover="function: AArch32.CheckIllegalState()">AArch32.CheckIllegalState</anchor>()
    if <a link="AArch32.GeneralExceptionsToAArch64.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GeneralExceptionsToAArch64()">AArch32.GeneralExceptionsToAArch64</a>() then
        <a link="AArch64.CheckIllegalState.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckIllegalState()">AArch64.CheckIllegalState</a>();
    elsif PSTATE.IL == '1' then
        route_to_hyp = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR.TGE == '1';

        bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
        vect_offset = 0x04;

        if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_hyp then
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_IllegalState" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</a>);
            if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
                <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
            else
                <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);
        else
            <a link="AArch32.TakeUndefInstrException.0" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException()">AArch32.TakeUndefInstrException</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.CheckSETENDEnabled" mylink="aarch32.exceptions.traps.AArch32.CheckSETENDEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckSETENDEnabled()
// ============================
// Check whether the AArch32 SETEND instruction is disabled.

<anchor link="AArch32.CheckSETENDEnabled.0" hover="function: AArch32.CheckSETENDEnabled()">AArch32.CheckSETENDEnabled</anchor>()
    bit setend_disabled;
    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        setend_disabled = HSCTLR.SED;
    else
        setend_disabled = (if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then SCTLR.SED else SCTLR[].SED);
    if setend_disabled == '1' then
        UNDEFINED;

    return;</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.SystemAccessTrap" mylink="aarch32.exceptions.traps.AArch32.SystemAccessTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SystemAccessTrap()
// ==========================
// Trapped  System register access.

<anchor link="AArch32.SystemAccessTrap.2" hover="function: AArch32.SystemAccessTrap(bits(5) mode, integer ec)">AArch32.SystemAccessTrap</anchor>(bits(5) mode, integer ec)
    (valid, target_el) = <a link="impl-shared.ELFromM32.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</a>(mode);
    assert valid &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) &amp;&amp; target_el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);

    if target_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        exception = <a link="AArch32.SystemAccessTrapSyndrome.2" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch32.SystemAccessTrapSyndrome(bits(32) instr, integer ec)">AArch32.SystemAccessTrapSyndrome</a>(<a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>(), ec);
        <a link="AArch32.TakeHypTrapException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</a>(exception);
    else
        <a link="AArch32.TakeUndefInstrException.0" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException()">AArch32.TakeUndefInstrException</a>();</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.SystemAccessTrapSyndrome" mylink="aarch32.exceptions.traps.AArch32.SystemAccessTrapSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SystemAccessTrapSyndrome()
// ==================================
// Returns the syndrome information for traps on AArch32 MCR, MCRR, MRC, MRRC, and VMRS,
// VMSR instructions, other than traps that are due to HCPTR or CPACR.

ExceptionRecord <anchor link="AArch32.SystemAccessTrapSyndrome.2" hover="function: ExceptionRecord AArch32.SystemAccessTrapSyndrome(bits(32) instr, integer ec)">AArch32.SystemAccessTrapSyndrome</anchor>(bits(32) instr, integer ec)
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;

    case ec of
        when 0x0    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);
        when 0x3    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>);
        when 0x4    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>);
        when 0x5    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>);
        when 0x6    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a>);
        when 0x7    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>);
        when 0x8    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>);
        when 0xC    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>);
        otherwise   <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    bits(20) iss = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(20);

    if exception.exceptype == <a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a> then
        return exception;
    elsif exception.exceptype IN {<a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>, <a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>,
                                  <a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>} then
        // Trapped MRC/MCR, VMRS on FPSID
        iss&lt;13:10&gt; = instr&lt;19:16&gt;;        // CRn, Reg in case of VMRS
        iss&lt;8:5&gt;   = instr&lt;15:12&gt;;        // Rt
        iss&lt;9&gt;     = '0';                 // RES0

        if exception.exceptype != <a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a> then    // When trap is not for VMRS
            iss&lt;19:17&gt; = instr&lt;7:5&gt;;          // opc2
            iss&lt;16:14&gt; = instr&lt;23:21&gt;;        // opc1
            iss&lt;4:1&gt;   = instr&lt;3:0&gt;;          //CRm
        else //VMRS Access
            iss&lt;19:17&gt; = '000';               //opc2 - Hardcoded for VMRS
            iss&lt;16:14&gt; = '111';               //opc1 - Hardcoded for VMRS
            iss&lt;4:1&gt;   = '0000';              //CRm  - Hardcoded for VMRS
    elsif exception.exceptype IN {<a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>, <a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>,
                                  <a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>} then
        // Trapped MRRC/MCRR, VMRS/VMSR
        iss&lt;19:16&gt; = instr&lt;7:4&gt;;          // opc1
        iss&lt;13:10&gt; = instr&lt;19:16&gt;;        // Rt2
        iss&lt;8:5&gt; = instr&lt;15:12&gt;;          // Rt
        iss&lt;4:1&gt;   = instr&lt;3:0&gt;;         // CRm
    elsif exception.exceptype == <a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a> then
        // Trapped LDC/STC
        iss&lt;19:12&gt; = instr&lt;7:0&gt;;         // imm8
        iss&lt;4&gt;     = instr&lt;23&gt;;          // U
        iss&lt;2:1&gt;   = instr&lt;24,21&gt;;       // P,W
        if instr&lt;19:16&gt; == '1111' then   // Rn==15, LDC(Literal addressing)/STC
            iss&lt;8:5&gt; = bits(4) UNKNOWN;
            iss&lt;3&gt;   = '1';
    iss&lt;0&gt; = instr&lt;20&gt;;                  // Direction

    exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();
    exception.syndrome&lt;19:0&gt;  = iss;

    return exception;</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.TakeHypTrapException" mylink="aarch32.exceptions.traps.AArch32.TakeHypTrapException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeHypTrapException()
// ==============================
// Exceptions routed to Hyp mode as a Hyp Trap exception.

<anchor link="AArch32.TakeHypTrapException.1" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</anchor>(integer ec)
    exception = <a link="AArch32.SystemAccessTrapSyndrome.2" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch32.SystemAccessTrapSyndrome(bits(32) instr, integer ec)">AArch32.SystemAccessTrapSyndrome</a>(<a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>(), ec);
    <a link="AArch32.TakeHypTrapException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</a>(exception);

// AArch32.TakeHypTrapException()
// ==============================
// Exceptions routed to Hyp mode as a Hyp Trap exception.

<a link="AArch32.TakeHypTrapException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeHypTrapException(integer ec)">AArch32.TakeHypTrapException</a>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x14;

    <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.TakeMonitorTrapException" mylink="aarch32.exceptions.traps.AArch32.TakeMonitorTrapException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeMonitorTrapException()
// ==================================
// Exceptions routed to Monitor mode as a Monitor Trap exception.

<anchor link="AArch32.TakeMonitorTrapException.0" hover="function: AArch32.TakeMonitorTrapException()">AArch32.TakeMonitorTrapException</anchor>()
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);

    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x04;
    lr_offset = if <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then 4 else 2;

    <a link="AArch32.EnterMonitorMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterMonitorMode(bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMonitorMode</a>(preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.TakeUndefInstrException" mylink="aarch32.exceptions.traps.AArch32.TakeUndefInstrException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TakeUndefInstrException()
// =================================

<anchor link="AArch32.TakeUndefInstrException.0" hover="function: AArch32.TakeUndefInstrException()">AArch32.TakeUndefInstrException</anchor>()
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);
    <a link="AArch32.TakeUndefInstrException.1" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException(ExceptionRecord exception)">AArch32.TakeUndefInstrException</a>(exception);

// AArch32.TakeUndefInstrException()
// =================================

<anchor link="AArch32.TakeUndefInstrException.1" hover="function: AArch32.TakeUndefInstrException(ExceptionRecord exception)">AArch32.TakeUndefInstrException</anchor>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception)

    route_to_hyp = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR.TGE == '1';
    bits(32) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(32);
    vect_offset = 0x04;
    lr_offset = if <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then 4 else 2;

    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, vect_offset);
    elsif route_to_hyp then
        <a link="AArch32.EnterHypMode.3" file="shared_pseudocode.xml" hover="function: AArch32.EnterHypMode(ExceptionRecord exception, bits(32) preferred_exception_return, integer vect_offset)">AArch32.EnterHypMode</a>(exception, preferred_exception_return, 0x14);
    else
        <a link="AArch32.EnterMode.4" file="shared_pseudocode.xml" hover="function: AArch32.EnterMode(bits(5) target_mode, bits(32) preferred_exception_return, integer lr_offset, integer vect_offset)">AArch32.EnterMode</a>(<a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>, preferred_exception_return, lr_offset, vect_offset);</pstext>
    </ps>
    <ps name="aarch32/exceptions/traps/AArch32.UndefinedFault" mylink="aarch32.exceptions.traps.AArch32.UndefinedFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.UndefinedFault()
// ========================

<anchor link="AArch32.UndefinedFault.0" hover="function: AArch32.UndefinedFault()">AArch32.UndefinedFault</anchor>()

    if <a link="AArch32.GeneralExceptionsToAArch64.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GeneralExceptionsToAArch64()">AArch32.GeneralExceptionsToAArch64</a>() then <a link="AArch64.UndefinedFault.0" file="shared_pseudocode.xml" hover="function: AArch64.UndefinedFault()">AArch64.UndefinedFault</a>();
    <a link="AArch32.TakeUndefInstrException.0" file="shared_pseudocode.xml" hover="function: AArch32.TakeUndefInstrException()">AArch32.TakeUndefInstrException</a>();</pstext>
    </ps>
    <ps name="aarch32/functions/aborts/AArch32.DomainValid" mylink="aarch32.functions.aborts.AArch32.DomainValid" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DomainValid()
// =====================
// Returns TRUE if the Domain is valid for a Short-descriptor translation scheme.

boolean <anchor link="AArch32.DomainValid.2" hover="function: boolean AArch32.DomainValid(Fault statuscode, integer level)">AArch32.DomainValid</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode, integer level)
    assert statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    case statuscode of
        when <a link="Fault_Domain" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Domain</a>
            return TRUE;
        when <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>, <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>, <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>, <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>
            return level == 2;
        otherwise
            return FALSE;</pstext>
    </ps>
    <ps name="aarch32/functions/aborts/AArch32.FaultSyndrome" mylink="aarch32.functions.aborts.AArch32.FaultSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.FaultSyndrome()
// =======================
// Creates an exception syndrome value for Abort and Watchpoint exceptions taken to
// AArch32 Hyp mode.

bits(25) <anchor link="AArch32.FaultSyndrome.2" hover="function: bits(25) AArch32.FaultSyndrome(boolean d_side, FaultRecord fault)">AArch32.FaultSyndrome</anchor>(boolean d_side, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    bits(25) iss  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(25);
    bits(24) iss2 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24);

    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; <a link="impl-shared.IsAsyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsAsyncAbort(Fault statuscode)">IsAsyncAbort</a>(fault) then
        <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errstate = <a link="AArch32.PEErrorState.1" file="shared_pseudocode.xml" hover="function: ErrorState AArch32.PEErrorState(FaultRecord fault)">AArch32.PEErrorState</a>(fault);
        iss&lt;11:10&gt; = <a link="AArch32.EncodeAsyncErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch32.EncodeAsyncErrorSyndrome(ErrorState errorstate)">AArch32.EncodeAsyncErrorSyndrome</a>(errstate); // AET

    if d_side then
        if (<a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault) &amp;&amp; !fault.s2fs1walk &amp;&amp;
            (!<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) ||
            (!<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> &amp;&amp;
            boolean IMPLEMENTATION_DEFINED "ISV on second stage translation table walk"))) then
            iss&lt;24:14&gt; = <a link="impl-shared.LSInstructionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(11) LSInstructionSyndrome()">LSInstructionSyndrome</a>();

        if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
            iss&lt;8&gt; = '1';

        if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
            iss&lt;6&gt; = '1';
        elsif fault.statuscode IN {<a link="Fault_HWUpdateAccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_HWUpdateAccessFlag</a>, <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>} then
            iss&lt;6&gt; = bit UNKNOWN;
        elsif fault.access.atomicop &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then
            iss&lt;6&gt; = bit UNKNOWN;
        else
            iss&lt;6&gt; = if fault.write then '1' else '0';

    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then iss&lt;9&gt; = fault.extflag;
    iss&lt;7&gt; = if fault.s2fs1walk then '1' else '0';
    iss&lt;5:0&gt; = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level);

    return (iss);</pstext>
    </ps>
    <ps name="aarch32/functions/aborts/EncodeSDFSC" mylink="aarch32.functions.aborts.EncodeSDFSC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EncodeSDFSC()
// =============
// Function that gives the Short-descriptor FSR code for different types of Fault

bits(5) <anchor link="impl-aarch32.EncodeSDFSC.2" hover="function: bits(5) EncodeSDFSC(Fault statuscode, integer level)">EncodeSDFSC</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode, integer level)

    bits(5) result;
    case statuscode of
        when <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>
            assert level IN {1,2};
            result = if level == 1 then '00011' else '00110';
        when <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>
            result = '00001';
        when <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>
            assert level IN {1,2};
            result = if level == 1 then '01101' else '01111';
        when <a link="Fault_Domain" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Domain</a>
            assert level IN {1,2};
            result = if level == 1 then '01001' else '01011';
        when <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>
            assert level IN {1,2};
            result = if level == 1 then '00101' else '00111';
        when <a link="Fault_SyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</a>
            result = '01000';
        when <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>
            assert level IN {1,2};
            result = if level == 1 then '01100' else '01110';
        when <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a>
            result = '11001';
        when <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>
            assert level IN {1,2};
            result = if level == 1 then '11100' else '11110';
        when <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>
            result = '11000';
        when <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>
            result = '10110';
        when <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>
            result = '00010';
        when <a link="Fault_TLBConflict" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TLBConflict</a>
            result = '10000';
        when <a link="Fault_Lockdown" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Lockdown</a>
            result = '10100';   // IMPLEMENTATION DEFINED
        when <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>
            result = '10101';   // IMPLEMENTATION DEFINED
        when <a link="Fault_ICacheMaint" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_ICacheMaint</a>
            result = '00100';
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/common/A32ExpandImm" mylink="aarch32.functions.common.A32ExpandImm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// A32ExpandImm()
// ==============

bits(32) <anchor link="impl-aarch32.A32ExpandImm.1" hover="function: bits(32) A32ExpandImm(bits(12) imm12)">A32ExpandImm</anchor>(bits(12) imm12)

    // PSTATE.C argument to following function call does not affect the imm32 result.
    (imm32, -) = <a link="impl-aarch32.A32ExpandImm_C.2" file="shared_pseudocode.xml" hover="function: (bits(32), bit) A32ExpandImm_C(bits(12) imm12, bit carry_in)">A32ExpandImm_C</a>(imm12, PSTATE.C);

    return imm32;</pstext>
    </ps>
    <ps name="aarch32/functions/common/A32ExpandImm_C" mylink="aarch32.functions.common.A32ExpandImm_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// A32ExpandImm_C()
// ================

(bits(32), bit) <anchor link="impl-aarch32.A32ExpandImm_C.2" hover="function: (bits(32), bit) A32ExpandImm_C(bits(12) imm12, bit carry_in)">A32ExpandImm_C</anchor>(bits(12) imm12, bit carry_in)

    unrotated_value = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(imm12&lt;7:0&gt;, 32);
    (imm32, carry_out) = <a link="impl-aarch32.Shift_C.4" file="shared_pseudocode.xml" hover="function: (bits(N), bit) Shift_C(bits(N) value, SRType srtype, integer amount, bit carry_in)">Shift_C</a>(unrotated_value, <a link="SRType_ROR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ROR</a>, 2*<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imm12&lt;11:8&gt;), carry_in);

    return (imm32, carry_out);</pstext>
    </ps>
    <ps name="aarch32/functions/common/DecodeImmShift" mylink="aarch32.functions.common.DecodeImmShift" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeImmShift()
// ================

(SRType, integer) <anchor link="impl-aarch32.DecodeImmShift.2" hover="function: (SRType, integer) DecodeImmShift(bits(2) srtype, bits(5) imm5)">DecodeImmShift</anchor>(bits(2) srtype, bits(5) imm5)

    <a link="SRType" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType</a> shift_t;
    integer shift_n;
    case srtype of
        when '00'
            shift_t = <a link="SRType_LSL" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSL</a>;  shift_n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imm5);
        when '01'
            shift_t = <a link="SRType_LSR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSR</a>;  shift_n = if imm5 == '00000' then 32 else <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imm5);
        when '10'
            shift_t = <a link="SRType_ASR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ASR</a>;  shift_n = if imm5 == '00000' then 32 else <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imm5);
        when '11'
            if imm5 == '00000' then
                shift_t = <a link="SRType_RRX" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_RRX</a>;  shift_n = 1;
            else
                shift_t = <a link="SRType_ROR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ROR</a>;  shift_n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imm5);

    return (shift_t, shift_n);</pstext>
    </ps>
    <ps name="aarch32/functions/common/DecodeRegShift" mylink="aarch32.functions.common.DecodeRegShift" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeRegShift()
// ================

SRType <anchor link="impl-aarch32.DecodeRegShift.1" hover="function: SRType DecodeRegShift(bits(2) srtype)">DecodeRegShift</anchor>(bits(2) srtype)
    <a link="SRType" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType</a> shift_t;
    case srtype of
        when '00'  shift_t = <a link="SRType_LSL" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSL</a>;
        when '01'  shift_t = <a link="SRType_LSR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSR</a>;
        when '10'  shift_t = <a link="SRType_ASR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ASR</a>;
        when '11'  shift_t = <a link="SRType_ROR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ROR</a>;
    return shift_t;</pstext>
    </ps>
    <ps name="aarch32/functions/common/RRX" mylink="aarch32.functions.common.RRX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RRX()
// =====

bits(N) <anchor link="impl-aarch32.RRX.2" hover="function: bits(N) RRX(bits(N) x, bit carry_in)">RRX</anchor>(bits(N) x, bit carry_in)
    (result, -) = <a link="impl-aarch32.RRX_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) RRX_C(bits(N) x, bit carry_in)">RRX_C</a>(x, carry_in);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/common/RRX_C" mylink="aarch32.functions.common.RRX_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RRX_C()
// =======

(bits(N), bit) <anchor link="impl-aarch32.RRX_C.2" hover="function: (bits(N), bit) RRX_C(bits(N) x, bit carry_in)">RRX_C</anchor>(bits(N) x, bit carry_in)
    result = carry_in : x&lt;N-1:1&gt;;
    carry_out = x&lt;0&gt;;
    return (result, carry_out);</pstext>
    </ps>
    <ps name="aarch32/functions/common/SRType" mylink="aarch32.functions.common.SRType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SRType
// ======

enumeration <anchor link="SRType" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType</anchor> {<anchor link="SRType_LSL" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSL</anchor>, <anchor link="SRType_LSR" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSR</anchor>, <anchor link="SRType_ASR" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ASR</anchor>, <anchor link="SRType_ROR" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ROR</anchor>, <anchor link="SRType_RRX" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_RRX</anchor>};</pstext>
    </ps>
    <ps name="aarch32/functions/common/Shift" mylink="aarch32.functions.common.Shift" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Shift()
// =======

bits(N) <anchor link="impl-aarch32.Shift.4" hover="function: bits(N) Shift(bits(N) value, SRType srtype, integer amount, bit carry_in)">Shift</anchor>(bits(N) value, <a link="SRType" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType</a> srtype, integer amount, bit carry_in)
    (result, -) = <a link="impl-aarch32.Shift_C.4" file="shared_pseudocode.xml" hover="function: (bits(N), bit) Shift_C(bits(N) value, SRType srtype, integer amount, bit carry_in)">Shift_C</a>(value, srtype, amount, carry_in);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/common/Shift_C" mylink="aarch32.functions.common.Shift_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Shift_C()
// =========

(bits(N), bit) <anchor link="impl-aarch32.Shift_C.4" hover="function: (bits(N), bit) Shift_C(bits(N) value, SRType srtype, integer amount, bit carry_in)">Shift_C</anchor>(bits(N) value, <a link="SRType" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType</a> srtype, integer amount, bit carry_in)
    assert !(srtype == <a link="SRType_RRX" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_RRX</a> &amp;&amp; amount != 1);

    bits(N) result;
    bit carry_out;
    if amount == 0 then
        (result, carry_out) = (value, carry_in);
    else
        case srtype of
            when <a link="SRType_LSL" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSL</a>
                (result, carry_out) = <a link="impl-shared.LSL_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) LSL_C(bits(N) x, integer shift)">LSL_C</a>(value, amount);
            when <a link="SRType_LSR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_LSR</a>
                (result, carry_out) = <a link="impl-shared.LSR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) LSR_C(bits(N) x, integer shift)">LSR_C</a>(value, amount);
            when <a link="SRType_ASR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ASR</a>
                (result, carry_out) = <a link="impl-shared.ASR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) ASR_C(bits(N) x, integer shift)">ASR_C</a>(value, amount);
            when <a link="SRType_ROR" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_ROR</a>
                (result, carry_out) = <a link="impl-shared.ROR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) ROR_C(bits(N) x, integer shift)">ROR_C</a>(value, amount);
            when <a link="SRType_RRX" file="shared_pseudocode.xml" hover="enumeration SRType {SRType_LSL, SRType_LSR, SRType_ASR, SRType_ROR, SRType_RRX}">SRType_RRX</a>
                (result, carry_out) = <a link="impl-aarch32.RRX_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) RRX_C(bits(N) x, bit carry_in)">RRX_C</a>(value, carry_in);

    return (result, carry_out);</pstext>
    </ps>
    <ps name="aarch32/functions/common/T32ExpandImm" mylink="aarch32.functions.common.T32ExpandImm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// T32ExpandImm()
// ==============

bits(32) <anchor link="impl-aarch32.T32ExpandImm.1" hover="function: bits(32) T32ExpandImm(bits(12) imm12)">T32ExpandImm</anchor>(bits(12) imm12)

    // PSTATE.C argument to following function call does not affect the imm32 result.
    (imm32, -) = <a link="impl-aarch32.T32ExpandImm_C.2" file="shared_pseudocode.xml" hover="function: (bits(32), bit) T32ExpandImm_C(bits(12) imm12, bit carry_in)">T32ExpandImm_C</a>(imm12, PSTATE.C);

    return imm32;</pstext>
    </ps>
    <ps name="aarch32/functions/common/T32ExpandImm_C" mylink="aarch32.functions.common.T32ExpandImm_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// T32ExpandImm_C()
// ================

(bits(32), bit) <anchor link="impl-aarch32.T32ExpandImm_C.2" hover="function: (bits(32), bit) T32ExpandImm_C(bits(12) imm12, bit carry_in)">T32ExpandImm_C</anchor>(bits(12) imm12, bit carry_in)
    bits(32) imm32;
    bit carry_out;
    if imm12&lt;11:10&gt; == '00' then
        case imm12&lt;9:8&gt; of
            when '00'
                imm32 = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(imm12&lt;7:0&gt;, 32);
            when '01'
                imm32 = '00000000' : imm12&lt;7:0&gt; : '00000000' : imm12&lt;7:0&gt;;
            when '10'
                imm32 = imm12&lt;7:0&gt; : '00000000' : imm12&lt;7:0&gt; : '00000000';
            when '11'
                imm32 = imm12&lt;7:0&gt; : imm12&lt;7:0&gt; : imm12&lt;7:0&gt; : imm12&lt;7:0&gt;;
        carry_out = carry_in;
    else
        unrotated_value = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>('1':imm12&lt;6:0&gt;, 32);
        (imm32, carry_out) = <a link="impl-shared.ROR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) ROR_C(bits(N) x, integer shift)">ROR_C</a>(unrotated_value, <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imm12&lt;11:7&gt;));

    return (imm32, carry_out);</pstext>
    </ps>
    <ps name="aarch32/functions/common/VBitOps" mylink="aarch32.functions.common.VBitOps" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VBitOps
// =======

enumeration <anchor link="VBitOps" hover="enumeration VBitOps {VBitOps_VBIF, VBitOps_VBIT, VBitOps_VBSL}">VBitOps</anchor> {<anchor link="VBitOps_VBIF" hover="enumeration VBitOps {VBitOps_VBIF, VBitOps_VBIT, VBitOps_VBSL}">VBitOps_VBIF</anchor>, <anchor link="VBitOps_VBIT" hover="enumeration VBitOps {VBitOps_VBIF, VBitOps_VBIT, VBitOps_VBSL}">VBitOps_VBIT</anchor>, <anchor link="VBitOps_VBSL" hover="enumeration VBitOps {VBitOps_VBIF, VBitOps_VBIT, VBitOps_VBSL}">VBitOps_VBSL</anchor>};</pstext>
    </ps>
    <ps name="aarch32/functions/common/VCGEType" mylink="aarch32.functions.common.VCGEType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VCGEType
// ========

enumeration <anchor link="VCGEType" hover="enumeration VCGEType {VCGEType_signed, VCGEType_unsigned, VCGEType_fp}">VCGEType</anchor> {<anchor link="VCGEType_signed" hover="enumeration VCGEType {VCGEType_signed, VCGEType_unsigned, VCGEType_fp}">VCGEType_signed</anchor>, <anchor link="VCGEType_unsigned" hover="enumeration VCGEType {VCGEType_signed, VCGEType_unsigned, VCGEType_fp}">VCGEType_unsigned</anchor>, <anchor link="VCGEType_fp" hover="enumeration VCGEType {VCGEType_signed, VCGEType_unsigned, VCGEType_fp}">VCGEType_fp</anchor>};</pstext>
    </ps>
    <ps name="aarch32/functions/common/VCGTtype" mylink="aarch32.functions.common.VCGTtype" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VCGTtype
// ========

enumeration <anchor link="VCGTtype" hover="enumeration VCGTtype {VCGTtype_signed, VCGTtype_unsigned, VCGTtype_fp}">VCGTtype</anchor> {<anchor link="VCGTtype_signed" hover="enumeration VCGTtype {VCGTtype_signed, VCGTtype_unsigned, VCGTtype_fp}">VCGTtype_signed</anchor>, <anchor link="VCGTtype_unsigned" hover="enumeration VCGTtype {VCGTtype_signed, VCGTtype_unsigned, VCGTtype_fp}">VCGTtype_unsigned</anchor>, <anchor link="VCGTtype_fp" hover="enumeration VCGTtype {VCGTtype_signed, VCGTtype_unsigned, VCGTtype_fp}">VCGTtype_fp</anchor>};</pstext>
    </ps>
    <ps name="aarch32/functions/common/VFPNegMul" mylink="aarch32.functions.common.VFPNegMul" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VFPNegMul
// =========

enumeration <anchor link="VFPNegMul" hover="enumeration VFPNegMul {VFPNegMul_VNMLA, VFPNegMul_VNMLS, VFPNegMul_VNMUL}">VFPNegMul</anchor> {<anchor link="VFPNegMul_VNMLA" hover="enumeration VFPNegMul {VFPNegMul_VNMLA, VFPNegMul_VNMLS, VFPNegMul_VNMUL}">VFPNegMul_VNMLA</anchor>, <anchor link="VFPNegMul_VNMLS" hover="enumeration VFPNegMul {VFPNegMul_VNMLA, VFPNegMul_VNMLS, VFPNegMul_VNMUL}">VFPNegMul_VNMLS</anchor>, <anchor link="VFPNegMul_VNMUL" hover="enumeration VFPNegMul {VFPNegMul_VNMLA, VFPNegMul_VNMLS, VFPNegMul_VNMUL}">VFPNegMul_VNMUL</anchor>};</pstext>
    </ps>
    <ps name="aarch32/functions/coproc/AArch32.CheckCP15InstrCoarseTraps" mylink="aarch32.functions.coproc.AArch32.CheckCP15InstrCoarseTraps" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckCP15InstrCoarseTraps()
// ===================================
// Check for coarse-grained  traps to System registers in the
// coproc=0b1111 encoding space by HSTR and HCR.

<anchor link="AArch32.CheckCP15InstrCoarseTraps.3" hover="function: AArch32.CheckCP15InstrCoarseTraps(integer CRn, integer nreg, integer CRm)">AArch32.CheckCP15InstrCoarseTraps</anchor>(integer CRn, integer nreg, integer CRm)
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) ||
            (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>))) then
        <a link="AArch64.CheckCP15InstrCoarseTraps.3" file="shared_pseudocode.xml" hover="function: AArch64.CheckCP15InstrCoarseTraps(integer CRn, integer nreg, integer CRm)">AArch64.CheckCP15InstrCoarseTraps</a>(CRn, nreg, CRm);

    trapped_encoding = ((CRn == 9  &amp;&amp; CRm IN {0,1,2,    5,6,7,8   }) ||
                        (CRn == 10 &amp;&amp; CRm IN {0,1,    4,      8   }) ||
                        (CRn == 11 &amp;&amp; CRm IN {0,1,2,3,4,5,6,7,8,15}));

    // Check for coarse-grained Hyp traps
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        major = if nreg == 1 then CRn else CRm;
        // Check for MCR, MRC, MCRR, and MRRC disabled by HSTR&lt;CRn/CRm&gt;
        // and MRC and MCR disabled by HCR.TIDCP.
        if ((!(major IN {4,14}) &amp;&amp; HSTR&lt;major&gt; == '1') ||
                (HCR.TIDCP == '1' &amp;&amp; nreg == 1 &amp;&amp; trapped_encoding)) then
            if (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp;
                    boolean IMPLEMENTATION_DEFINED "UNDEF unallocated CP15 access at <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>") then
                UNDEFINED;
            if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
                <a link="AArch32.SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch32.SystemAccessTrap(bits(5) mode, integer ec)">AArch32.SystemAccessTrap</a>(<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>, 0x3);
            else
                <a link="AArch64.AArch32SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, 0x3);</pstext>
    </ps>
    <ps name="aarch32/functions/exclusive/AArch32.ExclusiveMonitorsPass" mylink="aarch32.functions.exclusive.AArch32.ExclusiveMonitorsPass" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ExclusiveMonitorsPass()
// ===============================
// Return TRUE if the Exclusives monitors for the current PE include all of the addresses
// associated with the virtual address region of size bytes starting at address.
// The immediately following memory write must be to the same addresses.

boolean <anchor link="AArch32.ExclusiveMonitorsPass.2" hover="function: boolean AArch32.ExclusiveMonitorsPass(bits(32) address, integer size)">AArch32.ExclusiveMonitorsPass</anchor>(bits(32) address, integer size)

    // It is IMPLEMENTATION DEFINED whether the detection of memory aborts happens
    // before or after the check on the local Exclusives monitor. As a result a failure
    // of the local monitor can occur on some implementations even if the memory
    // access would give an memory abort.
    boolean acqrel = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescExLDST.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>, acqrel, tagchecked);
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if !<a link="AArch32.IsExclusiveVA.3" file="shared_pseudocode.xml" hover="function: boolean AArch32.IsExclusiveVA(bits(32) address, integer processorid, integer size)">AArch32.IsExclusiveVA</a>(address, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size) then
        return FALSE;

    memaddrdesc = <a link="AArch32.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, memaddrdesc.fault);

    passed = <a link="impl-shared.IsExclusiveLocal.3" file="shared_pseudocode.xml" hover="function: boolean IsExclusiveLocal(FullAddress paddress, integer processorid, integer size)">IsExclusiveLocal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);
    <a link="impl-shared.ClearExclusiveLocal.1" file="shared_pseudocode.xml" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</a>(<a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>());

    if passed &amp;&amp; memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        passed = <a link="impl-shared.IsExclusiveGlobal.3" file="shared_pseudocode.xml" hover="function: boolean IsExclusiveGlobal(FullAddress paddress, integer processorid, integer size)">IsExclusiveGlobal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    return passed;</pstext>
    </ps>
    <ps name="aarch32/functions/exclusive/AArch32.IsExclusiveVA" mylink="aarch32.functions.exclusive.AArch32.IsExclusiveVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.IsExclusiveVA()
// =======================
// An optional IMPLEMENTATION DEFINED test for an exclusive access to a virtual
// address region of size bytes starting at address.
//
// It is permitted (but not required) for this function to return FALSE and
// cause a store exclusive to fail if the virtual address region is not
// totally included within the region recorded by MarkExclusiveVA().
//
// It is always safe to return TRUE which will check the physical address only.

boolean <anchor link="AArch32.IsExclusiveVA.3" hover="function: boolean AArch32.IsExclusiveVA(bits(32) address, integer processorid, integer size)">AArch32.IsExclusiveVA</anchor>(bits(32) address, integer processorid, integer size);</pstext>
    </ps>
    <ps name="aarch32/functions/exclusive/AArch32.MarkExclusiveVA" mylink="aarch32.functions.exclusive.AArch32.MarkExclusiveVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.MarkExclusiveVA()
// =========================
// Optionally record an exclusive access to the virtual address region of size bytes
// starting at address for processorid.

<anchor link="AArch32.MarkExclusiveVA.3" hover="function: AArch32.MarkExclusiveVA(bits(32) address, integer processorid, integer size)">AArch32.MarkExclusiveVA</anchor>(bits(32) address, integer processorid, integer size);</pstext>
    </ps>
    <ps name="aarch32/functions/exclusive/AArch32.SetExclusiveMonitors" mylink="aarch32.functions.exclusive.AArch32.SetExclusiveMonitors" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SetExclusiveMonitors()
// ==============================
// Sets the Exclusives monitors for the current PE to record the addresses associated
// with the virtual address region of size bytes starting at address.

<anchor link="AArch32.SetExclusiveMonitors.2" hover="function: AArch32.SetExclusiveMonitors(bits(32) address, integer size)">AArch32.SetExclusiveMonitors</anchor>(bits(32) address, integer size)
    boolean acqrel = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescExLDST.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>, acqrel, tagchecked);
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    memaddrdesc = <a link="AArch32.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        return;

    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.MarkExclusiveGlobal.3" file="shared_pseudocode.xml" hover="function: MarkExclusiveGlobal(FullAddress paddress, integer processorid, integer size)">MarkExclusiveGlobal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    <a link="impl-shared.MarkExclusiveLocal.3" file="shared_pseudocode.xml" hover="function: MarkExclusiveLocal(FullAddress paddress, integer processorid, integer size)">MarkExclusiveLocal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    <a link="AArch32.MarkExclusiveVA.3" file="shared_pseudocode.xml" hover="function: AArch32.MarkExclusiveVA(bits(32) address, integer processorid, integer size)">AArch32.MarkExclusiveVA</a>(address, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);</pstext>
    </ps>
    <ps name="aarch32/functions/float/CheckAdvSIMDEnabled" mylink="aarch32.functions.float.CheckAdvSIMDEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckAdvSIMDEnabled()
// =====================

<anchor link="impl-aarch32.CheckAdvSIMDEnabled.0" hover="function: CheckAdvSIMDEnabled()">CheckAdvSIMDEnabled</anchor>()

    fpexc_check = TRUE;
    advsimd = TRUE;

    <a link="AArch32.CheckAdvSIMDOrFPEnabled.2" file="shared_pseudocode.xml" hover="function: AArch32.CheckAdvSIMDOrFPEnabled(boolean fpexc_check, boolean advsimd)">AArch32.CheckAdvSIMDOrFPEnabled</a>(fpexc_check, advsimd);
    // Return from CheckAdvSIMDOrFPEnabled() occurs only if Advanced SIMD access is permitted

    // Make temporary copy of D registers
    // _Dclone[] is used as input data for instruction pseudocode
    for i = 0 to 31
        _Dclone[i] = <a link="impl-aarch32.D.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) D[integer n]">D</a>[i];

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/float/CheckAdvSIMDOrVFPEnabled" mylink="aarch32.functions.float.CheckAdvSIMDOrVFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckAdvSIMDOrVFPEnabled()
// ==========================

<anchor link="impl-aarch32.CheckAdvSIMDOrVFPEnabled.2" hover="function: CheckAdvSIMDOrVFPEnabled(boolean include_fpexc_check, boolean advsimd)">CheckAdvSIMDOrVFPEnabled</anchor>(boolean include_fpexc_check, boolean advsimd)
    <a link="AArch32.CheckAdvSIMDOrFPEnabled.2" file="shared_pseudocode.xml" hover="function: AArch32.CheckAdvSIMDOrFPEnabled(boolean fpexc_check, boolean advsimd)">AArch32.CheckAdvSIMDOrFPEnabled</a>(include_fpexc_check, advsimd);
    // Return from CheckAdvSIMDOrFPEnabled() occurs only if VFP access is permitted
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/float/CheckCryptoEnabled32" mylink="aarch32.functions.float.CheckCryptoEnabled32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckCryptoEnabled32()
// ======================

<anchor link="impl-aarch32.CheckCryptoEnabled32.0" hover="function: CheckCryptoEnabled32()">CheckCryptoEnabled32</anchor>()
    <a link="impl-aarch32.CheckAdvSIMDEnabled.0" file="shared_pseudocode.xml" hover="function: CheckAdvSIMDEnabled()">CheckAdvSIMDEnabled</a>();
    // Return from CheckAdvSIMDEnabled() occurs only if access is permitted
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/float/CheckVFPEnabled" mylink="aarch32.functions.float.CheckVFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckVFPEnabled()
// =================

<anchor link="impl-aarch32.CheckVFPEnabled.1" hover="function: CheckVFPEnabled(boolean include_fpexc_check)">CheckVFPEnabled</anchor>(boolean include_fpexc_check)
    advsimd = FALSE;
    <a link="AArch32.CheckAdvSIMDOrFPEnabled.2" file="shared_pseudocode.xml" hover="function: AArch32.CheckAdvSIMDOrFPEnabled(boolean fpexc_check, boolean advsimd)">AArch32.CheckAdvSIMDOrFPEnabled</a>(include_fpexc_check, advsimd);
    // Return from CheckAdvSIMDOrFPEnabled() occurs only if VFP access is permitted
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/float/FPHalvedSub" mylink="aarch32.functions.float.FPHalvedSub" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPHalvedSub()
// =============

bits(N) <anchor link="impl-aarch32.FPHalvedSub.3" hover="function: bits(N) FPHalvedSub(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPHalvedSub</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);
    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);  inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);     zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        if inf1 &amp;&amp; inf2 &amp;&amp; sign1 == sign2 then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif (inf1 &amp;&amp; sign1 == '0') || (inf2 &amp;&amp; sign2 == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif (inf1 &amp;&amp; sign1 == '1') || (inf2 &amp;&amp; sign2 == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);
        elsif zero1 &amp;&amp; zero2 &amp;&amp; sign1 != sign2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1, N);
        else
            result_value = (value1 - value2) / 2.0;
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, N);
            else
                result = <a link="impl-shared.FPRound.3" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</a>(result_value, fpcr, N);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/float/FPRSqrtStep" mylink="aarch32.functions.float.FPRSqrtStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRSqrtStep()
// =============

bits(N) <anchor link="impl-aarch32.FPRSqrtStep.2" hover="function: bits(N) FPRSqrtStep(bits(N) op1, bits(N) op2)">FPRSqrtStep</anchor>(bits(N) op1, bits(N) op2)
    assert N IN {16,32};
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = <a link="impl-aarch32.StandardFPSCRValue.0" file="shared_pseudocode.xml" hover="function: FPCRType StandardFPSCRValue()">StandardFPSCRValue</a>();
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);
    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);  inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);     zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        bits(N) product;
        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            product = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>('0', N);
        else
            product = <a link="impl-shared.FPMul.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMul</a>(op1, op2, fpcr);
        bits(N) three = <a link="impl-shared.FPThree.2" file="shared_pseudocode.xml" hover="function: bits(N) FPThree(bit sign, integer N)">FPThree</a>('0', N);
        result = <a link="impl-aarch32.FPHalvedSub.3" file="shared_pseudocode.xml" hover="function: bits(N) FPHalvedSub(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPHalvedSub</a>(three, product, fpcr);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/float/FPRecipStep" mylink="aarch32.functions.float.FPRecipStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRecipStep()
// =============

bits(N) <anchor link="impl-aarch32.FPRecipStep.2" hover="function: bits(N) FPRecipStep(bits(N) op1, bits(N) op2)">FPRecipStep</anchor>(bits(N) op1, bits(N) op2)
    assert N IN {16,32};
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = <a link="impl-aarch32.StandardFPSCRValue.0" file="shared_pseudocode.xml" hover="function: FPCRType StandardFPSCRValue()">StandardFPSCRValue</a>();
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);
    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);  inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);     zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        bits(N) product;
        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            product = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>('0', N);
        else
            product = <a link="impl-shared.FPMul.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMul</a>(op1, op2, fpcr);
        bits(N) two = <a link="impl-shared.FPTwo.2" file="shared_pseudocode.xml" hover="function: bits(N) FPTwo(bit sign, integer N)">FPTwo</a>('0', N);
        result = <a link="impl-shared.FPSub.3" file="shared_pseudocode.xml" hover="function: bits(N) FPSub(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPSub</a>(two, product, fpcr);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/float/StandardFPSCRValue" mylink="aarch32.functions.float.StandardFPSCRValue" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StandardFPSCRValue()
// ====================

FPCRType <anchor link="impl-aarch32.StandardFPSCRValue.0" hover="function: FPCRType StandardFPSCRValue()">StandardFPSCRValue</anchor>()
    bits(32) value = '00000' : FPSCR.AHP : '110000' : FPSCR.FZ16 : '0000000000000000000';
    return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, 64);</pstext>
    </ps>
    <ps name="aarch32/functions/memory/AArch32.MemSingle" mylink="aarch32.functions.memory.AArch32.MemSingle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.MemSingle[] - non-assignment (read) form
// ================================================
// Perform an atomic, little-endian read of 'size' bytes.

bits(size*8) <anchor link="AArch32.MemSingle.read.4" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch32.MemSingle</anchor>[bits(32) address, integer size,
                               <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned]
    boolean ispair = FALSE;
    return <a link="AArch32.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch32.MemSingle</a>[address, size, accdesc, aligned, ispair];

// AArch32.MemSingle[] - non-assignment (read) form
// ================================================
// Perform an atomic, little-endian read of 'size' bytes.

bits(size*8) <anchor link="AArch32.MemSingle.read.5" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch32.MemSingle</anchor>[bits(32) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in,
                               boolean aligned, boolean ispair]
    assert size IN {1, 2, 4, 8, 16};
    bits(size*8) value;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    assert <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    memaddrdesc = <a link="AArch32.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, memaddrdesc.fault);

    // Memory array access
    if SPESampleInFlight then
        boolean is_load = TRUE;
        SPESampleLoadStore(is_load, accdesc, memaddrdesc);

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, value) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, size, accdesc);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, size, accdesc);
    return value;

// AArch32.MemSingle[] - assignment (write) form
// =============================================

<anchor link="AArch32.MemSingle.write.4" hover="accessor: AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch32.MemSingle</anchor>[bits(32) address, integer size,
                  <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned] = bits(size*8) value
    boolean ispair = FALSE;
    <a link="AArch32.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch32.MemSingle</a>[address, size, accdesc, aligned, ispair] = value;
    return;

// AArch32.MemSingle[] - assignment (write) form
// =============================================
// Perform an atomic, little-endian write of 'size' bytes.

<anchor link="AArch32.MemSingle.write.5" hover="accessor: AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch32.MemSingle</anchor>[bits(32) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in,
                  boolean aligned, boolean ispair] = bits(size*8) value
    assert size IN {1, 2, 4, 8, 16};
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    assert <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    memaddrdesc = <a link="AArch32.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    if SPESampleInFlight then
        boolean is_load = FALSE;
        SPESampleLoadStore(is_load, accdesc, memaddrdesc);

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, size, accdesc, value);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, size, accdesc);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/memory/AArch32.UnalignedAccessFaults" mylink="aarch32.functions.memory.AArch32.UnalignedAccessFaults" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.UnalignedAccessFaults()
// ===============================
// Determine whether the unaligned access generates an Alignment fault

boolean <anchor link="AArch32.UnalignedAccessFaults.1" hover="function: boolean AArch32.UnalignedAccessFaults(AccessDescriptor accdesc)">AArch32.UnalignedAccessFaults</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    return (<a link="impl-shared.AlignmentEnforced.0" file="shared_pseudocode.xml" hover="function: boolean AlignmentEnforced()">AlignmentEnforced</a>() ||
            accdesc.a32lsmd     ||
            accdesc.exclusive   ||
            accdesc.acqsc       ||
            accdesc.relsc);</pstext>
    </ps>
    <ps name="aarch32/functions/memory/Hint_PreloadData" mylink="aarch32.functions.memory.Hint_PreloadData" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_PreloadData()
// ==================

<anchor link="impl-aarch32.Hint_PreloadData.1" hover="function: Hint_PreloadData(bits(32) address)">Hint_PreloadData</anchor>(bits(32) address);</pstext>
    </ps>
    <ps name="aarch32/functions/memory/Hint_PreloadDataForWrite" mylink="aarch32.functions.memory.Hint_PreloadDataForWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_PreloadDataForWrite()
// ==========================

<anchor link="impl-aarch32.Hint_PreloadDataForWrite.1" hover="function: Hint_PreloadDataForWrite(bits(32) address)">Hint_PreloadDataForWrite</anchor>(bits(32) address);</pstext>
    </ps>
    <ps name="aarch32/functions/memory/Hint_PreloadInstr" mylink="aarch32.functions.memory.Hint_PreloadInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_PreloadInstr()
// ===================

<anchor link="impl-aarch32.Hint_PreloadInstr.1" hover="function: Hint_PreloadInstr(bits(32) address)">Hint_PreloadInstr</anchor>(bits(32) address);</pstext>
    </ps>
    <ps name="aarch32/functions/memory/MemA" mylink="aarch32.functions.memory.MemA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemA[] - non-assignment form
// ============================

bits(8*size) <anchor link="impl-aarch32.MemA.read.2" hover="accessor: bits(8*size) MemA[bits(32) address, integer size]">MemA</anchor>[bits(32) address, integer size]
    boolean acqrel = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescExLDST.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>, acqrel, tagchecked);
    return <a link="impl-aarch32.Mem_with_type.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc]">Mem_with_type</a>[address, size, accdesc];

// MemA[] - assignment form
// ========================

<anchor link="impl-aarch32.MemA.write.2" hover="accessor: MemA[bits(32) address, integer size] = bits(8*size) value">MemA</anchor>[bits(32) address, integer size] = bits(8*size) value
    boolean acqrel = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescExLDST.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>, acqrel, tagchecked);
    Mem_with_type[address, size, accdesc] = value;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/memory/MemO" mylink="aarch32.functions.memory.MemO" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemO[] - non-assignment form
// ============================

bits(8*size) <anchor link="impl-aarch32.MemO.read.2" hover="accessor: bits(8*size) MemO[bits(32) address, integer size]">MemO</anchor>[bits(32) address, integer size]
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescAcqRel.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescAcqRel(MemOp memop, boolean tagchecked)">CreateAccDescAcqRel</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>, tagchecked);
    return <a link="impl-aarch32.Mem_with_type.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc]">Mem_with_type</a>[address, size, accdesc];

// MemO[] - assignment form
// ========================

<anchor link="impl-aarch32.MemO.write.2" hover="accessor: MemO[bits(32) address, integer size] = bits(8*size) value">MemO</anchor>[bits(32) address, integer size] = bits(8*size) value
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescAcqRel.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescAcqRel(MemOp memop, boolean tagchecked)">CreateAccDescAcqRel</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>, tagchecked);
    Mem_with_type[address, size, accdesc] = value;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/memory/MemS" mylink="aarch32.functions.memory.MemS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemS[] - non-assignment form
// ============================
// Memory accessor for streaming load multiple instructions

bits(8*size) <anchor link="impl-aarch32.MemS.read.2" hover="accessor: bits(8*size) MemS[bits(32) address, integer size]">MemS</anchor>[bits(32) address, integer size]
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescA32LSMD.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescA32LSMD(MemOp memop)">CreateAccDescA32LSMD</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);
    return <a link="impl-aarch32.Mem_with_type.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc]">Mem_with_type</a>[address, size, accdesc];

// MemS[] - assignment form
// ========================
// Memory accessor for streaming store multiple instructions

<anchor link="impl-aarch32.MemS.write.2" hover="accessor: MemS[bits(32) address, integer size] = bits(8*size) value">MemS</anchor>[bits(32) address, integer size] = bits(8*size) value
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescA32LSMD.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescA32LSMD(MemOp memop)">CreateAccDescA32LSMD</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>);
    Mem_with_type[address, size, accdesc] = value;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/memory/MemU" mylink="aarch32.functions.memory.MemU" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemU[] - non-assignment form
// ============================

bits(8*size) <anchor link="impl-aarch32.MemU.read.2" hover="accessor: bits(8*size) MemU[bits(32) address, integer size]">MemU</anchor>[bits(32) address, integer size]
    boolean nontemporal = FALSE;
    boolean privileged = PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGPR.4" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGPR(MemOp memop, boolean nontemporal, boolean privileged, boolean tagchecked)">CreateAccDescGPR</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>, nontemporal, privileged, tagchecked);
    return <a link="impl-aarch32.Mem_with_type.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc]">Mem_with_type</a>[address, size, accdesc];

// MemU[] - assignment form
// ========================

<anchor link="impl-aarch32.MemU.write.2" hover="accessor: MemU[bits(32) address, integer size] = bits(8*size) value">MemU</anchor>[bits(32) address, integer size] = bits(8*size) value
    boolean nontemporal = FALSE;
    boolean privileged = PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGPR.4" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGPR(MemOp memop, boolean nontemporal, boolean privileged, boolean tagchecked)">CreateAccDescGPR</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>, nontemporal, privileged, tagchecked);
    Mem_with_type[address, size, accdesc] = value;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/memory/MemU_unpriv" mylink="aarch32.functions.memory.MemU_unpriv" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemU_unpriv[] - non-assignment form
// ===================================

bits(8*size) <anchor link="impl-aarch32.MemU_unpriv.read.2" hover="accessor: bits(8*size) MemU_unpriv[bits(32) address, integer size]">MemU_unpriv</anchor>[bits(32) address, integer size]
    boolean nontemporal = FALSE;
    boolean privileged = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGPR.4" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGPR(MemOp memop, boolean nontemporal, boolean privileged, boolean tagchecked)">CreateAccDescGPR</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>, nontemporal, privileged, tagchecked);
    return <a link="impl-aarch32.Mem_with_type.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc]">Mem_with_type</a>[address, size, accdesc];

// MemU_unpriv[] - assignment form
// ===============================

<anchor link="impl-aarch32.MemU_unpriv.write.2" hover="accessor: MemU_unpriv[bits(32) address, integer size] = bits(8*size) value">MemU_unpriv</anchor>[bits(32) address, integer size] = bits(8*size) value
    boolean nontemporal = FALSE;
    boolean privileged = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGPR.4" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGPR(MemOp memop, boolean nontemporal, boolean privileged, boolean tagchecked)">CreateAccDescGPR</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>, nontemporal, privileged, tagchecked);
    Mem_with_type[address, size, accdesc] = value;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/memory/Mem_with_type" mylink="aarch32.functions.memory.Mem_with_type" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Mem_with_type[] - non-assignment (read) form
// ============================================
// Perform a read of 'size' bytes. The access byte order is reversed for a big-endian access.
// Instruction fetches would call AArch32.MemSingle directly.

bits(size*8) <anchor link="impl-aarch32.Mem_with_type.read.3" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc]">Mem_with_type</anchor>[bits(32) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc]
    boolean ispair = FALSE;
    return <a link="impl-aarch32.Mem_with_type.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc, boolean ispair]">Mem_with_type</a>[address, size, accdesc, ispair];

bits(size*8) <anchor link="impl-aarch32.Mem_with_type.read.4" hover="accessor: bits(size*8) Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc, boolean ispair]">Mem_with_type</anchor>[bits(32) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean ispair]
    assert size IN {1, 2, 4, 8, 16};
    constant halfsize = size DIV 2;
    bits(size * 8) value;

    // Check alignment on size of element accessed, not overall access size
    integer alignment = if ispair then halfsize else size;
    boolean aligned   = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, alignment);

    if !aligned &amp;&amp; <a link="AArch32.UnalignedAccessFaults.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.UnalignedAccessFaults(AccessDescriptor accdesc)">AArch32.UnalignedAccessFaults</a>(accdesc) then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if aligned then
        value = <a link="AArch32.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch32.MemSingle</a>[address, size, accdesc, aligned, ispair];
    else
        assert size &gt; 1;
        value&lt;7:0&gt; = <a link="AArch32.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch32.MemSingle</a>[address, 1, accdesc, aligned];

        // For subsequent bytes it is CONSTRAINED UNPREDICTABLE whether an unaligned Device memory
        // access will generate an Alignment Fault, as to get this far means the first byte did
        // not, so we must be changing to a new translation page.
        c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVPAGE2" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVPAGE2</a>);
        assert c IN {<a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>};
        if c == <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a> then aligned = TRUE;

        for i = 1 to size-1
            value&lt;8*i+7:8*i&gt; = <a link="AArch32.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch32.MemSingle</a>[address+i, 1, accdesc, aligned];

    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        value = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value);

    return value;

// Mem_with_type[] - assignment (write) form
// =========================================
// Perform a write of 'size' bytes. The byte order is reversed for a big-endian access.

Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc] = bits(size*8) value_in
    boolean ispair = FALSE;
    Mem_with_type[address, size, accdesc, ispair] = value_in;

Mem_with_type[bits(32) address, integer size, AccessDescriptor accdesc,
        boolean ispair] = bits(size*8) value_in
    constant halfsize = size DIV 2;
    bits(size*8) value = value_in;

    // Check alignment on size of element accessed, not overall access size
    integer alignment = if ispair then halfsize else size;
    boolean aligned   = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, alignment);

    if !aligned &amp;&amp; <a link="AArch32.UnalignedAccessFaults.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.UnalignedAccessFaults(AccessDescriptor accdesc)">AArch32.UnalignedAccessFaults</a>(accdesc) then
        <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        value = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value);

    if aligned then
        <a link="AArch32.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch32.MemSingle</a>[address, size, accdesc, aligned, ispair] = value;
    else
        assert size &gt; 1;
        <a link="AArch32.MemSingle.write.4" file="shared_pseudocode.xml" hover="accessor: AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch32.MemSingle</a>[address, 1, accdesc, aligned] = value&lt;7:0&gt;;

        // For subsequent bytes it is CONSTRAINED UNPREDICTABLE whether an unaligned Device memory
        // access will generate an Alignment Fault, as to get this far means the first byte did
        // not, so we must be changing to a new translation page.

        c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVPAGE2" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVPAGE2</a>);
        assert c IN {<a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>};
        if c == <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a> then aligned = TRUE;

        for i = 1 to size-1
            <a link="AArch32.MemSingle.write.4" file="shared_pseudocode.xml" hover="accessor: AArch32.MemSingle[bits(32) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch32.MemSingle</a>[address+i, 1, accdesc, aligned] = value&lt;8*i+7:8*i&gt;;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/ras/AArch32.ESBOperation" mylink="aarch32.functions.ras.AArch32.ESBOperation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ESBOperation()
// ======================
// Perform the AArch32 ESB operation for ESB executed in AArch32 state

<anchor link="AArch32.ESBOperation.0" hover="function: AArch32.ESBOperation()">AArch32.ESBOperation</anchor>()

    // Check if routed to AArch64 state
    route_to_aarch64 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        route_to_aarch64 = HCR_EL2.TGE == '1' || HCR_EL2.AMO == '1';
    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        route_to_aarch64 = <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1';

    if route_to_aarch64 then
        <a link="AArch64.ESBOperation.0" file="shared_pseudocode.xml" hover="function: AArch64.ESBOperation()">AArch64.ESBOperation</a>();
        return;

    route_to_monitor = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1';
    route_to_hyp = PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; (HCR.TGE == '1' || HCR.AMO == '1');

    bits(5) target;
    if route_to_monitor then
        target = <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>;
    elsif route_to_hyp || PSTATE.M == <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a> then
        target = <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>;
    else
        target = <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>;

    boolean mask_active;
    if <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        mask_active = TRUE;
    elsif target == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then
        mask_active = SCR.AW == '1' &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) || (HCR.TGE == '0' &amp;&amp; HCR.AMO == '0'));
    else
        mask_active = target == <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a> || PSTATE.M == <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>;

    mask_set = PSTATE.A == '1';
    (-, el)  = <a link="impl-shared.ELFromM32.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</a>(target);
    intdis   = <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() || <a link="impl-shared.ExternalDebugInterruptsDisabled.1" file="shared_pseudocode.xml" hover="function: boolean ExternalDebugInterruptsDisabled(bits(2) target)">ExternalDebugInterruptsDisabled</a>(el);
    masked   = intdis || (mask_active &amp;&amp; mask_set);

    // Check for a masked Physical SError pending that can be synchronized
    // by an Error synchronization event.
    if masked &amp;&amp; <a link="impl-shared.IsSynchronizablePhysicalSErrorPending.0" file="shared_pseudocode.xml" hover="function: boolean IsSynchronizablePhysicalSErrorPending()">IsSynchronizablePhysicalSErrorPending</a>() then
        bits(32) syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
        syndrome&lt;31&gt; = '1';  // A
        syndrome&lt;15:0&gt; = <a link="AArch32.PhysicalSErrorSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(16) AArch32.PhysicalSErrorSyndrome()">AArch32.PhysicalSErrorSyndrome</a>();
        DISR = syndrome;
        <a link="impl-shared.ClearPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: ClearPendingPhysicalSError()">ClearPendingPhysicalSError</a>();

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/ras/AArch32.EncodeAsyncErrorSyndrome" mylink="aarch32.functions.ras.AArch32.EncodeAsyncErrorSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EncodeAsyncErrorSyndrome()
// ==================================
// Return the corresponding encoding for ErrorState.

bits(2) <anchor link="AArch32.EncodeAsyncErrorSyndrome.1" hover="function: bits(2) AArch32.EncodeAsyncErrorSyndrome(ErrorState errorstate)">AArch32.EncodeAsyncErrorSyndrome</anchor>(<a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errorstate)
    case errorstate of
        when <a link="ErrorState_UC" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</a>   return '00';
        when <a link="ErrorState_UEU" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEU</a>  return '01';
        when <a link="ErrorState_UEO" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEO</a>  return '10';
        when <a link="ErrorState_UER" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UER</a>  return '11';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch32/functions/ras/AArch32.PhysicalSErrorSyndrome" mylink="aarch32.functions.ras.AArch32.PhysicalSErrorSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PhysicalSErrorSyndrome()
// ================================
// Generate SError syndrome.

bits(16) <anchor link="AArch32.PhysicalSErrorSyndrome.0" hover="function: bits(16) AArch32.PhysicalSErrorSyndrome()">AArch32.PhysicalSErrorSyndrome</anchor>()
    bits(32) syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.GetPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: FaultRecord GetPendingPhysicalSError()">GetPendingPhysicalSError</a>();
    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errstate = <a link="AArch32.PEErrorState.1" file="shared_pseudocode.xml" hover="function: ErrorState AArch32.PEErrorState(FaultRecord fault)">AArch32.PEErrorState</a>(fault);
        syndrome&lt;11:10&gt; = <a link="AArch32.EncodeAsyncErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch32.EncodeAsyncErrorSyndrome(ErrorState errorstate)">AArch32.EncodeAsyncErrorSyndrome</a>(errstate);   // AET
        syndrome&lt;9&gt;     = fault.extflag;                                // EA
        syndrome&lt;5:0&gt;   = '010001';                                     // DFSC
    else
        boolean long_format = TTBCR.EAE == '1';
        syndrome = <a link="AArch32.CommonFaultStatus.2" file="shared_pseudocode.xml" hover="function: bits(32) AArch32.CommonFaultStatus(FaultRecord fault, boolean long_format)">AArch32.CommonFaultStatus</a>(fault, long_format);
    return syndrome&lt;15:0&gt;;</pstext>
    </ps>
    <ps name="aarch32/functions/ras/AArch32.vESBOperation" mylink="aarch32.functions.ras.AArch32.vESBOperation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.vESBOperation()
// =======================
// Perform the ESB operation for virtual SError interrupts executed in AArch32 state

<anchor link="AArch32.vESBOperation.0" hover="function: AArch32.vESBOperation()">AArch32.vESBOperation</anchor>()
    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    // Check for EL2 using AArch64 state
    if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        <a link="AArch64.vESBOperation.0" file="shared_pseudocode.xml" hover="function: AArch64.vESBOperation()">AArch64.vESBOperation</a>();
        return;

    // If physical SError interrupts are routed to Hyp mode, and TGE is not set,
    // then a virtual SError interrupt might be pending
    vSEI_enabled = HCR.TGE == '0' &amp;&amp; HCR.AMO == '1';
    vSEI_pending = vSEI_enabled &amp;&amp; HCR.VA == '1';
    vintdis      = <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() || <a link="impl-shared.ExternalDebugInterruptsDisabled.1" file="shared_pseudocode.xml" hover="function: boolean ExternalDebugInterruptsDisabled(bits(2) target)">ExternalDebugInterruptsDisabled</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    vmasked      = vintdis || PSTATE.A == '1';

    // Check for a masked virtual SError pending
    if vSEI_pending &amp;&amp; vmasked then
        bits(32) syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
        syndrome&lt;31&gt; = '1';              // A
        syndrome&lt;15:14&gt; = VDFSR&lt;15:14&gt;;  // AET
        syndrome&lt;12&gt;    = VDFSR&lt;12&gt;;     // ExT
        syndrome&lt;9&gt;     = TTBCR.EAE;     // LPAE
        if TTBCR.EAE == '1' then         // Long-descriptor format
            syndrome&lt;5:0&gt;    = '010001'; // STATUS
        else                             // Short-descriptor format
            syndrome&lt;10,3:0&gt; = '10110';  // FS
        VDISR = syndrome;
        HCR.VA = '0';                    // Clear pending virtual SError

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/AArch32.ResetGeneralRegisters" mylink="aarch32.functions.registers.AArch32.ResetGeneralRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ResetGeneralRegisters()
// ===============================

<anchor link="AArch32.ResetGeneralRegisters.0" hover="function: AArch32.ResetGeneralRegisters()">AArch32.ResetGeneralRegisters</anchor>()

    for i = 0 to 7
        <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[i] = bits(32) UNKNOWN;
    for i = 8 to 12
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>] = bits(32) UNKNOWN;
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>] = bits(32) UNKNOWN;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[13, <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>] = bits(32) UNKNOWN;   // No R14_hyp
    for i = 13 to 14
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>] = bits(32) UNKNOWN;
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>] = bits(32) UNKNOWN;
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>] = bits(32) UNKNOWN;
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>] = bits(32) UNKNOWN;
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>] = bits(32) UNKNOWN;
        <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>] = bits(32) UNKNOWN;
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[i, <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>] = bits(32) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/AArch32.ResetSIMDFPRegisters" mylink="aarch32.functions.registers.AArch32.ResetSIMDFPRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ResetSIMDFPRegisters()
// ==============================

<anchor link="AArch32.ResetSIMDFPRegisters.0" hover="function: AArch32.ResetSIMDFPRegisters()">AArch32.ResetSIMDFPRegisters</anchor>()

    for i = 0 to 15
        <a link="impl-aarch32.Q.write.1" file="shared_pseudocode.xml" hover="accessor: Q[integer n] = bits(128) value">Q</a>[i] = bits(128) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/AArch32.ResetSpecialRegisters" mylink="aarch32.functions.registers.AArch32.ResetSpecialRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ResetSpecialRegisters()
// ===============================

<anchor link="AArch32.ResetSpecialRegisters.0" hover="function: AArch32.ResetSpecialRegisters()">AArch32.ResetSpecialRegisters</anchor>()

    // AArch32 special registers
    SPSR_fiq&lt;31:0&gt; = bits(32) UNKNOWN;
    SPSR_irq&lt;31:0&gt; = bits(32) UNKNOWN;
    SPSR_svc&lt;31:0&gt; = bits(32) UNKNOWN;
    SPSR_abt&lt;31:0&gt; = bits(32) UNKNOWN;
    SPSR_und&lt;31:0&gt; = bits(32) UNKNOWN;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        SPSR_hyp = bits(32) UNKNOWN;
        ELR_hyp = bits(32) UNKNOWN;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        SPSR_mon = bits(32) UNKNOWN;

    // External debug special registers
    DLR = bits(32) UNKNOWN;
    DSPSR = bits(32) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/AArch32.ResetSystemRegisters" mylink="aarch32.functions.registers.AArch32.ResetSystemRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ResetSystemRegisters()
// ==============================

<anchor link="AArch32.ResetSystemRegisters.1" hover="function: AArch32.ResetSystemRegisters(boolean cold_reset)">AArch32.ResetSystemRegisters</anchor>(boolean cold_reset);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/ALUExceptionReturn" mylink="aarch32.functions.registers.ALUExceptionReturn" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ALUExceptionReturn()
// ====================

<anchor link="impl-aarch32.ALUExceptionReturn.1" hover="function: ALUExceptionReturn(bits(32) address)">ALUExceptionReturn</anchor>(bits(32) address)
    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        UNDEFINED;
    elsif PSTATE.M IN {<a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>,<a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>} then
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_ALUEXCEPTIONRETURN" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ALUEXCEPTIONRETURN</a>);
        assert c IN {<a link="Constraint_UNDEF" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNDEF</a>, <a link="Constraint_NOP" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NOP</a>};
        case c of
            when <a link="Constraint_UNDEF" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNDEF</a>
                UNDEFINED;
            when <a link="Constraint_NOP" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NOP</a>
                <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    else
        <a link="AArch32.ExceptionReturn.2" file="shared_pseudocode.xml" hover="function: AArch32.ExceptionReturn(bits(32) new_pc_in, bits(32) spsr)">AArch32.ExceptionReturn</a>(address, <a link="impl-shared.SPSR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(N) SPSR[]">SPSR</a>[]);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/ALUWritePC" mylink="aarch32.functions.registers.ALUWritePC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ALUWritePC()
// ============

<anchor link="impl-aarch32.ALUWritePC.1" hover="function: ALUWritePC(bits(32) address)">ALUWritePC</anchor>(bits(32) address)
    if <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then
        <a link="impl-aarch32.BXWritePC.2" file="shared_pseudocode.xml" hover="function: BXWritePC(bits(32) address_in, BranchType branch_type)">BXWritePC</a>(address, <a link="BranchType_INDIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</a>);
    else
        <a link="impl-aarch32.BranchWritePC.2" file="shared_pseudocode.xml" hover="function: BranchWritePC(bits(32) address_in, BranchType branch_type)">BranchWritePC</a>(address, <a link="BranchType_INDIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</a>);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/BXWritePC" mylink="aarch32.functions.registers.BXWritePC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BXWritePC()
// ===========

<anchor link="impl-aarch32.BXWritePC.2" hover="function: BXWritePC(bits(32) address_in, BranchType branch_type)">BXWritePC</anchor>(bits(32) address_in, <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type)
    bits(32) address = address_in;
    if address&lt;0&gt; == '1' then
        <a link="impl-aarch32.SelectInstrSet.1" file="shared_pseudocode.xml" hover="function: SelectInstrSet(InstrSet iset)">SelectInstrSet</a>(<a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a>);
        address&lt;0&gt; = '0';
    else
        <a link="impl-aarch32.SelectInstrSet.1" file="shared_pseudocode.xml" hover="function: SelectInstrSet(InstrSet iset)">SelectInstrSet</a>(<a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a>);
        // For branches to an unaligned PC counter in A32 state, the processor takes the branch
        // and does one of:
        // * Forces the address to be aligned
        // * Leaves the PC unaligned, meaning the target generates a PC Alignment fault.
        if address&lt;1&gt; == '1' &amp;&amp; <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_A32FORCEALIGNPC" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_A32FORCEALIGNPC</a>) then
            address&lt;1&gt; = '0';
    boolean branch_conditional = !(<a link="AArch32.CurrentCond.0" file="shared_pseudocode.xml" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</a>() IN {'111x'});
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(address, branch_type, branch_conditional);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/BranchWritePC" mylink="aarch32.functions.registers.BranchWritePC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchWritePC()
// ===============

<anchor link="impl-aarch32.BranchWritePC.2" hover="function: BranchWritePC(bits(32) address_in, BranchType branch_type)">BranchWritePC</anchor>(bits(32) address_in, <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type)
    bits(32) address = address_in;
    if <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then
        address&lt;1:0&gt; = '00';
    else
        address&lt;0&gt; = '0';
    boolean branch_conditional = !(<a link="AArch32.CurrentCond.0" file="shared_pseudocode.xml" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</a>() IN {'111x'});
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(address, branch_type, branch_conditional);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/CBWritePC" mylink="aarch32.functions.registers.CBWritePC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CBWritePC()
// ===========
// Takes a branch from a CBNZ/CBZ instruction.

<anchor link="impl-aarch32.CBWritePC.1" hover="function: CBWritePC(bits(32) address_in)">CBWritePC</anchor>(bits(32) address_in)
    bits(32) address = address_in;
    assert <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a>;
    address&lt;0&gt; = '0';
    boolean branch_conditional = TRUE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(address, <a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>, branch_conditional);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/D" mylink="aarch32.functions.registers.D" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// D[] - non-assignment form
// =========================

bits(64) <anchor link="impl-aarch32.D.read.1" hover="accessor: bits(64) D[integer n]">D</anchor>[integer n]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    base = (n MOD 2) * 64;
    bits(128) vreg = V[n DIV 2, 128];
    return vreg&lt;base+63:base&gt;;

// D[] - assignment form
// =====================

<anchor link="impl-aarch32.D.write.1" hover="accessor: D[integer n] = bits(64) value">D</anchor>[integer n] = bits(64) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    base = (n MOD 2) * 64;
    bits(128) vreg = V[n DIV 2, 128];
    vreg&lt;base+63:base&gt; = value;
    V[n DIV 2, 128] = vreg;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/Din" mylink="aarch32.functions.registers.Din" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Din[] - non-assignment form
// ===========================

bits(64) <anchor link="impl-aarch32.Din.read.1" hover="accessor: bits(64) Din[integer n]">Din</anchor>[integer n]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    return _Dclone[n];</pstext>
    </ps>
    <ps name="aarch32/functions/registers/LR" mylink="aarch32.functions.registers.LR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LR - assignment form
// ====================

<anchor link="impl-aarch32.LR.write.none" hover="accessor: LR = bits(32) value">LR</anchor> = bits(32) value
    <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[14] = value;
    return;

// LR - non-assignment form
// ========================

bits(32) <anchor link="impl-aarch32.LR.read.none" hover="accessor: bits(32) LR">LR</anchor>
    return <a link="impl-aarch32.R.read.1" file="shared_pseudocode.xml" hover="accessor: bits(32) R[integer n]">R</a>[14];</pstext>
    </ps>
    <ps name="aarch32/functions/registers/LoadWritePC" mylink="aarch32.functions.registers.LoadWritePC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LoadWritePC()
// =============

<anchor link="impl-aarch32.LoadWritePC.1" hover="function: LoadWritePC(bits(32) address)">LoadWritePC</anchor>(bits(32) address)
    <a link="impl-aarch32.BXWritePC.2" file="shared_pseudocode.xml" hover="function: BXWritePC(bits(32) address_in, BranchType branch_type)">BXWritePC</a>(address, <a link="BranchType_INDIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</a>);</pstext>
    </ps>
    <ps name="aarch32/functions/registers/LookUpRIndex" mylink="aarch32.functions.registers.LookUpRIndex" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LookUpRIndex()
// ==============

integer <anchor link="impl-aarch32.LookUpRIndex.2" hover="function: integer LookUpRIndex(integer n, bits(5) mode)">LookUpRIndex</anchor>(integer n, bits(5) mode)
    assert n &gt;= 0 &amp;&amp; n &lt;= 14;

    integer result;
    case n of  // Select  index by mode:     usr fiq irq svc abt und hyp
        when 8     result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode,  8, 24,  8,  8,  8,  8,  8);
        when 9     result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode,  9, 25,  9,  9,  9,  9,  9);
        when 10    result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode, 10, 26, 10, 10, 10, 10, 10);
        when 11    result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode, 11, 27, 11, 11, 11, 11, 11);
        when 12    result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode, 12, 28, 12, 12, 12, 12, 12);
        when 13    result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode, 13, 29, 17, 19, 21, 23, 15);
        when 14    result = <a link="impl-aarch32.RBankSelect.8" file="shared_pseudocode.xml" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</a>(mode, 14, 30, 16, 18, 20, 22, 14);
        otherwise  result = n;

    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/Monitor_mode_registers" mylink="aarch32.functions.registers.Monitor_mode_registers" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(32) SP_mon;
bits(32) <anchor link="impl-aarch32.LR.read.none_2" hover="accessor: bits(32) LR">LR</anchor>_mon;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/PC" mylink="aarch32.functions.registers.PC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PC - non-assignment form
// ========================

bits(32) <anchor link="impl-aarch32.PC.read.none" hover="accessor: bits(32) PC">PC</anchor>
    return <a link="impl-aarch32.R.read.1" file="shared_pseudocode.xml" hover="accessor: bits(32) R[integer n]">R</a>[15];               // This includes the offset from AArch32 state</pstext>
    </ps>
    <ps name="aarch32/functions/registers/PCStoreValue" mylink="aarch32.functions.registers.PCStoreValue" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PCStoreValue()
// ==============

bits(32) <anchor link="impl-aarch32.PCStoreValue.0" hover="function: bits(32) PCStoreValue()">PCStoreValue</anchor>()
    // This function returns the PC value. On architecture versions before Armv7, it
    // is permitted to instead return PC+4, provided it does so consistently. It is
    // used only to describe A32 instructions, so it returns the address of the current
    // instruction plus 8 (normally) or 12 (when the alternative is permitted).
    return <a link="impl-aarch32.PC.read.none" file="shared_pseudocode.xml" hover="accessor: bits(32) PC">PC</a>;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/Q" mylink="aarch32.functions.registers.Q" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Q[] - non-assignment form
// =========================

bits(128) <anchor link="impl-aarch32.Q.read.1" hover="accessor: bits(128) Q[integer n]">Q</anchor>[integer n]
    assert n &gt;= 0 &amp;&amp; n &lt;= 15;
    return V[n, 128];

// Q[] - assignment form
// =====================

<anchor link="impl-aarch32.Q.write.1" hover="accessor: Q[integer n] = bits(128) value">Q</anchor>[integer n] = bits(128) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 15;
    V[n, 128] = value;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/Qin" mylink="aarch32.functions.registers.Qin" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Qin[] - non-assignment form
// ===========================

bits(128) <anchor link="impl-aarch32.Qin.read.1" hover="accessor: bits(128) Qin[integer n]">Qin</anchor>[integer n]
    assert n &gt;= 0 &amp;&amp; n &lt;= 15;
    return <a link="impl-aarch32.Din.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) Din[integer n]">Din</a>[2*n+1]:<a link="impl-aarch32.Din.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) Din[integer n]">Din</a>[2*n];</pstext>
    </ps>
    <ps name="aarch32/functions/registers/R" mylink="aarch32.functions.registers.R" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// R[] - assignment form
// =====================

<anchor link="impl-aarch32.R.write.1" hover="accessor: R[integer n] = bits(32) value">R</anchor>[integer n] = bits(32) value
    <a link="impl-aarch32.Rmode.write.2" file="shared_pseudocode.xml" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</a>[n, PSTATE.M] = value;
    return;

// R[] - non-assignment form
// =========================

bits(32) <anchor link="impl-aarch32.R.read.1" hover="accessor: bits(32) R[integer n]">R</anchor>[integer n]
    if n == 15 then
        offset = (if <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then 8 else 4);
        return _PC&lt;31:0&gt; + offset;
    else
        return <a link="impl-aarch32.Rmode.read.2" file="shared_pseudocode.xml" hover="accessor: bits(32) Rmode[integer n, bits(5) mode]">Rmode</a>[n, PSTATE.M];</pstext>
    </ps>
    <ps name="aarch32/functions/registers/RBankSelect" mylink="aarch32.functions.registers.RBankSelect" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RBankSelect()
// =============

integer <anchor link="impl-aarch32.RBankSelect.8" hover="function: integer RBankSelect(bits(5) mode, integer usr, integer fiq, integer irq, integer svc, integer abt, integer und, integer hyp)">RBankSelect</anchor>(bits(5) mode, integer usr, integer fiq, integer irq,
                    integer svc, integer abt, integer und, integer hyp)

    integer result;
    case mode of
        when <a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>    result = usr;  // User mode
        when <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>     result = fiq;  // FIQ mode
        when <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>     result = irq;  // IRQ mode
        when <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>     result = svc;  // Supervisor mode
        when <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>   result = abt;  // Abort mode
        when <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>     result = hyp;  // Hyp mode
        when <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>   result = und;  // Undefined mode
        when <a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>  result = usr;  // System mode uses User mode registers
        otherwise        <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>(); // Monitor mode

    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/Rmode" mylink="aarch32.functions.registers.Rmode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Rmode[] - non-assignment form
// =============================

bits(32) <anchor link="impl-aarch32.Rmode.read.2" hover="accessor: bits(32) Rmode[integer n, bits(5) mode]">Rmode</anchor>[integer n, bits(5) mode]
    assert n &gt;= 0 &amp;&amp; n &lt;= 14;

    // Check for attempted use of Monitor mode in Non-secure state.
    if <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then assert mode != <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>;
    assert !<a link="impl-aarch32.BadMode.1" file="shared_pseudocode.xml" hover="function: boolean BadMode(bits(5) mode)">BadMode</a>(mode);

    if mode == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then
        if n == 13 then return SP_mon;
        elsif n == 14 then return LR_mon;
        else return _R[n]&lt;31:0&gt;;
    else
        return _R[<a link="impl-aarch32.LookUpRIndex.2" file="shared_pseudocode.xml" hover="function: integer LookUpRIndex(integer n, bits(5) mode)">LookUpRIndex</a>(n, mode)]&lt;31:0&gt;;

// Rmode[] - assignment form
// =========================

<anchor link="impl-aarch32.Rmode.write.2" hover="accessor: Rmode[integer n, bits(5) mode] = bits(32) value">Rmode</anchor>[integer n, bits(5) mode] = bits(32) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 14;

    // Check for attempted use of Monitor mode in Non-secure state.
    if <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then assert mode != <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>;
    assert !<a link="impl-aarch32.BadMode.1" file="shared_pseudocode.xml" hover="function: boolean BadMode(bits(5) mode)">BadMode</a>(mode);

    if mode == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then
        if n == 13 then SP_mon = value;
        elsif n == 14 then LR_mon = value;
        else _R[n]&lt;31:0&gt; = value;
    else
        // It is CONSTRAINED UNPREDICTABLE whether the upper 32 bits of the X
        // register are unchanged or set to zero. This is also tested for on
        // exception entry, as this applies to all AArch32 registers.
        if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ZEROUPPER</a>) then
            _R[<a link="impl-aarch32.LookUpRIndex.2" file="shared_pseudocode.xml" hover="function: integer LookUpRIndex(integer n, bits(5) mode)">LookUpRIndex</a>(n, mode)] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, 64);
        else
            _R[<a link="impl-aarch32.LookUpRIndex.2" file="shared_pseudocode.xml" hover="function: integer LookUpRIndex(integer n, bits(5) mode)">LookUpRIndex</a>(n, mode)]&lt;31:0&gt; = value;

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/S" mylink="aarch32.functions.registers.S" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S[] - non-assignment form
// =========================

bits(32) <anchor link="impl-aarch32.S.read.1" hover="accessor: bits(32) S[integer n]">S</anchor>[integer n]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    base = (n MOD 4) * 32;
    bits(128) vreg = V[n DIV 4, 128];
    return vreg&lt;base+31:base&gt;;

// S[] - assignment form
// =====================

<anchor link="impl-aarch32.S.write.1" hover="accessor: S[integer n] = bits(32) value">S</anchor>[integer n] = bits(32) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    base = (n MOD 4) * 32;
    bits(128) vreg = V[n DIV 4, 128];
    vreg&lt;base+31:base&gt; = value;
    V[n DIV 4, 128] = vreg;
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/registers/_Dclone" mylink="aarch32.functions.registers._Dclone" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// _Dclone[]
// =========
// Clone the 64-bit Advanced SIMD and VFP extension register bank for use as input to
// instruction pseudocode, to avoid read-after-write for Advanced SIMD and VFP operations.

array bits(64) _Dclone[0..31];</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.ExceptionReturn" mylink="aarch32.functions.system.AArch32.ExceptionReturn" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ExceptionReturn()
// =========================

<anchor link="AArch32.ExceptionReturn.2" hover="function: AArch32.ExceptionReturn(bits(32) new_pc_in, bits(32) spsr)">AArch32.ExceptionReturn</anchor>(bits(32) new_pc_in, bits(32) spsr)
    bits(32) new_pc = new_pc_in;
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();
    // Attempts to change to an illegal mode or state will invoke the Illegal Execution state
    // mechanism
    <a link="impl-shared.SetPSTATEFromPSR.1" file="shared_pseudocode.xml" hover="function: SetPSTATEFromPSR(bits(N) spsr)">SetPSTATEFromPSR</a>(spsr);
    <a link="impl-shared.ClearExclusiveLocal.1" file="shared_pseudocode.xml" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</a>(<a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>());
    <a link="impl-shared.SendEventLocal.0" file="shared_pseudocode.xml" hover="function: SendEventLocal()">SendEventLocal</a>();

    if PSTATE.IL == '1' then
        // If the exception return is illegal, PC[1:0] are UNKNOWN
        new_pc&lt;1:0&gt; = bits(2) UNKNOWN;
    else
        // LR[1:0] or LR[0] are treated as being 0, depending on the target instruction set state
        if PSTATE.T == '1' then
            new_pc&lt;0&gt; = '0';                 // T32
        else
            new_pc&lt;1:0&gt; = '00';              // A32

    boolean branch_conditional = !(<a link="AArch32.CurrentCond.0" file="shared_pseudocode.xml" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</a>() IN {'111x'});
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(new_pc, <a link="BranchType_ERET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_ERET</a>, branch_conditional);

    <a link="impl-shared.CheckExceptionCatch.1" file="shared_pseudocode.xml" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</a>(FALSE);              // Check for debug event on exception return</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.ExecutingCP10or11Instr" mylink="aarch32.functions.system.AArch32.ExecutingCP10or11Instr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ExecutingCP10or11Instr()
// ================================

boolean <anchor link="AArch32.ExecutingCP10or11Instr.0" hover="function: boolean AArch32.ExecutingCP10or11Instr()">AArch32.ExecutingCP10or11Instr</anchor>()
    instr =  <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>();
    instr_set = <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>();
    assert instr_set IN {<a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a>, <a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a>};

    if instr_set == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then
        return ((instr&lt;27:24&gt; == '1110' || instr&lt;27:25&gt; == '110') &amp;&amp; instr&lt;11:8&gt; IN {'101x'});
    else // InstrSet_T32
        return (instr&lt;31:28&gt; IN {'111x'} &amp;&amp; (instr&lt;27:24&gt; == '1110' || instr&lt;27:25&gt; == '110') &amp;&amp;
                instr&lt;11:8&gt; IN {'101x'});</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.ITAdvance" mylink="aarch32.functions.system.AArch32.ITAdvance" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ITAdvance()
// ===================

<anchor link="AArch32.ITAdvance.0" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</anchor>()
    if PSTATE.IT&lt;2:0&gt; == '000' then
        PSTATE.IT = '00000000';
    else
        PSTATE.IT&lt;4:0&gt; = <a link="impl-shared.LSL.2" file="shared_pseudocode.xml" hover="function: bits(N) LSL(bits(N) x, integer shift)">LSL</a>(PSTATE.IT&lt;4:0&gt;, 1);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.SysRegRead" mylink="aarch32.functions.system.AArch32.SysRegRead" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SysRegRead()
// ====================
// Read from a 32-bit AArch32 System register and write the register's contents to R[t].

<anchor link="AArch32.SysRegRead.3" hover="function: AArch32.SysRegRead(integer cp_num, bits(32) instr, integer t)">AArch32.SysRegRead</anchor>(integer cp_num, bits(32) instr, integer t);</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.SysRegRead64" mylink="aarch32.functions.system.AArch32.SysRegRead64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SysRegRead64()
// ======================
// Read from a 64-bit AArch32 System register and write the register's contents to R[t] and R[t2].

<anchor link="AArch32.SysRegRead64.4" hover="function: AArch32.SysRegRead64(integer cp_num, bits(32) instr, integer t, integer t2)">AArch32.SysRegRead64</anchor>(integer cp_num, bits(32) instr, integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.SysRegReadCanWriteAPSR" mylink="aarch32.functions.system.AArch32.SysRegReadCanWriteAPSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SysRegReadCanWriteAPSR()
// ================================
// Determines whether the AArch32 System register read instruction can write to APSR flags.

boolean <anchor link="AArch32.SysRegReadCanWriteAPSR.2" hover="function: boolean AArch32.SysRegReadCanWriteAPSR(integer cp_num, bits(32) instr)">AArch32.SysRegReadCanWriteAPSR</anchor>(integer cp_num, bits(32) instr)
    assert <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    assert (cp_num IN {14,15});
    assert cp_num == <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(instr&lt;11:8&gt;);

    opc1 = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(instr&lt;23:21&gt;);
    opc2 = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(instr&lt;7:5&gt;);
    CRn  = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(instr&lt;19:16&gt;);
    CRm  = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(instr&lt;3:0&gt;);

    if cp_num == 14 &amp;&amp; opc1 == 0 &amp;&amp; CRn == 0 &amp;&amp; CRm == 1 &amp;&amp; opc2 == 0 then // DBGDSCRint
        return TRUE;

    return FALSE;</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.SysRegWrite" mylink="aarch32.functions.system.AArch32.SysRegWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SysRegWrite()
// =====================
// Read the contents of R[t] and write to a 32-bit AArch32 System register.

<anchor link="AArch32.SysRegWrite.3" hover="function: AArch32.SysRegWrite(integer cp_num, bits(32) instr, integer t)">AArch32.SysRegWrite</anchor>(integer cp_num, bits(32) instr, integer t);</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.SysRegWrite64" mylink="aarch32.functions.system.AArch32.SysRegWrite64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SysRegWrite64()
// =======================
// Read the contents of R[t] and R[t2] and write to a 64-bit AArch32 System register.

<anchor link="AArch32.SysRegWrite64.4" hover="function: AArch32.SysRegWrite64(integer cp_num, bits(32) instr, integer t, integer t2)">AArch32.SysRegWrite64</anchor>(integer cp_num, bits(32) instr, integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.SysRegWriteM" mylink="aarch32.functions.system.AArch32.SysRegWriteM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SysRegWriteM()
// ======================
// Read a value from a virtual address and write it to an AArch32 System register.

<anchor link="AArch32.SysRegWriteM.3" hover="function: AArch32.SysRegWriteM(integer cp_num, bits(32) instr, bits(32) address)">AArch32.SysRegWriteM</anchor>(integer cp_num, bits(32) instr, bits(32) address);</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.WriteMode" mylink="aarch32.functions.system.AArch32.WriteMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.WriteMode()
// ===================
// Function for dealing with writes to PSTATE.M from AArch32 state only.
// This ensures that PSTATE.EL and PSTATE.SP are always valid.

<anchor link="AArch32.WriteMode.1" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</anchor>(bits(5) mode)
    (valid,el) = <a link="impl-shared.ELFromM32.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</a>(mode);
    assert valid;
    PSTATE.M   = mode;
    PSTATE.EL  = el;
    PSTATE.nRW = '1';
    PSTATE.SP  = (if mode IN {<a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>,<a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>} then '0' else '1');
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/system/AArch32.WriteModeByInstr" mylink="aarch32.functions.system.AArch32.WriteModeByInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.WriteModeByInstr()
// ==========================
// Function for dealing with writes to PSTATE.M from an AArch32 instruction, and ensuring that
// illegal state changes are correctly flagged in PSTATE.IL.

<anchor link="AArch32.WriteModeByInstr.1" hover="function: AArch32.WriteModeByInstr(bits(5) mode)">AArch32.WriteModeByInstr</anchor>(bits(5) mode)
    (valid,el) = <a link="impl-shared.ELFromM32.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</a>(mode);

    // 'valid' is set to FALSE if' mode' is invalid for this implementation or the current value
    // of SCR.NS/SCR_EL3.NS. Additionally, it is illegal for an instruction to write 'mode' to
    // PSTATE.EL if it would result in any of:
    // * A change to a mode that would cause entry to a higher Exception level.
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(el) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) then
        valid = FALSE;

    // * A change to or from Hyp mode.
    if (PSTATE.M == <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a> || mode == <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>) &amp;&amp; PSTATE.M != mode then
        valid = FALSE;

    // * When EL2 is implemented, the value of HCR.TGE is '1', a change to a Non-secure EL1 mode.
    if PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; SCR.NS == '1' &amp;&amp; HCR.TGE == '1' then
        valid = FALSE;

    if !valid then
        PSTATE.IL = '1';
    else
        <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(mode);</pstext>
    </ps>
    <ps name="aarch32/functions/system/BadMode" mylink="aarch32.functions.system.BadMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BadMode()
// =========

boolean <anchor link="impl-aarch32.BadMode.1" hover="function: boolean BadMode(bits(5) mode)">BadMode</anchor>(bits(5) mode)
    // Return TRUE if 'mode' encodes a mode that is not valid for this implementation
    boolean valid;
    case mode of
        when <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>
            valid = <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        when <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>
            valid = <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>, <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>, <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>, <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>, <a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>
            // If EL3 is implemented and using AArch32, then these modes are EL3 modes in Secure
            // state, and EL1 modes in Non-secure state. If EL3 is not implemented or is using
            // AArch64, then these modes are EL1 modes.
            // Therefore it is sufficient to test this implementation supports EL1 using AArch32.
            valid = <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
        when <a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>
            valid = <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>);
        otherwise
            valid = FALSE;           // Passed an illegal mode value
    return !valid;</pstext>
    </ps>
    <ps name="aarch32/functions/system/BankedRegisterAccessValid" mylink="aarch32.functions.system.BankedRegisterAccessValid" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BankedRegisterAccessValid()
// ===========================
// Checks for MRS (Banked register) or MSR (Banked register) accesses to registers
// other than the SPSRs that are invalid. This includes ELR_hyp accesses.

<anchor link="impl-aarch32.BankedRegisterAccessValid.2" hover="function: BankedRegisterAccessValid(bits(5) SYSm, bits(5) mode)">BankedRegisterAccessValid</anchor>(bits(5) SYSm, bits(5) mode)

    case SYSm of
        when '000xx', '00100'                          // R8_usr to R12_usr
            if mode != <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a> then UNPREDICTABLE;
        when '00101'                                   // SP_usr
            if mode == <a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a> then UNPREDICTABLE;
        when '00110'                                   // LR_usr
            if mode IN {<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>,<a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>} then UNPREDICTABLE;
        when '010xx', '0110x', '01110'                 // R8_fiq to R12_fiq, SP_fiq, LR_fiq
            if mode == <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a> then UNPREDICTABLE;
        when '1000x'                                   // LR_irq, SP_irq
            if mode == <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a> then UNPREDICTABLE;
        when '1001x'                                   // LR_svc, SP_svc
            if mode == <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a> then UNPREDICTABLE;
        when '1010x'                                   // LR_abt, SP_abt
            if mode == <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a> then UNPREDICTABLE;
        when '1011x'                                   // LR_und, SP_und
            if mode == <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a> then UNPREDICTABLE;
        when '1110x'                                   // LR_mon, SP_mon
            if (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> ||
                mode == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>) then UNPREDICTABLE;
        when '11110'                                   // ELR_hyp, only from Monitor or Hyp mode
            if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) || !(mode IN {<a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>,<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>}) then UNPREDICTABLE;
        when '11111'                                   // SP_hyp, only from Monitor mode
            if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) || mode != <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then UNPREDICTABLE;
        otherwise
            UNPREDICTABLE;

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/system/CPSRWriteByInstr" mylink="aarch32.functions.system.CPSRWriteByInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPSRWriteByInstr()
// ==================
// Update PSTATE.&lt;N,Z,C,V,Q,GE,E,A,I,F,M&gt; from a CPSR value written by an MSR instruction.

<anchor link="impl-aarch32.CPSRWriteByInstr.2" hover="function: CPSRWriteByInstr(bits(32) value, bits(4) bytemask)">CPSRWriteByInstr</anchor>(bits(32) value, bits(4) bytemask)
    privileged = PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;              // PSTATE.&lt;A,I,F,M&gt; are not writable at EL0

    // Write PSTATE from 'value', ignoring bytes masked by 'bytemask'
    if bytemask&lt;3&gt; == '1' then
        PSTATE.&lt;N,Z,C,V,Q&gt; = value&lt;31:27&gt;;
        // Bits &lt;26:24&gt; are ignored

    if bytemask&lt;2&gt; == '1' then
        if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then
            PSTATE.SSBS = value&lt;23&gt;;
        if privileged then
            PSTATE.PAN = value&lt;22&gt;;
        if <a link="impl-shared.HaveDITExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDITExt()">HaveDITExt</a>() then
            PSTATE.DIT = value&lt;21&gt;;
        // Bit &lt;20&gt; is RES0
        PSTATE.GE = value&lt;19:16&gt;;

    if bytemask&lt;1&gt; == '1' then
        // Bits &lt;15:10&gt; are RES0
        PSTATE.E = value&lt;9&gt;;                    // PSTATE.E is writable at EL0
        if privileged then
            PSTATE.A = value&lt;8&gt;;

    if bytemask&lt;0&gt; == '1' then
        if privileged then
            PSTATE.&lt;I,F&gt; = value&lt;7:6&gt;;
            // Bit &lt;5&gt; is RES0
            // AArch32.WriteModeByInstr() sets PSTATE.IL to 1 if this is an illegal mode change.
            <a link="AArch32.WriteModeByInstr.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteModeByInstr(bits(5) mode)">AArch32.WriteModeByInstr</a>(value&lt;4:0&gt;);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/system/ConditionPassed" mylink="aarch32.functions.system.ConditionPassed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConditionPassed()
// =================

boolean <anchor link="impl-aarch32.ConditionPassed.0" hover="function: boolean ConditionPassed()">ConditionPassed</anchor>()
    return <a link="impl-shared.ConditionHolds.1" file="shared_pseudocode.xml" hover="function: boolean ConditionHolds(bits(4) cond)">ConditionHolds</a>(<a link="AArch32.CurrentCond.0" file="shared_pseudocode.xml" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</a>());</pstext>
    </ps>
    <ps name="aarch32/functions/system/CurrentCond" mylink="aarch32.functions.system.CurrentCond" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentCond()
// =============

bits(4) <anchor link="AArch32.CurrentCond.0" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</anchor>();</pstext>
    </ps>
    <ps name="aarch32/functions/system/InITBlock" mylink="aarch32.functions.system.InITBlock" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InITBlock()
// ===========

boolean <anchor link="impl-aarch32.InITBlock.0" hover="function: boolean InITBlock()">InITBlock</anchor>()
    if <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() == <a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a> then
        return PSTATE.IT&lt;3:0&gt; != '0000';
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch32/functions/system/LastInITBlock" mylink="aarch32.functions.system.LastInITBlock" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LastInITBlock()
// ===============

boolean <anchor link="impl-aarch32.LastInITBlock.0" hover="function: boolean LastInITBlock()">LastInITBlock</anchor>()
    return (PSTATE.IT&lt;3:0&gt; == '1000');</pstext>
    </ps>
    <ps name="aarch32/functions/system/SPSRWriteByInstr" mylink="aarch32.functions.system.SPSRWriteByInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPSRWriteByInstr()
// ==================

<anchor link="impl-aarch32.SPSRWriteByInstr.2" hover="function: SPSRWriteByInstr(bits(32) value, bits(4) bytemask)">SPSRWriteByInstr</anchor>(bits(32) value, bits(4) bytemask)

    bits(32) new_spsr = <a link="impl-shared.SPSR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(N) SPSR[]">SPSR</a>[];

    if bytemask&lt;3&gt; == '1' then
        new_spsr&lt;31:24&gt; = value&lt;31:24&gt;;  // N,Z,C,V,Q flags, IT[1:0],J bits

    if bytemask&lt;2&gt; == '1' then
        new_spsr&lt;23:16&gt; = value&lt;23:16&gt;;  // IL bit, GE[3:0] flags

    if bytemask&lt;1&gt; == '1' then
        new_spsr&lt;15:8&gt; = value&lt;15:8&gt;;    // IT[7:2] bits, E bit, A interrupt mask

    if bytemask&lt;0&gt; == '1' then
        new_spsr&lt;7:0&gt; = value&lt;7:0&gt;;      // I,F interrupt masks, T bit, Mode bits

    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = new_spsr;                   // UNPREDICTABLE if User or System mode

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/system/SPSRaccessValid" mylink="aarch32.functions.system.SPSRaccessValid" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPSRaccessValid()
// =================
// Checks for MRS (Banked register) or MSR (Banked register) accesses to the SPSRs
// that are UNPREDICTABLE

<anchor link="impl-aarch32.SPSRaccessValid.2" hover="function: SPSRaccessValid(bits(5) SYSm, bits(5) mode)">SPSRaccessValid</anchor>(bits(5) SYSm, bits(5) mode)
    case SYSm of
        when '01110'                                                   // SPSR_fiq
            if mode == <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>   then UNPREDICTABLE;
        when '10000'                                                   // SPSR_irq
            if mode == <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>   then UNPREDICTABLE;
        when '10010'                                                   // SPSR_svc
            if mode == <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>   then UNPREDICTABLE;
        when '10100'                                                   // SPSR_abt
            if mode == <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a> then UNPREDICTABLE;
        when '10110'                                                   // SPSR_und
            if mode == <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a> then UNPREDICTABLE;
        when '11100'                                                   // SPSR_mon
            if (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || mode == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> ||
                <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then UNPREDICTABLE;
        when '11110'                                                   // SPSR_hyp
            if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) || mode != <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then UNPREDICTABLE;
        otherwise
            UNPREDICTABLE;

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/system/SelectInstrSet" mylink="aarch32.functions.system.SelectInstrSet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SelectInstrSet()
// ================

<anchor link="impl-aarch32.SelectInstrSet.1" hover="function: SelectInstrSet(InstrSet iset)">SelectInstrSet</anchor>(<a link="InstrSet" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet</a> iset)
    assert <a link="impl-shared.CurrentInstrSet.0" file="shared_pseudocode.xml" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</a>() IN {<a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a>, <a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a>};
    assert iset IN {<a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a>, <a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a>};

    PSTATE.T = if iset == <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> then '0' else '1';

    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.DTLBI_ALL" mylink="aarch32.functions.tlbi.AArch32.DTLBI_ALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DTLBI_ALL()
// ===================
// Invalidate all data TLB entries for the indicated translation regime with the
// the indicated security state for all TLBs within the indicated shareability domain.
// Invalidation applies to all applicable stage 1 and stage 2 entries.

<anchor link="AArch32.DTLBI_ALL.4" hover="function: AArch32.DTLBI_ALL(SecurityState security, Regime regime, Shareability shareability, TLBIMemAttr attr)">AArch32.DTLBI_ALL</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability,
                  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_DALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DALL</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.DTLBI_ASID" mylink="aarch32.functions.tlbi.AArch32.DTLBI_ASID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DTLBI_ASID()
// ====================
// Invalidate all data TLB stage 1 entries matching the indicated VMID (where regime supports)
// and ASID in the parameter Rt in the indicated translation regime with the
// indicated security state for all TLBs within the indicated shareability domain.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.DTLBI_ASID.6" hover="function: AArch32.DTLBI_ASID(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr, bits(32) Rt)">AArch32.DTLBI_ASID</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_DASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DASID</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;
    r.asid         = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : Rt&lt;7:0&gt;;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.DTLBI_VA" mylink="aarch32.functions.tlbi.AArch32.DTLBI_VA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DTLBI_VA()
// ==================
// Invalidate by VA all stage 1 data TLB entries in the indicated shareability domain
// matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime
// with the indicated security state.
// ASID, VA and related parameters are derived from Rt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.DTLBI_VA.7" hover="function: AArch32.DTLBI_VA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level,  TLBIMemAttr attr, bits(32) Rt)">AArch32.DTLBI_VA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                 <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level,  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_DVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DVA</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : Rt&lt;7:0&gt;;
    r.address      = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32) : Rt&lt;31:12&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12);

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.ITLBI_ALL" mylink="aarch32.functions.tlbi.AArch32.ITLBI_ALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ITLBI_ALL()
// ===================
// Invalidate all instruction TLB entries for the indicated translation regime with the
// the indicated security state for all TLBs within the indicated shareability domain.
// Invalidation applies to all applicable stage 1 and stage 2 entries.

<anchor link="AArch32.ITLBI_ALL.4" hover="function: AArch32.ITLBI_ALL(SecurityState security, Regime regime, Shareability shareability, TLBIMemAttr attr)">AArch32.ITLBI_ALL</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability,
                  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_IALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IALL</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.ITLBI_ASID" mylink="aarch32.functions.tlbi.AArch32.ITLBI_ASID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ITLBI_ASID()
// ====================
// Invalidate all instruction TLB stage 1 entries matching the indicated VMID
// (where regime supports) and ASID in the parameter Rt in the indicated translation
// regime with the indicated security state for all TLBs within the indicated shareability domain.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.ITLBI_ASID.6" hover="function: AArch32.ITLBI_ASID(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr, bits(32) Rt)">AArch32.ITLBI_ASID</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_IASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IASID</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;
    r.asid         = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : Rt&lt;7:0&gt;;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.ITLBI_VA" mylink="aarch32.functions.tlbi.AArch32.ITLBI_VA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.ITLBI_VA()
// ==================
// Invalidate by VA all stage 1 instruction TLB entries in the indicated shareability domain
// matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime
// with the indicated security state.
// ASID, VA and related parameters are derived from Rt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.ITLBI_VA.7" hover="function: AArch32.ITLBI_VA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level,  TLBIMemAttr attr, bits(32) Rt)">AArch32.ITLBI_VA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                 <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level,  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_IVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IVA</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : Rt&lt;7:0&gt;;
    r.address      = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32) : Rt&lt;31:12&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12);

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_ALL" mylink="aarch32.functions.tlbi.AArch32.TLBI_ALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_ALL()
// ==================
// Invalidate all entries for the indicated translation regime with the
// the indicated security state for all TLBs within the indicated shareability domain.
// Invalidation applies to all applicable stage 1 and stage 2 entries.

<anchor link="AArch32.TLBI_ALL.4" hover="function: AArch32.TLBI_ALL(SecurityState security, Regime regime, Shareability shareability, TLBIMemAttr attr)">AArch32.TLBI_ALL</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_ALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ALL</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_ASID" mylink="aarch32.functions.tlbi.AArch32.TLBI_ASID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_ASID()
// ===================
// Invalidate all stage 1 entries matching the indicated VMID (where regime supports)
// and ASID in the parameter Rt in the indicated translation regime with the
// indicated security state for all TLBs within the indicated shareability domain.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.TLBI_ASID.6" hover="function: AArch32.TLBI_ASID(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr, bits(32) Rt)">AArch32.TLBI_ASID</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                  <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_ASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ASID</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;
    r.asid         = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : Rt&lt;7:0&gt;;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_IPAS2" mylink="aarch32.functions.tlbi.AArch32.TLBI_IPAS2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_IPAS2()
// ====================
// Invalidate by IPA all stage 2 only TLB entries in the indicated shareability
// domain matching the indicated VMID in the indicated regime with the indicated security state.
// Note: stage 1 and stage 2 combined entries are not in the scope of this operation.
// IPA and related parameters of the are derived from Rt.

<anchor link="AArch32.TLBI_IPAS2.7" hover="function: AArch32.TLBI_IPAS2(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(32) Rt)">AArch32.TLBI_IPAS2</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};
    assert security == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_IPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IPAS2</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.address      = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24) : Rt&lt;27:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12);
    r.ipaspace     = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_VA" mylink="aarch32.functions.tlbi.AArch32.TLBI_VA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_VA()
// =================
// Invalidate by VA all stage 1 TLB entries in the indicated shareability domain
// matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime
// with the indicated security state.
// ASID, VA and related parameters are derived from Rt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.TLBI_VA.7" hover="function: AArch32.TLBI_VA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level,  TLBIMemAttr attr, bits(32) Rt)">AArch32.TLBI_VA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level,  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VA</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : Rt&lt;7:0&gt;;
    r.address      = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32) : Rt&lt;31:12&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12);

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_VAA" mylink="aarch32.functions.tlbi.AArch32.TLBI_VAA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_VAA()
// ==================
// Invalidate by VA all stage 1 TLB entries in the indicated shareability domain
// matching the indicated VMID (where regime supports VMID) and all ASID in the indicated regime
// with the indicated security state.
// VA and related parameters are derived from Rt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch32.TLBI_VAA.7" hover="function: AArch32.TLBI_VAA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr,  bits(32) Rt)">AArch32.TLBI_VAA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                 <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr,  bits(32) Rt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VAA</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.address      = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32) : Rt&lt;31:12&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12);

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_VMALL" mylink="aarch32.functions.tlbi.AArch32.TLBI_VMALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_VMALL()
// ====================
// Invalidate all stage 1 entries for the indicated translation regime with the
// the indicated security state for all TLBs within the indicated shareability
// domain that match the indicated VMID (where applicable).
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.
// Note: stage 2 only entries are not in the scope of this operation.

<anchor link="AArch32.TLBI_VMALL.5" hover="function: AArch32.TLBI_VMALL(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr)">AArch32.TLBI_VMALL</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VMALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALL</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.vmid         = vmid;
    r.attr         = attr;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/tlbi/AArch32.TLBI_VMALLS12" mylink="aarch32.functions.tlbi.AArch32.TLBI_VMALLS12" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBI_VMALLS12()
// =======================
// Invalidate all stage 1 and stage 2 entries for the indicated translation
// regime with the indicated security state for all TLBs within the indicated
// shareability domain that match the indicated VMID.

<anchor link="AArch32.TLBI_VMALLS12.5" hover="function: AArch32.TLBI_VMALLS12(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr)">AArch32.TLBI_VMALLS12</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                      <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VMALLS12" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALLS12</a>;
    r.from_aarch64 = FALSE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.vmid         = vmid;
    r.attr         = attr;

    TLBI(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then Broadcast(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch32/functions/v6simd/Sat" mylink="aarch32.functions.v6simd.Sat" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Sat()
// =====

bits(N) <anchor link="impl-aarch32.Sat.3" hover="function: bits(N) Sat(integer i, integer N, boolean unsigned)">Sat</anchor>(integer i, integer N, boolean unsigned)
    result = if unsigned then <a link="impl-aarch32.UnsignedSat.2" file="shared_pseudocode.xml" hover="function: bits(N) UnsignedSat(integer i, integer N)">UnsignedSat</a>(i, N) else <a link="impl-aarch32.SignedSat.2" file="shared_pseudocode.xml" hover="function: bits(N) SignedSat(integer i, integer N)">SignedSat</a>(i, N);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/v6simd/SignedSat" mylink="aarch32.functions.v6simd.SignedSat" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SignedSat()
// ===========

bits(N) <anchor link="impl-aarch32.SignedSat.2" hover="function: bits(N) SignedSat(integer i, integer N)">SignedSat</anchor>(integer i, integer N)
    (result, -) = <a link="impl-shared.SignedSatQ.2" file="shared_pseudocode.xml" hover="function: (bits(N), boolean) SignedSatQ(integer i, integer N)">SignedSatQ</a>(i, N);
    return result;</pstext>
    </ps>
    <ps name="aarch32/functions/v6simd/UnsignedSat" mylink="aarch32.functions.v6simd.UnsignedSat" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UnsignedSat()
// =============

bits(N) <anchor link="impl-aarch32.UnsignedSat.2" hover="function: bits(N) UnsignedSat(integer i, integer N)">UnsignedSat</anchor>(integer i, integer N)
    (result, -) = <a link="impl-shared.UnsignedSatQ.2" file="shared_pseudocode.xml" hover="function: (bits(N), boolean) UnsignedSatQ(integer i, integer N)">UnsignedSatQ</a>(i, N);
    return result;</pstext>
    </ps>
    <ps name="aarch32/ic/AArch32.IC" mylink="aarch32.ic.AArch32.IC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.IC()
// ============
// Perform Instruction Cache Operation.

<anchor link="AArch32.IC.1" hover="function: AArch32.IC(CacheOpScope opscope)">AArch32.IC</anchor>(<a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    regval = bits(32) UNKNOWN;
    <a link="AArch32.IC.2" file="shared_pseudocode.xml" hover="function: AArch32.IC(bits(32) regval, CacheOpScope opscope)">AArch32.IC</a>(regval, opscope);

// AArch32.IC()
// ============
// Perform Instruction Cache Operation.

<anchor link="AArch32.IC.2" hover="function: AArch32.IC(bits(32) regval, CacheOpScope opscope)">AArch32.IC</anchor>(bits(32) regval, <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    <a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache;

    cache.acctype   = <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>;
    cache.cachetype = <a link="CacheType_Instruction" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Instruction</a>;
    cache.cacheop   = <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a>;
    cache.opscope   = opscope;
    cache.security  = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);

    if opscope IN {<a link="CacheOpScope_ALLU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLU</a>, <a link="CacheOpScope_ALLUIS" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLUIS</a>} then
        if opscope == <a link="CacheOpScope_ALLUIS" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLUIS</a> || (opscope == <a link="CacheOpScope_ALLU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLU</a> &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR.FB == '1') then
            cache.shareability = <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a>;
        else
            cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        cache.regval = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(regval, 64);
        <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
    else
        assert opscope == <a link="CacheOpScope_PoU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoU</a>;

        if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
            if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
                cache.is_vmid_valid = TRUE;
                cache.vmid          = VMID[];
            else
                cache.is_vmid_valid = FALSE;
        else
            cache.is_vmid_valid = FALSE;

        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            cache.is_asid_valid = TRUE;
            cache.asid          = <a link="impl-shared.ASID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) ASID[]">ASID</a>[];
        else
            cache.is_asid_valid = FALSE;

        need_translate = <a link="impl-shared.ICInstNeedsTranslation.1" file="shared_pseudocode.xml" hover="function: boolean ICInstNeedsTranslation(CacheOpScope opscope)">ICInstNeedsTranslation</a>(opscope);

        cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        cache.vaddress     = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(regval, 64);
        cache.translated   = need_translate;

        if !need_translate then
            cache.paddress = <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> UNKNOWN;
            <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
            return;

        integer size    = 0;
        boolean aligned = TRUE;
        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescIC.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescIC(CacheRecord cache)">CreateAccDescIC</a>(cache);
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch32.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</a>(regval, accdesc, aligned, size);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
            <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(regval, memaddrdesc.fault);

        cache.paddress = memaddrdesc.paddress;
        <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
    return;</pstext>
    </ps>
    <ps name="aarch32/predictionrestrict/AArch32.RestrictPrediction" mylink="aarch32.predictionrestrict.AArch32.RestrictPrediction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.RestrictPrediction()
// ============================
// Clear all predictions in the context.

<anchor link="AArch32.RestrictPrediction.2" hover="function: AArch32.RestrictPrediction(bits(32) val, RestrictType restriction)">AArch32.RestrictPrediction</anchor>(bits(32) val, <a link="RestrictType" file="shared_pseudocode.xml" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType</a> restriction)

    <a link="ExecutionCntxt" file="shared_pseudocode.xml" hover="type ExecutionCntxt is ( boolean is_vmid_valid, boolean all_vmid, bits(16) vmid, boolean is_asid_valid, boolean all_asid, bits(16) asid, bits(2) target_el, SecurityState security, RestrictType restriction )">ExecutionCntxt</a> c;
    target_el    = val&lt;25:24&gt;;

    // If the target EL is not implemented or the instruction is executed at an
    // EL lower than the specified level, the instruction is treated as a NOP.
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) || <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();

    bit ns  = val&lt;26&gt;;
    bit nse = bit UNKNOWN;
    ss = <a link="impl-shared.TargetSecurityState.2" file="shared_pseudocode.xml" hover="function: SecurityState TargetSecurityState(bit NS, bit NSE)">TargetSecurityState</a>(ns, nse);

    c.security  = ss;
    c.target_el = target_el;

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
            c.is_vmid_valid = TRUE;
            c.all_vmid      = FALSE;
            c.vmid          = VMID[];

        elsif target_el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
            c.is_vmid_valid = TRUE;
            c.all_vmid      = val&lt;27&gt; == '1';
            c.vmid          = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(val&lt;23:16&gt;, 16);      // Only valid if  val&lt;27&gt; == '0';
        else
            c.is_vmid_valid = FALSE;
    else
        c.is_vmid_valid = FALSE;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        c.is_asid_valid = TRUE;
        c.all_asid      = FALSE;
        c.asid          = <a link="impl-shared.ASID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) ASID[]">ASID</a>[];

    elsif target_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        c.is_asid_valid = TRUE;
        c.all_asid      = val&lt;8&gt; == '1';
        c.asid          = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(val&lt;7:0&gt;, 16);            // Only valid if  val&lt;8&gt; == '0';

    else
        c.is_asid_valid = FALSE;

    c.restriction = restriction;
    <a link="impl-shared.RESTRICT_PREDICTIONS.1" file="shared_pseudocode.xml" hover="function: RESTRICT_PREDICTIONS(ExecutionCntxt c)">RESTRICT_PREDICTIONS</a>(c);</pstext>
    </ps>
    <ps name="aarch32/translation/attrs/AArch32.DefaultTEXDecode" mylink="aarch32.translation.attrs.AArch32.DefaultTEXDecode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DefaultTEXDecode()
// ==========================
// Apply short-descriptor format memory region attributes, without TEX remap

MemoryAttributes <anchor link="AArch32.DefaultTEXDecode.4" hover="function: MemoryAttributes AArch32.DefaultTEXDecode(bits(3) TEX_in, bit C_in, bit B_in, bit s)">AArch32.DefaultTEXDecode</anchor>(bits(3) TEX_in, bit C_in, bit B_in, bit s)
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    bits(3) TEX = TEX_in;
    bit C = C_in;
    bit B = B_in;

    // Reserved values map to allocated values
    if (TEX == '001' &amp;&amp; C:B == '01') || (TEX == '010' &amp;&amp; C:B != '00') || TEX == '011' then
        bits(5) texcb;
        (-, texcb) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESTEXCB" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTEXCB</a>, 5);
        TEX = texcb&lt;4:2&gt;;  C = texcb&lt;1&gt;;  B = texcb&lt;0&gt;;

    // Distinction between Inner Shareable and Outer Shareable is not supported in this format
    // A memory region is either Non-shareable or Outer Shareable
    case TEX:C:B of
        when '00000'
            // Device-nGnRnE
            memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
            memattrs.device       = <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a>;
            memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        when '00001', '01000'
            // Device-nGnRE
            memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
            memattrs.device       = <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a>;
            memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        when '00010'
            // Write-through Read allocate
            memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner.attrs  = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            memattrs.inner.hints  = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.outer.attrs  = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            memattrs.outer.hints  = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.shareability = if s == '1' then <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> else <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        when '00011'
            // Write-back Read allocate
            memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner.attrs  = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            memattrs.inner.hints  = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.outer.attrs  = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            memattrs.outer.hints  = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.shareability = if s == '1' then <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> else <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        when '00100'
            // Non-cacheable
            memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner.attrs  = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
            memattrs.outer.attrs  = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
            memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        when '00110'
            memattrs = <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> IMPLEMENTATION_DEFINED;
        when '00111'
            // Write-back Read and Write allocate
            memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner.attrs  = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            memattrs.inner.hints  = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
            memattrs.outer.attrs  = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            memattrs.outer.hints  = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
            memattrs.shareability = if s == '1' then <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> else <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        when '1xxxx'
            // Cacheable, TEX&lt;1:0&gt; = Outer attrs, {C,B} = Inner attrs
            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner   = <a link="impl-shared.DecodeSDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</a>(C:B);
            memattrs.outer   = <a link="impl-shared.DecodeSDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</a>(TEX&lt;1:0&gt;);

            if memattrs.inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp; memattrs.outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
                memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
            else
                memattrs.shareability = if s == '1' then <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> else <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        otherwise
            // Reserved, handled above
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    // The Transient hint is not supported in this format
    memattrs.inner.transient = FALSE;
    memattrs.outer.transient = FALSE;
    memattrs.tags            = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;

    if memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp; memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> then
        memattrs.xs = '0';
    else
        memattrs.xs = '1';

    return memattrs;</pstext>
    </ps>
    <ps name="aarch32/translation/attrs/AArch32.MAIRAttr" mylink="aarch32.translation.attrs.AArch32.MAIRAttr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.MAIRAttr()
// ==================
// Retrieve the memory attribute encoding indexed in the given MAIR

bits(8) AArch32.MAIRAttr(integer index, MAIRType mair)
    assert (index &lt; 8);
    bit_index = 8 * index;
    return mair&lt;bit_index+7:bit_index&gt;;</pstext>
    </ps>
    <ps name="aarch32/translation/attrs/AArch32.RemappedTEXDecode" mylink="aarch32.translation.attrs.AArch32.RemappedTEXDecode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.RemappedTEXDecode()
// ===========================
// Apply short-descriptor format memory region attributes, with TEX remap

MemoryAttributes <anchor link="AArch32.RemappedTEXDecode.5" hover="function: MemoryAttributes AArch32.RemappedTEXDecode(Regime regime, bits(3) TEX, bit C, bit B, bit s)">AArch32.RemappedTEXDecode</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(3) TEX, bit C, bit B, bit s)

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    PRRR_Type prrr;
    NMRR_Type nmrr;

    region = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(TEX&lt;0&gt;:C:B);         // TEX&lt;2:1&gt; are ignored in this mapping scheme
    if region == 6 then
        return <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> IMPLEMENTATION_DEFINED;

    if regime == <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> then
        prrr = PRRR_S;
        nmrr = NMRR_S;
    elsif <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        prrr = PRRR_NS;
        nmrr = NMRR_NS;
    else
        prrr = PRRR;
        nmrr = NMRR;

    base = 2 * region;
    attrfield = prrr&lt;base+1:base&gt;;

    if attrfield == '11' then      // Reserved, maps to allocated value
        (-, attrfield) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESPRRR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESPRRR</a>, 2);

    case attrfield of
        when '00'                  // Device-nGnRnE
            memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
            memattrs.device       = <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a>;
            memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        when '01'                  // Device-nGnRE
            memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
            memattrs.device       = <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a>;
            memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        when '10'
            NSn  = if s == '0' then prrr.NS0 else prrr.NS1;
            NOSm = prrr&lt;region+24&gt; AND NSn;
            IRn  = nmrr&lt;base+1:base&gt;;
            ORn  = nmrr&lt;base+17:base+16&gt;;

            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner   = <a link="impl-shared.DecodeSDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</a>(IRn);
            memattrs.outer   = <a link="impl-shared.DecodeSDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</a>(ORn);
            if memattrs.inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp; memattrs.outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
                memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
            else
                bits(2) sh = NSn:NOSm;
                memattrs.shareability = <a link="impl-shared.DecodeShareability.1" file="shared_pseudocode.xml" hover="function: Shareability DecodeShareability(bits(2) sh)">DecodeShareability</a>(sh);
        when '11'
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    // The Transient hint is not supported in this format
    memattrs.inner.transient = FALSE;
    memattrs.outer.transient = FALSE;
    memattrs.tags            = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;

    if memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp; memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> then
        memattrs.xs = '0';
    else
        memattrs.xs = '1';

    return memattrs;</pstext>
    </ps>
    <ps name="aarch32/translation/debug/AArch32.CheckBreakpoint" mylink="aarch32.translation.debug.AArch32.CheckBreakpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckBreakpoint()
// =========================
// Called before executing the instruction of length "size" bytes at "vaddress" in an AArch32
// translation regime, when either debug exceptions are enabled, or halting debug is enabled
// and halting is allowed.

FaultRecord <anchor link="AArch32.CheckBreakpoint.4" hover="function: FaultRecord AArch32.CheckBreakpoint(FaultRecord fault_in, bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.CheckBreakpoint</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, bits(32) vaddress,
                                    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size)
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    assert size IN {2,4};

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    match = FALSE;
    mismatch = FALSE;

    for i = 0 to <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - 1
        (match_i, mismatch_i) = <a link="AArch32.BreakpointMatch.4" file="shared_pseudocode.xml" hover="function: (boolean,boolean) AArch32.BreakpointMatch(integer n, bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.BreakpointMatch</a>(i, vaddress, accdesc, size);
        match = match || match_i;
        mismatch = mismatch || mismatch_i;

    if match &amp;&amp; <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() then
        reason = <a link="DebugHalt_Breakpoint" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Breakpoint = '000111'">DebugHalt_Breakpoint</a>;
        <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(reason);
    elsif (match || mismatch) then
        fault.statuscode = <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;
        fault.debugmoe   = <a link="DebugException_Breakpoint" file="shared_pseudocode.xml" hover="constant bits(4) DebugException_Breakpoint = '0001'">DebugException_Breakpoint</a>;

    return fault;</pstext>
    </ps>
    <ps name="aarch32/translation/debug/AArch32.CheckDebug" mylink="aarch32.translation.debug.AArch32.CheckDebug" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckDebug()
// ====================
// Called on each access to check for a debug exception or entry to Debug state.

FaultRecord <anchor link="AArch32.CheckDebug.3" hover="function: FaultRecord AArch32.CheckDebug(bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.CheckDebug</anchor>(bits(32) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size)

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);

    boolean d_side = (<a link="impl-shared.IsDataAccess.1" file="shared_pseudocode.xml" hover="function: boolean IsDataAccess(AccessType acctype)">IsDataAccess</a>(accdesc.acctype) || accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>);
    boolean i_side = (accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>);
    generate_exception = <a link="AArch32.GenerateDebugExceptions.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GenerateDebugExceptions()">AArch32.GenerateDebugExceptions</a>() &amp;&amp; DBGDSCRext.MDBGen == '1';
    halt = <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>();
    // Relative priority of Vector Catch and Breakpoint exceptions not defined in the architecture
    vector_catch_first = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPVECTORCATCHPRI" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPVECTORCATCHPRI</a>);

    if i_side &amp;&amp; vector_catch_first &amp;&amp; generate_exception then
        fault = <a link="AArch32.CheckVectorCatch.3" file="shared_pseudocode.xml" hover="function: FaultRecord AArch32.CheckVectorCatch(FaultRecord fault_in, bits(32) vaddress, integer size)">AArch32.CheckVectorCatch</a>(fault, vaddress, size);

    if fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> &amp;&amp; (generate_exception || halt) then
        if d_side then
            fault = <a link="AArch32.CheckWatchpoint.4" file="shared_pseudocode.xml" hover="function: FaultRecord AArch32.CheckWatchpoint(FaultRecord fault_in, bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.CheckWatchpoint</a>(fault, vaddress, accdesc, size);
        elsif i_side then
            fault = <a link="AArch32.CheckBreakpoint.4" file="shared_pseudocode.xml" hover="function: FaultRecord AArch32.CheckBreakpoint(FaultRecord fault_in, bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.CheckBreakpoint</a>(fault, vaddress, accdesc, size);

    if fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> &amp;&amp; i_side &amp;&amp; !vector_catch_first &amp;&amp; generate_exception then
        return <a link="AArch32.CheckVectorCatch.3" file="shared_pseudocode.xml" hover="function: FaultRecord AArch32.CheckVectorCatch(FaultRecord fault_in, bits(32) vaddress, integer size)">AArch32.CheckVectorCatch</a>(fault, vaddress, size);

    return fault;</pstext>
    </ps>
    <ps name="aarch32/translation/debug/AArch32.CheckVectorCatch" mylink="aarch32.translation.debug.AArch32.CheckVectorCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckVectorCatch()
// ==========================
// Called before executing the instruction of length "size" bytes at "vaddress" in an AArch32
// translation regime, when debug exceptions are enabled.

FaultRecord <anchor link="AArch32.CheckVectorCatch.3" hover="function: FaultRecord AArch32.CheckVectorCatch(FaultRecord fault_in, bits(32) vaddress, integer size)">AArch32.CheckVectorCatch</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, bits(32) vaddress, integer size)
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    match = <a link="AArch32.VCRMatch.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.VCRMatch(bits(32) vaddress)">AArch32.VCRMatch</a>(vaddress);
    if size == 4 &amp;&amp; !match &amp;&amp; <a link="AArch32.VCRMatch.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.VCRMatch(bits(32) vaddress)">AArch32.VCRMatch</a>(vaddress + 2) then
        match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_VCMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_VCMATCHHALF</a>);

    if match then
        fault.statuscode = <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;
        fault.debugmoe   = <a link="DebugException_VectorCatch" file="shared_pseudocode.xml" hover="constant bits(4) DebugException_VectorCatch = '0101'">DebugException_VectorCatch</a>;

    return fault;</pstext>
    </ps>
    <ps name="aarch32/translation/debug/AArch32.CheckWatchpoint" mylink="aarch32.translation.debug.AArch32.CheckWatchpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckWatchpoint()
// =========================
// Called before accessing the memory location of "size" bytes at "address",
// when either debug exceptions are enabled for the access, or halting debug
// is enabled and halting is allowed.

FaultRecord <anchor link="AArch32.CheckWatchpoint.4" hover="function: FaultRecord AArch32.CheckWatchpoint(FaultRecord fault_in, bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.CheckWatchpoint</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, bits(32) vaddress,
                                    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size)
    assert <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a> then
        if accdesc.cacheop != <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> then
            return fault;
        elsif !(boolean IMPLEMENTATION_DEFINED "DCIMVAC generates watchpoint") then
            return fault;
    elsif !<a link="impl-shared.IsDataAccess.1" file="shared_pseudocode.xml" hover="function: boolean IsDataAccess(AccessType acctype)">IsDataAccess</a>(accdesc.acctype) then
        return fault;

    match = FALSE;
    for i = 0 to <a link="impl-shared.NumWatchpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumWatchpointsImplemented()">NumWatchpointsImplemented</a>() - 1
        if <a link="AArch32.WatchpointMatch.4" file="shared_pseudocode.xml" hover="function: boolean AArch32.WatchpointMatch(integer n, bits(32) vaddress, integer size, AccessDescriptor accdesc)">AArch32.WatchpointMatch</a>(i, vaddress, size, accdesc) then
            match = TRUE;

    if match &amp;&amp; <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() then
        reason = <a link="DebugHalt_Watchpoint" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Watchpoint = '101011'">DebugHalt_Watchpoint</a>;
        EDWAR = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress, 64);
        <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(reason);
    elsif match then
        fault.statuscode = <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;
        fault.debugmoe   = <a link="DebugException_Watchpoint" file="shared_pseudocode.xml" hover="constant bits(4) DebugException_Watchpoint = '1010'">DebugException_Watchpoint</a>;

    return fault;</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.IPAIsOutOfRange" mylink="aarch32.translation.faults.AArch32.IPAIsOutOfRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.IPAIsOutOfRange()
// =========================
// Check intermediate physical address bits not resolved by translation are ZERO

boolean AArch32.IPAIsOutOfRange(S2TTWParams walkparams, bits(40) ipa)
    // Input Address size
    iasize = <a link="AArch32.S2IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S2IASize(bits(4) t0sz)">AArch32.S2IASize</a>(walkparams.t0sz);

    return iasize &lt; 40 &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(ipa&lt;39:iasize&gt;);</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.S1HasAlignmentFault" mylink="aarch32.translation.faults.AArch32.S1HasAlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1HasAlignmentFault()
// =============================
// Returns whether stage 1 output fails alignment requirement on data accesses
// to Device memory

boolean <anchor link="AArch32.S1HasAlignmentFault.4" hover="function: boolean AArch32.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch32.S1HasAlignmentFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned,
                                    bit ntlsmd, <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        return FALSE;
    elsif accdesc.a32lsmd &amp;&amp; ntlsmd == '0' then
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;  memattrs.device != <a link="DeviceType_GRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_GRE</a>;
    elsif accdesc.acctype == <a link="AccessType_DCZero" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DCZero</a> then
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
    else
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp; !aligned;</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.S1LDHasPermissionsFault" mylink="aarch32.translation.faults.AArch32.S1LDHasPermissionsFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1LDHasPermissionsFault()
// =================================
// Returns whether an access using stage 1 long-descriptor translation
// violates permissions of target memory

boolean AArch32.S1LDHasPermissionsFault(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams, <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> perms,
                                        <a link="MemType" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType</a> memtype, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bit  r,  w,  x;
    bit pr, pw;
    bit ur, uw;
    bit xn;
    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        // Apply leaf permissions
        case perms.ap&lt;2:1&gt; of
            when '00' (pr,pw,ur,uw) = ('1','1','0','0'); // R/W at PL1 only
            when '01' (pr,pw,ur,uw) = ('1','1','1','1'); // R/W at any PL
            when '10' (pr,pw,ur,uw) = ('1','0','0','0'); // RO at PL1 only
            when '11' (pr,pw,ur,uw) = ('1','0','1','0'); // RO at any PL

        // Apply hierarchical permissions
        case perms.ap_table of
            when '00' (pr,pw,ur,uw) = ( pr, pw, ur, uw); // No effect
            when '01' (pr,pw,ur,uw) = ( pr, pw,'0','0'); // Privileged access
            when '10' (pr,pw,ur,uw) = ( pr,'0', ur,'0'); // Read-only
            when '11' (pr,pw,ur,uw) = ( pr,'0','0','0'); // Read-only, privileged access

        xn   = perms.xn OR perms.xn_table;
        pxn  = perms.pxn OR perms.pxn_table;

        ux = ur AND NOT(xn OR (uw AND walkparams.wxn));
        px = pr AND NOT(xn OR pxn OR (pw AND walkparams.wxn) OR (uw AND walkparams.uwxn));

        if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; accdesc.pan then
            pan = PSTATE.PAN AND (ur OR uw);
            pr  = pr AND NOT(pan);
            pw  = pw AND NOT(pan);

        (r,w,x) = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then (ur,uw,ux) else (pr,pw,px);

        // Prevent execution from Non-secure space by PE in Secure state if SIF is set
        if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
            x = x AND NOT(walkparams.sif);
    else
        // Apply leaf permissions
        case perms.ap&lt;2&gt; of
            when '0' (r,w) = ('1','1'); // No effect
            when '1' (r,w) = ('1','0'); // Read-only

        // Apply hierarchical permissions
        case perms.ap_table&lt;1&gt; of
            when '0' (r,w) = ( r , w ); // No effect
            when '1' (r,w) = ( r ,'0'); // Read-only

        xn = perms.xn OR perms.xn_table;
        x  = NOT(xn OR (w AND walkparams.wxn));

    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        constraint = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_INSTRDEVICE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_INSTRDEVICE</a>);
        if constraint == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a> &amp;&amp; memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
            return TRUE;
        else
            return x == '0';
    elsif accdesc.acctype IN {<a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>} then
        return FALSE;
    elsif accdesc.write then
        return w == '0';
    else
        return r == '0';</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.S1SDHasPermissionsFault" mylink="aarch32.translation.faults.AArch32.S1SDHasPermissionsFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1SDHasPermissionsFault()
// =================================
// Returns whether an access using stage 1 short-descriptor translation
// violates permissions of target memory

boolean <anchor link="AArch32.S1SDHasPermissionsFault.5" hover="function: boolean AArch32.S1SDHasPermissionsFault(Regime regime, Permissions perms_in, MemType memtype, PASpace paspace, AccessDescriptor accdesc)">AArch32.S1SDHasPermissionsFault</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> perms_in, <a link="MemType" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType</a> memtype,
                                        <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> perms = perms_in;
    bit pr, pw;
    bit ur, uw;
    SCTLR_Type sctlr;
    if regime == <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> then
        sctlr = SCTLR_S;
    elsif <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        sctlr = SCTLR_NS;
    else
        sctlr = SCTLR;

    if sctlr.AFE == '0' then
        // Map Reserved encoding '100'
        if perms.ap == '100' then
            perms.ap = bits(3) IMPLEMENTATION_DEFINED "Reserved short descriptor AP encoding";

        case perms.ap of
            when '000' (pr,pw,ur,uw) = ('0','0','0','0'); // No access
            when '001' (pr,pw,ur,uw) = ('1','1','0','0'); // R/W at PL1 only
            when '010' (pr,pw,ur,uw) = ('1','1','1','0'); // R/W at PL1, RO at PL0
            when '011' (pr,pw,ur,uw) = ('1','1','1','1'); // R/W at any PL
            //   '100' is reserved
            when '101' (pr,pw,ur,uw) = ('1','0','0','0'); // RO at PL1 only
            when '110' (pr,pw,ur,uw) = ('1','0','1','0'); // RO at any PL (deprecated)
            when '111' (pr,pw,ur,uw) = ('1','0','1','0'); // RO at any PL
    else // Simplified access permissions model
        case perms.ap&lt;2:1&gt; of
            when '00' (pr,pw,ur,uw) = ('1','1','0','0'); // R/W at PL1 only
            when '01' (pr,pw,ur,uw) = ('1','1','1','1'); // R/W at any PL
            when '10' (pr,pw,ur,uw) = ('1','0','0','0'); // RO at PL1 only
            when '11' (pr,pw,ur,uw) = ('1','0','1','0'); // RO at any PL

    ux = ur AND NOT(perms.xn OR (uw AND sctlr.WXN));
    px = pr AND NOT(perms.xn OR perms.pxn OR (pw AND sctlr.WXN) OR (uw AND sctlr.UWXN));

    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; accdesc.pan then
        pan = PSTATE.PAN AND (ur OR uw);
        pr  = pr AND NOT(pan);
        pw  = pw AND NOT(pan);

    (r,w,x) = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then (ur,uw,ux) else (pr,pw,px);

    // Prevent execution from Non-secure space by PE in Secure state if SIF is set
    if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
        x = x AND NOT(if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCR.SIF else SCR_EL3.SIF);

    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        if (memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;
                <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_INSTRDEVICE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_INSTRDEVICE</a>) == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>) then
            return TRUE;
        else
            return x == '0';
    elsif accdesc.acctype IN {<a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>} then
        return FALSE;
    elsif accdesc.write then
        return w == '0';
    else
        return r == '0';</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.S2HasAlignmentFault" mylink="aarch32.translation.faults.AArch32.S2HasAlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2HasAlignmentFault()
// =============================
// Returns whether stage 2 output fails alignment requirement on data accesses
// to Device memory

boolean <anchor link="AArch32.S2HasAlignmentFault.3" hover="function: boolean AArch32.S2HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, MemoryAttributes memattrs)">AArch32.S2HasAlignmentFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned,
                                    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        return FALSE;
    elsif accdesc.acctype == <a link="AccessType_DCZero" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DCZero</a> then
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
    else
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp; !aligned;</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.S2HasPermissionsFault" mylink="aarch32.translation.faults.AArch32.S2HasPermissionsFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2HasPermissionsFault()
// ===============================
// Returns whether stage 2 access violates permissions of target memory

boolean AArch32.S2HasPermissionsFault(S2TTWParams walkparams, <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> perms, <a link="MemType" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType</a> memtype,
                                      <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bit px;
    bit ux;
    r = perms.s2ap&lt;0&gt;;
    w = perms.s2ap&lt;1&gt;;
    bit x;
    if <a link="impl-shared.HaveExtendedExecuteNeverExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveExtendedExecuteNeverExt()">HaveExtendedExecuteNeverExt</a>() then
        case perms.s2xn:perms.s2xnx of
            when '00'  (px, ux) = ( r , r );
            when '01'  (px, ux) = ('0', r );
            when '10'  (px, ux) = ('0','0');
            when '11'  (px, ux) = ( r ,'0');

        x = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then ux else px;
    else
        x = r AND NOT(perms.s2xn);

    if accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> then
        return (walkparams.ptw == '1' &amp;&amp; memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>) || r == '0';

    elsif accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        constraint = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_INSTRDEVICE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_INSTRDEVICE</a>);
        return (constraint == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a> &amp;&amp; memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>) || x == '0';

    elsif accdesc.acctype IN {<a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>} then
        return FALSE;

    elsif accdesc.write then
        return w == '0';

    else
        return r == '0';</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.S2InconsistentSL" mylink="aarch32.translation.faults.AArch32.S2InconsistentSL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2InconsistentSL()
// ==========================
// Detect inconsistent configuration of stage 2 T0SZ and SL fields

boolean AArch32.S2InconsistentSL(S2TTWParams walkparams)
    startlevel  = <a link="AArch32.S2StartLevel.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S2StartLevel(bits(2) sl0)">AArch32.S2StartLevel</a>(walkparams.sl0);
    levels      = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - startlevel;
    granulebits = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    stride      = granulebits - 3;

    // Input address size must at least be large enough to be resolved from the start level
    sl_min_iasize = (
        levels * stride // Bits resolved by table walk, except initial level
        + granulebits   // Bits directly mapped to output address
        + 1);           // At least 1 more bit to be decoded by initial level

    // Can accomodate 1 more stride in the level + concatenation of up to 2^4 tables
    sl_max_iasize = sl_min_iasize + (stride-1) + 4;
    // Configured Input Address size
    iasize        = <a link="AArch32.S2IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S2IASize(bits(4) t0sz)">AArch32.S2IASize</a>(walkparams.t0sz);

    return iasize &lt; sl_min_iasize || iasize &gt; sl_max_iasize;</pstext>
    </ps>
    <ps name="aarch32/translation/faults/AArch32.VAIsOutOfRange" mylink="aarch32.translation.faults.AArch32.VAIsOutOfRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.VAIsOutOfRange()
// ========================
// Check virtual address bits not resolved by translation are identical
// and of accepted value

boolean AArch32.VAIsOutOfRange(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams, bits(32) va)
    if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> then
        // Input Address size
        iasize = <a link="AArch32.S1IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</a>(walkparams.t0sz);
        return walkparams.t0sz != '000' &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;31:iasize&gt;);
    elsif walkparams.t1sz != '000' &amp;&amp; walkparams.t0sz != '000' then
        // Lower range Input Address size
        lo_iasize = <a link="AArch32.S1IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</a>(walkparams.t0sz);
        // Upper range Input Address size
        up_iasize = <a link="AArch32.S1IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</a>(walkparams.t1sz);
        return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;31:lo_iasize&gt;) &amp;&amp; !<a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(va&lt;31:up_iasize&gt;);
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch32/translation/tlbcontext/AArch32.GetS1TLBContext" mylink="aarch32.translation.tlbcontext.AArch32.GetS1TLBContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GetS1TLBContext()
// =========================
// Gather translation context for accesses with VA to match against TLB entries

TLBContext <anchor link="AArch32.GetS1TLBContext.3" hover="function: TLBContext AArch32.GetS1TLBContext(Regime regime, SecurityState ss, bits(32) va)">AArch32.GetS1TLBContext</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(32) va)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    case regime of
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  tlbcontext = <a link="AArch32.TLBContextEL2.1" file="shared_pseudocode.xml" hover="function: TLBContext AArch32.TLBContextEL2(bits(32) va)">AArch32.TLBContextEL2</a>(va);
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> tlbcontext = <a link="AArch32.TLBContextEL10.2" file="shared_pseudocode.xml" hover="function: TLBContext AArch32.TLBContextEL10(SecurityState ss, bits(32) va)">AArch32.TLBContextEL10</a>(ss, va);
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> tlbcontext = <a link="AArch32.TLBContextEL30.1" file="shared_pseudocode.xml" hover="function: TLBContext AArch32.TLBContextEL30(bits(32) va)">AArch32.TLBContextEL30</a>(va);

    tlbcontext.includes_s1 = TRUE;
    // The following may be amended for EL1&amp;0 Regime if caching of stage 2 is successful
    tlbcontext.includes_s2 = FALSE;
    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch32/translation/tlbcontext/AArch32.GetS2TLBContext" mylink="aarch32.translation.tlbcontext.AArch32.GetS2TLBContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GetS2TLBContext()
// =========================
// Gather translation context for accesses with IPA to match against TLB entries

TLBContext <anchor link="AArch32.GetS2TLBContext.1" hover="function: TLBContext AArch32.GetS2TLBContext(FullAddress ipa)">AArch32.GetS2TLBContext</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> ipa)
    assert ipa.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss          = <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
    tlbcontext.regime      = <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
    tlbcontext.ipaspace    = ipa.paspace;
    tlbcontext.vmid        = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR.VMID, 16);
    tlbcontext.tg          = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
    tlbcontext.includes_s1 = FALSE;
    tlbcontext.includes_s2 = TRUE;
    tlbcontext.ia          = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.address, 64);
    tlbcontext.cnp         = if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then VTTBR.CnP else '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch32/translation/tlbcontext/AArch32.TLBContextEL10" mylink="aarch32.translation.tlbcontext.AArch32.TLBContextEL10" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBContextEL10()
// ========================
// Gather translation context for accesses under EL10 regime
// (PL10 when EL3 is A64) to match against TLB entries

TLBContext <anchor link="AArch32.TLBContextEL10.2" hover="function: TLBContext AArch32.TLBContextEL10(SecurityState ss, bits(32) va)">AArch32.TLBContextEL10</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(32) va)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;
    TTBCR_Type ttbcr;
    TTBR0_Type ttbr0;
    TTBR1_Type ttbr1;
    CONTEXTIDR_Type contextidr;

    if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        ttbcr      = TTBCR_NS;
        ttbr0      = TTBR0_NS;
        ttbr1      = TTBR1_NS;
        contextidr = CONTEXTIDR_NS;
    else
        ttbcr      = TTBCR;
        ttbr0      = TTBR0;
        ttbr1      = TTBR1;
        contextidr = CONTEXTIDR;

    tlbcontext.ss     = ss;
    tlbcontext.regime = <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;

    if <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(ss) then
        tlbcontext.vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR.VMID, 16);

    if ttbcr.EAE == '1' then
        tlbcontext.asid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(if ttbcr.A1 == '0' then ttbr0.ASID else ttbr1.ASID, 16);
    else
        tlbcontext.asid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(contextidr.ASID, 16);

    tlbcontext.tg = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
    tlbcontext.ia = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);

    if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() &amp;&amp; ttbcr.EAE == '1' then
        if <a link="AArch32.GetVARange.3" file="shared_pseudocode.xml" hover="function: VARange AArch32.GetVARange(bits(32) va, bits(3) t0sz, bits(3) t1sz)">AArch32.GetVARange</a>(va, ttbcr.T0SZ, ttbcr.T1SZ) == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
            tlbcontext.cnp = ttbr0.CnP;
        else
            tlbcontext.cnp = ttbr1.CnP;
    else
        tlbcontext.cnp = '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch32/translation/tlbcontext/AArch32.TLBContextEL2" mylink="aarch32.translation.tlbcontext.AArch32.TLBContextEL2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBContextEL2()
// =======================
// Gather translation context for accesses under EL2 regime to match against TLB entries

TLBContext <anchor link="AArch32.TLBContextEL2.1" hover="function: TLBContext AArch32.TLBContextEL2(bits(32) va)">AArch32.TLBContextEL2</anchor>(bits(32) va)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss     = <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
    tlbcontext.regime = <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>;
    tlbcontext.ia     = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);
    tlbcontext.tg     = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
    tlbcontext.cnp    = if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then HTTBR.CnP else '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch32/translation/tlbcontext/AArch32.TLBContextEL30" mylink="aarch32.translation.tlbcontext.AArch32.TLBContextEL30" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TLBContextEL30()
// ========================
// Gather translation context for accesses under EL30 regime
// (PL10 in Secure state and EL3 is A32) to match against TLB entries

TLBContext <anchor link="AArch32.TLBContextEL30.1" hover="function: TLBContext AArch32.TLBContextEL30(bits(32) va)">AArch32.TLBContextEL30</anchor>(bits(32) va)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss     = <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
    tlbcontext.regime = <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a>;

    if TTBCR_S.EAE == '1' then
        tlbcontext.asid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(if TTBCR_S.A1 == '0' then TTBR0_S.ASID else TTBR1_S.ASID, 16);
    else
        tlbcontext.asid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(CONTEXTIDR_S.ASID, 16);

    tlbcontext.tg = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
    tlbcontext.ia = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);

    if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() &amp;&amp; TTBCR_S.EAE == '1' then
        if <a link="AArch32.GetVARange.3" file="shared_pseudocode.xml" hover="function: VARange AArch32.GetVARange(bits(32) va, bits(3) t0sz, bits(3) t1sz)">AArch32.GetVARange</a>(va, TTBCR_S.T0SZ, TTBCR_S.T1SZ) == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
            tlbcontext.cnp = TTBR0_S.CnP;
        else
            tlbcontext.cnp = TTBR1_S.CnP;
    else
        tlbcontext.cnp = '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.EL2Enabled" mylink="aarch32.translation.translation.AArch32.EL2Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.EL2Enabled()
// ====================
// Returns whether EL2 is enabled for the given Security State

boolean <anchor link="AArch32.EL2Enabled.1" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    if ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        if !(<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>()) then
            return FALSE;
        elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            return SCR_EL3.EEL2 == '1';
        else
            return boolean IMPLEMENTATION_DEFINED "Secure-only implementation";
    else
        return <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.FullTranslate" mylink="aarch32.translation.translation.AArch32.FullTranslate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.FullTranslate()
// =======================
// Perform address translation as specified by VMSA-A32

AddressDescriptor <anchor link="AArch32.FullTranslate.3" hover="function: AddressDescriptor AArch32.FullTranslate(bits(32) va, AccessDescriptor accdesc, boolean aligned)">AArch32.FullTranslate</anchor>(bits(32) va, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned)

    // Prepare fault fields in case a fault is detected
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(accdesc.el);

    // First Stage Translation
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa;
    if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> || TTBCR.EAE == '1' then
        (fault, ipa) = <a link="AArch32.S1TranslateLD.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1TranslateLD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateLD</a>(fault, regime, va, aligned, accdesc);
    else
        (fault, ipa, -) = <a link="AArch32.S1TranslateSD.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor, SDFType) AArch32.S1TranslateSD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateSD</a>(fault, regime, va, aligned, accdesc);

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return <a link="impl-shared.CreateFaultyAddressDescriptor.2" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateFaultyAddressDescriptor(bits(64) va, FaultRecord fault)">CreateFaultyAddressDescriptor</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), fault);

    if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        ipa.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> pa;
        (fault, pa) = <a link="AArch32.S2Translate.4" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean aligned, AccessDescriptor accdesc)">AArch32.S2Translate</a>(fault, ipa, aligned, accdesc);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return <a link="impl-shared.CreateFaultyAddressDescriptor.2" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateFaultyAddressDescriptor(bits(64) va, FaultRecord fault)">CreateFaultyAddressDescriptor</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), fault);
        else
            return pa;
    else
        return ipa;</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.OutputDomain" mylink="aarch32.translation.translation.AArch32.OutputDomain" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.OutputDomain()
// ======================
// Determine the domain the translated output address

bits(2) <anchor link="AArch32.OutputDomain.2" hover="function: bits(2) AArch32.OutputDomain(Regime regime, bits(4) domain)">AArch32.OutputDomain</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(4) domain)
    bits(2) Dn;
    index = 2 * <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(domain);
    if regime == <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> then
        Dn = DACR_S&lt;index+1:index&gt;;
    elsif <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        Dn = DACR_NS&lt;index+1:index&gt;;
    else
        Dn = DACR&lt;index+1:index&gt;;

    if Dn == '10' then
        // Reserved value maps to an allocated value
        (-, Dn) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESDACR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESDACR</a>, 2);

    return Dn;</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.S1DisabledOutput" mylink="aarch32.translation.translation.AArch32.S1DisabledOutput" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1DisabledOutput()
// ==========================
// Flat map the VA to IPA/PA, depending on the regime, assigning default memory attributes

(FaultRecord, AddressDescriptor) <anchor link="AArch32.S1DisabledOutput.5" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1DisabledOutput(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1DisabledOutput</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                                          bits(32) va, boolean aligned,
                                                          <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    // No memory page is guarded when stage 1 address translation is disabled
    SetInGuardedPage(FALSE);

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    bit default_cacheable;
    if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) then
        if <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then
            default_cacheable = HCR.DC;
        else
            default_cacheable = HCR_EL2.DC;
    else
        default_cacheable = '0';

    if default_cacheable == '1' then
        // Use default cacheable settings
        memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
        memattrs.inner.attrs  = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
        memattrs.inner.hints  = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
        memattrs.outer.attrs  = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
        memattrs.outer.hints  = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
        memattrs.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        if (!<a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) &amp;&amp;
                <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; HCR_EL2.DCT == '1') then
            memattrs.tags     = <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>;
        else
            memattrs.tags     = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
        memattrs.xs           = '0';
    elsif accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
        memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        memattrs.tags         = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
        if <a link="AArch32.S1ICacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1ICacheEnabled(Regime regime)">AArch32.S1ICacheEnabled</a>(regime) then
            memattrs.inner.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            memattrs.inner.hints = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.outer.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            memattrs.outer.hints = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
        else
            memattrs.inner.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
            memattrs.outer.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
        memattrs.xs           = '1';
    else
        // Treat memory region as Device
        memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
        memattrs.device       = <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a>;
        memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        memattrs.tags         = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
        memattrs.xs           = '1';

    bit ntlsmd;
    if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then
        case regime of
            when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> ntlsmd = SCTLR_S.nTLSMD;
            when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  ntlsmd = HSCTLR.nTLSMD;
            when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> ntlsmd = if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCTLR_NS.nTLSMD else SCTLR.nTLSMD;
    else
        ntlsmd = '1';

    if <a link="AArch32.S1HasAlignmentFault.4" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch32.S1HasAlignmentFault</a>(accdesc, aligned, ntlsmd, memattrs) then
        fault.statuscode  = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> oa;
    oa.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 56);
    oa.paspace = if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> else <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    ipa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), oa, memattrs);

    return (fault, ipa);</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.S1Enabled" mylink="aarch32.translation.translation.AArch32.S1Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1Enabled()
// ===================
// Returns whether stage 1 translation is enabled for the active translation regime

boolean <anchor link="AArch32.S1Enabled.2" hover="function: boolean AArch32.S1Enabled(Regime regime, SecurityState ss)">AArch32.S1Enabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> then
        return HSCTLR.M == '1';
    elsif regime == <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> then
        return SCTLR_S.M == '1';
    elsif !<a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(ss) then
        return (if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCTLR_NS.M else SCTLR.M) == '1';
    elsif <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then
        return HCR.&lt;TGE,DC&gt; == '00' &amp;&amp; (if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCTLR_NS.M else SCTLR.M) == '1';
    else
        return HCR_EL2.&lt;TGE,DC&gt; == '00' &amp;&amp; SCTLR.M == '1';</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.S1TranslateLD" mylink="aarch32.translation.translation.AArch32.S1TranslateLD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1TranslateLD()
// =======================
// Perform a stage 1 translation using long-descriptor format mapping VA to IPA/PA
// depending on the regime

(FaultRecord, AddressDescriptor) <anchor link="AArch32.S1TranslateLD.5" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1TranslateLD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateLD</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                                       bits(32) va, boolean aligned,
                                                       <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if !<a link="AArch32.S1Enabled.2" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1Enabled(Regime regime, SecurityState ss)">AArch32.S1Enabled</a>(regime, accdesc.ss) then
        return <a link="AArch32.S1DisabledOutput.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1DisabledOutput(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1DisabledOutput</a>(fault, regime, va, aligned, accdesc);

    walkparams = AArch32.GetS1TTWParams(regime, va);

    if AArch32.VAIsOutOfRange(regime, walkparams, va) then
        fault.level      = 1;
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    (fault, walkstate) = AArch32.S1WalkLD(fault, regime, walkparams, accdesc, va);

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    SetInGuardedPage(FALSE);  // AArch32-VMSA does not guard any pages

    if <a link="AArch32.S1HasAlignmentFault.4" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch32.S1HasAlignmentFault</a>(accdesc, aligned, walkparams.ntlsmd, walkstate.memattrs) then
        fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;
    elsif AArch32.S1LDHasPermissionsFault(regime, walkparams,
                                          walkstate.permissions,
                                          walkstate.memattrs.memtype,
                                          walkstate.baseaddress.paspace,
                                          accdesc) then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    if ((accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
            (walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> || !<a link="AArch32.S1ICacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1ICacheEnabled(Regime regime)">AArch32.S1ICacheEnabled</a>(regime))) ||
        (accdesc.acctype != <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
             walkstate.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp; !<a link="AArch32.S1DCacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1DCacheEnabled(Regime regime)">AArch32.S1DCacheEnabled</a>(regime))) then
        // Treat memory attributes as Normal Non-Cacheable
        memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        memattrs.xs = walkstate.memattrs.xs;
    else
        memattrs = walkstate.memattrs;

    // Shareability value of stage 1 translation subject to stage 2 is IMPLEMENTATION DEFINED
    // to be either effective value or descriptor value
    if (regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) &amp;&amp;
        (if <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss==<a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then HCR.VM else HCR_EL2.VM) == '1' &amp;&amp;
        !(boolean IMPLEMENTATION_DEFINED "Apply effective shareability at stage 1")) then
        memattrs.shareability = walkstate.memattrs.shareability;
    else
        memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(memattrs);

    // Output Address
    oa = <a link="impl-shared.StageOA.4" file="shared_pseudocode.xml" hover="function: FullAddress StageOA(bits(64) ia, bit d128, TGx tgx, TTWState walkstate)">StageOA</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), walkparams.d128, walkparams.tgx, walkstate);
    ipa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), oa, memattrs);

    return (fault, ipa);</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.S1TranslateSD" mylink="aarch32.translation.translation.AArch32.S1TranslateSD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1TranslateSD()
// =======================
// Perform a stage 1 translation using short-descriptor format mapping VA to IPA/PA
// depending on the regime

(FaultRecord, AddressDescriptor, SDFType) <anchor link="AArch32.S1TranslateSD.5" hover="function: (FaultRecord, AddressDescriptor, SDFType) AArch32.S1TranslateSD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateSD</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                                                bits(32) va, boolean aligned,
                                                                <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if !<a link="AArch32.S1Enabled.2" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1Enabled(Regime regime, SecurityState ss)">AArch32.S1Enabled</a>(regime, accdesc.ss) then
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa;
        (fault, ipa) = <a link="AArch32.S1DisabledOutput.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1DisabledOutput(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1DisabledOutput</a>(fault, regime, va, aligned, accdesc);
        return (fault, ipa, <a link="SDFType" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</a> UNKNOWN);

    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    (fault, walkstate) = <a link="AArch32.S1WalkSD.4" file="shared_pseudocode.xml" hover="function: (FaultRecord, TTWState) AArch32.S1WalkSD(FaultRecord fault_in, Regime regime, AccessDescriptor accdesc, bits(32) va)">AArch32.S1WalkSD</a>(fault, regime, accdesc, va);

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="SDFType" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</a> UNKNOWN);

    domain = <a link="AArch32.OutputDomain.2" file="shared_pseudocode.xml" hover="function: bits(2) AArch32.OutputDomain(Regime regime, bits(4) domain)">AArch32.OutputDomain</a>(regime, walkstate.domain);
    SetInGuardedPage(FALSE);  // AArch32-VMSA does not guard any pages

    bit ntlsmd;
    if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then
        case regime of
            when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> ntlsmd = SCTLR_S.nTLSMD;
            when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> ntlsmd = if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCTLR_NS.nTLSMD else SCTLR.nTLSMD;
    else
        ntlsmd = '1';

    if <a link="AArch32.S1HasAlignmentFault.4" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch32.S1HasAlignmentFault</a>(accdesc, aligned, ntlsmd, walkstate.memattrs) then
        fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;
    elsif (!(accdesc.acctype IN {<a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>}) &amp;&amp;
            domain == <a link="Domain_NoAccess" file="shared_pseudocode.xml" hover="constant bits(2) Domain_NoAccess = '00'">Domain_NoAccess</a>) then
        fault.statuscode = <a link="Fault_Domain" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Domain</a>;
    elsif domain == <a link="Domain_Client" file="shared_pseudocode.xml" hover="constant bits(2) Domain_Client = '01'">Domain_Client</a> then
        if <a link="AArch32.S1SDHasPermissionsFault.5" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1SDHasPermissionsFault(Regime regime, Permissions perms_in, MemType memtype, PASpace paspace, AccessDescriptor accdesc)">AArch32.S1SDHasPermissionsFault</a>(regime, walkstate.permissions,
                                           walkstate.memattrs.memtype,
                                           walkstate.baseaddress.paspace,
                                           accdesc) then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        fault.domain = walkstate.domain;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, walkstate.sdftype);

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    if ((accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
            (walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> || !<a link="AArch32.S1ICacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1ICacheEnabled(Regime regime)">AArch32.S1ICacheEnabled</a>(regime))) ||
        (accdesc.acctype != <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
             walkstate.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp; !<a link="AArch32.S1DCacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1DCacheEnabled(Regime regime)">AArch32.S1DCacheEnabled</a>(regime))) then
        // Treat memory attributes as Normal Non-Cacheable
        memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        memattrs.xs = walkstate.memattrs.xs;
    else
        memattrs = walkstate.memattrs;

    // Shareability value of stage 1 translation subject to stage 2 is IMPLEMENTATION DEFINED
    // to be either effective value or descriptor value
    if (regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) &amp;&amp;
        (if <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss==<a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then HCR.VM else HCR_EL2.VM) == '1' &amp;&amp;
        !(boolean IMPLEMENTATION_DEFINED "Apply effective shareability at stage 1")) then
        memattrs.shareability = walkstate.memattrs.shareability;
    else
        memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(memattrs);

    // Output Address
    oa = <a link="AArch32.SDStageOA.3" file="shared_pseudocode.xml" hover="function: FullAddress AArch32.SDStageOA(FullAddress baseaddress, bits(32) va, SDFType sdftype)">AArch32.SDStageOA</a>(walkstate.baseaddress, va, walkstate.sdftype);
    ipa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), oa, memattrs);

    return (fault, ipa, walkstate.sdftype);</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.S2Translate" mylink="aarch32.translation.translation.AArch32.S2Translate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2Translate()
// =====================
// Perform a stage 2 translation mapping an IPA to a PA

(FaultRecord, AddressDescriptor) <anchor link="AArch32.S2Translate.4" hover="function: (FaultRecord, AddressDescriptor) AArch32.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean aligned, AccessDescriptor accdesc)">AArch32.S2Translate</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa,
                                                     boolean aligned, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    assert <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(ipa.paddress.address&lt;55:40&gt;);

    if !<a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then
        s1aarch64 = FALSE;
        return <a link="AArch64.S2Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</a>(fault, ipa, s1aarch64, aligned, accdesc);

    // Prepare fault fields in case a fault is detected
    fault.statuscode  = <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;
    fault.secondstage = TRUE;
    fault.s2fs1walk   = accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>;
    fault.ipaddress   = ipa.paddress;

    walkparams = AArch32.GetS2TTWParams();

    if walkparams.vm == '0' then
        // Stage 2 is disabled
        return (fault, ipa);

    if AArch32.IPAIsOutOfRange(walkparams, ipa.paddress.address&lt;39:0&gt;) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 1;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    (fault, walkstate) = AArch32.S2Walk(fault, walkparams, accdesc, ipa);

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    if <a link="AArch32.S2HasAlignmentFault.3" file="shared_pseudocode.xml" hover="function: boolean AArch32.S2HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, MemoryAttributes memattrs)">AArch32.S2HasAlignmentFault</a>(accdesc, aligned, walkstate.memattrs) then
        fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;
    elsif AArch32.S2HasPermissionsFault(walkparams,
                                        walkstate.permissions,
                                        walkstate.memattrs.memtype,
                                        accdesc) then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> s2_memattrs;
    if ((accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> &amp;&amp;
             walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>) ||
        (accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
            (walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> || HCR2.ID == '1')) ||
        (accdesc.acctype != <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
             walkstate.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp; HCR2.CD == '1')) then
        // Treat memory attributes as Normal Non-Cacheable
        s2_memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        s2_memattrs.xs = walkstate.memattrs.xs;
    else
        s2_memattrs = walkstate.memattrs;

    s2aarch64 = FALSE;
    memattrs = <a link="impl-shared.S2CombineS1MemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes S2CombineS1MemAttrs(MemoryAttributes s1_memattrs, MemoryAttributes s2_memattrs, boolean s2aarch64)">S2CombineS1MemAttrs</a>(ipa.memattrs, s2_memattrs, s2aarch64);
    ipa_64 = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.paddress.address&lt;39:0&gt;, 64);
    // Output Address
    oa = <a link="impl-shared.StageOA.4" file="shared_pseudocode.xml" hover="function: FullAddress StageOA(bits(64) ia, bit d128, TGx tgx, TTWState walkstate)">StageOA</a>(ipa_64, walkparams.d128, walkparams.tgx, walkstate);
    pa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(ipa.vaddress, oa, memattrs);

    return (fault, pa);</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.SDStageOA" mylink="aarch32.translation.translation.AArch32.SDStageOA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.SDStageOA()
// ===================
// Given the final walk state of a short-descriptor translation walk,
// map the untranslated input address bits to the base output address

FullAddress <anchor link="AArch32.SDStageOA.3" hover="function: FullAddress AArch32.SDStageOA(FullAddress baseaddress, bits(32) va, SDFType sdftype)">AArch32.SDStageOA</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> baseaddress, bits(32) va, <a link="SDFType" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</a> sdftype)
    integer tsize;
    case sdftype of
        when <a link="SDFType_SmallPage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_SmallPage</a>      tsize = 12;
        when <a link="SDFType_LargePage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_LargePage</a>      tsize = 16;
        when <a link="SDFType_Section" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Section</a>        tsize = 20;
        when <a link="SDFType_Supersection" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Supersection</a>   tsize = 24;

    // Output Address
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> oa;
    oa.address = baseaddress.address&lt;55:tsize&gt;:va&lt;tsize-1:0&gt;;
    oa.paspace = baseaddress.paspace;
    return oa;</pstext>
    </ps>
    <ps name="aarch32/translation/translation/AArch32.TranslateAddress" mylink="aarch32.translation.translation.AArch32.TranslateAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TranslateAddress()
// ==========================
// Main entry point for translating an address

AddressDescriptor <anchor link="AArch32.TranslateAddress.4" hover="function: AddressDescriptor AArch32.TranslateAddress(bits(32) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch32.TranslateAddress</anchor>(bits(32) va, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                           boolean aligned, integer size)

    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(PSTATE.EL);
    if !<a link="impl-shared.RegimeUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean RegimeUsingAArch32(Regime regime)">RegimeUsingAArch32</a>(regime) then
        return <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(<a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64), accdesc, aligned, size);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> result = <a link="AArch32.FullTranslate.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch32.FullTranslate(bits(32) va, AccessDescriptor accdesc, boolean aligned)">AArch32.FullTranslate</a>(va, accdesc, aligned);

    if !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(result) then
        result.fault = <a link="AArch32.CheckDebug.3" file="shared_pseudocode.xml" hover="function: FaultRecord AArch32.CheckDebug(bits(32) vaddress, AccessDescriptor accdesc, integer size)">AArch32.CheckDebug</a>(va, accdesc, size);

    // Update virtual address for abort functions
    result.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);

    return result;</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.DecodeDescriptorTypeLD" mylink="aarch32.translation.walk.AArch32.DecodeDescriptorTypeLD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DecodeDescriptorTypeLD()
// ================================
// Determine whether the long-descriptor is a page, block or table

DescriptorType <anchor link="AArch32.DecodeDescriptorTypeLD.2" hover="function: DescriptorType AArch32.DecodeDescriptorTypeLD(bits(64) descriptor, integer level)">AArch32.DecodeDescriptorTypeLD</anchor>(bits(64) descriptor, integer level)
    if descriptor&lt;1:0&gt; == '11' &amp;&amp; level == <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> then
        return <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;
    elsif descriptor&lt;1:0&gt; == '11' then
        return <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>;
    elsif descriptor&lt;1:0&gt; == '01' &amp;&amp; level != <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> then
        return <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;
    else
        return <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>;</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.DecodeDescriptorTypeSD" mylink="aarch32.translation.walk.AArch32.DecodeDescriptorTypeSD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.DecodeDescriptorTypeSD()
// ================================
// Determine the type of the short-descriptor

SDFType <anchor link="AArch32.DecodeDescriptorTypeSD.2" hover="function: SDFType AArch32.DecodeDescriptorTypeSD(bits(32) descriptor, integer level)">AArch32.DecodeDescriptorTypeSD</anchor>(bits(32) descriptor, integer level)
    if level == 1 &amp;&amp; descriptor&lt;1:0&gt; == '01' then
        return <a link="SDFType_Table" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Table</a>;
    elsif level == 1 &amp;&amp; descriptor&lt;18,1&gt; == '01' then
        return <a link="SDFType_Section" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Section</a>;
    elsif level == 1 &amp;&amp; descriptor&lt;18,1&gt; == '11' then
        return <a link="SDFType_Supersection" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Supersection</a>;
    elsif level == 2 &amp;&amp; descriptor&lt;1:0&gt; == '01' then
        return <a link="SDFType_LargePage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_LargePage</a>;
    elsif level == 2 &amp;&amp; descriptor&lt;1:0&gt; IN {'1x'} then
        return <a link="SDFType_SmallPage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_SmallPage</a>;
    else
        return <a link="SDFType_Invalid" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Invalid</a>;</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.S1IASize" mylink="aarch32.translation.walk.AArch32.S1IASize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1IASize()
// ==================
// Retrieve the number of bits containing the input address for stage 1 translation

integer <anchor link="AArch32.S1IASize.1" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</anchor>(bits(3) txsz)
    return 32 - <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(txsz);</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.S1WalkLD" mylink="aarch32.translation.walk.AArch32.S1WalkLD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1WalkLD()
// ==================
// Traverse stage 1 translation tables in long format to obtain the final descriptor

(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a>, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>) AArch32.S1WalkLD(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                         S1TTWParams walkparams, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                         bits(32) va)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    bits(3) txsz;
    bits(64) ttbr;
    bit epd;
    <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange;
    if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> then
        ttbr = HTTBR;
        txsz = walkparams.t0sz;
        varange = <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a>;
    else
        varange = <a link="AArch32.GetVARange.3" file="shared_pseudocode.xml" hover="function: VARange AArch32.GetVARange(bits(32) va, bits(3) t0sz, bits(3) t1sz)">AArch32.GetVARange</a>(va, walkparams.t0sz, walkparams.t1sz);
        bits(64) ttbr0;
        bits(64) ttbr1;
        TTBCR_Type ttbcr;
        if regime == <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> then
            ttbcr = TTBCR_S;
            ttbr0 = TTBR0_S;
            ttbr1 = TTBR1_S;
        elsif <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            ttbcr = TTBCR_NS;
            ttbr0 = TTBR0_NS;
            ttbr1 = TTBR1_NS;
        else
            ttbcr = TTBCR;
            ttbr0 = TTBR0;
            ttbr1 = TTBR1;

        assert ttbcr.EAE == '1';
        if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
            txsz = walkparams.t0sz;
            ttbr = ttbr0;
            epd  = ttbcr.EPD0;
        else
            txsz = walkparams.t1sz;
            ttbr = ttbr1;
            epd  = ttbcr.EPD1;

    if regime != <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> &amp;&amp; epd == '1' then
        fault.level      = 1;
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    // Input Address size
    iasize      = <a link="AArch32.S1IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</a>(txsz);
    granulebits = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    stride      = granulebits - 3;
    startlevel  = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - (((iasize-1) - granulebits) DIV stride);
    levels      = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - startlevel;

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(ttbr&lt;47:40&gt;) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
        fault.level      = 0;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> baseaddress;
    baselsb = (iasize - (levels*stride + granulebits)) + 3;
    baseaddress.paspace = if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> else <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ttbr&lt;39:baselsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(baselsb), 56);

    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    walkstate.baseaddress = baseaddress;
    walkstate.level       = startlevel;
    walkstate.istable     = TRUE;
    // In regimes that support global and non-global translations, translation
    // table entries from lookup levels other than the final level of lookup
    // are treated as being non-global
    walkstate.nG          = if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then '1' else '0';
    walkstate.memattrs    = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(walkparams.sh, walkparams.irgn, walkparams.orgn);
    walkstate.permissions.ap_table  = '00';
    walkstate.permissions.xn_table  = '0';
    walkstate.permissions.pxn_table = '0';

    indexmsb = iasize - 1;
    bits(64) descriptor;
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> walkaddress;

    walkaddress.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);

    if !<a link="AArch32.S1DCacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1DCacheEnabled(Regime regime)">AArch32.S1DCacheEnabled</a>(regime) then
        walkaddress.memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        walkaddress.memattrs.xs = walkstate.memattrs.xs;
    else
        walkaddress.memattrs = walkstate.memattrs;

    // Shareability value of stage 1 translation subject to stage 2 is IMPLEMENTATION DEFINED
    // to be either effective value or descriptor value
    if (regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) &amp;&amp;
        (if <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss==<a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then HCR.VM else HCR_EL2.VM) == '1' &amp;&amp;
        !(boolean IMPLEMENTATION_DEFINED "Apply effective shareability at stage 1")) then
        walkaddress.memattrs.shareability = walkstate.memattrs.shareability;
    else
        walkaddress.memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(walkaddress.memattrs);

    integer indexlsb;
    <a link="DescriptorType" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType</a> desctype;
    repeat
        fault.level = walkstate.level;
        indexlsb = (<a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - walkstate.level)*stride + granulebits;
        bits(40) index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va&lt;indexmsb:indexlsb&gt;:'000', 40);

        walkaddress.paddress.address = walkstate.baseaddress.address OR <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(index, 56);
        walkaddress.paddress.paspace = walkstate.baseaddress.paspace;

        boolean toplevel = walkstate.level == startlevel;
        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> walkaccess = <a link="impl-shared.CreateAccDescS1TTW.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescS1TTW(boolean toplevel, VARange varange, AccessDescriptor accdesc_in)">CreateAccDescS1TTW</a>(toplevel, varange, accdesc);
        // If there are two stages of translation, then the first stage table walk addresses
        // are themselves subject to translation
        if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) then
            s2aligned = TRUE;
            (s2fault, s2walkaddress) = <a link="AArch32.S2Translate.4" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean aligned, AccessDescriptor accdesc)">AArch32.S2Translate</a>(fault, walkaddress, s2aligned,
                                                           walkaccess);
            // Check for a fault on the stage 2 walk
            if s2fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
                return (s2fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

            (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(walkparams.ee, s2walkaddress, walkaccess,
                                                  fault, 64);
        else
            (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(walkparams.ee, walkaddress, walkaccess,
                                                  fault, 64);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

        desctype = <a link="AArch32.DecodeDescriptorTypeLD.2" file="shared_pseudocode.xml" hover="function: DescriptorType AArch32.DecodeDescriptorTypeLD(bits(64) descriptor, integer level)">AArch32.DecodeDescriptorTypeLD</a>(descriptor, walkstate.level);

        case desctype of
            when <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>
                if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(descriptor&lt;47:40&gt;) then
                    fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
                    return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;39:12&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 56);
                if walkstate.baseaddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> &amp;&amp; descriptor&lt;63&gt; == '1' then
                    walkstate.baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

                if walkparams.hpd == '0' then
                    walkstate.permissions.xn_table  = (walkstate.permissions.xn_table  OR
                                                        descriptor&lt;60&gt;);
                    walkstate.permissions.ap_table  = (walkstate.permissions.ap_table  OR
                                                        descriptor&lt;62:61&gt;);
                    walkstate.permissions.pxn_table = (walkstate.permissions.pxn_table OR
                                                        descriptor&lt;59&gt;);

                walkstate.level = walkstate.level + 1;
                indexmsb = indexlsb - 1;

            when <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>
                fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

            when <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>
                walkstate.istable = FALSE;

    until desctype == <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;

    // Check the output address is inside the supported range
    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(descriptor&lt;47:40&gt;) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    // Check the access flag
    if descriptor&lt;10&gt; == '0' then
        fault.statuscode = <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    walkstate.permissions.xn  = descriptor&lt;54&gt;;
    walkstate.permissions.pxn = descriptor&lt;53&gt;;
    walkstate.permissions.ap  = descriptor&lt;7:6&gt;:'1';
    walkstate.contiguous      = descriptor&lt;52&gt;;
    if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> then
        // All EL2 regime accesses are treated as Global
        walkstate.nG = '0';
    elsif accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; walkstate.baseaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
        // When a PE is using the Long-descriptor translation table format,
        // and is in Secure state, a translation must be treated as non-global,
        // regardless of the value of the nG bit,
        // if NSTable is set to 1 at any level of the translation table walk.
        walkstate.nG = '1';
    else
        walkstate.nG = descriptor&lt;11&gt;;

    walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;39:indexlsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(indexlsb), 56);
    if walkstate.baseaddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> &amp;&amp; descriptor&lt;5&gt; == '1' then
        walkstate.baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    memattr = descriptor&lt;4:2&gt;;
    sh      = descriptor&lt;9:8&gt;;
    attr    = AArch32.MAIRAttr(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(memattr), walkparams.mair);
    s1aarch64 = FALSE;
    walkstate.memattrs = S1DecodeMemAttrs(attr, sh, s1aarch64, walkparams);

    return (fault, walkstate);</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.S1WalkSD" mylink="aarch32.translation.walk.AArch32.S1WalkSD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1WalkSD()
// ==================
// Traverse stage 1 translation tables in short format to obtain the final descriptor

(FaultRecord, TTWState) <anchor link="AArch32.S1WalkSD.4" hover="function: (FaultRecord, TTWState) AArch32.S1WalkSD(FaultRecord fault_in, Regime regime, AccessDescriptor accdesc, bits(32) va)">AArch32.S1WalkSD</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                         <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, bits(32) va)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    SCTLR_Type sctlr;
    TTBCR_Type ttbcr;
    TTBR0_Type ttbr0;
    TTBR1_Type ttbr1;
    // Determine correct translation control registers to use.
    if regime == <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> then
        sctlr = SCTLR_S;
        ttbcr = TTBCR_S;
        ttbr0 = TTBR0_S;
        ttbr1 = TTBR1_S;
    elsif <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        sctlr = SCTLR_NS;
        ttbcr = TTBCR_NS;
        ttbr0 = TTBR0_NS;
        ttbr1 = TTBR1_NS;
    else
        sctlr = SCTLR;
        ttbcr = TTBCR;
        ttbr0 = TTBR0;
        ttbr1 = TTBR1;

    assert ttbcr.EAE == '0';
    ee  = sctlr.EE;
    afe = sctlr.AFE;
    tre = sctlr.TRE;
    n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ttbcr.N);
    bits(32) ttb;
    bits(1) pd;
    bits(2) irgn;
    bits(2) rgn;
    bits(1) s;
    bits(1) nos;
    <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange;
    if n == 0 || <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;31:(32-n)&gt;) then
        ttb  = ttbr0.TTB0:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(7);
        pd   = ttbcr.PD0;
        irgn = ttbr0.IRGN;
        rgn  = ttbr0.RGN;
        s    = ttbr0.S;
        nos  = ttbr0.NOS;
        varange = <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a>;
    else
        n    = 0;  // TTBR1 translation always treats N as 0
        ttb  = ttbr1.TTB1:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(7);
        pd   = ttbcr.PD1;
        irgn = ttbr1.IRGN;
        rgn  = ttbr1.RGN;
        s    = ttbr1.S;
        nos  = ttbr1.NOS;
        varange = <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a>;

    // Check if Translation table walk disabled for translations with this Base register.
    if pd == '1' then
        fault.level      = 1;
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> baseaddress;
    baseaddress.paspace = if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> else <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ttb&lt;31:14-n&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(14-n), 56);

    constant integer startlevel = 1;
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    walkstate.baseaddress = baseaddress;
    // In regimes that support global and non-global translations, translation
    // table entries from lookup levels other than the final level of lookup
    // are treated as being non-global. Translations in Short-Descriptor Format
    // always support global &amp; non-global translations.
    walkstate.nG          = '1';
    walkstate.memattrs    = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(s:nos, irgn, rgn);
    walkstate.level       = startlevel;
    walkstate.istable     = TRUE;

    bits(4) domain;
    bits(32) descriptor;
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> walkaddress;

    walkaddress.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);

    if !<a link="AArch32.S1DCacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.S1DCacheEnabled(Regime regime)">AArch32.S1DCacheEnabled</a>(regime) then
        walkaddress.memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        walkaddress.memattrs.xs = walkstate.memattrs.xs;
    else
        walkaddress.memattrs = walkstate.memattrs;

    // Shareability value of stage 1 translation subject to stage 2 is IMPLEMENTATION DEFINED
    // to be either effective value or descriptor value
    if (regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) &amp;&amp;
        (if <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, accdesc.ss==<a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>) then HCR.VM else HCR_EL2.VM) == '1' &amp;&amp;
        !(boolean IMPLEMENTATION_DEFINED "Apply effective shareability at stage 1")) then
        walkaddress.memattrs.shareability = walkstate.memattrs.shareability;
    else
        walkaddress.memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(walkaddress.memattrs);

    bit nG;
    bit ns;
    bit pxn;
    bits(3) ap;
    bits(3) tex;
    bit c;
    bit b;
    bit xn;
    repeat
        fault.level = walkstate.level;

        bits(32) index;
        if walkstate.level == 1 then
            index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va&lt;31-n:20&gt;:'00', 32);
        else
            index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va&lt;19:12&gt;:'00', 32);

        walkaddress.paddress.address = walkstate.baseaddress.address OR <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(index,
                                                                                   56);
        walkaddress.paddress.paspace = walkstate.baseaddress.paspace;

        boolean toplevel = walkstate.level == startlevel;
        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> walkaccess = <a link="impl-shared.CreateAccDescS1TTW.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescS1TTW(boolean toplevel, VARange varange, AccessDescriptor accdesc_in)">CreateAccDescS1TTW</a>(toplevel, varange, accdesc);
        if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="AArch32.EL2Enabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.EL2Enabled(SecurityState ss)">AArch32.EL2Enabled</a>(accdesc.ss) then
            s2aligned = TRUE;
            (s2fault, s2walkaddress) = <a link="AArch32.S2Translate.4" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean aligned, AccessDescriptor accdesc)">AArch32.S2Translate</a>(fault, walkaddress, s2aligned,
                                                           walkaccess);

            if s2fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
                return (s2fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

            (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(ee, s2walkaddress, walkaccess, fault, 32);
        else
            (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(ee, walkaddress, walkaccess, fault, 32);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

        walkstate.sdftype = <a link="AArch32.DecodeDescriptorTypeSD.2" file="shared_pseudocode.xml" hover="function: SDFType AArch32.DecodeDescriptorTypeSD(bits(32) descriptor, integer level)">AArch32.DecodeDescriptorTypeSD</a>(descriptor, walkstate.level);

        case walkstate.sdftype of
            when <a link="SDFType_Invalid" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Invalid</a>
                fault.domain     = domain;
                fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

            when <a link="SDFType_Table" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Table</a>
                domain = descriptor&lt;8:5&gt;;
                ns     = descriptor&lt;3&gt;;
                pxn    = descriptor&lt;2&gt;;

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;31:10&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(10),
                                                           56);
                walkstate.level = 2;

            when <a link="SDFType_SmallPage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_SmallPage</a>
                nG  = descriptor&lt;11&gt;;
                s   = descriptor&lt;10&gt;;
                ap  = descriptor&lt;9,5:4&gt;;
                tex = descriptor&lt;8:6&gt;;
                c   = descriptor&lt;3&gt;;
                b   = descriptor&lt;2&gt;;
                xn  = descriptor&lt;0&gt;;

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;31:12&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12),
                                                           56);
                walkstate.istable = FALSE;

            when <a link="SDFType_LargePage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_LargePage</a>
                xn  = descriptor&lt;15&gt;;
                tex = descriptor&lt;14:12&gt;;
                nG  = descriptor&lt;11&gt;;
                s   = descriptor&lt;10&gt;;
                ap  = descriptor&lt;9,5:4&gt;;
                c   = descriptor&lt;3&gt;;
                b   = descriptor&lt;2&gt;;

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;31:16&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16),
                                                           56);
                walkstate.istable = FALSE;

            when <a link="SDFType_Section" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Section</a>
                ns     = descriptor&lt;19&gt;;
                nG     = descriptor&lt;17&gt;;
                s      = descriptor&lt;16&gt;;
                ap     = descriptor&lt;15,11:10&gt;;
                tex    = descriptor&lt;14:12&gt;;
                domain = descriptor&lt;8:5&gt;;
                xn     = descriptor&lt;4&gt;;
                c      = descriptor&lt;3&gt;;
                b      = descriptor&lt;2&gt;;
                pxn    = descriptor&lt;0&gt;;

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;31:20&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(20),
                                                           56);
                walkstate.istable = FALSE;

            when <a link="SDFType_Supersection" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Supersection</a>
                ns     = descriptor&lt;19&gt;;
                nG     = descriptor&lt;17&gt;;
                s      = descriptor&lt;16&gt;;
                ap     = descriptor&lt;15,11:10&gt;;
                tex    = descriptor&lt;14:12&gt;;
                xn     = descriptor&lt;4&gt;;
                c      = descriptor&lt;3&gt;;
                b      = descriptor&lt;2&gt;;
                pxn    = descriptor&lt;0&gt;;
                domain = '0000';

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;8:5,23:20,31:24&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24),
                                                           56);
                walkstate.istable = FALSE;

    until walkstate.sdftype != <a link="SDFType_Table" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Table</a>;

    if afe == '1' &amp;&amp; ap&lt;0&gt; == '0' then
        fault.domain     = domain;
        fault.statuscode = <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    // Decode the TEX, C, B and S bits to produce target memory attributes
    if tre == '1' then
        walkstate.memattrs = <a link="AArch32.RemappedTEXDecode.5" file="shared_pseudocode.xml" hover="function: MemoryAttributes AArch32.RemappedTEXDecode(Regime regime, bits(3) TEX, bit C, bit B, bit s)">AArch32.RemappedTEXDecode</a>(regime, tex, c, b, s);
    elsif <a link="impl-aarch32.RemapRegsHaveResetValues.0" file="shared_pseudocode.xml" hover="function: boolean RemapRegsHaveResetValues()">RemapRegsHaveResetValues</a>() then
        walkstate.memattrs = <a link="AArch32.DefaultTEXDecode.4" file="shared_pseudocode.xml" hover="function: MemoryAttributes AArch32.DefaultTEXDecode(bits(3) TEX_in, bit C_in, bit B_in, bit s)">AArch32.DefaultTEXDecode</a>(tex, c, b, s);
    else
        walkstate.memattrs = <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> IMPLEMENTATION_DEFINED;

    walkstate.permissions.ap  = ap;
    walkstate.permissions.xn  = xn;
    walkstate.permissions.pxn = pxn;
    walkstate.domain = domain;
    walkstate.nG     = nG;

    if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; ns == '0' then
        walkstate.baseaddress.paspace = <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
    else
        walkstate.baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    return (fault, walkstate);</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.S2IASize" mylink="aarch32.translation.walk.AArch32.S2IASize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2IASize()
// ==================
// Retrieve the number of bits containing the input address for stage 2 translation

integer <anchor link="AArch32.S2IASize.1" hover="function: integer AArch32.S2IASize(bits(4) t0sz)">AArch32.S2IASize</anchor>(bits(4) t0sz)
    return 32 - <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(t0sz);</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.S2StartLevel" mylink="aarch32.translation.walk.AArch32.S2StartLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2StartLevel()
// ======================
// Determine the initial lookup level when performing a stage 2 translation
// table walk

integer <anchor link="AArch32.S2StartLevel.1" hover="function: integer AArch32.S2StartLevel(bits(2) sl0)">AArch32.S2StartLevel</anchor>(bits(2) sl0)
    return 2 - <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(sl0);</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.S2Walk" mylink="aarch32.translation.walk.AArch32.S2Walk" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S2Walk()
// ================
// Traverse stage 2 translation tables in long format to obtain the final descriptor

(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a>, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>) AArch32.S2Walk(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, S2TTWParams walkparams,
                                       <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if walkparams.sl0 IN {'1x'} || AArch32.S2InconsistentSL(walkparams) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 1;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    // Input Address size
    iasize      = <a link="AArch32.S2IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S2IASize(bits(4) t0sz)">AArch32.S2IASize</a>(walkparams.t0sz);
    startlevel  = <a link="AArch32.S2StartLevel.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S2StartLevel(bits(2) sl0)">AArch32.S2StartLevel</a>(walkparams.sl0);
    levels      = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - startlevel;
    granulebits = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    stride      = granulebits - 3;

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(VTTBR&lt;47:40&gt;) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
        fault.level      = 0;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> baseaddress;
    baselsb = (iasize - (levels*stride + granulebits)) + 3;
    baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR&lt;39:baselsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(baselsb), 56);

    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    walkstate.baseaddress = baseaddress;
    walkstate.level       = startlevel;
    walkstate.istable     = TRUE;
    walkstate.memattrs    = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(walkparams.sh, walkparams.irgn,
                                         walkparams.orgn);

    indexmsb = iasize - 1;
    bits(64) descriptor;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> walkaccess = <a link="impl-shared.CreateAccDescS2TTW.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescS2TTW(AccessDescriptor accdesc_in)">CreateAccDescS2TTW</a>(accdesc);
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> walkaddress;

    walkaddress.vaddress = ipa.vaddress;

    if HCR2.CD == '1' then
        walkaddress.memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        walkaddress.memattrs.xs = walkstate.memattrs.xs;
    else
        walkaddress.memattrs = walkstate.memattrs;

    walkaddress.memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(walkaddress.memattrs);

    integer indexlsb;
    <a link="DescriptorType" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType</a> desctype;
    repeat
        fault.level = walkstate.level;

        indexlsb = (<a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - walkstate.level)*stride + granulebits;
        bits(40) index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.paddress.address&lt;indexmsb:indexlsb&gt;:'000', 40);

        walkaddress.paddress.address = walkstate.baseaddress.address OR <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(index, 56);
        walkaddress.paddress.paspace = walkstate.baseaddress.paspace;

        (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(walkparams.ee, walkaddress, walkaccess, fault, 64);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

        desctype = <a link="AArch32.DecodeDescriptorTypeLD.2" file="shared_pseudocode.xml" hover="function: DescriptorType AArch32.DecodeDescriptorTypeLD(bits(64) descriptor, integer level)">AArch32.DecodeDescriptorTypeLD</a>(descriptor, walkstate.level);

        case desctype of
            when <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>
                if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(descriptor&lt;47:40&gt;) then
                    fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
                    return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

                walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;39:12&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 56);
                walkstate.level = walkstate.level + 1;
                indexmsb = indexlsb - 1;

            when <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>
                fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

            when <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>
                walkstate.istable = FALSE;

    until desctype IN {<a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>};

    // Check the output address is inside the supported range
    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(descriptor&lt;47:40&gt;) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    // Check the access flag
    if descriptor&lt;10&gt; == '0' then
        fault.statuscode = <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>;
        return (fault, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN);

    // Unpack the descriptor into address and upper and lower block attributes
    walkstate.baseaddress.address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(descriptor&lt;39:indexlsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(indexlsb), 56);

    walkstate.permissions.s2ap = descriptor&lt;7:6&gt;;
    walkstate.permissions.s2xn = descriptor&lt;54&gt;;
    if <a link="impl-shared.HaveExtendedExecuteNeverExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveExtendedExecuteNeverExt()">HaveExtendedExecuteNeverExt</a>() then
        walkstate.permissions.s2xnx = descriptor&lt;53&gt;;
    else
        walkstate.permissions.s2xnx = '0';

    memattr = descriptor&lt;5:2&gt;;
    sh      = descriptor&lt;9:8&gt;;
    s2aarch64 = FALSE;
    walkstate.memattrs   = <a link="impl-shared.S2DecodeMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes S2DecodeMemAttrs(bits(4) attr, bits(2) sh, boolean s2aarch64)">S2DecodeMemAttrs</a>(memattr, sh, s2aarch64);
    walkstate.contiguous = descriptor&lt;52&gt;;

    return (fault, walkstate);</pstext>
    </ps>
    <ps name="aarch32/translation/walk/AArch32.TranslationSizeSD" mylink="aarch32.translation.walk.AArch32.TranslationSizeSD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.TranslationSizeSD()
// ===========================
// Determine the size of the translation

integer <anchor link="AArch32.TranslationSizeSD.1" hover="function: integer AArch32.TranslationSizeSD(SDFType sdftype)">AArch32.TranslationSizeSD</anchor>(<a link="SDFType" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</a> sdftype)
    integer tsize;
    case sdftype of
        when <a link="SDFType_SmallPage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_SmallPage</a>      tsize = 12;
        when <a link="SDFType_LargePage" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_LargePage</a>      tsize = 16;
        when <a link="SDFType_Section" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Section</a>        tsize = 20;
        when <a link="SDFType_Supersection" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Supersection</a>   tsize = 24;

    return tsize;</pstext>
    </ps>
    <ps name="aarch32/translation/walk/RemapRegsHaveResetValues" mylink="aarch32.translation.walk.RemapRegsHaveResetValues" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RemapRegsHaveResetValues()
// ==========================

boolean <anchor link="impl-aarch32.RemapRegsHaveResetValues.0" hover="function: boolean RemapRegsHaveResetValues()">RemapRegsHaveResetValues</anchor>();</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.GetS1TTWParams" mylink="aarch32.translation.walkparams.AArch32.GetS1TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GetS1TTWParams()
// ========================
// Returns stage 1 translation table walk parameters from respective controlling
// System registers.

S1TTWParams AArch32.GetS1TTWParams(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(32) va)
    S1TTWParams walkparams;

    case regime of
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  walkparams = AArch32.S1TTWParamsEL2();
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> walkparams = AArch32.S1TTWParamsEL10(va);
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> walkparams = AArch32.S1TTWParamsEL30(va);

    return walkparams;</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.GetS2TTWParams" mylink="aarch32.translation.walkparams.AArch32.GetS2TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GetS2TTWParams()
// ========================
// Gather walk parameters for stage 2 translation

S2TTWParams AArch32.GetS2TTWParams()
    S2TTWParams walkparams;

    walkparams.tgx  = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
    walkparams.s    = VTCR.S;
    walkparams.t0sz = VTCR.T0SZ;
    walkparams.sl0  = VTCR.SL0;
    walkparams.irgn = VTCR.IRGN0;
    walkparams.orgn = VTCR.ORGN0;
    walkparams.sh   = VTCR.SH0;
    walkparams.ee   = HSCTLR.EE;
    walkparams.ptw  = HCR.PTW;
    walkparams.vm   = HCR.VM OR HCR.DC;

    // VTCR.S must match VTCR.T0SZ[3]
    if walkparams.s != walkparams.t0sz&lt;3&gt; then
        (-, walkparams.t0sz) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESVTCRS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESVTCRS</a>, 4);

    return walkparams;</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.GetVARange" mylink="aarch32.translation.walkparams.AArch32.GetVARange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.GetVARange()
// ====================
// Select the translation base address for stage 1 long-descriptor walks

VARange <anchor link="AArch32.GetVARange.3" hover="function: VARange AArch32.GetVARange(bits(32) va, bits(3) t0sz, bits(3) t1sz)">AArch32.GetVARange</anchor>(bits(32) va, bits(3) t0sz, bits(3) t1sz)
    // Lower range Input Address size
    lo_iasize = <a link="AArch32.S1IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</a>(t0sz);
    // Upper range Input Address size
    up_iasize = <a link="AArch32.S1IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch32.S1IASize(bits(3) txsz)">AArch32.S1IASize</a>(t1sz);

    if t1sz == '000' &amp;&amp; t0sz == '000' then
        return <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a>;
    elsif t1sz == '000' then
        return if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;31:lo_iasize&gt;) then <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> else <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a>;
    elsif t0sz == '000' then
        return if <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(va&lt;31:up_iasize&gt;) then <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a> else <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a>;
    elsif <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;31:lo_iasize&gt;) then
        return <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a>;
    elsif <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(va&lt;31:up_iasize&gt;) then
        return <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a>;
    else
        // Will be reported as a Translation Fault
        return <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> UNKNOWN;</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.S1DCacheEnabled" mylink="aarch32.translation.walkparams.AArch32.S1DCacheEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1DCacheEnabled()
// =========================
// Determine cacheability of stage 1 data accesses

boolean <anchor link="AArch32.S1DCacheEnabled.1" hover="function: boolean AArch32.S1DCacheEnabled(Regime regime)">AArch32.S1DCacheEnabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> return SCTLR_S.C == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return HSCTLR.C == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return (if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCTLR_NS.C else SCTLR.C) == '1';</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.S1ICacheEnabled" mylink="aarch32.translation.walkparams.AArch32.S1ICacheEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1ICacheEnabled()
// =========================
// Determine cacheability of stage 1 instruction fetches

boolean <anchor link="AArch32.S1ICacheEnabled.1" hover="function: boolean AArch32.S1ICacheEnabled(Regime regime)">AArch32.S1ICacheEnabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> return SCTLR_S.I == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return HSCTLR.I == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return (if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCTLR_NS.I else SCTLR.I) == '1';</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.S1TTWParamsEL10" mylink="aarch32.translation.walkparams.AArch32.S1TTWParamsEL10" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1TTWParamsEL10()
// =========================
// Gather stage 1 translation table walk parameters for EL1&amp;0 regime
// (with EL2 enabled or disabled).

S1TTWParams AArch32.S1TTWParamsEL10(bits(32) va)
    bits(64) mair;
    bit sif;
    TTBCR_Type ttbcr;
    TTBCR2_Type ttbcr2;
    SCTLR_Type sctlr;

    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        ttbcr  = TTBCR_NS;
        ttbcr2 = TTBCR2_NS;
        sctlr  = SCTLR_NS;
        mair   = MAIR1_NS:MAIR0_NS;
        sif    = SCR.SIF;
    else
        ttbcr  = TTBCR;
        ttbcr2 = TTBCR2;
        sctlr  = SCTLR;
        mair   = MAIR1:MAIR0;
        sif    = if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SCR_EL3.SIF else '0';

    assert ttbcr.EAE == '1';
    S1TTWParams walkparams;

    walkparams.t0sz   = ttbcr.T0SZ;
    walkparams.t1sz   = ttbcr.T1SZ;
    walkparams.ee     = sctlr.EE;
    walkparams.wxn    = sctlr.WXN;
    walkparams.uwxn   = sctlr.UWXN;
    walkparams.ntlsmd = if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then sctlr.nTLSMD else '1';
    walkparams.mair   = mair;
    walkparams.sif    = sif;

    varange = <a link="AArch32.GetVARange.3" file="shared_pseudocode.xml" hover="function: VARange AArch32.GetVARange(bits(32) va, bits(3) t0sz, bits(3) t1sz)">AArch32.GetVARange</a>(va, walkparams.t0sz, walkparams.t1sz);
    if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
        walkparams.sh   = ttbcr.SH0;
        walkparams.irgn = ttbcr.IRGN0;
        walkparams.orgn = ttbcr.ORGN0;
        walkparams.hpd  = if <a link="AArch32.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.HaveHPDExt()">AArch32.HaveHPDExt</a>() then ttbcr.T2E AND ttbcr2.HPD0 else '0';
    else
        walkparams.sh   = ttbcr.SH1;
        walkparams.irgn = ttbcr.IRGN1;
        walkparams.orgn = ttbcr.ORGN1;
        walkparams.hpd  = if <a link="AArch32.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.HaveHPDExt()">AArch32.HaveHPDExt</a>() then ttbcr.T2E AND ttbcr2.HPD1 else '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.S1TTWParamsEL2" mylink="aarch32.translation.walkparams.AArch32.S1TTWParamsEL2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1TTWParamsEL2()
// ========================
// Gather stage 1 translation table walk parameters for EL2 regime

S1TTWParams AArch32.S1TTWParamsEL2()
    S1TTWParams walkparams;

    walkparams.tgx  = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
    walkparams.t0sz = HTCR.T0SZ;
    walkparams.irgn = HTCR.SH0;
    walkparams.orgn = HTCR.IRGN0;
    walkparams.sh   = HTCR.ORGN0;
    walkparams.hpd  = if <a link="AArch32.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.HaveHPDExt()">AArch32.HaveHPDExt</a>() then HTCR.HPD else '0';
    walkparams.ee   = HSCTLR.EE;
    walkparams.wxn  = HSCTLR.WXN;
    if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then
        walkparams.ntlsmd = HSCTLR.nTLSMD;
    else
        walkparams.ntlsmd = '1';

    walkparams.mair = HMAIR1:HMAIR0;

    return walkparams;</pstext>
    </ps>
    <ps name="aarch32/translation/walkparams/AArch32.S1TTWParamsEL30" mylink="aarch32.translation.walkparams.AArch32.S1TTWParamsEL30" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.S1TTWParamsEL30()
// =========================
// Gather stage 1 translation table walk parameters for EL3&amp;0 regime

S1TTWParams AArch32.S1TTWParamsEL30(bits(32) va)
    assert TTBCR_S.EAE == '1';
    S1TTWParams walkparams;

    walkparams.t0sz   = TTBCR_S.T0SZ;
    walkparams.t1sz   = TTBCR_S.T1SZ;
    walkparams.ee     = SCTLR_S.EE;
    walkparams.wxn    = SCTLR_S.WXN;
    walkparams.uwxn   = SCTLR_S.UWXN;
    walkparams.ntlsmd = if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then SCTLR_S.nTLSMD else '1';
    walkparams.mair   = MAIR1_S:MAIR0_S;
    walkparams.sif    = SCR.SIF;

    varange = <a link="AArch32.GetVARange.3" file="shared_pseudocode.xml" hover="function: VARange AArch32.GetVARange(bits(32) va, bits(3) t0sz, bits(3) t1sz)">AArch32.GetVARange</a>(va, walkparams.t0sz, walkparams.t1sz);
    if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
        walkparams.sh   = TTBCR_S.SH0;
        walkparams.irgn = TTBCR_S.IRGN0;
        walkparams.orgn = TTBCR_S.ORGN0;
        walkparams.hpd  = if <a link="AArch32.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.HaveHPDExt()">AArch32.HaveHPDExt</a>() then TTBCR_S.T2E AND TTBCR2_S.HPD0 else '0';
    else
        walkparams.sh   = TTBCR_S.SH1;
        walkparams.irgn = TTBCR_S.IRGN1;
        walkparams.orgn = TTBCR_S.ORGN1;
        walkparams.hpd  = if <a link="AArch32.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.HaveHPDExt()">AArch32.HaveHPDExt</a>() then TTBCR_S.T2E AND TTBCR2_S.HPD1 else '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBCycleCountingEnabled" mylink="aarch64.debug.brbe.BRBCycleCountingEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBCycleCountingEnabled()
// =========================
// Returns TRUE if the BRBINF&lt;n&gt;_EL1.{CCU, CC} fields are valid, FALSE otherwise.

boolean <anchor link="impl-aarch64.BRBCycleCountingEnabled.0" hover="function: boolean BRBCycleCountingEnabled()">BRBCycleCountingEnabled</anchor>()
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; BRBCR_EL2.CC == '0' then return FALSE;
    if BRBCR_EL1.CC == '0' then return FALSE;
    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEBranch" mylink="aarch64.debug.brbe.BRBEBranch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEBranch()
// ============
// Called to write branch record for the following branches when BRB is active:
// direct branches,
// indirect branches,
// direct branches with link,
// indirect branches with link,
// returns from subroutines.

<anchor link="impl-aarch64.BRBEBranch.3" hover="function: BRBEBranch(BranchType br_type, boolean cond, bits(64) target_address)">BRBEBranch</anchor>(<a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> br_type, boolean cond, bits(64) target_address)
    if <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(PSTATE.EL) &amp;&amp; <a link="impl-aarch64.FilterBranchRecord.2" file="shared_pseudocode.xml" hover="function: boolean FilterBranchRecord(BranchType br, boolean cond)">FilterBranchRecord</a>(br_type, cond) then
        bits(6) branch_type;
        case br_type of
            when <a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>
                branch_type = if cond then '001000' else '000000';
            when <a link="BranchType_INDIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</a>      branch_type = '000001';
            when <a link="BranchType_DIRCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIRCALL</a>    branch_type = '000010';
            when <a link="BranchType_INDCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDCALL</a>    branch_type = '000011';
            when <a link="BranchType_RET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RET</a>        branch_type = '000101';
            otherwise                  <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

        bit ccu;
        bits(14) cc;
        (ccu, cc) = <a link="impl-aarch64.BranchEncCycleCount.0" file="shared_pseudocode.xml" hover="function: (bit, bits(14)) BranchEncCycleCount()">BranchEncCycleCount</a>();
        bit lastfailed = if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then BRBFCR_EL1.LASTFAILED else '0';
        bit transactional = if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then '1' else '0';
        bits(2) el = PSTATE.EL;
        bit mispredict = if <a link="impl-aarch64.BRBEMispredictAllowed.0" file="shared_pseudocode.xml" hover="function: boolean BRBEMispredictAllowed()">BRBEMispredictAllowed</a>() &amp;&amp; <a link="impl-aarch64.BranchMispredict.0" file="shared_pseudocode.xml" hover="function: boolean BranchMispredict()">BranchMispredict</a>() then '1' else '0';

        <a link="impl-aarch64.UpdateBranchRecordBuffer.10" file="shared_pseudocode.xml" hover="function: UpdateBranchRecordBuffer(bit ccu, bits(14) cc, bit lastfailed, bit transactional, bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid, bits(64) source_address, bits(64) target_address)">UpdateBranchRecordBuffer</a>(ccu, cc, lastfailed, transactional, branch_type, el, mispredict,
                                 '11', <a link="impl-aarch64.PC.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) PC[]">PC</a>[], target_address);

        BRBFCR_EL1.LASTFAILED = '0';

        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_BRB_FILTRATE);

    return;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEBranchOnISB" mylink="aarch64.debug.brbe.BRBEBranchOnISB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEBranchOnISB()
// =================
// Returns TRUE if ISBs generate Branch records, and FALSE otherwise.

boolean <anchor link="impl-aarch64.BRBEBranchOnISB.0" hover="function: boolean BRBEBranchOnISB()">BRBEBranchOnISB</anchor>()
    return boolean IMPLEMENTATION_DEFINED "ISB generates Branch records";</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEDebugStateExit" mylink="aarch64.debug.brbe.BRBEDebugStateExit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEDebugStateExit()
// ====================
// Called to write Debug state exit branch record when BRB is active.

<anchor link="impl-aarch64.BRBEDebugStateExit.1" hover="function: BRBEDebugStateExit(bits(64) target_address)">BRBEDebugStateExit</anchor>(bits(64) target_address)
    if <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(PSTATE.EL) then
        // Debug state is a prohibited region, therefore ccu=1, cc=0, source_address=0
        bits(6) branch_type = '111001';
        bit ccu = '1';
        bits(14) cc = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(14);
        bit lastfailed = if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then BRBFCR_EL1.LASTFAILED else '0';
        bit transactional = '0';
        bits(2) el = PSTATE.EL;
        bit mispredict = '0';

        <a link="impl-aarch64.UpdateBranchRecordBuffer.10" file="shared_pseudocode.xml" hover="function: UpdateBranchRecordBuffer(bit ccu, bits(14) cc, bit lastfailed, bit transactional, bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid, bits(64) source_address, bits(64) target_address)">UpdateBranchRecordBuffer</a>(ccu, cc, lastfailed, transactional, branch_type, el, mispredict,
                                 '01', <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64), target_address);

        BRBFCR_EL1.LASTFAILED = '0';

        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_BRB_FILTRATE);

    return;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEException" mylink="aarch64.debug.brbe.BRBEException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEException()
// ===============
// Called to write exception branch record when BRB is active.

<anchor link="impl-aarch64.BRBEException.5" hover="function: BRBEException(ExceptionRecord erec, bits(64) preferred_exception_return, bits(64) target_address_in, bits(2) target_el, boolean trappedsyscallinst)">BRBEException</anchor>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> erec, bits(64) preferred_exception_return,
              bits(64) target_address_in, bits(2) target_el, boolean trappedsyscallinst)
    bits(64) target_address = target_address_in;
    <a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exception = erec.exceptype;
    bits(25) iss = erec.syndrome;
    case target_el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  if !<a link="impl-shared.HaveBRBEv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBEv1p1()">HaveBRBEv1p1</a>() || (MDCR_EL3.E3BREC == MDCR_EL3.E3BREW) then return;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  if BRBCR_EL2.EXCEPTION == '0' then return;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  if BRBCR_EL1.EXCEPTION == '0' then return;

    boolean source_valid = <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(PSTATE.EL);
    boolean target_valid = <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(target_el);

    if source_valid || target_valid then
        bits(6) branch_type;
        case exception of
            when <a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>         branch_type = '100011'; // Trap
            when <a link="Exception_WFxTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_WFxTrap</a>               branch_type = '100011'; // Trap
            when <a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>            branch_type = '100011'; // Trap
            when <a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>           branch_type = '100011'; // Trap
            when <a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>            branch_type = '100011'; // Trap
            when <a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a>            branch_type = '100011'; // Trap
            when <a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>   branch_type = '100011'; // Trap
            when <a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>              branch_type = '100011'; // Trap
            when <a link="Exception_PACTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACTrap</a>               branch_type = '100011'; // Trap
            when <a link="Exception_TSTARTAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_TSTARTAccessTrap</a>      branch_type = '100011'; // Trap
            when <a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>           branch_type = '100011'; // Trap
            when <a link="Exception_BranchTarget" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_BranchTarget</a>          branch_type = '101011'; // Inst Fault
            when <a link="Exception_IllegalState" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</a>          branch_type = '100011'; // Trap
            when <a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>
                if !trappedsyscallinst then      branch_type = '100010'; // Call
                else                             branch_type = '100011'; // Trap
            when <a link="Exception_HypervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_HypervisorCall</a>        branch_type = '100010'; // Call
            when <a link="Exception_MonitorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</a>
                if !trappedsyscallinst then      branch_type = '100010'; // Call
                else                             branch_type = '100011'; // Trap
            when <a link="Exception_SystemRegisterTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegisterTrap</a>    branch_type = '100011'; // Trap
            when <a link="Exception_SystemRegister128Trap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegister128Trap</a> branch_type = '100011'; // Trap
            when <a link="Exception_SVEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SVEAccessTrap</a>         branch_type = '100011'; // Trap
            when <a link="Exception_SMEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SMEAccessTrap</a>         branch_type = '100011'; // Trap
            when <a link="Exception_ERetTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_ERetTrap</a>              branch_type = '100011'; // Trap
            when <a link="Exception_PACFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACFail</a>               branch_type = '101100'; // Data Fault
            when <a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>      branch_type = '101011'; // Inst Fault
            when <a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>           branch_type = '101010'; // Alignment
            when <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>             branch_type = '101100'; // Data Fault
            when <a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a>          branch_type = '101100'; // Data Fault
            when <a link="Exception_SPAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SPAlignment</a>           branch_type = '101010'; // Alignment
            when <a link="Exception_FPTrappedException" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPTrappedException</a>    branch_type = '100011'; // Trap
            when <a link="Exception_SError" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SError</a>                branch_type = '100100'; // System Error
            when <a link="Exception_Breakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</a>            branch_type = '100110'; // Inst debug
            when <a link="Exception_SoftwareStep" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</a>          branch_type = '100110'; // Inst debug
            when <a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>            branch_type = '100111'; // Data debug
            when <a link="Exception_NV2Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2Watchpoint</a>         branch_type = '100111'; // Data debug
            when <a link="Exception_SoftwareBreakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</a>    branch_type = '100110'; // Inst debug
            when <a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>                   branch_type = '101110'; // IRQ
            when <a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>                   branch_type = '101111'; // FIQ
            when <a link="Exception_MemCpyMemSet" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MemCpyMemSet</a>          branch_type = '100011'; // Trap
            when <a link="Exception_GCSFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GCSFail</a>
                if iss&lt;23:20&gt; == '0000' then     branch_type = '101100'; // Data Fault
                elsif iss&lt;23:20&gt; == '0001' then  branch_type = '101011'; // Inst Fault
                elsif iss&lt;23:20&gt; == '0010' then  branch_type = '100011'; // Trap
                else                             <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
            otherwise                            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

        bit ccu;
        bits(14) cc;
        (ccu, cc) = <a link="impl-aarch64.BranchEncCycleCount.0" file="shared_pseudocode.xml" hover="function: (bit, bits(14)) BranchEncCycleCount()">BranchEncCycleCount</a>();
        bit lastfailed = if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then BRBFCR_EL1.LASTFAILED else '0';
        bit transactional = if source_valid &amp;&amp; <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then '1' else '0';
        bits(2) el = if target_valid then target_el else '00';
        bit mispredict = '0';
        bit sv = if source_valid then '1' else '0';
        bit tv = if target_valid then '1' else '0';
        bits(64) source_address = if source_valid then preferred_exception_return else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

        if !target_valid then
            target_address = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        else
            target_address = <a link="AArch64.BranchAddr.2" file="shared_pseudocode.xml" hover="function: bits(64) AArch64.BranchAddr(bits(64) vaddress, bits(2) el)">AArch64.BranchAddr</a>(target_address, target_el);

        <a link="impl-aarch64.UpdateBranchRecordBuffer.10" file="shared_pseudocode.xml" hover="function: UpdateBranchRecordBuffer(bit ccu, bits(14) cc, bit lastfailed, bit transactional, bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid, bits(64) source_address, bits(64) target_address)">UpdateBranchRecordBuffer</a>(ccu, cc, lastfailed, transactional, branch_type, el, mispredict,
                                 sv:tv, source_address, target_address);

        BRBFCR_EL1.LASTFAILED = '0';

        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_BRB_FILTRATE);

    return;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEExceptionReturn" mylink="aarch64.debug.brbe.BRBEExceptionReturn" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEExceptionReturn()
// =====================
// Called to write exception return branch record when BRB is active.

<anchor link="impl-aarch64.BRBEExceptionReturn.2" hover="function: BRBEExceptionReturn(bits(64) target_address_in, bits(2) source_el)">BRBEExceptionReturn</anchor>(bits(64) target_address_in, bits(2) source_el)
    bits(64) target_address = target_address_in;
    case source_el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  if !<a link="impl-shared.HaveBRBEv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBEv1p1()">HaveBRBEv1p1</a>() || (MDCR_EL3.E3BREC == MDCR_EL3.E3BREW) then return;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  if BRBCR_EL2.ERTN == '0' then return;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  if BRBCR_EL1.ERTN == '0' then return;

    boolean source_valid = <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(source_el);
    boolean target_valid = <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(PSTATE.EL);

    if source_valid || target_valid then
        bits(6) branch_type = '000111';
        bit ccu;
        bits(14) cc;
        (ccu, cc) = <a link="impl-aarch64.BranchEncCycleCount.0" file="shared_pseudocode.xml" hover="function: (bit, bits(14)) BranchEncCycleCount()">BranchEncCycleCount</a>();
        bit lastfailed = if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then BRBFCR_EL1.LASTFAILED else '0';
        bit transactional = if source_valid &amp;&amp; <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then '1' else '0';
        bits(2) el = if target_valid then PSTATE.EL else '00';
        bit mispredict = if (source_valid &amp;&amp; <a link="impl-aarch64.BRBEMispredictAllowed.0" file="shared_pseudocode.xml" hover="function: boolean BRBEMispredictAllowed()">BRBEMispredictAllowed</a>() &amp;&amp;
                             <a link="impl-aarch64.BranchMispredict.0" file="shared_pseudocode.xml" hover="function: boolean BranchMispredict()">BranchMispredict</a>()) then '1' else '0';
        bit sv = if source_valid then '1' else '0';
        bit tv = if target_valid then '1' else '0';
        bits(64) source_address = if source_valid then <a link="impl-aarch64.PC.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) PC[]">PC</a>[] else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        if !target_valid then
            target_address = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

        <a link="impl-aarch64.UpdateBranchRecordBuffer.10" file="shared_pseudocode.xml" hover="function: UpdateBranchRecordBuffer(bit ccu, bits(14) cc, bit lastfailed, bit transactional, bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid, bits(64) source_address, bits(64) target_address)">UpdateBranchRecordBuffer</a>(ccu, cc, lastfailed, transactional, branch_type, el, mispredict,
                                 sv:tv, source_address, target_address);

        BRBFCR_EL1.LASTFAILED = '0';

        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_BRB_FILTRATE);

    return;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEFreeze" mylink="aarch64.debug.brbe.BRBEFreeze" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEFreeze()
// ============
// Generates BRBE freeze event.

<anchor link="impl-aarch64.BRBEFreeze.0" hover="function: BRBEFreeze()">BRBEFreeze</anchor>()
    BRBFCR_EL1.PAUSED = '1';
    BRBTS_EL1 = <a link="impl-shared.GetTimestamp.1" file="shared_pseudocode.xml" hover="function: bits(64) GetTimestamp(TimeStamp timeStampType)">GetTimestamp</a>(<a link="impl-aarch64.BRBETimeStamp.0" file="shared_pseudocode.xml" hover="function: TimeStamp BRBETimeStamp()">BRBETimeStamp</a>());</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEISB" mylink="aarch64.debug.brbe.BRBEISB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEISB()
// =========
// Handles ISB instruction for BRBE.

<anchor link="impl-aarch64.BRBEISB.0" hover="function: BRBEISB()">BRBEISB</anchor>()
    boolean branch_conditional = FALSE;
    <a link="impl-aarch64.BRBEBranch.3" file="shared_pseudocode.xml" hover="function: BRBEBranch(BranchType br_type, boolean cond, bits(64) target_address)">BRBEBranch</a>(<a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>, branch_conditional, <a link="impl-aarch64.PC.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) PC[]">PC</a>[] + 4);</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBEMispredictAllowed" mylink="aarch64.debug.brbe.BRBEMispredictAllowed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBEMispredictAllowed()
// =======================
// Returns TRUE if the recording of branch misprediction is allowed, FALSE otherwise.

boolean <anchor link="impl-aarch64.BRBEMispredictAllowed.0" hover="function: boolean BRBEMispredictAllowed()">BRBEMispredictAllowed</anchor>()
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; BRBCR_EL2.MPRED == '0' then return FALSE;
    if BRBCR_EL1.MPRED == '0' then return FALSE;
    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRBETimeStamp" mylink="aarch64.debug.brbe.BRBETimeStamp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRBETimeStamp()
// ===============
// Returns captured timestamp.

TimeStamp <anchor link="impl-aarch64.BRBETimeStamp.0" hover="function: TimeStamp BRBETimeStamp()">BRBETimeStamp</anchor>()
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        TS_el2 = BRBCR_EL2.TS;
        if !<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() &amp;&amp; TS_el2 == '10' then
            // Reserved value
            (-, TS_el2) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_EL2TIMESTAMP" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_EL2TIMESTAMP</a>, 2);
        case TS_el2 of
            when '00'
                // Falls out to check BRBCR_EL1.TS
            when '01'
                return <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
            when '10'
                assert <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>(); // Otherwise ConstrainUnpredictableBits removes this case
                return <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>;
            when '11'
                return <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>;

    TS_el1 = BRBCR_EL1.TS;
    if TS_el1 == '00' || (!<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() &amp;&amp; TS_el1 == '10') then
        // Reserved value
        (-, TS_el1) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_EL1TIMESTAMP" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_EL1TIMESTAMP</a>, 2);
    case TS_el1 of
        when '01'
            return <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
        when '10'
            return <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>;
        when '11'
            return <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();           // ConstrainUnpredictableBits removes this case</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRB_IALL" mylink="aarch64.debug.brbe.BRB_IALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRB_IALL()
// ==========
// Called to perform invalidation of branch records

<anchor link="impl-aarch64.BRB_IALL.0" hover="function: BRB_IALL()">BRB_IALL</anchor>()
    for i = 0 to <a link="impl-aarch64.GetBRBENumRecords.0" file="shared_pseudocode.xml" hover="function: integer GetBRBENumRecords()">GetBRBENumRecords</a>() - 1
        Records_SRC[i] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        Records_TGT[i] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        Records_INF[i] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BRB_INJ" mylink="aarch64.debug.brbe.BRB_INJ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BRB_INJ()
// =========
// Called to perform manual injection of branch records.

<anchor link="impl-aarch64.BRB_INJ.0" hover="function: BRB_INJ()">BRB_INJ</anchor>()
    <a link="impl-aarch64.UpdateBranchRecordBuffer.10" file="shared_pseudocode.xml" hover="function: UpdateBranchRecordBuffer(bit ccu, bits(14) cc, bit lastfailed, bit transactional, bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid, bits(64) source_address, bits(64) target_address)">UpdateBranchRecordBuffer</a>(BRBINFINJ_EL1.CCU, BRBINFINJ_EL1.CC, BRBINFINJ_EL1.LASTFAILED,
                             BRBINFINJ_EL1.T, BRBINFINJ_EL1.TYPE, BRBINFINJ_EL1.EL,
                             BRBINFINJ_EL1.MPRED, BRBINFINJ_EL1.VALID, BRBSRCINJ_EL1.ADDRESS,
                             BRBTGTINJ_EL1.ADDRESS);
    BRBINFINJ_EL1 = bits(64) UNKNOWN;
    BRBSRCINJ_EL1 = bits(64) UNKNOWN;
    BRBTGTINJ_EL1 = bits(64) UNKNOWN;

    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BRBFILTRATE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BRBFILTRATE</a>) then <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_BRB_FILTRATE);</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/Branch" mylink="aarch64.debug.brbe.Branch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="BRBSRCType" hover="type BRBSRCType">BRBSRCType</anchor>;
type <anchor link="BRBTGTType" hover="type BRBTGTType">BRBTGTType</anchor>;
type <anchor link="BRBINFType" hover="type BRBINFType">BRBINFType</anchor>;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BranchEncCycleCount" mylink="aarch64.debug.brbe.BranchEncCycleCount" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchEncCycleCount()
// =====================
// The first return result is '1' if either of the following is true, and '0' otherwise:
// - This is the first Branch record after the PE exited a Prohibited Region.
// - This is the first Branch record after cycle counting has been enabled.
// If the first return return is '0', the second return result is the encoded cycle count
// since the last branch.
// The format of this field uses a mantissa and exponent to express the cycle count value.
//  - bits[7:0] indicate the mantissa M.
//  - bits[13:8] indicate the exponent E.
// The cycle count is expressed using the following function:
//   cycle_count = (if IsZero(E) then UInt(M) else UInt('1':M:Zeros(UInt(E)-1)))
// A value of all ones in both the mantissa and exponent indicates the cycle count value
// exceeded the size of the cycle counter.
// If the cycle count is not known, the second return result is zero.

(bit, bits(14)) <anchor link="impl-aarch64.BranchEncCycleCount.0" hover="function: (bit, bits(14)) BranchEncCycleCount()">BranchEncCycleCount</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BranchMispredict" mylink="aarch64.debug.brbe.BranchMispredict" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchMispredict()
// ==================
// Returns TRUE if the branch being executed was mispredicted, FALSE otherwise.

boolean <anchor link="impl-aarch64.BranchMispredict.0" hover="function: boolean BranchMispredict()">BranchMispredict</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BranchRawCycleCount" mylink="aarch64.debug.brbe.BranchRawCycleCount" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchRawCycleCount()
// =====================
// If the cycle count is known, the return result is the cycle count since the last branch.

integer <anchor link="impl-aarch64.BranchRawCycleCount.0" hover="function: integer BranchRawCycleCount()">BranchRawCycleCount</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/BranchRecordAllowed" mylink="aarch64.debug.brbe.BranchRecordAllowed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchRecordAllowed()
// =====================
// Returns TRUE if branch recording is allowed, FALSE otherwise.

boolean <anchor link="impl-aarch64.BranchRecordAllowed.1" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</anchor>(bits(2) el)
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el) then
        return FALSE;

    if BRBFCR_EL1.PAUSED == '1' then
        return FALSE;

    if el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.HaveBRBEv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBEv1p1()">HaveBRBEv1p1</a>() then
        return (MDCR_EL3.E3BREC != MDCR_EL3.E3BREW);

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; (MDCR_EL3.SBRBE == '00' ||
        (<a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; MDCR_EL3.SBRBE == '01')) then
        return FALSE;

    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  return FALSE;                // FEAT_BRBEv1p1 not implemented
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  return BRBCR_EL2.E2BRE == '1';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  return BRBCR_EL1.E1BRE == '1';
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
                return BRBCR_EL2.E0HBRE == '1';
            else
                return BRBCR_EL1.E0BRE == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/Contents" mylink="aarch64.debug.brbe.Contents" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Contents of the Branch Record Buffer
//=====================================

array [0..63] of <a link="BRBSRCType" file="shared_pseudocode.xml" hover="type BRBSRCType">BRBSRCType</a> Records_SRC;

array [0..63] of <a link="BRBTGTType" file="shared_pseudocode.xml" hover="type BRBTGTType">BRBTGTType</a> Records_TGT;

array [0..63] of <a link="BRBINFType" file="shared_pseudocode.xml" hover="type BRBINFType">BRBINFType</a> Records_INF;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/FilterBranchRecord" mylink="aarch64.debug.brbe.FilterBranchRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FilterBranchRecord()
// ====================
// Returns TRUE if the branch record is not filtered out, FALSE otherwise.

boolean <anchor link="impl-aarch64.FilterBranchRecord.2" hover="function: boolean FilterBranchRecord(BranchType br, boolean cond)">FilterBranchRecord</anchor>(<a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> br, boolean cond)
    case br of
        when <a link="BranchType_DIRCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIRCALL</a>
            return BRBFCR_EL1.DIRCALL != BRBFCR_EL1.EnI;
        when <a link="BranchType_INDCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDCALL</a>
            return BRBFCR_EL1.INDCALL != BRBFCR_EL1.EnI;
        when <a link="BranchType_RET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RET</a>
            return BRBFCR_EL1.RTN != BRBFCR_EL1.EnI;
        when <a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>
            if cond then
                return BRBFCR_EL1.CONDDIR != BRBFCR_EL1.EnI;
            else
                return BRBFCR_EL1.DIRECT != BRBFCR_EL1.EnI;
        when <a link="BranchType_INDIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</a>
            return BRBFCR_EL1.INDIRECT != BRBFCR_EL1.EnI;
        otherwise  <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/FirstBranchAfterProhibited" mylink="aarch64.debug.brbe.FirstBranchAfterProhibited" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FirstBranchAfterProhibited()
// ============================
// Returns TRUE if branch recorded is the first branch after a prohibited region,
// FALSE otherwise.

<anchor link="impl-aarch64.FirstBranchAfterProhibited.0" hover="function: FirstBranchAfterProhibited()">FirstBranchAfterProhibited</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/GetBRBENumRecords" mylink="aarch64.debug.brbe.GetBRBENumRecords" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetBRBENumRecords()
// ===================
// Returns the number of branch records implemented.

integer <anchor link="impl-aarch64.GetBRBENumRecords.0" hover="function: integer GetBRBENumRecords()">GetBRBENumRecords</anchor>()
    assert <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(BRBIDR0_EL1.NUMREC) IN {0x08, 0x10, 0x20, 0x40};
    return integer IMPLEMENTATION_DEFINED "Number of BRB records";</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/Getter" mylink="aarch64.debug.brbe.Getter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Getter functions for branch records
// ===================================
// Functions used by MRS instructions that access branch records

BRBSRCType <anchor link="impl-aarch64.BRBSRC_EL1.read.1" hover="accessor: BRBSRCType BRBSRC_EL1[integer n]">BRBSRC_EL1</anchor>[integer n]
    assert n IN {0..31};
    integer record = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(BRBFCR_EL1.BANK:n&lt;4:0&gt;);
    if record &lt; <a link="impl-aarch64.GetBRBENumRecords.0" file="shared_pseudocode.xml" hover="function: integer GetBRBENumRecords()">GetBRBENumRecords</a>() then
        return Records_SRC[record];
    else
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

BRBTGTType <anchor link="impl-aarch64.BRBTGT_EL1.read.1" hover="accessor: BRBTGTType BRBTGT_EL1[integer n]">BRBTGT_EL1</anchor>[integer n]
    assert n IN {0..31};
    integer record = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(BRBFCR_EL1.BANK:n&lt;4:0&gt;);
    if record &lt; <a link="impl-aarch64.GetBRBENumRecords.0" file="shared_pseudocode.xml" hover="function: integer GetBRBENumRecords()">GetBRBENumRecords</a>() then
        return Records_TGT[record];
    else
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

BRBINFType <anchor link="impl-aarch64.BRBINF_EL1.read.1" hover="accessor: BRBINFType BRBINF_EL1[integer n]">BRBINF_EL1</anchor>[integer n]
    assert n IN {0..31};
    integer record = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(BRBFCR_EL1.BANK:n&lt;4:0&gt;);
    if record &lt; <a link="impl-aarch64.GetBRBENumRecords.0" file="shared_pseudocode.xml" hover="function: integer GetBRBENumRecords()">GetBRBENumRecords</a>() then
        return Records_INF[record];
    else
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/ShouldBRBEFreeze" mylink="aarch64.debug.brbe.ShouldBRBEFreeze" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ShouldBRBEFreeze()
// ==================
// Returns TRUE if the BRBE freeze event conditions have been met, and FALSE otherwise.

boolean <anchor link="impl-aarch64.ShouldBRBEFreeze.0" hover="function: boolean ShouldBRBEFreeze()">ShouldBRBEFreeze</anchor>()
    if !<a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(PSTATE.EL) then return FALSE;
    boolean check_e      = FALSE;
    boolean check_cnten  = FALSE;
    boolean check_inten  = FALSE;
    boolean exclude_sync = FALSE;
    boolean exclude_cyc  = TRUE;
    boolean include_lo;
    boolean include_hi;

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        include_lo = (BRBCR_EL1.FZP == '1');
        include_hi = (BRBCR_EL2.FZP == '1');
    else
        include_lo = TRUE;
        include_hi = TRUE;

    return <a link="impl-shared.PMUOverflowCondition.7" file="shared_pseudocode.xml" hover="function: boolean PMUOverflowCondition(boolean check_e, boolean check_cnten, boolean check_inten, boolean include_hi, boolean include_lo, boolean exclude_cyc, boolean exclude_sync)">PMUOverflowCondition</a>(check_e, check_cnten, check_inten,
                                include_hi, include_lo, exclude_cyc,
                                exclude_sync);</pstext>
    </ps>
    <ps name="aarch64/debug/brbe/UpdateBranchRecordBuffer" mylink="aarch64.debug.brbe.UpdateBranchRecordBuffer" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UpdateBranchRecordBuffer()
// ==========================
// Add a new Branch record to the buffer.

<anchor link="impl-aarch64.UpdateBranchRecordBuffer.10" hover="function: UpdateBranchRecordBuffer(bit ccu, bits(14) cc, bit lastfailed, bit transactional, bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid, bits(64) source_address, bits(64) target_address)">UpdateBranchRecordBuffer</anchor>(bit ccu, bits(14) cc, bit lastfailed, bit transactional,
                         bits(6) branch_type, bits(2) el, bit mispredict, bits(2) valid,
                         bits(64) source_address, bits(64) target_address)
    // Shift the Branch Records in the buffer
    for i = <a link="impl-aarch64.GetBRBENumRecords.0" file="shared_pseudocode.xml" hover="function: integer GetBRBENumRecords()">GetBRBENumRecords</a>() - 1 downto 1
        Records_SRC[i] = Records_SRC[i - 1];
        Records_TGT[i] = Records_TGT[i - 1];
        Records_INF[i] = Records_INF[i - 1];

    Records_INF[0].CCU        = ccu;
    Records_INF[0].CC         = cc;

    Records_INF[0].EL         = el;
    Records_INF[0].VALID      = valid;
    Records_INF[0].T          = transactional;
    Records_INF[0].LASTFAILED = lastfailed;
    Records_INF[0].MPRED      = mispredict;
    Records_INF[0].TYPE       = branch_type;

    Records_SRC[0] = source_address;
    Records_TGT[0] = target_address;

    return;</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/AArch64.BreakpointMatch" mylink="aarch64.debug.breakpoint.AArch64.BreakpointMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BreakpointMatch()
// =========================
// Breakpoint matching in an AArch64 translation regime.

boolean <anchor link="AArch64.BreakpointMatch.4" hover="function: boolean AArch64.BreakpointMatch(integer n, bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.BreakpointMatch</anchor>(integer n, bits(64) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                integer size)
    assert !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    assert n &lt; <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>();

    enabled = <a link="impl-aarch64.IsBreakpointEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsBreakpointEnabled(integer n)">IsBreakpointEnabled</a>(n);
    linked  = DBGBCR_EL1[n].BT IN {'0x01'};
    isbreakpnt = TRUE;
    linked_to  = FALSE;

    ssce = if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then DBGBCR_EL1[n].SSCE else '0';
    state_match = <a link="AArch64.StateMatch.8" file="shared_pseudocode.xml" hover="function: boolean AArch64.StateMatch(bits(2) ssc_in, bit ssce_in, bit hmc_in, bits(2) pxc_in, boolean linked_in, bits(4) lbn, boolean isbreakpnt, AccessDescriptor accdesc)">AArch64.StateMatch</a>(DBGBCR_EL1[n].SSC, ssce, DBGBCR_EL1[n].HMC, DBGBCR_EL1[n].PMC,
                                     linked, DBGBCR_EL1[n].LBN, isbreakpnt, accdesc);
    value_match = <a link="AArch64.BreakpointValueMatch.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.BreakpointValueMatch(integer n_in, bits(64) vaddress, boolean linked_to)">AArch64.BreakpointValueMatch</a>(n, vaddress, linked_to);

    if <a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() &amp;&amp; size == 4 then                    // Check second halfword
        // If the breakpoint address and BAS of an Address breakpoint match the address of the
        // second halfword of an instruction, but not the address of the first halfword, it is
        // CONSTRAINED UNPREDICTABLE whether or not this breakpoint generates a Breakpoint debug
        // event.
        match_i = <a link="AArch64.BreakpointValueMatch.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.BreakpointValueMatch(integer n_in, bits(64) vaddress, boolean linked_to)">AArch64.BreakpointValueMatch</a>(n, vaddress + 2, linked_to);
        if !value_match &amp;&amp; match_i then
            value_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMATCHHALF</a>);

    if vaddress&lt;1&gt; == '1' &amp;&amp; DBGBCR_EL1[n].BAS == '1111' then
        // The above notwithstanding, if DBGBCR_EL1[n].BAS == '1111', then it is CONSTRAINED
        // UNPREDICTABLE whether or not a Breakpoint debug event is generated for an instruction
        // at the address DBGBVR_EL1[n]+2.
        if value_match then value_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BPMATCHHALF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMATCHHALF</a>);

    match = value_match &amp;&amp; state_match &amp;&amp; enabled;

    return match;</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/AArch64.BreakpointValueMatch" mylink="aarch64.debug.breakpoint.AArch64.BreakpointValueMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BreakpointValueMatch()
// ==============================

boolean <anchor link="AArch64.BreakpointValueMatch.3" hover="function: boolean AArch64.BreakpointValueMatch(integer n_in, bits(64) vaddress, boolean linked_to)">AArch64.BreakpointValueMatch</anchor>(integer n_in, bits(64) vaddress, boolean linked_to)

    // "n" is the identity of the breakpoint unit to match against.
    // "vaddress" is the current instruction address, ignored if linked_to is TRUE and for Context
    //   matching breakpoints.
    // "linked_to" is TRUE if this is a call from StateMatch for linking.
    integer n = n_in;

    // If a non-existent breakpoint then it is CONSTRAINED UNPREDICTABLE whether this gives
    // no match or the breakpoint is mapped to another UNKNOWN implemented breakpoint.
    if n &gt;= <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() then
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, n) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(0, <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - 1,
                                               <a link="Unpredictable_BPNOTIMPL" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPNOTIMPL</a>);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then return FALSE;

    // If this breakpoint is not enabled, it cannot generate a match. (This could also happen on a
    // call from StateMatch for linking).
    if !<a link="impl-aarch64.IsBreakpointEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsBreakpointEnabled(integer n)">IsBreakpointEnabled</a>(n) then return FALSE;

    context_aware = <a link="impl-shared.IsContextMatchingBreakpoint.1" file="shared_pseudocode.xml" hover="function: boolean IsContextMatchingBreakpoint(integer n)">IsContextMatchingBreakpoint</a>(n);

    // If BT is set to a reserved type, behaves either as disabled or as a not-reserved type.
    dbgtype = DBGBCR_EL1[n].BT;

    if ((dbgtype IN {'011x','11xx'} &amp;&amp; !<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; !<a link="impl-shared.HaveV82Debug.0" file="shared_pseudocode.xml" hover="function: boolean HaveV82Debug()">HaveV82Debug</a>()) || // Context matching
          dbgtype IN {'010x'} ||                                                 // Reserved
          (!(dbgtype IN {'0x0x'}) &amp;&amp; !context_aware) ||                          // Context matching
          (dbgtype IN {'1xxx'} &amp;&amp; !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>))) then                            // EL2 extension
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, dbgtype) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESBPTYPE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESBPTYPE</a>, 4);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then return FALSE;
        // Otherwise the value returned by ConstrainUnpredictableBits must be a not-reserved value

    // Determine what to compare against.
    match_addr = (dbgtype IN {'0x0x'});
    match_vmid = (dbgtype IN {'10xx'});
    match_cid  = (dbgtype IN {'001x'});
    match_cid1 = (dbgtype IN {'101x', 'x11x'});
    match_cid2 = (dbgtype IN {'11xx'});
    linked     = (dbgtype IN {'xxx1'});

    // If this is a call from StateMatch, return FALSE if the breakpoint is not programmed for a
    // VMID and/or context ID match, of if not context-aware. The above assertions mean that the
    // code can just test for match_addr == TRUE to confirm all these things.
    if linked_to &amp;&amp; (!linked || match_addr) then return FALSE;

    // If called from BreakpointMatch return FALSE for Linked context ID and/or VMID matches.
    if !linked_to &amp;&amp; linked &amp;&amp; !match_addr then return FALSE;

    boolean bvr_match  = FALSE;
    boolean bxvr_match = FALSE;

    // Do the comparison.
    if match_addr then
        boolean byte_select_match;
        integer byte = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;1:0&gt;);

        if <a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() then
            // T32 instructions can be executed at EL0 in an AArch64 translation regime.
            assert byte IN {0,2};                 // "vaddress" is halfword aligned
            byte_select_match = (DBGBCR_EL1[n].BAS&lt;byte&gt; == '1');
        else
            assert byte == 0;                     // "vaddress" is word aligned
            byte_select_match = TRUE;             // DBGBCR_EL1[n].BAS&lt;byte&gt; is RES1

        // If the DBGBVR_EL1[n].RESS field bits are not a sign extension of the MSB
        // of DBGBVR_EL1[n].VA, it is UNPREDICTABLE whether they appear to be
        // included in the match.
        // If 'vaddress' is outside of the current virtual address space, then the access
        // generates a Translation fault.
        integer top = <a link="impl-aarch64.DebugAddrTop.0" file="shared_pseudocode.xml" hover="function: integer DebugAddrTop()">DebugAddrTop</a>();
        if !<a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(DBGBVR_EL1[n]&lt;63:top&gt;) &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(DBGBVR_EL1[n]&lt;63:top&gt;) then
            if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_DBGxVR_RESS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DBGxVR_RESS</a>) then
                top = 63;
        bvr_match = (vaddress&lt;top:2&gt; == DBGBVR_EL1[n]&lt;top:2&gt;) &amp;&amp; byte_select_match;

    elsif match_cid then
        if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            bvr_match = (CONTEXTIDR_EL2&lt;31:0&gt; == DBGBVR_EL1[n]&lt;31:0&gt;);
        else
            bvr_match = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; CONTEXTIDR_EL1&lt;31:0&gt; == DBGBVR_EL1[n]&lt;31:0&gt;);

    elsif match_cid1 then
        bvr_match = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp;
                     CONTEXTIDR_EL1&lt;31:0&gt; == DBGBVR_EL1[n]&lt;31:0&gt;);

    if match_vmid then
        bits(16) vmid;
        bits(16) bvr_vmid;

        if !<a link="impl-shared.Have16bitVMID.0" file="shared_pseudocode.xml" hover="function: boolean Have16bitVMID()">Have16bitVMID</a>() || VTCR_EL2.VS == '0' then
            vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR_EL2.VMID&lt;7:0&gt;, 16);
            bvr_vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(DBGBVR_EL1[n]&lt;39:32&gt;, 16);
        else
            vmid     = VTTBR_EL2.VMID;
            bvr_vmid = DBGBVR_EL1[n]&lt;47:32&gt;;

        bxvr_match = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; vmid == bvr_vmid);

    elsif match_cid2 then
        bxvr_match = (PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                      DBGBVR_EL1[n]&lt;63:32&gt; == CONTEXTIDR_EL2&lt;31:0&gt;);

    bvr_match_valid  = (match_addr || match_cid || match_cid1);
    bxvr_match_valid = (match_vmid || match_cid2);

    match = (!bxvr_match_valid || bxvr_match) &amp;&amp; (!bvr_match_valid || bvr_match);

    return match;</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/AArch64.StateMatch" mylink="aarch64.debug.breakpoint.AArch64.StateMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.StateMatch()
// ====================
// Determine whether a breakpoint or watchpoint is enabled in the current mode and state.

boolean <anchor link="AArch64.StateMatch.8" hover="function: boolean AArch64.StateMatch(bits(2) ssc_in, bit ssce_in, bit hmc_in, bits(2) pxc_in, boolean linked_in, bits(4) lbn, boolean isbreakpnt, AccessDescriptor accdesc)">AArch64.StateMatch</anchor>(bits(2) ssc_in, bit ssce_in, bit hmc_in,
                           bits(2) pxc_in, boolean linked_in, bits(4) lbn,
                           boolean isbreakpnt, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then assert ssce_in == '0';

    // "ssc_in","ssce_in","hmc_in","pxc_in" are the control fields from
    // the DBGBCR_EL1[n] or DBGWCR_EL1[n] register.
    // "linked_in" is TRUE if this is a linked breakpoint/watchpoint type.
    // "lbn" is the linked breakpoint number from the DBGBCR_EL1[n] or DBGWCR_EL1[n] register.
    // "isbreakpnt" is TRUE for breakpoints, FALSE for watchpoints.
    // "accdesc" describes the properties of the access being matched.
    bits(2) ssc = ssc_in;
    bit ssce    = ssce_in;
    bit hmc     = hmc_in;
    bits(2) pxc = pxc_in;
    boolean linked = linked_in;

    // If parameters are set to a reserved type, behaves as either disabled or a defined type
    <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
    (c, ssc, ssce, hmc, pxc) = <a link="impl-shared.CheckValidStateMatch.5" file="shared_pseudocode.xml" hover="function: (Constraint, bits(2), bit, bit, bits(2)) CheckValidStateMatch(bits(2) ssc_in, bit ssce_in, bit hmc_in, bits(2) pxc_in, boolean isbreakpnt)">CheckValidStateMatch</a>(ssc, ssce, hmc, pxc, isbreakpnt);
    if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then return FALSE;
    // Otherwise the hmc,ssc,ssce,pxc values are either valid or the values returned by
    // CheckValidStateMatch are valid.

    EL3_match = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; hmc == '1' &amp;&amp; ssc&lt;0&gt; == '0';
    EL2_match = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; ((hmc == '1' &amp;&amp; (ssc:pxc != '1000')) || ssc == '11');
    EL1_match = pxc&lt;0&gt; == '1';
    EL0_match = pxc&lt;1&gt; == '1';

    boolean priv_match;
    case accdesc.el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  priv_match = EL3_match;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  priv_match = EL2_match;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  priv_match = EL1_match;
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>  priv_match = EL0_match;

    // Security state match
    boolean ss_match;
    case ssce:ssc of
        when '000' ss_match = hmc == '1' || accdesc.ss != <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>;
        when '001' ss_match = accdesc.ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
        when '010' ss_match = (hmc == '1' &amp;&amp; accdesc.ss == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>) || accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
        when '011' ss_match = (hmc == '1' &amp;&amp; accdesc.ss != <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>) || accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
        when '101' ss_match = accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>;

    boolean linked_match = FALSE;

    if linked then
        // "lbn" must be an enabled context-aware breakpoint unit. If it is not context-aware then
        // it is CONSTRAINED UNPREDICTABLE whether this gives no match, gives a match without
        // linking, or lbn is mapped to some UNKNOWN breakpoint that is context-aware.
        integer linked_n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(lbn);

        if !<a link="impl-shared.IsContextMatchingBreakpoint.1" file="shared_pseudocode.xml" hover="function: boolean IsContextMatchingBreakpoint(integer n)">IsContextMatchingBreakpoint</a>(linked_n) then
            (first_ctx_cmp, last_ctx_cmp) = <a link="impl-shared.ContextMatchingBreakpointRange.0" file="shared_pseudocode.xml" hover="function: (integer, integer) ContextMatchingBreakpointRange()">ContextMatchingBreakpointRange</a>();
            (c, linked_n) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(first_ctx_cmp, last_ctx_cmp,
                                                         <a link="Unpredictable_BPNOTCTXCMP" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPNOTCTXCMP</a>);
            assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};

            case c of
                when <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>  return FALSE;      // Disabled
                when <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>      linked = FALSE;    // No linking
                // Otherwise ConstrainUnpredictableInteger returned a context-aware breakpoint

        vaddress  = bits(64) UNKNOWN;
        linked_to = TRUE;
        linked_match = <a link="AArch64.BreakpointValueMatch.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.BreakpointValueMatch(integer n_in, bits(64) vaddress, boolean linked_to)">AArch64.BreakpointValueMatch</a>(linked_n, vaddress, linked_to);

    return priv_match &amp;&amp; ss_match &amp;&amp; (!linked || linked_match);</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/DebugAddrTop" mylink="aarch64.debug.breakpoint.DebugAddrTop" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugAddrTop()
// ==============
// Returns the value for the top bit used in Breakpoint and Watchpoint address comparisons.

integer <anchor link="impl-aarch64.DebugAddrTop.0" hover="function: integer DebugAddrTop()">DebugAddrTop</anchor>()
    if <a link="impl-shared.Have56BitVAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitVAExt()">Have56BitVAExt</a>() then
        return 55;
    elsif <a link="impl-shared.Have52BitVAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitVAExt()">Have52BitVAExt</a>() then
        return 52;
    else
        return 48;</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/EffectiveMDSELR_EL1_BANK" mylink="aarch64.debug.breakpoint.EffectiveMDSELR_EL1_BANK" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveMDSELR_EL1_BANK()
// ==========================
// Return the effective value of MDSELR_EL1.BANK.

bits(2) <anchor link="impl-aarch64.EffectiveMDSELR_EL1_BANK.0" hover="function: bits(2) EffectiveMDSELR_EL1_BANK()">EffectiveMDSELR_EL1_BANK</anchor>()
    if !<a link="impl-aarch64.SelfHostedExtendedBPWPEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedExtendedBPWPEnabled()">SelfHostedExtendedBPWPEnabled</a>() then
        return '00';

    return MDSELR_EL1.BANK;</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/IsBreakpointEnabled" mylink="aarch64.debug.breakpoint.IsBreakpointEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsBreakpointEnabled()
// =====================
// Returns TRUE if the effective value of DBGBCR_EL1[n].E is '1', and FALSE otherwise.

boolean <anchor link="impl-aarch64.IsBreakpointEnabled.1" hover="function: boolean IsBreakpointEnabled(integer n)">IsBreakpointEnabled</anchor>(integer n)
    if (n &gt; 15 &amp;&amp;
            ((!<a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() &amp;&amp; !<a link="impl-aarch64.SelfHostedExtendedBPWPEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedExtendedBPWPEnabled()">SelfHostedExtendedBPWPEnabled</a>()) ||
            (<a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() &amp;&amp; EDSCR2.EBWE == '0'))) then
        return FALSE;

    return DBGBCR_EL1[n].E == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/breakpoint/SelfHostedExtendedBPWPEnabled" mylink="aarch64.debug.breakpoint.SelfHostedExtendedBPWPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SelfHostedExtendedBPWPEnabled()
// ===============================
// Returns TRUE if the extended breakpoints and watchpoints are enabled, and FALSE otherwise
// from a self-hosted Debug perspective.

boolean <anchor link="impl-aarch64.SelfHostedExtendedBPWPEnabled.0" hover="function: boolean SelfHostedExtendedBPWPEnabled()">SelfHostedExtendedBPWPEnabled</anchor>()
    if <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() &lt;= 16 &amp;&amp; <a link="impl-shared.NumWatchpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumWatchpointsImplemented()">NumWatchpointsImplemented</a>() &lt;= 16 then
        return FALSE;

    if ((<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; MDCR_EL3.EBWE == '0') ||
            (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; MDCR_EL2.EBWE == '0')) then
        return FALSE;

    return MDSCR_EL1.EBWE == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/enables/AArch64.GenerateDebugExceptions" mylink="aarch64.debug.enables.AArch64.GenerateDebugExceptions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GenerateDebugExceptions()
// =================================

boolean <anchor link="AArch64.GenerateDebugExceptions.0" hover="function: boolean AArch64.GenerateDebugExceptions()">AArch64.GenerateDebugExceptions</anchor>()
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    return <a link="AArch64.GenerateDebugExceptionsFrom.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state, bit mask)">AArch64.GenerateDebugExceptionsFrom</a>(PSTATE.EL, ss, PSTATE.D);</pstext>
    </ps>
    <ps name="aarch64/debug/enables/AArch64.GenerateDebugExceptionsFrom" mylink="aarch64.debug.enables.AArch64.GenerateDebugExceptionsFrom" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GenerateDebugExceptionsFrom()
// =====================================

boolean <anchor link="AArch64.GenerateDebugExceptionsFrom.3" hover="function: boolean AArch64.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state, bit mask)">AArch64.GenerateDebugExceptionsFrom</anchor>(bits(2) from_el, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> from_state, bit mask)

    if OSLSR_EL1.OSLK == '1' || <a link="impl-shared.DoubleLockStatus.0" file="shared_pseudocode.xml" hover="function: boolean DoubleLockStatus()">DoubleLockStatus</a>() || <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        return FALSE;

    route_to_el2 = (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (from_state != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> || <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>()) &amp;&amp;
                   (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1'));
    target = (if route_to_el2 then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    boolean enabled;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; from_state == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        enabled = MDCR_EL3.SDD == '0';
        if from_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
            enabled = enabled || SDER32_EL3.SUIDEN == '1';
    else
        enabled = TRUE;

    if from_el == target then
        enabled = enabled &amp;&amp; MDSCR_EL1.KDE == '1' &amp;&amp; mask == '0';
    else
        enabled = enabled &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(from_el);

    return enabled;</pstext>
    </ps>
    <ps name="aarch64/debug/ite/AArch64.TRCIT" mylink="aarch64.debug.ite.AArch64.TRCIT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TRCIT()
// ===============
// Determines whether an Instrumentation trace packet should
// be generated and then generates an instrumentation trace packet
// containing the value of the register passed as an argument

<anchor link="AArch64.TRCIT.1" hover="function: AArch64.TRCIT(bits(64) Xt)">AArch64.TRCIT</anchor>(bits(64) Xt)
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    if <a link="impl-shared.TraceInstrumentationAllowed.2" file="shared_pseudocode.xml" hover="function: boolean TraceInstrumentationAllowed(SecurityState ss, bits(2) el)">TraceInstrumentationAllowed</a>(ss, PSTATE.EL) then
        <a link="impl-aarch64.TraceInstrumentation.1" file="shared_pseudocode.xml" hover="function: TraceInstrumentation(bits(64) Xt)">TraceInstrumentation</a>(Xt);</pstext>
    </ps>
    <ps name="aarch64/debug/ite/TraceInstrumentation" mylink="aarch64.debug.ite.TraceInstrumentation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceInstrumentation()
// ======================
// Generates an instrumentation trace packet
// containing the value of the register passed as an argument

<anchor link="impl-aarch64.TraceInstrumentation.1" hover="function: TraceInstrumentation(bits(64) Xt)">TraceInstrumentation</anchor>(bits(64) Xt);</pstext>
    </ps>
    <ps name="aarch64/debug/pmu/AArch64.ClearEventCounters" mylink="aarch64.debug.pmu.AArch64.ClearEventCounters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ClearEventCounters()
// ============================
// Zero all the event counters.

<anchor link="AArch64.ClearEventCounters.0" hover="function: AArch64.ClearEventCounters()">AArch64.ClearEventCounters</anchor>()
    integer counters = <a link="AArch64.GetNumEventCountersAccessible.0" file="shared_pseudocode.xml" hover="function: integer AArch64.GetNumEventCountersAccessible()">AArch64.GetNumEventCountersAccessible</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            PMEVCNTR_EL0[idx] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);</pstext>
    </ps>
    <ps name="aarch64/debug/pmu/AArch64.GetNumEventCountersAccessible" mylink="aarch64.debug.pmu.AArch64.GetNumEventCountersAccessible" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GetNumEventCountersAccessible()
// =======================================
// Return the number of event counters that can be accessed at the current Exception level.

integer <anchor link="AArch64.GetNumEventCountersAccessible.0" hover="function: integer AArch64.GetNumEventCountersAccessible()">AArch64.GetNumEventCountersAccessible</anchor>()
    integer n;
    integer total_counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();
    // Software can reserve some counters for EL2
    if PSTATE.EL IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(MDCR_EL2.HPMN);
        if n &gt; total_counters || (!<a link="impl-shared.HaveFeatHPMN0.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatHPMN0()">HaveFeatHPMN0</a>() &amp;&amp; n == 0) then
            (-, n) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(0, total_counters,
                                                   <a link="Unpredictable_PMUEVENTCOUNTER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_PMUEVENTCOUNTER</a>);
    else
        n = total_counters;

    return n;</pstext>
    </ps>
    <ps name="aarch64/debug/pmu/AArch64.IncrementCycleCounter" mylink="aarch64.debug.pmu.AArch64.IncrementCycleCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IncrementCycleCounter()
// ===============================
// Increment the cycle counter and possibly set overflow bits.

<anchor link="AArch64.IncrementCycleCounter.0" hover="function: AArch64.IncrementCycleCounter()">AArch64.IncrementCycleCounter</anchor>()
    if (<a link="impl-shared.CountPMUEvents.1" file="shared_pseudocode.xml" hover="function: boolean CountPMUEvents(integer idx)">CountPMUEvents</a>(<a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>) &amp;&amp;
        (!<a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() || PMCR_EL0.LC == '1' || PMCR_EL0.D == '0' || <a link="impl-shared.HasElapsed64Cycles.0" file="shared_pseudocode.xml" hover="function: boolean HasElapsed64Cycles()">HasElapsed64Cycles</a>())) then
        integer old_value = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMCCNTR_EL0);
        integer new_value = old_value + 1;
        PMCCNTR_EL0 = new_value&lt;63:0&gt;;

        integer ovflw;
        if <a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() then
            ovflw = if PMCR_EL0.LC == '1' then 64 else 32;
        else
            ovflw = 64;

        if old_value&lt;64:ovflw&gt; != new_value&lt;64:ovflw&gt; then
            PMOVSSET_EL0.C = '1';
            PMOVSCLR_EL0.C = '1';</pstext>
    </ps>
    <ps name="aarch64/debug/pmu/AArch64.IncrementEventCounter" mylink="aarch64.debug.pmu.AArch64.IncrementEventCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IncrementEventCounter()
// ===============================
// Increment the specified event counter by the specified amount.

<anchor link="AArch64.IncrementEventCounter.2" hover="function: AArch64.IncrementEventCounter(integer idx, integer increment)">AArch64.IncrementEventCounter</anchor>(integer idx, integer increment)
    integer old_value;
    integer new_value;
    integer ovflw;
    bit lp;
    old_value = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMEVCNTR_EL0[idx]);
    new_value = old_value + <a link="impl-shared.PMUCountValue.2" file="shared_pseudocode.xml" hover="function: integer PMUCountValue(integer n, integer Vb)">PMUCountValue</a>(idx, increment);

    if <a link="impl-shared.HavePMUv3p5.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p5()">HavePMUv3p5</a>() then
        PMEVCNTR_EL0[idx] = new_value&lt;63:0&gt;;
        lp = if <a link="impl-shared.PMUCounterIsHyp.1" file="shared_pseudocode.xml" hover="function: boolean PMUCounterIsHyp(integer n)">PMUCounterIsHyp</a>(idx) then MDCR_EL2.HLP else PMCR_EL0.LP;
        ovflw = if lp == '1' then 64 else 32;
    else
        PMEVCNTR_EL0[idx] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(new_value&lt;31:0&gt;, 64);
        ovflw = 32;

    if old_value&lt;64:ovflw&gt; != new_value&lt;64:ovflw&gt; then
        PMOVSSET_EL0&lt;idx&gt; = '1';
        PMOVSCLR_EL0&lt;idx&gt; = '1';
        // Check for the CHAIN event from an even counter
        if idx&lt;0&gt; == '0' &amp;&amp; idx + 1 &lt; <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>() &amp;&amp; (!<a link="impl-shared.HavePMUv3p5.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p5()">HavePMUv3p5</a>() || lp == '0') then
            <a link="impl-shared.PMUEvent.3" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event, integer increment, integer idx)">PMUEvent</a>(PMU_EVENT_CHAIN, 1, idx + 1);</pstext>
    </ps>
    <ps name="aarch64/debug/pmu/AArch64.PMUCycle" mylink="aarch64.debug.pmu.AArch64.PMUCycle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PMUCycle()
// ==================
// Called at the end of each cycle to increment event counters and
// check for PMU overflow. In pseudocode, a cycle ends after the
// execution of the operational pseudocode.

<anchor link="AArch64.PMUCycle.0" hover="function: AArch64.PMUCycle()">AArch64.PMUCycle</anchor>()
    if !<a link="impl-shared.HavePMUv3.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3()">HavePMUv3</a>() then
        return;

    <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_CPU_CYCLES);

    integer counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            if <a link="impl-shared.CountPMUEvents.1" file="shared_pseudocode.xml" hover="function: boolean CountPMUEvents(integer idx)">CountPMUEvents</a>(idx) then
                integer accumulated = PMUEventAccumulator[idx];
                <a link="AArch64.IncrementEventCounter.2" file="shared_pseudocode.xml" hover="function: AArch64.IncrementEventCounter(integer idx, integer increment)">AArch64.IncrementEventCounter</a>(idx, accumulated);
            PMUEventAccumulator[idx] = 0;

    <a link="AArch64.IncrementCycleCounter.0" file="shared_pseudocode.xml" hover="function: AArch64.IncrementCycleCounter()">AArch64.IncrementCycleCounter</a>();
    <a link="impl-shared.CheckForPMUOverflow.0" file="shared_pseudocode.xml" hover="function: CheckForPMUOverflow()">CheckForPMUOverflow</a>();</pstext>
    </ps>
    <ps name="aarch64/debug/pmu/AArch64.PMUSwIncrement" mylink="aarch64.debug.pmu.AArch64.PMUSwIncrement" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PMUSwIncrement()
// ========================
// Generate PMU Events on a write to PMSWINC_EL0.

<anchor link="AArch64.PMUSwIncrement.1" hover="function: AArch64.PMUSwIncrement(bits(32) sw_incr)">AArch64.PMUSwIncrement</anchor>(bits(32) sw_incr)
    integer counters = <a link="AArch64.GetNumEventCountersAccessible.0" file="shared_pseudocode.xml" hover="function: integer AArch64.GetNumEventCountersAccessible()">AArch64.GetNumEventCountersAccessible</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            if sw_incr&lt;idx&gt; == '1' then
                <a link="impl-shared.PMUEvent.3" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event, integer increment, integer idx)">PMUEvent</a>(PMU_EVENT_SW_INCR, 1, idx);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/CollectContextIDR1" mylink="aarch64.debug.statisticalprofiling.CollectContextIDR1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CollectContextIDR1()
// ====================

boolean <anchor link="impl-aarch64.CollectContextIDR1.0" hover="function: boolean CollectContextIDR1()">CollectContextIDR1</anchor>()
    if !<a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() then return FALSE;
    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then return FALSE;
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then return FALSE;
    return PMSCR_EL1.CX == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/CollectContextIDR2" mylink="aarch64.debug.statisticalprofiling.CollectContextIDR2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CollectContextIDR2()
// ====================

boolean <anchor link="impl-aarch64.CollectContextIDR2.0" hover="function: boolean CollectContextIDR2()">CollectContextIDR2</anchor>()
    if !<a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() then return FALSE;
    if !<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then return FALSE;
    return PMSCR_EL2.CX == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/CollectPhysicalAddress" mylink="aarch64.debug.statisticalprofiling.CollectPhysicalAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CollectPhysicalAddress()
// ========================

boolean <anchor link="impl-aarch64.CollectPhysicalAddress.0" hover="function: boolean CollectPhysicalAddress()">CollectPhysicalAddress</anchor>()
    if !<a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() then return FALSE;
    (owning_ss, owning_el) = <a link="impl-aarch64.ProfilingBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) ProfilingBufferOwner()">ProfilingBufferOwner</a>();
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (owning_ss != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> || <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>()) then
        return PMSCR_EL2.PA == '1' &amp;&amp; (owning_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || PMSCR_EL1.PA == '1');
    else
        return PMSCR_EL1.PA == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/CollectTimeStamp" mylink="aarch64.debug.statisticalprofiling.CollectTimeStamp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CollectTimeStamp()
// ==================

TimeStamp <anchor link="impl-aarch64.CollectTimeStamp.0" hover="function: TimeStamp CollectTimeStamp()">CollectTimeStamp</anchor>()
    if !<a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() then return <a link="TimeStamp_None" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_None</a>;
    (-, owning_el) = <a link="impl-aarch64.ProfilingBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) ProfilingBufferOwner()">ProfilingBufferOwner</a>();

    if owning_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        if PMSCR_EL2.TS == '0' then return <a link="TimeStamp_None" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_None</a>;
    else
        if PMSCR_EL1.TS == '0' then return <a link="TimeStamp_None" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_None</a>;

    bits(2) PCT_el1;
    if !<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() then
        PCT_el1 = '0':PMSCR_EL1.PCT&lt;0&gt;;       // PCT&lt;1&gt; is RES0
    else
        PCT_el1 = PMSCR_EL1.PCT;
        if PCT_el1 == '10' then
            // Reserved value
            (-, PCT_el1) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_PMSCR_PCT" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_PMSCR_PCT</a>, 2);
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        bits(2) PCT_el2;
        if !<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() then
            PCT_el2 = '0':PMSCR_EL2.PCT&lt;0&gt;;   // PCT&lt;1&gt; is RES0
        else
            PCT_el2 = PMSCR_EL2.PCT;
            if PCT_el2 == '10' then
                // Reserved value
                (-, PCT_el2) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_PMSCR_PCT" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_PMSCR_PCT</a>, 2);
        case PCT_el2 of
            when '00'
                return if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a> else <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
            when '01'
                if owning_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then return <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>;
            when '11'
                assert <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>();          // FEAT_ECV must be implemented
                if owning_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; PCT_el1 == '00' then
                    return if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a> else <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
                else
                    return <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>;
            otherwise
                <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    case PCT_el1 of
        when '00' return if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a> else <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
        when '01' return <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>;
        when '11'
            assert <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>();              // FEAT_ECV must be implemented
            return <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/OpType" mylink="aarch64.debug.statisticalprofiling.OpType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// OpType
// ======
// Types of operation filtered by SPECollectRecord().

enumeration <anchor link="OpType" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType</anchor> {
    <anchor link="OpType_Load" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Load</anchor>,        // Any memory-read operation other than atomics, compare-and-swap, and swap
    <anchor link="OpType_Store" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</anchor>,       // Any memory-write operation, including atomics without return
    <anchor link="OpType_LoadAtomic" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_LoadAtomic</anchor>,  // Atomics with return, compare-and-swap and swap
    <anchor link="OpType_Branch" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Branch</anchor>,      // Software write to the PC
    <anchor link="OpType_Other" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Other</anchor>        // Any other class of operation
};</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/ProfilingBufferEnabled" mylink="aarch64.debug.statisticalprofiling.ProfilingBufferEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ProfilingBufferEnabled()
// ========================

boolean <anchor link="impl-aarch64.ProfilingBufferEnabled.0" hover="function: boolean ProfilingBufferEnabled()">ProfilingBufferEnabled</anchor>()
    if !<a link="impl-shared.HaveStatisticalProfiling.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfiling()">HaveStatisticalProfiling</a>() then return FALSE;
    (owning_ss, owning_el) = <a link="impl-aarch64.ProfilingBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) ProfilingBufferOwner()">ProfilingBufferOwner</a>();
    bits(2) state_bits;
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        state_bits = SCR_EL3.NSE : <a link="impl-shared.EffectiveSCR_EL3_NS.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</a>();
    else
        state_bits = '0' : SCR_EL3.NS;

    boolean state_match;
    case owning_ss of
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    state_match = state_bits == '00';
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> state_match = state_bits == '01';
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     state_match = state_bits == '11';
    return (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(owning_el) &amp;&amp; state_match &amp;&amp;
            PMBLIMITR_EL1.E == '1' &amp;&amp; PMBSR_EL1.S == '0');</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/ProfilingBufferOwner" mylink="aarch64.debug.statisticalprofiling.ProfilingBufferOwner" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ProfilingBufferOwner()
// ======================

(SecurityState, bits(2)) <anchor link="impl-aarch64.ProfilingBufferOwner.0" hover="function: (SecurityState, bits(2)) ProfilingBufferOwner()">ProfilingBufferOwner</anchor>()
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> owning_ss;

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        bits(3) state_bits;
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
            state_bits = MDCR_EL3.&lt;NSPBE,NSPB&gt;;
            if (state_bits IN {'10x'} ||
                (!<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; state_bits IN {'00x'})) then
                // Reserved value
                (-, state_bits) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESERVEDNSxB" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESERVEDNSxB</a>, 3);
        else
            state_bits = '0' : MDCR_EL3.NSPB;

        case state_bits of
            when '00x' owning_ss = <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
            when '01x' owning_ss = <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
            when '11x' owning_ss = <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>;
    else
        owning_ss = if <a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>() then <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> else <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;

    bits(2) owning_el;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (owning_ss != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> || <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>()) then
        owning_el = if MDCR_EL2.E2PB == '00' then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    else
        owning_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    return (owning_ss, owning_el);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/ProfilingSynchronizationBarrier" mylink="aarch64.debug.statisticalprofiling.ProfilingSynchronizationBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ProfilingSynchronizationBarrier()
// =================================
// Barrier to ensure that all existing profiling data has been formatted, and profiling buffer
// addresses have been translated such that writes to the profiling buffer have been initiated.
// A following DSB completes when writes to the profiling buffer have completed.

<anchor link="impl-aarch64.ProfilingSynchronizationBarrier.0" hover="function: ProfilingSynchronizationBarrier()">ProfilingSynchronizationBarrier</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEAddByteToRecord" mylink="aarch64.debug.statisticalprofiling.SPEAddByteToRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEAddByteToRecord()
// ====================
// Add one byte to a record and increase size property appropriately.

<anchor link="impl-aarch64.SPEAddByteToRecord.1" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</anchor>(bits(8) b)
    assert SPERecordSize &lt; <a link="SPEMaxRecordSize" file="shared_pseudocode.xml" hover="constant integer SPEMaxRecordSize = 64">SPEMaxRecordSize</a>;
    SPERecordData[SPERecordSize] = b;
    SPERecordSize = SPERecordSize + 1;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEAddPacketToRecord" mylink="aarch64.debug.statisticalprofiling.SPEAddPacketToRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEAddPacketToRecord()
// ======================
// Add passed header and payload data to the record.
// Payload must be a multiple of 8.

<anchor link="impl-aarch64.SPEAddPacketToRecord.3" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</anchor>(bits(2) header_hi, bits(4) header_lo,
                        bits(N) payload)
    assert N MOD 8 == 0;
    bits(2) sz;
    case N of
        when 8 sz = '00';
        when 16 sz = '01';
        when 32 sz = '10';
        when 64 sz = '11';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    bits(8) header = header_hi:sz:header_lo;
    <a link="impl-aarch64.SPEAddByteToRecord.1" file="shared_pseudocode.xml" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</a>(header);
    for i = 0 to (N DIV 8)-1
        <a link="impl-aarch64.SPEAddByteToRecord.1" file="shared_pseudocode.xml" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</a>(payload&lt;i*8+7:i*8&gt;);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEBranch" mylink="aarch64.debug.statisticalprofiling.SPEBranch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEBranch()
// ===========
// Called on every branch if SPE is present. Maintains previous branch target
// and branch related SPE functionality.

<anchor link="impl-aarch64.SPEBranch.4" hover="function: SPEBranch(bits(N) target, BranchType branch_type, boolean conditional, boolean taken_flag)">SPEBranch</anchor>(bits(N) target, <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type, boolean conditional, boolean taken_flag)
    boolean is_isb = FALSE;
    <a link="impl-aarch64.SPEBranch.5" file="shared_pseudocode.xml" hover="function: SPEBranch(bits(N) target, BranchType branch_type, boolean conditional, boolean taken_flag, boolean is_isb)">SPEBranch</a>(target, branch_type, conditional, taken_flag, is_isb);

<anchor link="impl-aarch64.SPEBranch.5" hover="function: SPEBranch(bits(N) target, BranchType branch_type, boolean conditional, boolean taken_flag, boolean is_isb)">SPEBranch</anchor>(bits(N) target, <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type, boolean conditional, boolean taken_flag,
          boolean is_isb)
    // If the PE implements branch prediction, data about (mis)prediction is collected
    // through the PMU events.

    boolean collect_prev_br;
    boolean collect_prev_br_eret = boolean IMPLEMENTATION_DEFINED "SPE prev br on eret";
    boolean collect_prev_br_exception = boolean IMPLEMENTATION_DEFINED "SPE prev br on exception";
    boolean collect_prev_br_isb = boolean IMPLEMENTATION_DEFINED "SPE prev br on isb";
    case branch_type of
        when <a link="BranchType_EXCEPTION" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_EXCEPTION</a>
            collect_prev_br = collect_prev_br_exception;
        when <a link="BranchType_ERET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_ERET</a>
            collect_prev_br = collect_prev_br_eret;
        otherwise
            collect_prev_br = !is_isb || collect_prev_br_isb;

    // Implements previous branch target functionality
    if (taken_flag &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSIDR_EL1.PBT) &amp;&amp; <a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() &amp;&amp;
            collect_prev_br) then

        if SPESampleInFlight then
            // Save the target address for it to be added to record.
            bits(64) previous_target = SPESamplePreviousBranchAddress;
            SPESampleAddress[<a link="SPEAddrPosPrevBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosPrevBranchTarget = 4">SPEAddrPosPrevBranchTarget</a>]&lt;63:0&gt; = previous_target&lt;63:0&gt;;
            boolean previous_branch_valid = SPESamplePreviousBranchAddressValid;
            SPESampleAddressValid[<a link="SPEAddrPosPrevBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosPrevBranchTarget = 4">SPEAddrPosPrevBranchTarget</a>] = previous_branch_valid;
        SPESamplePreviousBranchAddress&lt;55:0&gt; = target&lt;55:0&gt;;

        bit ns;
        bit nse;
        case <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() of
            when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
                ns = '0';
                nse = '0';
            when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
                ns = '1';
                nse = '0';
            when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
                ns = '1';
                nse = '1';
            otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

        SPESamplePreviousBranchAddress&lt;63&gt; = ns;
        SPESamplePreviousBranchAddress&lt;60&gt; = nse;
        SPESamplePreviousBranchAddress&lt;62:61&gt; = PSTATE.EL;
        SPESamplePreviousBranchAddressValid = TRUE;

    if !<a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() then
        if taken_flag then
            // Invalidate previous branch address, if profiling is disabled
            // or prohibited.
            SPESamplePreviousBranchAddressValid = FALSE;
        return;

    if SPESampleInFlight then
        is_direct = branch_type IN {<a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>, <a link="BranchType_DIRCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIRCALL</a>};
        SPESampleClass = '10';
        SPESampleSubclass&lt;1&gt; = if is_direct then '0' else '1';
        SPESampleSubclass&lt;0&gt; = if conditional then '1' else '0';
        SPESampleOpType = <a link="OpType_Branch" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Branch</a>;

        // Save the target address.
        if taken_flag then
            SPESampleAddress[<a link="SPEAddrPosBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosBranchTarget = 1">SPEAddrPosBranchTarget</a>]&lt;55:0&gt; = target&lt;55:0&gt;;

            bit ns;
            bit nse;
            case <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() of
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
                    ns = '0';
                    nse = '0';
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
                    ns = '1';
                    nse = '0';
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
                    ns = '1';
                    nse = '1';
                otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

            SPESampleAddress[<a link="SPEAddrPosBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosBranchTarget = 1">SPEAddrPosBranchTarget</a>]&lt;63&gt; = ns;
            SPESampleAddress[<a link="SPEAddrPosBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosBranchTarget = 1">SPEAddrPosBranchTarget</a>]&lt;60&gt; = nse;
            SPESampleAddress[<a link="SPEAddrPosBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosBranchTarget = 1">SPEAddrPosBranchTarget</a>]&lt;62:61&gt; = PSTATE.EL;
            SPESampleAddressValid[<a link="SPEAddrPosBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosBranchTarget = 1">SPEAddrPosBranchTarget</a>] = TRUE;

        SPESampleEvents&lt;6&gt; = if !taken_flag then '1' else '0';</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEBufferFilled" mylink="aarch64.debug.statisticalprofiling.SPEBufferFilled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEBufferFilled()
// =================
// Deal with a full buffer event.

<anchor link="impl-aarch64.SPEBufferFilled.0" hover="function: SPEBufferFilled()">SPEBufferFilled</anchor>()
    if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMBSR_EL1.S) then
        PMBSR_EL1.S = '1';                          // Assert PMBIRQ
        PMBSR_EL1.EC = '000000';                    // Other buffer management event
        PMBSR_EL1.MSS = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>('000001', 16);   // Set buffer full event

    <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_WRAP);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEBufferIsFull" mylink="aarch64.debug.statisticalprofiling.SPEBufferIsFull" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEBufferIsFull()
// =================
// Return true if another full size sample record would not fit in the
// profiling buffer.

boolean <anchor link="impl-aarch64.SPEBufferIsFull.0" hover="function: boolean SPEBufferIsFull()">SPEBufferIsFull</anchor>()
    integer write_pointer_limit = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMBLIMITR_EL1.LIMIT:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12));
    integer current_write_pointer = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMBPTR_EL1);
    integer record_max_size = 1&lt;&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMSIDR_EL1.MaxSize);
    return current_write_pointer &gt; (write_pointer_limit - record_max_size);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPECollectRecord" mylink="aarch64.debug.statisticalprofiling.SPECollectRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPECollectRecord()
// ==================
// Returns TRUE if the sampled class of instructions or operations, as
// determined by PMSFCR_EL1, are recorded and FALSE otherwise.

boolean <anchor link="impl-aarch64.SPECollectRecord.3" hover="function: boolean SPECollectRecord(bits(64) events, integer total_latency, OpType optype)">SPECollectRecord</anchor>(bits(64) events, integer total_latency, <a link="OpType" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType</a> optype)
    assert <a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>();

    bits(64) mask = 0xAA&lt;63:0&gt;;                             // Bits [7,5,3,1]
    bits(64) e;
    bits(64) m;
    if <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() then mask&lt;18:17&gt; = '11';                   // Predicate flags
    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then mask&lt;16&gt; = '1';
    if <a link="impl-shared.HaveStatisticalProfilingv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p1()">HaveStatisticalProfilingv1p1</a>() then mask&lt;11&gt; = '1';  // Alignment Flag
    if <a link="impl-shared.HaveStatisticalProfilingv1p2.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p2()">HaveStatisticalProfilingv1p2</a>() then mask&lt;6&gt; = '1';   // Not taken flag
    if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
        mask&lt;10:8,4,2&gt; = '11111';
    else
        bits(5) impdef_mask;
        impdef_mask = bits(5) IMPLEMENTATION_DEFINED "SPE mask 10:8,4,2";
        mask&lt;10:8,4,2&gt; = impdef_mask;

    mask&lt;63:48&gt; = bits(16) IMPLEMENTATION_DEFINED "SPE mask 63:48";
    mask&lt;31:24&gt; = bits(8) IMPLEMENTATION_DEFINED "SPE mask 31:24";
    mask&lt;15:12&gt; = bits(4) IMPLEMENTATION_DEFINED "SPE mask 15:12";

    e = events AND mask;
    boolean is_rejected_nevent = FALSE;
    boolean is_nevt;
    // Filtering by inverse event
    if <a link="impl-shared.HaveStatisticalProfilingv1p2.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p2()">HaveStatisticalProfilingv1p2</a>() then
        m = PMSNEVFR_EL1 AND mask;
        is_nevt = <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(e AND m);
        if PMSFCR_EL1.FnE == '1' then
            // Inverse filtering by event is enabled
            if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(m) then
                // Not UNPREDICTABLE case
                is_rejected_nevent = !is_nevt;
            else
                is_rejected_nevent = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BADPMSFCR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</a>);
    else
        is_nevt = TRUE; // not implemented

    boolean is_rejected_event = FALSE;

    // Filtering by event
    m = PMSEVFR_EL1 AND mask;
    boolean is_evt = <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(NOT(e) AND m);
    if PMSFCR_EL1.FE == '1' then
        // Filtering by event is enabled
        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(m) then
            // Not UNPREDICTABLE case
            is_rejected_event = !is_evt;
        else
            is_rejected_event = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BADPMSFCR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</a>);

    if (<a link="impl-shared.HaveStatisticalProfilingv1p2.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p2()">HaveStatisticalProfilingv1p2</a>() &amp;&amp; PMSFCR_EL1.&lt;FnE,FE&gt; == '11' &amp;&amp;
            !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSEVFR_EL1 AND PMSNEVFR_EL1 AND mask)) then
        // UNPREDICTABLE case due to combination of filter and inverse filter
        is_rejected_nevent = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BADPMSFCR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</a>);
        is_rejected_event = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BADPMSFCR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</a>);

    if is_evt &amp;&amp; is_nevt then
        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED_EVENT);

    boolean is_op_br = FALSE;
    boolean is_op_ld = FALSE;
    boolean is_op_st = FALSE;

    is_op_br = (optype == <a link="OpType_Branch" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Branch</a>);
    is_op_ld = (optype IN {<a link="OpType_Load" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Load</a>, <a link="OpType_LoadAtomic" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_LoadAtomic</a>});
    is_op_st = (optype IN {<a link="OpType_Store" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</a>, <a link="OpType_LoadAtomic" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_LoadAtomic</a>});

    if is_op_br then <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED_BR);
    if is_op_ld then <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED_LD);
    if is_op_st then <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED_ST);

    boolean is_op = ((is_op_br &amp;&amp; PMSFCR_EL1.B == '1') ||
                    (is_op_ld &amp;&amp; PMSFCR_EL1.LD == '1') ||
                    (is_op_st &amp;&amp; PMSFCR_EL1.ST == '1'));

    if is_op then <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED_OP);

    // Filter by type
    boolean is_rejected_type = FALSE;
    if PMSFCR_EL1.FT == '1' then
        // Filtering by type is enabled
        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSFCR_EL1.&lt;B, LD, ST&gt;) then
            // Not an UNPREDICTABLE case
            is_rejected_type = !is_op;
        else
            is_rejected_type = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BADPMSFCR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</a>);

    // Filter by latency
    boolean is_rejected_latency = FALSE;
    boolean is_lat = (total_latency &lt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMSLATFR_EL1.MINLAT));
    if is_lat then <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED_LAT);

    if PMSFCR_EL1.FL == '1' then
        // Filtering by latency is enabled
        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSLATFR_EL1.MINLAT) then
            // Not an UNPREDICTABLE case
            is_rejected_latency = !is_lat;
        else
            is_rejected_latency = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_BADPMSFCR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</a>);

    boolean is_rejected_data_source;
    // Filtering by Data Source
    if (<a link="impl-shared.HaveStatisticalProfilingFDS.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingFDS()">HaveStatisticalProfilingFDS</a>() &amp;&amp; PMSFCR_EL1.FDS == '1' &amp;&amp;
            is_op_ld &amp;&amp; SPESampleDataSourceValid) then
        bits(16) data_source = SPESampleDataSource;
        integer index = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(data_source&lt;5:0&gt;);
        is_rejected_data_source = PMSDSFR_EL1&lt;index&gt; == '0';
    else
        is_rejected_data_source = FALSE;

    boolean return_value;
    return_value = !(is_rejected_nevent || is_rejected_event ||
                     is_rejected_type || is_rejected_latency);

    if return_value then
        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FILTRATE);
    return return_value;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEConstructRecord" mylink="aarch64.debug.statisticalprofiling.SPEConstructRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEConstructRecord()
// ====================
// Create new record and populate it with packets using sample storage data.
// This is an example implementation, packets may appear in
// any order as long as the record ends with an End or Timestamp packet.

<anchor link="impl-aarch64.SPEConstructRecord.0" hover="function: SPEConstructRecord()">SPEConstructRecord</anchor>()
    integer payload_size;

    // Empty the record.
    <a link="impl-aarch64.SPEEmptyRecord.0" file="shared_pseudocode.xml" hover="function: SPEEmptyRecord()">SPEEmptyRecord</a>();

    // Add contextEL1 if available
    if SPESampleContextEL1Valid then
        <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('01', '0100', SPESampleContextEL1);

     // Add contextEL2 if available
    if SPESampleContextEL2Valid then
        <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('01', '0101', SPESampleContextEL2);

    // Add valid counters
    for counter_index = 0 to (<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a> - 1)
        if SPESampleCounterValid[counter_index] then
            if counter_index &gt;= 8 then
                // Need extended format
                <a link="impl-aarch64.SPEAddByteToRecord.1" file="shared_pseudocode.xml" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</a>('001000':counter_index&lt;4:3&gt;);
            // Check for overflow
            boolean large_counters = boolean IMPLEMENTATION_DEFINED "SPE 16bit counters";
            if SPESampleCounter[counter_index] &gt; 0xFFFF &amp;&amp; large_counters then
                SPESampleCounter[counter_index] = 0xFFFF;
            elsif SPESampleCounter[counter_index] &gt; 0xFFF then
                SPESampleCounter[counter_index] = 0xFFF;

            // Add byte0 for short format (byte1 for extended format)
            <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('10', '1':counter_index&lt;2:0&gt;,
                SPESampleCounter[counter_index]&lt;15:0&gt;);

    // Add valid addresses
    if <a link="impl-shared.HaveStatisticalProfilingv1p2.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p2()">HaveStatisticalProfilingv1p2</a>() then
        // Under the some conditions, it is IMPLEMENTATION_DEFINED whether
        // previous branch packet is present.
        boolean include_prev_br = boolean IMPLEMENTATION_DEFINED "SPE get prev br if not br";
        if SPESampleOpType != <a link="OpType_Branch" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Branch</a> &amp;&amp; !include_prev_br then
            SPESampleAddressValid[<a link="SPEAddrPosPrevBranchTarget" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosPrevBranchTarget = 4">SPEAddrPosPrevBranchTarget</a>] = FALSE;

    // Data Virtual address should not be collected if this was an NV2 access and Statistical
    // Profiling is disabled at EL2.
    if !<a link="impl-aarch64.StatisticalProfilingEnabled.1" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled(bits(2) el)">StatisticalProfilingEnabled</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; SPESampleInstIsNV2 then
        SPESampleAddressValid[<a link="SPEAddrPosDataVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataVirtual = 2">SPEAddrPosDataVirtual</a>] = FALSE;

    for address_index = 0 to (<a link="SPEMaxAddrs" file="shared_pseudocode.xml" hover="constant integer SPEMaxAddrs = 32">SPEMaxAddrs</a> - 1)
        if SPESampleAddressValid[address_index] then
            if address_index &gt;= 8 then
                // Need extended format
                <a link="impl-aarch64.SPEAddByteToRecord.1" file="shared_pseudocode.xml" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</a>('001000':address_index&lt;4:3&gt;);
            // Add byte0 for short format (byte1 for extended format)
            <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('10', '0':address_index&lt;2:0&gt;,
                SPESampleAddress[address_index]);

    // Add Data Source
    if SPESampleDataSourceValid then
        payload_size = <a link="impl-aarch64.SPEGetDataSourcePayloadSize.0" file="shared_pseudocode.xml" hover="function: integer SPEGetDataSourcePayloadSize()">SPEGetDataSourcePayloadSize</a>();
        <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('01', '0011', SPESampleDataSource&lt;8*payload_size-1:0&gt;);

    // Add operation details
    <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('01', '10':SPESampleClass, SPESampleSubclass);

    // Add events
    // Get size of payload in bytes.
    payload_size = <a link="impl-aarch64.SPEGetEventsPayloadSize.0" file="shared_pseudocode.xml" hover="function: integer SPEGetEventsPayloadSize()">SPEGetEventsPayloadSize</a>();
    <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('01', '0010', SPESampleEvents&lt;8*payload_size-1:0&gt;);

    // Add Timestamp to end the record if one is available.
    // Otherwise end with an End packet.
    if SPESampleTimestampValid then
        <a link="impl-aarch64.SPEAddPacketToRecord.3" file="shared_pseudocode.xml" hover="function: SPEAddPacketToRecord(bits(2) header_hi, bits(4) header_lo, bits(N) payload)">SPEAddPacketToRecord</a>('01', '0001', SPESampleTimestamp);
    else
        <a link="impl-aarch64.SPEAddByteToRecord.1" file="shared_pseudocode.xml" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</a>('00000001');

    // Add padding
    while SPERecordSize MOD (1&lt;&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMBIDR_EL1.Align)) != 0 do
        <a link="impl-aarch64.SPEAddByteToRecord.1" file="shared_pseudocode.xml" hover="function: SPEAddByteToRecord(bits(8) b)">SPEAddByteToRecord</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8));
    <a link="impl-aarch64.SPEWriteToBuffer.0" file="shared_pseudocode.xml" hover="function: SPEWriteToBuffer()">SPEWriteToBuffer</a>();</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPECycle" mylink="aarch64.debug.statisticalprofiling.SPECycle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPECycle()
// ==========
// Function called at the end of every cycle. Responsible for asserting interrupts
// and advancing counters.

<anchor link="impl-aarch64.SPECycle.0" hover="function: SPECycle()">SPECycle</anchor>()
    if !<a link="impl-shared.HaveStatisticalProfiling.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfiling()">HaveStatisticalProfiling</a>() then
        return;

    // Increment pending counters
    if SPESampleInFlight then
        for i = 0 to (<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a> - 1)
            if SPESampleCounterPending[i] then
                SPESampleCounter[i] = SPESampleCounter[i] + 1;

    // Assert PMBIRQ if appropriate.
    SetInterruptRequestLevel(<a link="InterruptID_PMBIRQ" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_PMBIRQ</a>, if PMBSR_EL1.S == '1' then HIGH else LOW);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEEmptyRecord" mylink="aarch64.debug.statisticalprofiling.SPEEmptyRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEEmptyRecord()
// ================
// Reset record data.

<anchor link="impl-aarch64.SPEEmptyRecord.0" hover="function: SPEEmptyRecord()">SPEEmptyRecord</anchor>()
    SPERecordSize = 0;
    for i = 0 to (<a link="SPEMaxRecordSize" file="shared_pseudocode.xml" hover="constant integer SPEMaxRecordSize = 64">SPEMaxRecordSize</a> - 1)
        SPERecordData[i] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEEvent" mylink="aarch64.debug.statisticalprofiling.SPEEvent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEEvent()
// ==========
// Called by PMUEvent if a sample is in flight.
// Sets appropriate bit in SPESampleStorage.events.

<anchor link="impl-aarch64.SPEEvent.1" hover="function: SPEEvent(bits(16) event)">SPEEvent</anchor>(bits(16) event)
    case event of
        when PMU_EVENT_DSNP_HIT_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;23&gt; = '1';
        when PMU_EVENT_L1D_LFB_HIT_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;22&gt; = '1';
        when PMU_EVENT_L2D_LFB_HIT_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;22&gt; = '1';
        when PMU_EVENT_L3D_LFB_HIT_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;22&gt; = '1';
        when PMU_EVENT_LL_LFB_HIT_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;22&gt; = '1';
        when PMU_EVENT_L1D_CACHE_HITM_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;21&gt; = '1';
        when PMU_EVENT_L2D_CACHE_HITM_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;21&gt; = '1';
        when PMU_EVENT_L3D_CACHE_HITM_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;21&gt; = '1';
        when PMU_EVENT_LL_CACHE_HITM_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;21&gt; = '1';
        when PMU_EVENT_L2D_CACHE_LMISS_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;20&gt; = '1';
        when PMU_EVENT_L2D_CACHE_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;19&gt; = '1';
        when PMU_EVENT_SVE_PRED_EMPTY_SPEC
            if <a link="impl-shared.HaveStatisticalProfilingv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p1()">HaveStatisticalProfilingv1p1</a>() then
                SPESampleEvents&lt;18&gt; = '1';
        when PMU_EVENT_SVE_PRED_PARTIAL_SPEC
            if <a link="impl-shared.HaveStatisticalProfilingv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p1()">HaveStatisticalProfilingv1p1</a>() then
                SPESampleEvents&lt;17&gt; = '1';
        when PMU_EVENT_LDST_ALIGN_LAT
            if <a link="impl-shared.HaveStatisticalProfilingv1p1.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p1()">HaveStatisticalProfilingv1p1</a>() then
                SPESampleEvents&lt;11&gt; = '1';
        when PMU_EVENT_REMOTE_ACCESS         SPESampleEvents&lt;10&gt;  = '1';
        when PMU_EVENT_LL_CACHE_MISS         SPESampleEvents&lt;9&gt;   = '1';
        when PMU_EVENT_LL_CACHE              SPESampleEvents&lt;8&gt;   = '1';
        when PMU_EVENT_BR_MIS_PRED           SPESampleEvents&lt;7&gt;   = '1';
        when PMU_EVENT_BR_MIS_PRED_RETIRED   SPESampleEvents&lt;7&gt;   = '1';
        when PMU_EVENT_DTLB_WALK             SPESampleEvents&lt;5&gt;   = '1';
        when PMU_EVENT_L1D_TLB               SPESampleEvents&lt;4&gt;   = '1';
        when PMU_EVENT_L1D_CACHE_REFILL
            if !<a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;3&gt; = '1';
        when PMU_EVENT_L1D_CACHE_LMISS_RD
            if <a link="impl-shared.HaveStatisticalProfilingv1p4.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</a>() then
                SPESampleEvents&lt;3&gt; = '1';
        when PMU_EVENT_L1D_CACHE             SPESampleEvents&lt;2&gt;   = '1';
        when PMU_EVENT_INST_RETIRED          SPESampleEvents&lt;1&gt;   = '1';
        when PMU_EVENT_EXC_TAKEN             SPESampleEvents&lt;0&gt;   = '1';
        otherwise return;
    return;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEGetDataSourcePayloadSize" mylink="aarch64.debug.statisticalprofiling.SPEGetDataSourcePayloadSize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEGetDataSourcePayloadSize()
// =============================
// Returns the size of the Data Source payload in bytes.

integer <anchor link="impl-aarch64.SPEGetDataSourcePayloadSize.0" hover="function: integer SPEGetDataSourcePayloadSize()">SPEGetDataSourcePayloadSize</anchor>()
    return integer IMPLEMENTATION_DEFINED "SPE Data Source packet payload size";</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEGetEventsPayloadSize" mylink="aarch64.debug.statisticalprofiling.SPEGetEventsPayloadSize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEGetEventsPayloadSize()
// =========================
// Returns the size in bytes of the Events packet payload as an integer.

integer <anchor link="impl-aarch64.SPEGetEventsPayloadSize.0" hover="function: integer SPEGetEventsPayloadSize()">SPEGetEventsPayloadSize</anchor>()
    integer size = integer IMPLEMENTATION_DEFINED "SPE Events packet payload size";
    return size;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEGetRandomBoolean" mylink="aarch64.debug.statisticalprofiling.SPEGetRandomBoolean" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEGetRandomBoolean()
// =====================
// Returns a random or pseudo-random boolean value.

boolean <anchor link="impl-aarch64.SPEGetRandomBoolean.0" hover="function: boolean SPEGetRandomBoolean()">SPEGetRandomBoolean</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEGetRandomInterval" mylink="aarch64.debug.statisticalprofiling.SPEGetRandomInterval" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEGetRandomInterval()
// ======================
// Returns a random or pseudo-random byte for resetting COUNT or ECOUNT.

bits(8) <anchor link="impl-aarch64.SPEGetRandomInterval.0" hover="function: bits(8) SPEGetRandomInterval()">SPEGetRandomInterval</anchor>();</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEISB" mylink="aarch64.debug.statisticalprofiling.SPEISB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEISB()
// ========
// Called by ISB instruction, correctly calls SPEBranch to save previous branches.

<anchor link="impl-aarch64.SPEISB.0" hover="function: SPEISB()">SPEISB</anchor>()
    bits(64) address = <a link="impl-aarch64.PC.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) PC[]">PC</a>[] + 4;
    <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type = <a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>;
    boolean branch_conditional = FALSE;
    boolean taken = FALSE;
    boolean is_isb = TRUE;

    <a link="impl-aarch64.SPEBranch.5" file="shared_pseudocode.xml" hover="function: SPEBranch(bits(N) target, BranchType branch_type, boolean conditional, boolean taken_flag, boolean is_isb)">SPEBranch</a>(address, branch_type, branch_conditional, taken, is_isb);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEMaxAddrs" mylink="aarch64.debug.statisticalprofiling.SPEMaxAddrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="SPEMaxAddrs" hover="constant integer SPEMaxAddrs = 32">SPEMaxAddrs</anchor> = 32;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEMaxCounters" mylink="aarch64.debug.statisticalprofiling.SPEMaxCounters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="SPEMaxCounters" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</anchor> = 32;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEMaxRecordSize" mylink="aarch64.debug.statisticalprofiling.SPEMaxRecordSize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="SPEMaxRecordSize" hover="constant integer SPEMaxRecordSize = 64">SPEMaxRecordSize</anchor> = 64;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEPostExecution" mylink="aarch64.debug.statisticalprofiling.SPEPostExecution" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="SPEAddrPosPCVirtual" hover="constant integer SPEAddrPosPCVirtual = 0">SPEAddrPosPCVirtual</anchor> = 0;
constant integer <anchor link="SPEAddrPosBranchTarget" hover="constant integer SPEAddrPosBranchTarget = 1">SPEAddrPosBranchTarget</anchor> = 1;
constant integer <anchor link="SPEAddrPosDataVirtual" hover="constant integer SPEAddrPosDataVirtual = 2">SPEAddrPosDataVirtual</anchor> = 2;
constant integer <anchor link="SPEAddrPosDataPhysical" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</anchor> = 3;
constant integer <anchor link="SPEAddrPosPrevBranchTarget" hover="constant integer SPEAddrPosPrevBranchTarget = 4">SPEAddrPosPrevBranchTarget</anchor> = 4;
constant integer <anchor link="SPECounterPosTotalLatency" hover="constant integer SPECounterPosTotalLatency = 0">SPECounterPosTotalLatency</anchor> = 0;
constant integer <anchor link="SPECounterPosIssueLatency" hover="constant integer SPECounterPosIssueLatency = 1">SPECounterPosIssueLatency</anchor> = 1;
constant integer <anchor link="SPECounterPosTranslationLatency" hover="constant integer SPECounterPosTranslationLatency = 2">SPECounterPosTranslationLatency</anchor> = 2;
boolean SPESampleInFlight = FALSE;
bits(32) SPESampleContextEL1;
boolean SPESampleContextEL1Valid;
bits(32) SPESampleContextEL2;
boolean SPESampleContextEL2Valid;
boolean SPESampleInstIsNV2 = FALSE;
bits(64) SPESamplePreviousBranchAddress;
boolean SPESamplePreviousBranchAddressValid;
bits(16) SPESampleDataSource;
boolean SPESampleDataSourceValid;
<a link="OpType" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType</a> SPESampleOpType;
bits(2) SPESampleClass;
bits(8) SPESampleSubclass;
boolean SPESampleSubclassValid;
bits(64) SPESampleTimestamp;
boolean SPESampleTimestampValid;
bits(64) SPESampleEvents;

// SPEPostExecution()
// ==================
// Called after every executed instruction.

<anchor link="impl-aarch64.SPEPostExecution.0" hover="function: SPEPostExecution()">SPEPostExecution</anchor>()
    if SPESampleInFlight then
        SPESampleInFlight = FALSE;
        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_FEED);

        // Stop any pending counters
        for counter_index = 0 to (<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a> - 1)
            if SPESampleCounterPending[counter_index] then
                <a link="impl-aarch64.SPEStopCounter.1" file="shared_pseudocode.xml" hover="function: SPEStopCounter(integer counter_index)">SPEStopCounter</a>(counter_index);

        boolean discard = FALSE;
        if <a link="impl-shared.HaveStatisticalProfilingv1p2.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfilingv1p2()">HaveStatisticalProfilingv1p2</a>() then
            discard = PMBLIMITR_EL1.FM == '10';
        if <a link="impl-aarch64.SPECollectRecord.3" file="shared_pseudocode.xml" hover="function: boolean SPECollectRecord(bits(64) events, integer total_latency, OpType optype)">SPECollectRecord</a>(SPESampleEvents,
                            SPESampleCounter[<a link="SPECounterPosTotalLatency" file="shared_pseudocode.xml" hover="constant integer SPECounterPosTotalLatency = 0">SPECounterPosTotalLatency</a>],
                            SPESampleOpType) &amp;&amp; !discard then
            <a link="impl-aarch64.SPEConstructRecord.0" file="shared_pseudocode.xml" hover="function: SPEConstructRecord()">SPEConstructRecord</a>();
            if <a link="impl-aarch64.SPEBufferIsFull.0" file="shared_pseudocode.xml" hover="function: boolean SPEBufferIsFull()">SPEBufferIsFull</a>() then
                <a link="impl-aarch64.SPEBufferFilled.0" file="shared_pseudocode.xml" hover="function: SPEBufferFilled()">SPEBufferFilled</a>();

        <a link="impl-aarch64.SPEResetSampleStorage.0" file="shared_pseudocode.xml" hover="function: SPEResetSampleStorage()">SPEResetSampleStorage</a>();

// Counter storage
array [0..<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a>-1] of integer SPESampleCounter;

array [0..<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a>-1] of boolean SPESampleCounterValid;

array [0..<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a>-1] of boolean SPESampleCounterPending;

// Address storage
array [0..<a link="SPEMaxAddrs" file="shared_pseudocode.xml" hover="constant integer SPEMaxAddrs = 32">SPEMaxAddrs</a>-1] of bits(64) SPESampleAddress;

array [0..<a link="SPEMaxAddrs" file="shared_pseudocode.xml" hover="constant integer SPEMaxAddrs = 32">SPEMaxAddrs</a>-1] of boolean SPESampleAddressValid;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEPreExecution" mylink="aarch64.debug.statisticalprofiling.SPEPreExecution" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEPreExecution()
// =================
// Called prior to execution, for all instructions.

<anchor link="impl-aarch64.SPEPreExecution.0" hover="function: SPEPreExecution()">SPEPreExecution</anchor>()
    if <a link="impl-aarch64.StatisticalProfilingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</a>() then
        <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_POP);
        if <a link="impl-aarch64.SPEToCollectSample.0" file="shared_pseudocode.xml" hover="function: boolean SPEToCollectSample()">SPEToCollectSample</a>() then
            if !SPESampleInFlight then
                SPESampleInFlight = TRUE;

                // Start total latency and issue latency counters for SPE
                <a link="impl-aarch64.SPEStartCounter.1" file="shared_pseudocode.xml" hover="function: SPEStartCounter(integer counter_index)">SPEStartCounter</a>(<a link="SPECounterPosTotalLatency" file="shared_pseudocode.xml" hover="constant integer SPECounterPosTotalLatency = 0">SPECounterPosTotalLatency</a>);
                <a link="impl-aarch64.SPEStartCounter.1" file="shared_pseudocode.xml" hover="function: SPEStartCounter(integer counter_index)">SPEStartCounter</a>(<a link="SPECounterPosIssueLatency" file="shared_pseudocode.xml" hover="constant integer SPECounterPosIssueLatency = 1">SPECounterPosIssueLatency</a>);

                <a link="impl-aarch64.SPESampleAddContext.0" file="shared_pseudocode.xml" hover="function: SPESampleAddContext()">SPESampleAddContext</a>();

                <a link="impl-aarch64.SPESampleAddAddressPCVirtual.0" file="shared_pseudocode.xml" hover="function: SPESampleAddAddressPCVirtual()">SPESampleAddAddressPCVirtual</a>();

                // Timestamp may be collected at any point in the sampling operation.
                // Collecting prior to execution is one possible choice.
                // This choice is IMPLEMENTATION_DEFINED.
                <a link="impl-aarch64.SPESampleAddTimeStamp.0" file="shared_pseudocode.xml" hover="function: SPESampleAddTimeStamp()">SPESampleAddTimeStamp</a>();
            else
                <a link="impl-shared.PMUEvent.1" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event)">PMUEvent</a>(PMU_EVENT_SAMPLE_COLLISION);
                PMBSR_EL1.COLL = '1';

            // Many operations are type other and not conditional, can save footprint
            // and overhead by having this as the default and not calling SPESampleAddOpOther
            // if conditional == FALSE
            <a link="impl-aarch64.SPESampleAddOpOther.1" file="shared_pseudocode.xml" hover="function: SPESampleAddOpOther(boolean conditional)">SPESampleAddOpOther</a>(FALSE);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEResetSampleCounter" mylink="aarch64.debug.statisticalprofiling.SPEResetSampleCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEResetSampleCounter()
// =======================
// Reset PMSICR_EL1.Counter

<anchor link="impl-aarch64.SPEResetSampleCounter.0" hover="function: SPEResetSampleCounter()">SPEResetSampleCounter</anchor>()
    PMSICR_EL1.COUNT&lt;31:8&gt; = PMSIRR_EL1.INTERVAL;
    if PMSIRR_EL1.RND == '1' &amp;&amp; PMSIDR_EL1.ERnd == '0' then
        PMSICR_EL1.COUNT&lt;7:0&gt; = <a link="impl-aarch64.SPEGetRandomInterval.0" file="shared_pseudocode.xml" hover="function: bits(8) SPEGetRandomInterval()">SPEGetRandomInterval</a>();
    else
        PMSICR_EL1.COUNT&lt;7:0&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEResetSampleStorage" mylink="aarch64.debug.statisticalprofiling.SPEResetSampleStorage" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">integer SPERecordSize;

// SPEResetSampleStorage()
// =======================
// Reset all variables inside sample storage.

<anchor link="impl-aarch64.SPEResetSampleStorage.0" hover="function: SPEResetSampleStorage()">SPEResetSampleStorage</anchor>()
    // Context values
    SPESampleContextEL1 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
    SPESampleContextEL1Valid = FALSE;
    SPESampleContextEL2 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
    SPESampleContextEL2Valid = FALSE;

    // Counter values
    for i = 0 to (<a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a> - 1)
        SPESampleCounter[i] = 0;
        SPESampleCounterValid[i] = FALSE;
        SPESampleCounterPending[i] = FALSE;

    // Address values
    for i = 0 to (<a link="SPEMaxAddrs" file="shared_pseudocode.xml" hover="constant integer SPEMaxAddrs = 32">SPEMaxAddrs</a> - 1)
        SPESampleAddressValid[i] = FALSE;
        SPESampleAddress[i] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

    // Data source values
    SPESampleDataSource = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    SPESampleDataSourceValid = FALSE;

    // Operation values
    SPESampleClass = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(2);
    SPESampleSubclass = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
    SPESampleSubclassValid = FALSE;

    // Timestamp values
    SPESampleTimestamp = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    SPESampleTimestampValid = FALSE;

    // Event values
    SPESampleEvents&lt;63:48&gt; = bits(16) IMPLEMENTATION_DEFINED "SPE EVENTS 63_48";
    SPESampleEvents&lt;47:32&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    SPESampleEvents&lt;31:24&gt; = bits(8) IMPLEMENTATION_DEFINED "SPE EVENTS 31_24";
    SPESampleEvents&lt;23:16&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
    SPESampleEvents&lt;15:12&gt; = bits(4) IMPLEMENTATION_DEFINED "SPE EVENTS 15_12";
    SPESampleEvents&lt;11:0&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12);

    SPESampleInstIsNV2 = FALSE;

array [0..<a link="SPEMaxRecordSize" file="shared_pseudocode.xml" hover="constant integer SPEMaxRecordSize = 64">SPEMaxRecordSize</a>-1] of bits(8) SPERecordData;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleAddAddressPCVirtual" mylink="aarch64.debug.statisticalprofiling.SPESampleAddAddressPCVirtual" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleAddAddressPCVirtual()
// ==============================
// Save the current PC address to sample storage.

<anchor link="impl-aarch64.SPESampleAddAddressPCVirtual.0" hover="function: SPESampleAddAddressPCVirtual()">SPESampleAddAddressPCVirtual</anchor>()
    bits(64) this_address = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    SPESampleAddress[<a link="SPEAddrPosPCVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosPCVirtual = 0">SPEAddrPosPCVirtual</a>]&lt;55:0&gt; = this_address&lt;55:0&gt;;

    bit ns;
    bit nse;
    case <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() of
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            ns = '0';
            nse = '0';
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            ns = '1';
            nse = '0';
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            ns = '1';
            nse = '1';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    bits(2) el = PSTATE.EL;
    SPESampleAddress[<a link="SPEAddrPosPCVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosPCVirtual = 0">SPEAddrPosPCVirtual</a>]&lt;63:56&gt; = ns:el:nse:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(4);
    SPESampleAddressValid[<a link="SPEAddrPosPCVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosPCVirtual = 0">SPEAddrPosPCVirtual</a>] = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleAddContext" mylink="aarch64.debug.statisticalprofiling.SPESampleAddContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleAddContext()
// =====================
// Save contexts to sample storage if appropriate.

<anchor link="impl-aarch64.SPESampleAddContext.0" hover="function: SPESampleAddContext()">SPESampleAddContext</anchor>()
    if <a link="impl-aarch64.CollectContextIDR1.0" file="shared_pseudocode.xml" hover="function: boolean CollectContextIDR1()">CollectContextIDR1</a>() then
        SPESampleContextEL1 = CONTEXTIDR_EL1&lt;31:0&gt;;
        SPESampleContextEL1Valid = TRUE;
    if <a link="impl-aarch64.CollectContextIDR2.0" file="shared_pseudocode.xml" hover="function: boolean CollectContextIDR2()">CollectContextIDR2</a>() then
        SPESampleContextEL2 = CONTEXTIDR_EL2&lt;31:0&gt;;
        SPESampleContextEL2Valid = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleAddOpOther" mylink="aarch64.debug.statisticalprofiling.SPESampleAddOpOther" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleAddOpOther()
// =====================
// Add other operation to sample storage.

<anchor link="impl-aarch64.SPESampleAddOpOther.2" hover="function: SPESampleAddOpOther(boolean conditional, boolean taken)">SPESampleAddOpOther</anchor>(boolean conditional, boolean taken)
    SPESampleEvents&lt;6&gt; = if conditional &amp;&amp; !taken then '1' else '0';
    <a link="impl-aarch64.SPESampleAddOpOther.1" file="shared_pseudocode.xml" hover="function: SPESampleAddOpOther(boolean conditional)">SPESampleAddOpOther</a>(conditional);

<anchor link="impl-aarch64.SPESampleAddOpOther.1" hover="function: SPESampleAddOpOther(boolean conditional)">SPESampleAddOpOther</anchor>(boolean conditional)
    SPESampleClass = '00';
    SPESampleSubclass&lt;0&gt; = if conditional then '1' else '0';
    SPESampleOpType = <a link="OpType_Other" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Other</a>;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleAddOpSVELoadStore" mylink="aarch64.debug.statisticalprofiling.SPESampleAddOpSVELoadStore" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleAddOpSVELoadStore()
// ============================
// Sets the subclass of the operation type packet to Load/Store for SVE operations.

<anchor link="impl-aarch64.SPESampleAddOpSVELoadStore.4" hover="function: SPESampleAddOpSVELoadStore(boolean is_gather_scatter, bits(3) evl, boolean predicated, boolean is_load)">SPESampleAddOpSVELoadStore</anchor>(boolean is_gather_scatter, bits(3) evl, boolean predicated,
                           boolean is_load)
    bit sg = if is_gather_scatter then '1' else '0';
    bit pred = if predicated then '1' else '0';
    bit ldst = if is_load then '0' else '1';
    SPESampleClass = '01';
    SPESampleSubclass&lt;7:0&gt; = sg:evl:'1':pred:'0':ldst;
    SPESampleSubclassValid = TRUE;
    SPESampleOpType = if is_load then <a link="OpType_Load" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Load</a> else <a link="OpType_Store" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</a>;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleAddOpSVEOther" mylink="aarch64.debug.statisticalprofiling.SPESampleAddOpSVEOther" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleAddOpSVEOther()
// ========================
// Sets the subclass of the operation type packet to Other for SVE operations.

<anchor link="impl-aarch64.SPESampleAddOpSVEOther.3" hover="function: SPESampleAddOpSVEOther(bits(3) evl, boolean predicated, boolean floating_point)">SPESampleAddOpSVEOther</anchor>(bits(3) evl, boolean predicated, boolean floating_point)
    bit pred = if predicated then '1' else '0';
    bit fp = if floating_point then '1' else '0';
    SPESampleClass = '00';
    SPESampleSubclass&lt;7:0&gt; = '0':evl:'1':pred:fp:'0';
    SPESampleSubclassValid = TRUE;
    SPESampleOpType = <a link="OpType_Other" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Other</a>;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleAddTimeStamp" mylink="aarch64.debug.statisticalprofiling.SPESampleAddTimeStamp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleAddTimeStamp()
// =======================
// Save the appropriate type of timestamp to sample storage.

<anchor link="impl-aarch64.SPESampleAddTimeStamp.0" hover="function: SPESampleAddTimeStamp()">SPESampleAddTimeStamp</anchor>()
    <a link="TimeStamp" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp</a> timestamp = <a link="impl-aarch64.CollectTimeStamp.0" file="shared_pseudocode.xml" hover="function: TimeStamp CollectTimeStamp()">CollectTimeStamp</a>();
    case timestamp of
        when <a link="TimeStamp_None" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_None</a>
            SPESampleTimestampValid = FALSE;
        otherwise
            SPESampleTimestampValid = TRUE;
            SPESampleTimestamp = <a link="impl-shared.GetTimestamp.1" file="shared_pseudocode.xml" hover="function: bits(64) GetTimestamp(TimeStamp timeStampType)">GetTimestamp</a>(timestamp);</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleExtendedLoadStore" mylink="aarch64.debug.statisticalprofiling.SPESampleExtendedLoadStore" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleExtendedLoadStore()
// ============================
// Sets the subclass of the operation type packet for
// extended load/store operations.

<anchor link="impl-aarch64.SPESampleExtendedLoadStore.4" hover="function: SPESampleExtendedLoadStore(bit ar, bit excl, bit at, boolean is_load)">SPESampleExtendedLoadStore</anchor>(bit ar, bit excl, bit at, boolean is_load)
    SPESampleClass = '01';
    bit ldst = if is_load then '0' else '1';
    SPESampleSubclass = '000':ar:excl:at:'1':ldst;

    SPESampleSubclassValid = TRUE;

    if is_load then
        if at == '1' then
            SPESampleOpType = <a link="OpType_LoadAtomic" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_LoadAtomic</a>;
        else
            SPESampleOpType = <a link="OpType_Load" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Load</a>;
    else
        SPESampleOpType = <a link="OpType_Store" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</a>;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleGeneralPurposeLoadStore" mylink="aarch64.debug.statisticalprofiling.SPESampleGeneralPurposeLoadStore" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleGeneralPurposeLoadStore()
// ==================================
// Sets the subclass of the operation type packet for general
// purpose load/store operations.

<anchor link="impl-aarch64.SPESampleGeneralPurposeLoadStore.0" hover="function: SPESampleGeneralPurposeLoadStore()">SPESampleGeneralPurposeLoadStore</anchor>()
    SPESampleClass = '01';

    SPESampleSubclass&lt;7:1&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(7);
    SPESampleSubclassValid = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleLoadStore" mylink="aarch64.debug.statisticalprofiling.SPESampleLoadStore" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleLoadStore()
// ====================
// Called if a sample is in flight when writing or reading memory,
// indicating that the operation being sampled is in the Load, Store or atomic category.

<anchor link="impl-aarch64.SPESampleLoadStore.3" hover="function: SPESampleLoadStore(boolean is_load, AccessDescriptor accdesc, AddressDescriptor addrdesc)">SPESampleLoadStore</anchor>(boolean is_load, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc)
    // Check if this access type should be sampled.
    if accdesc.acctype IN {<a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>,
                           <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>,
                           <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>,
                           <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>,
                           <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
        return;

    // MOPS instructions indicate which operation should be sampled before the
    // operation is executed. Has the instruction indicated that the load should be sampled?
    boolean sample_loads;
    sample_loads = SPESampleSubclass&lt;0&gt; == '0' &amp;&amp; SPESampleSubclassValid;

    // Has the instruction indicated that the store should be sampled?
    boolean sample_stores;
    sample_stores = SPESampleSubclass&lt;0&gt; == '1' &amp;&amp; SPESampleSubclassValid;

    // No valid data has been collected, or this is operation has specifically been selected for
    // sampling.
    if (!SPESampleSubclassValid || (sample_loads &amp;&amp; is_load) ||
            (sample_stores &amp;&amp; !is_load)) then
        // Data access virtual address
        <a link="impl-aarch64.SPESetDataVirtualAddress.1" file="shared_pseudocode.xml" hover="function: SPESetDataVirtualAddress(bits(64) vaddress)">SPESetDataVirtualAddress</a>(addrdesc.vaddress);

        // Data access physical address
        if <a link="impl-aarch64.CollectPhysicalAddress.0" file="shared_pseudocode.xml" hover="function: boolean CollectPhysicalAddress()">CollectPhysicalAddress</a>() then
            <a link="impl-aarch64.SPESetDataPhysicalAddress.2" file="shared_pseudocode.xml" hover="function: SPESetDataPhysicalAddress(AddressDescriptor addrdesc, AccessDescriptor accdesc)">SPESetDataPhysicalAddress</a>(addrdesc, accdesc);

    if !SPESampleSubclassValid then
        // Set as unspecified load/store by default, instructions will overwrite this if it does not
        // apply to them.
        SPESampleClass = '01';
        SPESampleSubclassValid = TRUE;
        SPESampleSubclass&lt;7:1&gt; = '0001000';
        SPESampleSubclass&lt;0&gt; = if is_load then '0' else '1';
        SPESampleOpType = if is_load then <a link="OpType_Load" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Load</a> else <a link="OpType_Store" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</a>;

        if accdesc.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
            // NV2 register load/store
            SPESampleSubclass&lt;7:1&gt; = '0011000';
            SPESampleInstIsNV2 = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleMemCopy" mylink="aarch64.debug.statisticalprofiling.SPESampleMemCopy" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleMemCopy()
// ==================
// Sets the subclass of the operation type packet for Memory Copy load/store
// operations.

<anchor link="impl-aarch64.SPESampleMemCopy.0" hover="function: SPESampleMemCopy()">SPESampleMemCopy</anchor>()
    // MemCopy does a read and a write. If one is filtered out, the other should be recorded.
    // If neither or both are filtered out, pick one in a (pseudo)random way.

    // Are loads allowed by filter?
    boolean loads_pass_filter = PMSFCR_EL1.FT == '1' &amp;&amp; PMSFCR_EL1.LD == '1';
    // Are stores allowed by filter?
    boolean stores_pass_filter = PMSFCR_EL1.FT == '1' &amp;&amp; PMSFCR_EL1.ST == '1';

    boolean record_load;
    if loads_pass_filter &amp;&amp; !stores_pass_filter then
        // Only loads pass filter
        record_load = TRUE;
    elsif !loads_pass_filter &amp;&amp; stores_pass_filter then
        // Only stores pass filter
        record_load = FALSE;
    else
        // Pick randomly between
        record_load = <a link="impl-aarch64.SPEGetRandomBoolean.0" file="shared_pseudocode.xml" hover="function: boolean SPEGetRandomBoolean()">SPEGetRandomBoolean</a>();

    SPESampleClass = '01';
    bit ldst = if record_load then '0' else '1';
    SPESampleSubclass&lt;7:0&gt; = '0010000':ldst;
    SPESampleSubclassValid = TRUE;
    SPESampleOpType = if record_load then <a link="OpType_Load" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Load</a> else <a link="OpType_Store" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</a>;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleMemSet" mylink="aarch64.debug.statisticalprofiling.SPESampleMemSet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleMemSet()
// =================
// Sets the subclass of the operation type packet for Memory Set load/store
// operation.

<anchor link="impl-aarch64.SPESampleMemSet.0" hover="function: SPESampleMemSet()">SPESampleMemSet</anchor>()
    SPESampleClass = '01';
    SPESampleSubclass&lt;7:0&gt; = '00100101';
    SPESampleSubclassValid = TRUE;
    SPESampleOpType = <a link="OpType_Store" file="shared_pseudocode.xml" hover="enumeration OpType { OpType_Load, OpType_Store, OpType_LoadAtomic, OpType_Branch, OpType_Other }">OpType_Store</a>;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESampleSIMDFPLoadStore" mylink="aarch64.debug.statisticalprofiling.SPESampleSIMDFPLoadStore" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESampleSIMDFPLoadStore()
// ==========================
// Sets the subclass of the operation type packet for SIMD &amp; FP
// load store operations.

<anchor link="impl-aarch64.SPESampleSIMDFPLoadStore.0" hover="function: SPESampleSIMDFPLoadStore()">SPESampleSIMDFPLoadStore</anchor>()
    SPESampleClass = '01';

    SPESampleSubclass&lt;7:1&gt; = '0000010';
    SPESampleSubclassValid = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESetDataPhysicalAddress" mylink="aarch64.debug.statisticalprofiling.SPESetDataPhysicalAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESetDataPhysicalAddress()
// ===========================
// Called from SampleLoadStore() to save data physical packet.

<anchor link="impl-aarch64.SPESetDataPhysicalAddress.2" hover="function: SPESetDataPhysicalAddress(AddressDescriptor addrdesc, AccessDescriptor accdesc)">SPESetDataPhysicalAddress</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bit ns;
    bit nse;
    case addrdesc.paddress.paspace of
        when <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>
            ns = '0';
            nse = '0';
        when <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>
            ns = '1';
            nse = '0';
        when <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>
            ns  = '1';
            nse = '1';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then
        bits(4) pat;
        if accdesc.tagchecked then
            SPESampleAddress[<a link="SPEAddrPosDataPhysical" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</a>]&lt;62&gt; = '1'; // CH
            pat = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(addrdesc.vaddress);
        else
            // CH is reset to 0 on each new packet
            // If the access is Unchecked, this is an IMPLEMENTATION_DEFINED choice
            // between 0b0000 and the Physical Address Tag
            boolean zero_unchecked;
            zero_unchecked = boolean IMPLEMENTATION_DEFINED "SPE PAT for tag unchecked access zero";
            if !zero_unchecked then
                pat = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(addrdesc.vaddress);
            else
                pat = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(4);
        SPESampleAddress[<a link="SPEAddrPosDataPhysical" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</a>]&lt;59:56&gt; = pat;

    bits(56) paddr = addrdesc.paddress.address;
    SPESampleAddress[<a link="SPEAddrPosDataPhysical" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</a>]&lt;56-1:0&gt; = paddr;
    SPESampleAddress[<a link="SPEAddrPosDataPhysical" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</a>]&lt;63&gt; = ns;
    SPESampleAddress[<a link="SPEAddrPosDataPhysical" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</a>]&lt;60&gt; = nse;
    SPESampleAddressValid[<a link="SPEAddrPosDataPhysical" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataPhysical = 3">SPEAddrPosDataPhysical</a>] = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPESetDataVirtualAddress" mylink="aarch64.debug.statisticalprofiling.SPESetDataVirtualAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPESetDataVirtualAddress()
// ==========================
// Called from SampleLoadStore() to save data virtual packet.
// Also used by exclusive load/stores to save virtual addresses if exclusive monitor is lost
// before a read/write is completed.

<anchor link="impl-aarch64.SPESetDataVirtualAddress.1" hover="function: SPESetDataVirtualAddress(bits(64) vaddress)">SPESetDataVirtualAddress</anchor>(bits(64) vaddress)
    bit tbi;
    tbi = <a link="impl-shared.EffectiveTBI.3" file="shared_pseudocode.xml" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</a>(vaddress, FALSE, PSTATE.EL);
    boolean non_tbi_is_zeros;
    non_tbi_is_zeros = boolean IMPLEMENTATION_DEFINED "SPE non-tbi tag is zero";
    if tbi == '1' || !non_tbi_is_zeros then
        SPESampleAddress[<a link="SPEAddrPosDataVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataVirtual = 2">SPEAddrPosDataVirtual</a>]&lt;63:0&gt; = vaddress&lt;63:0&gt;;
    else
        SPESampleAddress[<a link="SPEAddrPosDataVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataVirtual = 2">SPEAddrPosDataVirtual</a>]&lt;63:56&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
        SPESampleAddress[<a link="SPEAddrPosDataVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataVirtual = 2">SPEAddrPosDataVirtual</a>]&lt;55:0&gt; = vaddress&lt;55:0&gt;;
    SPESampleAddressValid[<a link="SPEAddrPosDataVirtual" file="shared_pseudocode.xml" hover="constant integer SPEAddrPosDataVirtual = 2">SPEAddrPosDataVirtual</a>] = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEStartCounter" mylink="aarch64.debug.statisticalprofiling.SPEStartCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEStartCounter()
// =================
// Enables incrementing of the counter at the passed index when SPECycle is called.

<anchor link="impl-aarch64.SPEStartCounter.1" hover="function: SPEStartCounter(integer counter_index)">SPEStartCounter</anchor>(integer counter_index)
    assert counter_index &lt; <a link="SPEMaxCounters" file="shared_pseudocode.xml" hover="constant integer SPEMaxCounters = 32">SPEMaxCounters</a>;
    SPESampleCounterPending[counter_index] = TRUE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEStopCounter" mylink="aarch64.debug.statisticalprofiling.SPEStopCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEStopCounter()
// ================
// Disables incrementing of the counter at the passed index when SPECycle is called.

<anchor link="impl-aarch64.SPEStopCounter.1" hover="function: SPEStopCounter(integer counter_index)">SPEStopCounter</anchor>(integer counter_index)
    SPESampleCounterValid[counter_index] = TRUE;
    SPESampleCounterPending[counter_index] = FALSE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEToCollectSample" mylink="aarch64.debug.statisticalprofiling.SPEToCollectSample" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEToCollectSample()
// ====================
// Returns TRUE if the instruction which is about to be executed should be
// sampled. Returns FALSE otherwise.

boolean <anchor link="impl-aarch64.SPEToCollectSample.0" hover="function: boolean SPEToCollectSample()">SPEToCollectSample</anchor>()
    if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSICR_EL1.COUNT) then
        <a link="impl-aarch64.SPEResetSampleCounter.0" file="shared_pseudocode.xml" hover="function: SPEResetSampleCounter()">SPEResetSampleCounter</a>();
    else
        PMSICR_EL1.COUNT = PMSICR_EL1.COUNT - 1;
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSICR_EL1.COUNT) then
            if PMSIRR_EL1.RND == '1' &amp;&amp; PMSIDR_EL1.ERnd == '1' then
                PMSICR_EL1.ECOUNT = <a link="impl-aarch64.SPEGetRandomInterval.0" file="shared_pseudocode.xml" hover="function: bits(8) SPEGetRandomInterval()">SPEGetRandomInterval</a>();
            else
                return TRUE;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMSICR_EL1.ECOUNT) != 0 then
        PMSICR_EL1.ECOUNT = PMSICR_EL1.ECOUNT - 1;
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMSICR_EL1.ECOUNT) then
            return TRUE;
    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/SPEWriteToBuffer" mylink="aarch64.debug.statisticalprofiling.SPEWriteToBuffer" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPEWriteToBuffer()
// ==================
// Write the active record to the Profiling Buffer.

<anchor link="impl-aarch64.SPEWriteToBuffer.0" hover="function: SPEWriteToBuffer()">SPEWriteToBuffer</anchor>()
    assert <a link="impl-aarch64.ProfilingBufferEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ProfilingBufferEnabled()">ProfilingBufferEnabled</a>();

    // Check alignment
    boolean aligned = <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMBPTR_EL1.PTR&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMBIDR_EL1.Align)-1:0&gt;);
    boolean ttw_fault_as_external_abort;
    ttw_fault_as_external_abort = boolean IMPLEMENTATION_DEFINED "SPE TTW fault External abort";

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault;
    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc;

    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> owning_ss;
    bits(2) owning_el;
    (owning_ss, owning_el) = <a link="impl-aarch64.ProfilingBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) ProfilingBufferOwner()">ProfilingBufferOwner</a>();
    accdesc = <a link="impl-shared.CreateAccDescSPE.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescSPE(SecurityState owning_ss, bits(2) owning_el)">CreateAccDescSPE</a>(owning_ss, owning_el);

    bits(64) start_vaddr = PMBPTR_EL1&lt;63:0&gt;;
    for i = 0 to SPERecordSize - 1
        // If a previous write did not cause an issue
        if PMBSR_EL1.S == '0' then
            (memstatus, addrdesc) = <a link="impl-shared.DebugMemWrite.4" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, AddressDescriptor) DebugMemWrite(bits(64) vaddress, AccessDescriptor accdesc, boolean aligned, bits(8) data)">DebugMemWrite</a>(PMBPTR_EL1&lt;63:0&gt;, accdesc, aligned,
                                                  SPERecordData[i]);

            fault = addrdesc.fault;

            boolean ttw_fault;
            ttw_fault = fault.statuscode IN {<a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>, <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>};

            if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(fault.statuscode) &amp;&amp; !(ttw_fault &amp;&amp; ttw_fault_as_external_abort) then
                <a link="impl-shared.DebugWriteFault.2" file="shared_pseudocode.xml" hover="function: DebugWriteFault(bits(64) vaddress, FaultRecord fault)">DebugWriteFault</a>(PMBPTR_EL1&lt;63:0&gt;, fault);
            elsif <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) || (ttw_fault &amp;&amp; ttw_fault_as_external_abort) then
                <a link="impl-shared.DebugWriteExternalAbort.3" file="shared_pseudocode.xml" hover="function: DebugWriteExternalAbort(PhysMemRetStatus memstatus, AddressDescriptor addrdesc, bits(64) start_vaddr)">DebugWriteExternalAbort</a>(memstatus, addrdesc, start_vaddr);

            // Move pointer if no Buffer Management Event has been caused.
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(PMBSR_EL1.S) then
                PMBPTR_EL1 = PMBPTR_EL1 + 1;

    return;</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/StatisticalProfilingEnabled" mylink="aarch64.debug.statisticalprofiling.StatisticalProfilingEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StatisticalProfilingEnabled()
// =============================
// Return TRUE if Statistical Profiling is Enabled in the current EL, FALSE otherwise.

boolean <anchor link="impl-aarch64.StatisticalProfilingEnabled.0" hover="function: boolean StatisticalProfilingEnabled()">StatisticalProfilingEnabled</anchor>()
    return <a link="impl-aarch64.StatisticalProfilingEnabled.1" file="shared_pseudocode.xml" hover="function: boolean StatisticalProfilingEnabled(bits(2) el)">StatisticalProfilingEnabled</a>(PSTATE.EL);

// StatisticalProfilingEnabled()
// =============================
// Return TRUE if Statistical Profiling is Enabled in the specified EL, FALSE otherwise.

boolean <anchor link="impl-aarch64.StatisticalProfilingEnabled.1" hover="function: boolean StatisticalProfilingEnabled(bits(2) el)">StatisticalProfilingEnabled</anchor>(bits(2) el)
    if !<a link="impl-shared.HaveStatisticalProfiling.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfiling()">HaveStatisticalProfiling</a>() || <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() || !<a link="impl-aarch64.ProfilingBufferEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ProfilingBufferEnabled()">ProfilingBufferEnabled</a>() then
        return FALSE;

    tge_set = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';
    (owning_ss, owning_el) = <a link="impl-aarch64.ProfilingBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) ProfilingBufferOwner()">ProfilingBufferOwner</a>();
    if (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(owning_el) &lt;  <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(el) || (tge_set &amp;&amp; owning_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) ||
            owning_ss != <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(el))  then
        return FALSE;
    bit spe_bit;
    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  spe_bit = PMSCR_EL2.E2SPE;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  spe_bit = PMSCR_EL1.E1SPE;
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>  spe_bit = (if tge_set then PMSCR_EL2.E0HSPE else PMSCR_EL1.E0SPE);

    return spe_bit == '1';</pstext>
    </ps>
    <ps name="aarch64/debug/statisticalprofiling/TimeStamp" mylink="aarch64.debug.statisticalprofiling.TimeStamp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TimeStamp
// =========

enumeration <anchor link="TimeStamp" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp</anchor> {
    <anchor link="TimeStamp_None" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_None</anchor>,              // No timestamp
    <anchor link="TimeStamp_CoreSight" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_CoreSight</anchor>,         // CoreSight time (IMPLEMENTATION DEFINED)
    <anchor link="TimeStamp_Physical" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</anchor>,          // Physical counter value with no offset
    <anchor link="TimeStamp_OffsetPhysical" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</anchor>,    // Physical counter value minus CNTPOFF_EL2
    <anchor link="TimeStamp_Virtual" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</anchor>  };       // Physical counter value minus CNTVOFF_EL2</pstext>
    </ps>
    <ps name="aarch64/debug/takeexceptiondbg/AArch64.TakeExceptionInDebugState" mylink="aarch64.debug.takeexceptiondbg.AArch64.TakeExceptionInDebugState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakeExceptionInDebugState()
// ===================================
// Take an exception in Debug state to an Exception level using AArch64.

<anchor link="AArch64.TakeExceptionInDebugState.2" hover="function: AArch64.TakeExceptionInDebugState(bits(2) target_el, ExceptionRecord exception_in)">AArch64.TakeExceptionInDebugState</anchor>(bits(2) target_el, <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception_in)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(target_el) &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);
    assert target_el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> || EDSCR.SDD == '0';
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception = exception_in;
    boolean sync_errors;
    boolean iesb_req;
    if <a link="impl-shared.HaveIESB.0" file="shared_pseudocode.xml" hover="function: boolean HaveIESB()">HaveIESB</a>() then
        sync_errors = <a link="impl-aarch64.SCTLR.read.1" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[bits(2) regime]">SCTLR</a>[target_el].IESB == '1';
        if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() then
            sync_errors = sync_errors || (SCR_EL3.&lt;EA,NMEA&gt; == '11' &amp;&amp; target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        // SCTLR[].IESB and/or SCR_EL3.NMEA (if applicable) might be ignored in Debug state.
        if !<a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_IESBinDebug" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_IESBinDebug</a>) then
            sync_errors = FALSE;
    else
        sync_errors = FALSE;

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then
        <a link="TMFailure" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure</a> cause;
        case exception.exceptype of
            when <a link="Exception_SoftwareBreakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</a> cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            when <a link="Exception_Breakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</a>         cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            when <a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>         cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            when <a link="Exception_SoftwareStep" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</a>       cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            otherwise                         cause = <a link="TMFailure_ERR" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</a>;
        <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(cause, FALSE);

    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();

    // If coming from AArch32 state, the top parts of the X[] registers might be set to zero
    from_32 = <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    if from_32 then <a link="AArch64.MaybeZeroRegisterUppers.0" file="shared_pseudocode.xml" hover="function: AArch64.MaybeZeroRegisterUppers()">AArch64.MaybeZeroRegisterUppers</a>();
    if from_32 &amp;&amp; <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then
        <a link="impl-aarch64.ResetSVEState.0" file="shared_pseudocode.xml" hover="function: ResetSVEState()">ResetSVEState</a>();
    else
        <a link="impl-aarch64.MaybeZeroSVEUppers.1" file="shared_pseudocode.xml" hover="function: MaybeZeroSVEUppers(bits(2) target_el)">MaybeZeroSVEUppers</a>(target_el);

    <a link="AArch64.ReportException.2" file="shared_pseudocode.xml" hover="function: AArch64.ReportException(ExceptionRecord exception, bits(2) target_el)">AArch64.ReportException</a>(exception, target_el);

    PSTATE.EXLOCK = '0';  // Effective value of GCSCR_ELx.EXLOCKEN is 0 in Debug state

    PSTATE.EL = target_el;
    PSTATE.nRW = '0';
    PSTATE.SP = '1';

    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = bits(64) UNKNOWN;
    <a link="impl-aarch64.ELR.write.0" file="shared_pseudocode.xml" hover="accessor: ELR[] = bits(64) value">ELR</a>[] = bits(64) UNKNOWN;

    // PSTATE.{SS,D,A,I,F} are not observable and ignored in Debug state, so behave as if UNKNOWN.
    PSTATE.&lt;SS,D,A,I,F&gt; = bits(5) UNKNOWN;
    PSTATE.IL = '0';
    if from_32 then                             // Coming from AArch32
        PSTATE.IT = '00000000';
        PSTATE.T = '0';                         // PSTATE.J is RES0
    if (<a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>))) &amp;&amp;
        <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].SPAN == '0') then
        PSTATE.PAN = '1';
    if <a link="impl-shared.HaveUAOExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveUAOExt()">HaveUAOExt</a>() then PSTATE.UAO = '0';
    if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then PSTATE.BTYPE = '00';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = bit UNKNOWN;
    if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() then PSTATE.TCO = '1';

    DLR_EL0 = bits(64) UNKNOWN;
    DSPSR_EL0 = bits(64) UNKNOWN;

    EDSCR.ERR = '1';
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                        // Update EDSCR processor state flags.

    if sync_errors then
        <a link="impl-shared.SynchronizeErrors.0" file="shared_pseudocode.xml" hover="function: SynchronizeErrors()">SynchronizeErrors</a>();

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch64/debug/watchpoint/AArch64.WatchpointByteMatch" mylink="aarch64.debug.watchpoint.AArch64.WatchpointByteMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.WatchpointByteMatch()
// =============================

boolean <anchor link="AArch64.WatchpointByteMatch.2" hover="function: boolean AArch64.WatchpointByteMatch(integer n, bits(64) vaddress)">AArch64.WatchpointByteMatch</anchor>(integer n, bits(64) vaddress)

    integer top = <a link="impl-aarch64.DebugAddrTop.0" file="shared_pseudocode.xml" hover="function: integer DebugAddrTop()">DebugAddrTop</a>();
    bottom = if DBGWVR_EL1[n]&lt;2&gt; == '1' then 2 else 3;            // Word or doubleword
    byte_select_match = (DBGWCR_EL1[n].BAS&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vaddress&lt;bottom-1:0&gt;)&gt; != '0');
    mask = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(DBGWCR_EL1[n].MASK);

    // If DBGWCR_EL1[n].MASK is non-zero value and DBGWCR_EL1[n].BAS is not set to '11111111', or
    // DBGWCR_EL1[n].BAS specifies a non-contiguous set of bytes behavior is CONSTRAINED
    // UNPREDICTABLE.
    if mask &gt; 0 &amp;&amp; !<a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(DBGWCR_EL1[n].BAS) then
        byte_select_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_WPMASKANDBAS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPMASKANDBAS</a>);
    else
        LSB = (DBGWCR_EL1[n].BAS AND NOT(DBGWCR_EL1[n].BAS - 1));  MSB = (DBGWCR_EL1[n].BAS + LSB);
        if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(MSB AND (MSB - 1)) then                     // Not contiguous
            byte_select_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_WPBASCONTIGUOUS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPBASCONTIGUOUS</a>);
            bottom = 3;                                        // For the whole doubleword

    // If the address mask is set to a reserved value, the behavior is CONSTRAINED UNPREDICTABLE.
    if mask &gt; 0 &amp;&amp; mask &lt;= 2 then
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, mask) = <a link="impl-shared.ConstrainUnpredictableInteger.3" file="shared_pseudocode.xml" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</a>(3, 31, <a link="Unpredictable_RESWPMASK" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESWPMASK</a>);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        case c of
            when <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>  return FALSE;            // Disabled
            when <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>      mask = 0;                // No masking
            // Otherwise the value returned by ConstrainUnpredictableInteger is a not-reserved value

    boolean WVR_match;
    if mask &gt; bottom then
        // If the DBGxVR&lt;n&gt;_EL1.RESS field bits are not a sign extension of the MSB
        // of DBGxVR&lt;n&gt;_EL1.VA, it is UNPREDICTABLE whether they appear to be
        // included in the match.
        if !<a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(DBGWVR_EL1[n]&lt;63:top&gt;) &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(DBGWVR_EL1[n]&lt;63:top&gt;) then
            if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_DBGxVR_RESS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DBGxVR_RESS</a>) then
                top = 63;

        WVR_match = (vaddress&lt;top:mask&gt; == DBGWVR_EL1[n]&lt;top:mask&gt;);
        // If masked bits of DBGWVR_EL1[n] are not zero, the behavior is CONSTRAINED UNPREDICTABLE.
        if WVR_match &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(DBGWVR_EL1[n]&lt;mask-1:bottom&gt;) then
            WVR_match = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_WPMASKEDBITS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPMASKEDBITS</a>);
    else
        WVR_match = vaddress&lt;top:bottom&gt; == DBGWVR_EL1[n]&lt;top:bottom&gt;;

    return WVR_match &amp;&amp; byte_select_match;</pstext>
    </ps>
    <ps name="aarch64/debug/watchpoint/AArch64.WatchpointMatch" mylink="aarch64.debug.watchpoint.AArch64.WatchpointMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.WatchpointMatch()
// =========================
// Watchpoint matching in an AArch64 translation regime.

boolean <anchor link="AArch64.WatchpointMatch.4" hover="function: boolean AArch64.WatchpointMatch(integer n, bits(64) vaddress, integer size, AccessDescriptor accdesc)">AArch64.WatchpointMatch</anchor>(integer n, bits(64) vaddress, integer size,
                                <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    assert !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    assert n &lt; <a link="impl-shared.NumWatchpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumWatchpointsImplemented()">NumWatchpointsImplemented</a>();

    enabled = <a link="impl-aarch64.IsWatchpointEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsWatchpointEnabled(integer n)">IsWatchpointEnabled</a>(n);
    linked = DBGWCR_EL1[n].WT == '1';
    isbreakpnt = FALSE;

    ssce = if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then DBGWCR_EL1[n].SSCE else '0';
    state_match = <a link="AArch64.StateMatch.8" file="shared_pseudocode.xml" hover="function: boolean AArch64.StateMatch(bits(2) ssc_in, bit ssce_in, bit hmc_in, bits(2) pxc_in, boolean linked_in, bits(4) lbn, boolean isbreakpnt, AccessDescriptor accdesc)">AArch64.StateMatch</a>(DBGWCR_EL1[n].SSC, ssce, DBGWCR_EL1[n].HMC, DBGWCR_EL1[n].PAC,
                                     linked, DBGWCR_EL1[n].LBN, isbreakpnt, accdesc);

    boolean ls_match;
    case DBGWCR_EL1[n].LSC&lt;1:0&gt; of
        when '00' ls_match = FALSE;
        when '01' ls_match = accdesc.read;
        when '10' ls_match = accdesc.write || accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>;
        when '11' ls_match = TRUE;

    value_match = FALSE;
    for byte = 0 to size - 1
        value_match = value_match || <a link="AArch64.WatchpointByteMatch.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.WatchpointByteMatch(integer n, bits(64) vaddress)">AArch64.WatchpointByteMatch</a>(n, vaddress + byte);

    return value_match &amp;&amp; state_match &amp;&amp; ls_match &amp;&amp; enabled;</pstext>
    </ps>
    <ps name="aarch64/debug/watchpoint/IsWatchpointEnabled" mylink="aarch64.debug.watchpoint.IsWatchpointEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsWatchpointEnabled()
// =====================
// Returns TRUE if the effective value of DBGBCR_EL1[n].E is '1', and FALSE otherwise.

boolean <anchor link="impl-aarch64.IsWatchpointEnabled.1" hover="function: boolean IsWatchpointEnabled(integer n)">IsWatchpointEnabled</anchor>(integer n)
    if (n &gt; 15 &amp;&amp;
            ((!<a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() &amp;&amp; !<a link="impl-aarch64.SelfHostedExtendedBPWPEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedExtendedBPWPEnabled()">SelfHostedExtendedBPWPEnabled</a>()) ||
            (<a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() &amp;&amp; EDSCR2.EBWE == '0'))) then
        return FALSE;
    return DBGWCR_EL1[n].E == '1';</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.Abort" mylink="aarch64.exceptions.aborts.AArch64.Abort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.Abort()
// ===============
// Abort and Debug exception handling in an AArch64 translation regime.

<anchor link="AArch64.Abort.2" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</anchor>(bits(64) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)

    if <a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) then
        if fault.access.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
            if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fault.debugmoe == <a link="DebugException_VectorCatch" file="shared_pseudocode.xml" hover="constant bits(4) DebugException_VectorCatch = '0101'">DebugException_VectorCatch</a> then
                <a link="AArch64.VectorCatchException.1" file="shared_pseudocode.xml" hover="function: AArch64.VectorCatchException(FaultRecord fault)">AArch64.VectorCatchException</a>(fault);
            else
                <a link="AArch64.BreakpointException.1" file="shared_pseudocode.xml" hover="function: AArch64.BreakpointException(FaultRecord fault)">AArch64.BreakpointException</a>(fault);
        else
            <a link="AArch64.WatchpointException.2" file="shared_pseudocode.xml" hover="function: AArch64.WatchpointException(bits(64) vaddress, FaultRecord fault)">AArch64.WatchpointException</a>(vaddress, fault);
    elsif fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> &amp;&amp; <a link="impl-shared.ReportAsGPCException.1" file="shared_pseudocode.xml" hover="function: boolean ReportAsGPCException(FaultRecord fault)">ReportAsGPCException</a>(fault) then
        <a link="impl-aarch64.TakeGPCException.2" file="shared_pseudocode.xml" hover="function: TakeGPCException(bits(64) vaddress, FaultRecord fault)">TakeGPCException</a>(vaddress, fault);
    elsif fault.access.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        <a link="AArch64.InstructionAbort.2" file="shared_pseudocode.xml" hover="function: AArch64.InstructionAbort(bits(64) vaddress, FaultRecord fault)">AArch64.InstructionAbort</a>(vaddress, fault);
    else
        <a link="AArch64.DataAbort.2" file="shared_pseudocode.xml" hover="function: AArch64.DataAbort(bits(64) vaddress, FaultRecord fault)">AArch64.DataAbort</a>(vaddress, fault);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.AbortSyndrome" mylink="aarch64.exceptions.aborts.AArch64.AbortSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AbortSyndrome()
// =======================
// Creates an exception syndrome record for Abort and Watchpoint exceptions
//
// from an AArch64 translation regime.

ExceptionRecord <anchor link="AArch64.AbortSyndrome.4" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</anchor>(<a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault,
                                      bits(64) vaddress, bits(2) target_el)
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(exceptype);

    d_side = exceptype IN {<a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>, <a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a>, <a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>,
                           <a link="Exception_NV2Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2Watchpoint</a>};
    if (<a link="impl-shared.HavePFAR.0" file="shared_pseudocode.xml" hover="function: boolean HavePFAR()">HavePFAR</a>() &amp;&amp;
            ((<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.VM == '1' &amp;&amp; target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) ||
             !<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault))) then
        exception.pavalid = FALSE;
    else
        exception.pavalid = boolean IMPLEMENTATION_DEFINED "PFAR_ELx is valid";

    (exception.syndrome, exception.syndrome2) = <a link="AArch64.FaultSyndrome.3" file="shared_pseudocode.xml" hover="function: (bits(25), bits(24)) AArch64.FaultSyndrome(boolean d_side, FaultRecord fault, boolean pavalid)">AArch64.FaultSyndrome</a>(d_side, fault,
                                                                      exception.pavalid);
    if fault.statuscode == <a link="Fault_TagCheck" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TagCheck</a> then
        if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>() then
            exception.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress, 64);
        else
            exception.vaddress = bits(4) UNKNOWN : vaddress&lt;59:0&gt;;
    else
        exception.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress, 64);

    if <a link="impl-shared.IPAValid.1" file="shared_pseudocode.xml" hover="function: boolean IPAValid(FaultRecord fault)">IPAValid</a>(fault) then
        exception.ipavalid = TRUE;
        exception.NS = if fault.ipaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then '1' else '0';
        exception.ipaddress = fault.ipaddress.address;
    else
        exception.ipavalid = FALSE;

    return exception;</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.CheckPCAlignment" mylink="aarch64.exceptions.aborts.AArch64.CheckPCAlignment" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckPCAlignment()
// ==========================

<anchor link="AArch64.CheckPCAlignment.0" hover="function: AArch64.CheckPCAlignment()">AArch64.CheckPCAlignment</anchor>()
    bits(64) pc = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);

    if pc&lt;1:0&gt; != '00' then
        <a link="AArch64.PCAlignmentFault.0" file="shared_pseudocode.xml" hover="function: AArch64.PCAlignmentFault()">AArch64.PCAlignmentFault</a>();</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.DataAbort" mylink="aarch64.exceptions.aborts.AArch64.DataAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.DataAbort()
// ===================

<anchor link="AArch64.DataAbort.2" hover="function: AArch64.DataAbort(bits(64) vaddress, FaultRecord fault)">AArch64.DataAbort</anchor>(bits(64) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    bits(2) target_el;
    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then
        target_el = <a link="AArch64.SyncExternalAbortTarget.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch64.SyncExternalAbortTarget(FaultRecord fault)">AArch64.SyncExternalAbortTarget</a>(fault);
    else
        route_to_el2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp;
                        (HCR_EL2.TGE == '1' ||
                         (<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; fault.gpcf.gpf == <a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a> &amp;&amp; HCR_EL2.GPF == '1') ||
                         (<a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a>) ||
                         <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault)));

        if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
        elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2 then
            target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
        else
            target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset;

    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) &amp;&amp; <a link="AArch64.RouteToSErrorOffset.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.RouteToSErrorOffset(bits(2) target_el)">AArch64.RouteToSErrorOffset</a>(target_el) then
        vect_offset = 0x180;
    else
        vect_offset = 0x0;

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
    if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
        exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a>, fault, vaddress, target_el);
    else
        exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>, fault, vaddress, target_el);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.EffectiveTCF" mylink="aarch64.exceptions.aborts.AArch64.EffectiveTCF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.EffectiveTCF()
// ======================
// Returns the TCF field applied to tag check faults in the given Exception level.

bits(2) <anchor link="AArch64.EffectiveTCF.1" hover="function: bits(2) AArch64.EffectiveTCF(bits(2) el)">AArch64.EffectiveTCF</anchor>(bits(2) el)
    bits(2) tcf;

    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(el);

    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  tcf = SCTLR_EL3.TCF;
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  tcf = SCTLR_EL2.TCF;
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> tcf = if el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then SCTLR_EL2.TCF0 else SCTLR_EL2.TCF;
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> tcf = if el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then SCTLR_EL1.TCF0 else SCTLR_EL1.TCF;
        otherwise        <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    if tcf == '11' then        //reserved value
        if !<a link="impl-shared.HaveMTEAsymFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEAsymFaultExt()">HaveMTEAsymFaultExt</a>() then
            (-,tcf) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESTCF" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTCF</a>, 2);

    return tcf;</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.InstructionAbort" mylink="aarch64.exceptions.aborts.AArch64.InstructionAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.InstructionAbort()
// ==========================

<anchor link="AArch64.InstructionAbort.2" hover="function: AArch64.InstructionAbort(bits(64) vaddress, FaultRecord fault)">AArch64.InstructionAbort</anchor>(bits(64) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    // External aborts on instruction fetch must be taken synchronously
    if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() then assert fault.statuscode != <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>;

    bits(2) target_el;
    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then
        target_el = <a link="AArch64.SyncExternalAbortTarget.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch64.SyncExternalAbortTarget(FaultRecord fault)">AArch64.SyncExternalAbortTarget</a>(fault);
    else
        route_to_el2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp;
                        (HCR_EL2.TGE == '1' ||
                         (<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; fault.gpcf.gpf == <a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a> &amp;&amp; HCR_EL2.GPF == '1') ||
                         <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault)));

        if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
        elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2 then
            target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
        else
            target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset;

    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) &amp;&amp; <a link="AArch64.RouteToSErrorOffset.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.RouteToSErrorOffset(bits(2) target_el)">AArch64.RouteToSErrorOffset</a>(target_el) then
        vect_offset = 0x180;
    else
        vect_offset = 0x0;

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>, fault,
                                                      vaddress, target_el);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.PCAlignmentFault" mylink="aarch64.exceptions.aborts.AArch64.PCAlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PCAlignmentFault()
// ==========================
// Called on unaligned program counter in AArch64 state.

<anchor link="AArch64.PCAlignmentFault.0" hover="function: AArch64.PCAlignmentFault()">AArch64.PCAlignmentFault</anchor>()

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>);
    exception.vaddress = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    bits(2) target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        target_el = PSTATE.EL;
    elsif <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.PhysicalSErrorTarget" mylink="aarch64.exceptions.aborts.AArch64.PhysicalSErrorTarget" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PhysicalSErrorTarget()
// ==============================
// Returns a tuple of whether SError exception can be taken and, if so, the target Exception level.

(boolean, bits(2)) <anchor link="AArch64.PhysicalSErrorTarget.0" hover="function: (boolean, bits(2)) AArch64.PhysicalSErrorTarget()">AArch64.PhysicalSErrorTarget</anchor>()
    boolean route_to_el3;
    boolean route_to_el2;

    // The exception is explicitly routed to EL3.
    if PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        route_to_el3 = (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1');
    else
        route_to_el3 = FALSE;

    // The exception is explicitly routed to EL2.
    if !route_to_el3 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
        route_to_el2 = (HCR_EL2.AMO == '1');
    elsif !route_to_el3 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        route_to_el2 = (!<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; HCR_EL2.&lt;TGE,AMO&gt; != '00');
    else
        route_to_el2 = FALSE;

    // The exception is "masked".
    boolean masked;
    case PSTATE.EL of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            masked = (<a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>()  == '0' || PSTATE.A == '1');
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            masked = (!route_to_el3 &amp;&amp;
                      (HCR_EL2.&lt;TGE,AMO&gt; == '00' || PSTATE.A == '1'));
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            masked = (!route_to_el3 &amp;&amp; !route_to_el2 &amp;&amp; PSTATE.A == '1');

    // When FEAT_DoubleFault or FEAT_DoubleFault2 is implemented, the mask might be overridden.
    if <a link="impl-shared.HaveDoubleFault2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFault2Ext()">HaveDoubleFault2Ext</a>() then
        bit nmea_bit;
        case PSTATE.EL of
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
                nmea_bit = SCR_EL3.NMEA;
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
                nmea_bit = if <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then SCTLR2_EL2.NMEA else '0';
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                nmea_bit = if <a link="impl-aarch64.IsSCTLR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL1Enabled()">IsSCTLR2EL1Enabled</a>() then SCTLR2_EL1.NMEA else '0';
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
                if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
                    nmea_bit = if <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then SCTLR2_EL2.NMEA else '0';
                else
                    nmea_bit = if <a link="impl-aarch64.IsSCTLR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL1Enabled()">IsSCTLR2EL1Enabled</a>() then SCTLR2_EL1.NMEA else '0';
        masked = masked &amp;&amp; (nmea_bit == '0');

    elsif <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        bit nmea_bit = SCR_EL3.NMEA AND <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>();
        masked = masked &amp;&amp; (nmea_bit == '0');

    boolean route_masked_to_el3;
    boolean route_masked_to_el2;

    if <a link="impl-shared.HaveDoubleFault2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFault2Ext()">HaveDoubleFault2Ext</a>() then
        // The masked exception is routed to EL2.
        route_masked_to_el2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !route_to_el3 &amp;&amp;
                               <a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() &amp;&amp; HCRX_EL2.TMEA == '1' &amp;&amp;
                               ((PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; (PSTATE.A == '1' || masked)) ||
                               (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; masked &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>())));

        // The masked exception is routed to EL3.
        route_masked_to_el3 = (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.TMEA == '1' &amp;&amp;
                               !(route_to_el2 || route_masked_to_el2) &amp;&amp;
                               ((PSTATE.EL IN {<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp;
                                   (PSTATE.A == '1' || masked)) ||
                                   (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; masked)));
    else
        route_masked_to_el2 = FALSE;
        route_masked_to_el3 = FALSE;

    // The exception is taken at EL3.
    take_in_el3 = PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; !masked;

    // The exception is taken at EL2 or in the Host EL0.
    take_in_el2_0 = ((PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) &amp;&amp;
                     !(route_to_el3 || route_masked_to_el3) &amp;&amp; !masked);

    // The exception is taken at EL1 or in the non-Host EL0.
    take_in_el1_0 = ((PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>())) &amp;&amp;
                     !(route_to_el2 || route_masked_to_el2) &amp;&amp;
                     !(route_to_el3 || route_masked_to_el3) &amp;&amp; !masked);

    bits(2) target_el;
    if take_in_el3 || route_to_el3 || route_masked_to_el3 then
        masked = FALSE;  target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif take_in_el2_0 || route_to_el2 || route_masked_to_el2 then
        masked = FALSE;  target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    elsif take_in_el1_0 then
        masked = FALSE;  target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    else
        masked = TRUE;  target_el = bits(2) UNKNOWN;

    return (masked, target_el);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.RaiseTagCheckFault" mylink="aarch64.exceptions.aborts.AArch64.RaiseTagCheckFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.RaiseTagCheckFault()
// ============================
// Raise a tag check fault exception.

<anchor link="AArch64.RaiseTagCheckFault.2" hover="function: AArch64.RaiseTagCheckFault(bits(64) va, FaultRecord fault)">AArch64.RaiseTagCheckFault</anchor>(bits(64) va, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset = 0x0;
    bits(2) target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        target_el = PSTATE.EL;
    elsif PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>, fault, va, target_el);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.ReportTagCheckFault" mylink="aarch64.exceptions.aborts.AArch64.ReportTagCheckFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ReportTagCheckFault()
// =============================
// Records a tag check fault exception into the appropriate TFSR_ELx.

<anchor link="AArch64.ReportTagCheckFault.2" hover="function: AArch64.ReportTagCheckFault(bits(2) el, bit ttbr)">AArch64.ReportTagCheckFault</anchor>(bits(2) el, bit ttbr)
    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> assert ttbr == '0'; TFSR_EL3.TF0   = '1';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> if ttbr == '0' then TFSR_EL2.TF0   = '1'; else TFSR_EL2.TF1   = '1';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> if ttbr == '0' then TFSR_EL1.TF0   = '1'; else TFSR_EL1.TF1   = '1';
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> if ttbr == '0' then TFSRE0_EL1.TF0 = '1'; else TFSRE0_EL1.TF1 = '1';</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.RouteToSErrorOffset" mylink="aarch64.exceptions.aborts.AArch64.RouteToSErrorOffset" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.RouteToSErrorOffset()
// =============================
// Returns TRUE if synchronous External abort exceptions are taken to the
// appropriate SError vector offset, and FALSE otherwise.

boolean <anchor link="AArch64.RouteToSErrorOffset.1" hover="function: boolean AArch64.RouteToSErrorOffset(bits(2) target_el)">AArch64.RouteToSErrorOffset</anchor>(bits(2) target_el)
    if !<a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() then return FALSE;

    bit ease_bit;
    case target_el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            ease_bit = SCR_EL3.EASE;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if <a link="impl-shared.HaveDoubleFault2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFault2Ext()">HaveDoubleFault2Ext</a>() &amp;&amp; <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then
                ease_bit = SCTLR2_EL2.EASE;
            else
                ease_bit = '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            if <a link="impl-shared.HaveDoubleFault2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFault2Ext()">HaveDoubleFault2Ext</a>() &amp;&amp; <a link="impl-aarch64.IsSCTLR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL1Enabled()">IsSCTLR2EL1Enabled</a>() then
                ease_bit = SCTLR2_EL1.EASE;
            else
                ease_bit = '0';

    return (ease_bit == '1');</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.SPAlignmentFault" mylink="aarch64.exceptions.aborts.AArch64.SPAlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SPAlignmentFault()
// ==========================
// Called on an unaligned stack pointer in AArch64 state.

<anchor link="AArch64.SPAlignmentFault.0" hover="function: AArch64.SPAlignmentFault()">AArch64.SPAlignmentFault</anchor>()

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SPAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SPAlignment</a>);

    bits(2) target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        target_el = PSTATE.EL;
    elsif <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.SyncExternalAbortTarget" mylink="aarch64.exceptions.aborts.AArch64.SyncExternalAbortTarget" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SyncExternalAbortTarget()
// =================================
// Returns the target Exception level for a Synchronous External
// Data or Instruction Abort.

bits(2) <anchor link="AArch64.SyncExternalAbortTarget.1" hover="function: bits(2) AArch64.SyncExternalAbortTarget(FaultRecord fault)">AArch64.SyncExternalAbortTarget</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    boolean route_to_el3;

    // The exception is explicitly routed to EL3
    if PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        route_to_el3 = (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1');
    else
        route_to_el3 = FALSE;

    // The exception is explicitly routed to EL2
    bit tea_bit = (if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() then HCR_EL2.TEA else '0');

    boolean route_to_el2;
    if !route_to_el3 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
        route_to_el2 = (tea_bit == '1' ||
                        fault.access.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> ||
                        <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault));

    elsif !route_to_el3 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        route_to_el2 = (!<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; (HCR_EL2.TGE == '1' || tea_bit == '1' ||
                        <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault)));
    else
        route_to_el2 = FALSE;

    boolean route_masked_to_el3;
    boolean route_masked_to_el2;

    if <a link="impl-shared.HaveDoubleFault2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFault2Ext()">HaveDoubleFault2Ext</a>() then
        // The masked exception is routed to EL2
        route_masked_to_el2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !route_to_el3 &amp;&amp;
                               (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; PSTATE.A == '1') &amp;&amp;
                               <a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() &amp;&amp; HCRX_EL2.TMEA == '1');

        // The masked exception is routed to EL3
        route_masked_to_el3 = (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp;
                               !(route_to_el2 || route_masked_to_el2) &amp;&amp;
                               (PSTATE.EL IN {<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; PSTATE.A == '1') &amp;&amp;
                               SCR_EL3.TMEA == '1');
    else
        route_masked_to_el2 = FALSE;
        route_masked_to_el3 = FALSE;

    // The exception is taken at EL3
    take_in_el3 = PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    // The exception is taken at EL2 or in the Host EL0
    take_in_el2_0 = ((PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) &amp;&amp;
                     !(route_to_el3 || route_masked_to_el3));

    // The exception is taken at EL1 or in the non-Host EL0
    take_in_el1_0 = ((PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>())) &amp;&amp;
                     !(route_to_el2 || route_masked_to_el2) &amp;&amp;
                     !(route_to_el3 || route_masked_to_el3));

    bits(2) target_el;
    if take_in_el3 || route_to_el3 || route_masked_to_el3 then
        target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif take_in_el2_0 || route_to_el2 || route_masked_to_el2 then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    elsif take_in_el1_0 then
        target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    else
        assert(FALSE);

    return target_el;</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/AArch64.TagCheckFault" mylink="aarch64.exceptions.aborts.AArch64.TagCheckFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TagCheckFault()
// =======================
// Handle a tag check fault condition.

<anchor link="AArch64.TagCheckFault.2" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</anchor>(bits(64) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bits(2) tcf;

    tcf = <a link="AArch64.EffectiveTCF.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch64.EffectiveTCF(bits(2) el)">AArch64.EffectiveTCF</a>(accdesc.el);

    fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
    fault.statuscode = <a link="Fault_TagCheck" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TagCheck</a>;

    case tcf of
        when '00'   // Tag Check Faults have no effect on the PE
            return;
        when '01'   // Tag Check Faults cause a synchronous exception
            <a link="AArch64.RaiseTagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.RaiseTagCheckFault(bits(64) va, FaultRecord fault)">AArch64.RaiseTagCheckFault</a>(vaddress, fault);
        when '10'
            if <a link="impl-shared.HaveMTEAsyncExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEAsyncExt()">HaveMTEAsyncExt</a>() then
                // If asynchronous faults are implemented,
                // Tag Check Faults are asynchronously accumulated
                <a link="AArch64.ReportTagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.ReportTagCheckFault(bits(2) el, bit ttbr)">AArch64.ReportTagCheckFault</a>(accdesc.el, vaddress&lt;55&gt;);
            else
                // Otherwise, Tag Check Faults have no effect on the PE.
                return;
        when '11'
            if <a link="impl-shared.HaveMTEAsymFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEAsymFaultExt()">HaveMTEAsymFaultExt</a>() then
                // Tag Check Faults cause a synchronous exception on reads or on
                // a read/write access, and are asynchronously accumulated on writes
                if accdesc.read then
                    <a link="AArch64.RaiseTagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.RaiseTagCheckFault(bits(64) va, FaultRecord fault)">AArch64.RaiseTagCheckFault</a>(vaddress, fault);
                else
                    <a link="AArch64.ReportTagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.ReportTagCheckFault(bits(2) el, bit ttbr)">AArch64.ReportTagCheckFault</a>(accdesc.el, vaddress&lt;55&gt;);
            else
                // Otherwise, Tag Check Faults have no effect on the PE.
                return;</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/BranchTargetException" mylink="aarch64.exceptions.aborts.BranchTargetException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchTargetException()
// =======================
// Raise branch target exception.

<anchor link="AArch64.BranchTargetException.1" hover="function: AArch64.BranchTargetException(bits(52) vaddress)">AArch64.BranchTargetException</anchor>(bits(52) vaddress)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_BranchTarget" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_BranchTarget</a>);
    exception.syndrome&lt;1:0&gt;   = PSTATE.BTYPE;
    exception.syndrome&lt;24:2&gt;  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(23);         // RES0

    bits(2) target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        target_el = PSTATE.EL;
    elsif PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/aborts/TakeGPCException" mylink="aarch64.exceptions.aborts.TakeGPCException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TakeGPCException()
// ==================
// Report Granule Protection Exception faults

<anchor link="impl-aarch64.TakeGPCException.2" hover="function: TakeGPCException(bits(64) vaddress, FaultRecord fault)">TakeGPCException</anchor>(bits(64) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>();
    assert <a link="impl-shared.HaveAtomicExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAtomicExt()">HaveAtomicExt</a>();
    assert <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>();
    assert <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>();
    assert <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>();

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;

    exception.exceptype = <a link="Exception_GPC" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GPC</a>;
    exception.vaddress  = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress, 64);
    exception.paddress  = fault.paddress;
    exception.pavalid   = TRUE;

    if <a link="impl-shared.IPAValid.1" file="shared_pseudocode.xml" hover="function: boolean IPAValid(FaultRecord fault)">IPAValid</a>(fault) then
        exception.ipavalid  = TRUE;
        exception.NS        = if fault.ipaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then '1' else '0';
        exception.ipaddress = fault.ipaddress.address;
    else
        exception.ipavalid = FALSE;

    if fault.access.acctype == <a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a> then
        exception.syndrome2&lt;8&gt; = '1'; //GCS

    // Populate the fields grouped in ISS
    exception.syndrome&lt;24:22&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(3); // RES0
    exception.syndrome&lt;21&gt;    = if fault.gpcfs2walk then '1' else '0';  // S2PTW
    if fault.access.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        exception.syndrome&lt;20&gt; = '1'; // InD
    else
        exception.syndrome&lt;20&gt; = '0'; // InD
    exception.syndrome&lt;19:14&gt; = <a link="impl-aarch64.EncodeGPCSC.1" file="shared_pseudocode.xml" hover="function: bits(6) EncodeGPCSC(GPCFRecord gpcf)">EncodeGPCSC</a>(fault.gpcf); // GPCSC
    if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
        exception.syndrome&lt;13&gt; = '1'; // VNCR
    else
        exception.syndrome&lt;13&gt; = '0'; // VNCR
    exception.syndrome&lt;12:11&gt; = '00'; // RES0
    exception.syndrome&lt;10:9&gt;  = '00'; // RES0

    if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
        exception.syndrome&lt;8&gt; = '1'; // CM
    else
        exception.syndrome&lt;8&gt; = '0';  // CM

    exception.syndrome&lt;7&gt; = if fault.s2fs1walk then '1' else '0'; // S1PTW

    if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
        exception.syndrome&lt;6&gt; = '1';                              // WnR
    elsif fault.statuscode IN {<a link="Fault_HWUpdateAccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_HWUpdateAccessFlag</a>, <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>} then
        exception.syndrome&lt;6&gt; = bit UNKNOWN;                      // WnR
    elsif fault.access.atomicop &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then
        exception.syndrome&lt;6&gt; = bit UNKNOWN;                      // WnR
    else
        exception.syndrome&lt;6&gt; = if fault.write then '1' else '0'; // WnR

    exception.syndrome&lt;5:0&gt; = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level); // xFSC

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    bits(2) target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    integer vect_offset;
    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) &amp;&amp; <a link="AArch64.RouteToSErrorOffset.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.RouteToSErrorOffset(bits(2) target_el)">AArch64.RouteToSErrorOffset</a>(target_el) then
        vect_offset = 0x180;
    else
        vect_offset = 0x0;

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/async/AArch64.TakePhysicalFIQException" mylink="aarch64.exceptions.async.AArch64.TakePhysicalFIQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakePhysicalFIQException()
// ==================================

<anchor link="AArch64.TakePhysicalFIQException.0" hover="function: AArch64.TakePhysicalFIQException()">AArch64.TakePhysicalFIQException</anchor>()

    route_to_el3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.FIQ == '1';
    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR_EL2.TGE == '1' || HCR_EL2.FMO == '1'));
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x100;
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>);

    if route_to_el3 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, exception, preferred_exception_return, vect_offset);
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2 then
        assert PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/async/AArch64.TakePhysicalIRQException" mylink="aarch64.exceptions.async.AArch64.TakePhysicalIRQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakePhysicalIRQException()
// ==================================
// Take an enabled physical IRQ exception.

<anchor link="AArch64.TakePhysicalIRQException.0" hover="function: AArch64.TakePhysicalIRQException()">AArch64.TakePhysicalIRQException</anchor>()

    route_to_el3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.IRQ == '1';
    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR_EL2.TGE == '1' || HCR_EL2.IMO == '1'));
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x80;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>);

    if route_to_el3 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, exception, preferred_exception_return, vect_offset);
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2 then
        assert PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/async/AArch64.TakePhysicalSErrorException" mylink="aarch64.exceptions.async.AArch64.TakePhysicalSErrorException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakePhysicalSErrorException()
// =====================================

<anchor link="AArch64.TakePhysicalSErrorException.1" hover="function: AArch64.TakePhysicalSErrorException(boolean implicit_esb)">AArch64.TakePhysicalSErrorException</anchor>(boolean implicit_esb)

    route_to_el3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.EA == '1';
    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR_EL2.TGE == '1' || (!<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; HCR_EL2.AMO == '1')));
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x180;

    bits(2) target_el;
    if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> || route_to_el3 then
        target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2 then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SError" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SError</a>);
    bits(25) syndrome = <a link="AArch64.PhysicalSErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(25) AArch64.PhysicalSErrorSyndrome(boolean implicit_esb)">AArch64.PhysicalSErrorSyndrome</a>(implicit_esb);
    if <a link="impl-shared.IsSErrorEdgeTriggered.0" file="shared_pseudocode.xml" hover="function: boolean IsSErrorEdgeTriggered()">IsSErrorEdgeTriggered</a>() then
        <a link="impl-shared.ClearPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: ClearPendingPhysicalSError()">ClearPendingPhysicalSError</a>();
    exception.syndrome = syndrome;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/async/AArch64.TakeVirtualFIQException" mylink="aarch64.exceptions.async.AArch64.TakeVirtualFIQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakeVirtualFIQException()
// =================================

<anchor link="AArch64.TakeVirtualFIQException.0" hover="function: AArch64.TakeVirtualFIQException()">AArch64.TakeVirtualFIQException</anchor>()
    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    assert HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.FMO == '1';  // Virtual IRQ enabled if TGE==0 and FMO==1

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x100;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>);

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/async/AArch64.TakeVirtualIRQException" mylink="aarch64.exceptions.async.AArch64.TakeVirtualIRQException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakeVirtualIRQException()
// =================================

<anchor link="AArch64.TakeVirtualIRQException.0" hover="function: AArch64.TakeVirtualIRQException()">AArch64.TakeVirtualIRQException</anchor>()
    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    assert HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.IMO == '1';  // Virtual IRQ enabled if TGE==0 and IMO==1

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x80;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>);

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/async/AArch64.TakeVirtualSErrorException" mylink="aarch64.exceptions.async.AArch64.TakeVirtualSErrorException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakeVirtualSErrorException()
// ====================================

<anchor link="AArch64.TakeVirtualSErrorException.0" hover="function: AArch64.TakeVirtualSErrorException()">AArch64.TakeVirtualSErrorException</anchor>()

    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    assert HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.AMO == '1';  // Virtual SError enabled if TGE==0 and AMO==1

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x180;
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SError" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SError</a>);

    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() then
        exception.syndrome&lt;24&gt;   = VSESR_EL2.IDS;
        exception.syndrome&lt;23:0&gt; = VSESR_EL2.ISS;
    else
        bits(25) syndrome = bits(25) IMPLEMENTATION_DEFINED "Virtual SError syndrome";
        impdef_syndrome = syndrome&lt;24&gt; == '1';
        if impdef_syndrome then exception.syndrome = syndrome;

    <a link="impl-shared.ClearPendingVirtualSError.0" file="shared_pseudocode.xml" hover="function: ClearPendingVirtualSError()">ClearPendingVirtualSError</a>();
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/debug/AArch64.BreakpointException" mylink="aarch64.exceptions.debug.AArch64.BreakpointException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BreakpointException()
// =============================

<anchor link="AArch64.BreakpointException.1" hover="function: AArch64.BreakpointException(FaultRecord fault)">AArch64.BreakpointException</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1'));

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    bits(2) target_el;
    vect_offset = 0x0;
    target_el = if (PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2) then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    vaddress = bits(64) UNKNOWN;
    exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_Breakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</a>, fault, vaddress, target_el);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/debug/AArch64.SoftwareBreakpoint" mylink="aarch64.exceptions.debug.AArch64.SoftwareBreakpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SoftwareBreakpoint()
// ============================

<anchor link="AArch64.SoftwareBreakpoint.1" hover="function: AArch64.SoftwareBreakpoint(bits(16) immediate)">AArch64.SoftwareBreakpoint</anchor>(bits(16) immediate)

    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp;
                    <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1'));

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SoftwareBreakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</a>);
    exception.syndrome&lt;15:0&gt; = immediate;

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);
    elsif route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/debug/AArch64.SoftwareStepException" mylink="aarch64.exceptions.debug.AArch64.SoftwareStepException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SoftwareStepException()
// ===============================

<anchor link="AArch64.SoftwareStepException.0" hover="function: AArch64.SoftwareStepException()">AArch64.SoftwareStepException</anchor>()
    assert PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1'));

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SoftwareStep" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</a>);
    if <a link="impl-shared.SoftwareStep_DidNotStep.0" file="shared_pseudocode.xml" hover="function: boolean SoftwareStep_DidNotStep()">SoftwareStep_DidNotStep</a>() then
        exception.syndrome&lt;24&gt; = '0';
    else
        exception.syndrome&lt;24&gt; = '1';
        exception.syndrome&lt;6&gt; = if <a link="impl-shared.SoftwareStep_SteppedEX.0" file="shared_pseudocode.xml" hover="function: boolean SoftwareStep_SteppedEX()">SoftwareStep_SteppedEX</a>() then '1' else '0';
    exception.syndrome&lt;5:0&gt; = '100010';                // IFSC = Debug Exception

    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/debug/AArch64.VectorCatchException" mylink="aarch64.exceptions.debug.AArch64.VectorCatchException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.VectorCatchException()
// ==============================
// Vector Catch taken from EL0 or EL1 to EL2. This can only be called when debug exceptions are
// being routed to EL2, as Vector Catch is a legacy debug event.

<anchor link="AArch64.VectorCatchException.1" hover="function: AArch64.VectorCatchException(FaultRecord fault)">AArch64.VectorCatchException</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert PSTATE.EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    assert <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1');

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    vaddress = bits(64) UNKNOWN;
    exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_VectorCatch" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_VectorCatch</a>, fault, vaddress, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/debug/AArch64.WatchpointException" mylink="aarch64.exceptions.debug.AArch64.WatchpointException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.WatchpointException()
// =============================

<anchor link="AArch64.WatchpointException.2" hover="function: AArch64.WatchpointException(bits(64) vaddress, FaultRecord fault)">AArch64.WatchpointException</anchor>(bits(64) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    route_to_el2 = (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    (HCR_EL2.TGE == '1' || MDCR_EL2.TDE == '1'));

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    bits(2) target_el;
    vect_offset = 0x0;
    target_el = if (PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || route_to_el2) then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
    if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
        exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_NV2Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2Watchpoint</a>, fault, vaddress, target_el);
    else
        exception = <a link="AArch64.AbortSyndrome.4" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AbortSyndrome(Exception exceptype, FaultRecord fault, bits(64) vaddress, bits(2) target_el)">AArch64.AbortSyndrome</a>(<a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>, fault, vaddress, target_el);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/exceptions/AArch64.ExceptionClass" mylink="aarch64.exceptions.exceptions.AArch64.ExceptionClass" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ExceptionClass()
// ========================
// Returns the Exception Class and Instruction Length fields to be reported in ESR

(integer,bit) <anchor link="AArch64.ExceptionClass.2" hover="function: (integer,bit) AArch64.ExceptionClass(Exception exceptype, bits(2) target_el)">AArch64.ExceptionClass</anchor>(<a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype, bits(2) target_el)

    il_is_valid = TRUE;
    from_32 = <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    integer ec;
    case exceptype of
        when <a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>         ec = 0x00; il_is_valid = FALSE;
        when <a link="Exception_WFxTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_WFxTrap</a>               ec = 0x01;
        when <a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>            ec = 0x03; assert from_32;
        when <a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>           ec = 0x04; assert from_32;
        when <a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>            ec = 0x05; assert from_32;
        when <a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a>            ec = 0x06; assert from_32;
        when <a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>   ec = 0x07;
        when <a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>              ec = 0x08;
        when <a link="Exception_PACTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACTrap</a>               ec = 0x09;
        when <a link="Exception_LDST64BTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_LDST64BTrap</a>           ec = 0x0A;
        when <a link="Exception_TSTARTAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_TSTARTAccessTrap</a>      ec = 0x1B;
        when <a link="Exception_GPC" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GPC</a>                   ec = 0x1E;
        when <a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>           ec = 0x0C; assert from_32;
        when <a link="Exception_BranchTarget" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_BranchTarget</a>          ec = 0x0D;
        when <a link="Exception_IllegalState" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</a>          ec = 0x0E; il_is_valid = FALSE;
        when <a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>        ec = 0x11;
        when <a link="Exception_HypervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_HypervisorCall</a>        ec = 0x12;
        when <a link="Exception_MonitorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</a>           ec = 0x13;
        when <a link="Exception_SystemRegisterTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegisterTrap</a>    ec = 0x18; assert !from_32;
        when <a link="Exception_SystemRegister128Trap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegister128Trap</a> ec = 0x14; assert !from_32;
        when <a link="Exception_SVEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SVEAccessTrap</a>         ec = 0x19; assert !from_32;
        when <a link="Exception_ERetTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_ERetTrap</a>              ec = 0x1A; assert !from_32;
        when <a link="Exception_PACFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACFail</a>               ec = 0x1C; assert !from_32;
        when <a link="Exception_SMEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SMEAccessTrap</a>         ec = 0x1D; assert !from_32;
        when <a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>      ec = 0x20; il_is_valid = FALSE;
        when <a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>           ec = 0x22; il_is_valid = FALSE;
        when <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>             ec = 0x24;
        when <a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a>          ec = 0x25;
        when <a link="Exception_SPAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SPAlignment</a>           ec = 0x26; il_is_valid = FALSE; assert !from_32;
        when <a link="Exception_MemCpyMemSet" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MemCpyMemSet</a>          ec = 0x27;
        when <a link="Exception_GCSFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GCSFail</a>               ec = 0x2D; assert !from_32;
        when <a link="Exception_FPTrappedException" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPTrappedException</a>    ec = 0x28;
        when <a link="Exception_SError" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SError</a>                ec = 0x2F; il_is_valid = FALSE;
        when <a link="Exception_Breakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</a>            ec = 0x30; il_is_valid = FALSE;
        when <a link="Exception_SoftwareStep" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</a>          ec = 0x32; il_is_valid = FALSE;
        when <a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>            ec = 0x34; il_is_valid = FALSE;
        when <a link="Exception_NV2Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2Watchpoint</a>         ec = 0x35; il_is_valid = FALSE;
        when <a link="Exception_SoftwareBreakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</a>    ec = 0x38;
        when <a link="Exception_VectorCatch" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_VectorCatch</a>           ec = 0x3A; il_is_valid = FALSE; assert from_32;
        otherwise                            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    if ec IN {0x20,0x24,0x30,0x32,0x34} &amp;&amp; target_el == PSTATE.EL then
        ec = ec + 1;

    if ec IN {0x11,0x12,0x13,0x28,0x38} &amp;&amp; !from_32 then
        ec = ec + 4;
    bit il;
    if il_is_valid then
        il = if <a link="impl-shared.ThisInstrLength.0" file="shared_pseudocode.xml" hover="function: integer ThisInstrLength()">ThisInstrLength</a>() == 32 then '1' else '0';
    else
        il = '1';
    assert from_32 || il == '1';            // AArch64 instructions always 32-bit

    return (ec,il);</pstext>
    </ps>
    <ps name="aarch64/exceptions/exceptions/AArch64.ReportException" mylink="aarch64.exceptions.exceptions.AArch64.ReportException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ReportException()
// =========================
// Report syndrome information for exception taken to AArch64 state.

<anchor link="AArch64.ReportException.2" hover="function: AArch64.ReportException(ExceptionRecord exception, bits(2) target_el)">AArch64.ReportException</anchor>(<a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception, bits(2) target_el)

    <a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype = exception.exceptype;

    (ec,il) = <a link="AArch64.ExceptionClass.2" file="shared_pseudocode.xml" hover="function: (integer,bit) AArch64.ExceptionClass(Exception exceptype, bits(2) target_el)">AArch64.ExceptionClass</a>(exceptype, target_el);
    iss  = exception.syndrome;
    iss2 = exception.syndrome2;

    // IL is not valid for Data Abort exceptions without valid instruction syndrome information
    if ec IN {0x24,0x25} &amp;&amp; iss&lt;24&gt; == '0' then
        il = '1';

    <a link="impl-aarch64.ESR.write.1" file="shared_pseudocode.xml" hover="accessor: ESR[bits(2) regime] = ESRType value">ESR</a>[target_el] = (<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8)  :   // &lt;63:56&gt;
                      iss2      :   // &lt;55:32&gt;
                      ec&lt;5:0&gt;   :   // &lt;31:26&gt;
                      il        :   // &lt;25&gt;
                      iss);         // &lt;24:0&gt;

    if exceptype IN {
        <a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>,
        <a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>,
        <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>,
        <a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a>,
        <a link="Exception_NV2Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2Watchpoint</a>,
        <a link="Exception_GPC" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GPC</a>,
        <a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>
    } then
        <a link="impl-aarch64.FAR.write.1" file="shared_pseudocode.xml" hover="accessor: FAR[bits(2) regime] = bits(64) value">FAR</a>[target_el] = exception.vaddress;
    else
        <a link="impl-aarch64.FAR.write.1" file="shared_pseudocode.xml" hover="accessor: FAR[bits(2) regime] = bits(64) value">FAR</a>[target_el] = bits(64) UNKNOWN;

    if exception.ipavalid then
        HPFAR_EL2&lt;47:4&gt; = exception.ipaddress&lt;55:12&gt;;
        if <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>() &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
            HPFAR_EL2.NS = exception.NS;
        else
            HPFAR_EL2.NS = '0';
    elsif target_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        HPFAR_EL2&lt;47:4&gt; = bits(44) UNKNOWN;

    if exception.pavalid then
        MFAR_EL3.FPA = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(exception.paddress.address&lt;<a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>()-1:12&gt;, 44);
        case exception.paddress.paspace of
            when <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>     MFAR_EL3.&lt;NSE,NS&gt; = '00';
            when <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>  MFAR_EL3.&lt;NSE,NS&gt; = '01';
            when <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>       MFAR_EL3.&lt;NSE,NS&gt; = '10';
            when <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>      MFAR_EL3.&lt;NSE,NS&gt; = '11';
    return;</pstext>
    </ps>
    <ps name="aarch64/exceptions/exceptions/AArch64.ResetControlRegisters" mylink="aarch64.exceptions.exceptions.AArch64.ResetControlRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ResetControlRegisters()
// ===============================
// Resets System registers and memory-mapped control registers that have architecturally-defined
// reset values to those values.

<anchor link="AArch64.ResetControlRegisters.1" hover="function: AArch64.ResetControlRegisters(boolean cold_reset)">AArch64.ResetControlRegisters</anchor>(boolean cold_reset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/exceptions/AArch64.TakeReset" mylink="aarch64.exceptions.exceptions.AArch64.TakeReset" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakeReset()
// ===================
// Reset into AArch64 state

<anchor link="AArch64.TakeReset.1" hover="function: AArch64.TakeReset(boolean cold_reset)">AArch64.TakeReset</anchor>(boolean cold_reset)
    assert <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>();

    // Enter the highest implemented Exception level in AArch64 state
    PSTATE.nRW = '0';
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        PSTATE.EL = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        PSTATE.EL = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        PSTATE.EL = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    // Reset System registers
    // and other system components
    <a link="AArch64.ResetControlRegisters.1" file="shared_pseudocode.xml" hover="function: AArch64.ResetControlRegisters(boolean cold_reset)">AArch64.ResetControlRegisters</a>(cold_reset);

    // Reset all other PSTATE fields
    PSTATE.SP = '1';                    // Select stack pointer
    PSTATE.&lt;D,A,I,F&gt;  = '1111';         // All asynchronous exceptions masked
    PSTATE.SS = '0';                    // Clear software step bit
    PSTATE.DIT = '0';                   // PSTATE.DIT is reset to 0 when resetting into AArch64
    PSTATE.IL = '0';                    // Clear Illegal Execution state bit

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then TSTATE.depth = 0;             // Non-transactional state

    // All registers, bits and fields not reset by the above pseudocode or by the BranchTo() call
    // below are UNKNOWN bitstrings after reset. In particular, the return information registers
    // ELR_ELx and SPSR_ELx have UNKNOWN values, so that it
    // is impossible to return from a reset in an architecturally defined way.
    <a link="AArch64.ResetGeneralRegisters.0" file="shared_pseudocode.xml" hover="function: AArch64.ResetGeneralRegisters()">AArch64.ResetGeneralRegisters</a>();
    <a link="AArch64.ResetSIMDFPRegisters.0" file="shared_pseudocode.xml" hover="function: AArch64.ResetSIMDFPRegisters()">AArch64.ResetSIMDFPRegisters</a>();
    <a link="AArch64.ResetSpecialRegisters.0" file="shared_pseudocode.xml" hover="function: AArch64.ResetSpecialRegisters()">AArch64.ResetSpecialRegisters</a>();
    <a link="impl-shared.ResetExternalDebugRegisters.1" file="shared_pseudocode.xml" hover="function: ResetExternalDebugRegisters(boolean cold_reset)">ResetExternalDebugRegisters</a>(cold_reset);

    bits(64) rv;                      // IMPLEMENTATION DEFINED reset vector

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        rv = RVBAR_EL3;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        rv = RVBAR_EL2;
    else
        rv = RVBAR_EL1;

    // The reset vector must be correctly aligned
    assert <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(rv&lt;63:<a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>()&gt;) &amp;&amp; <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(rv&lt;1:0&gt;);

    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(rv, <a link="BranchType_RESET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RESET</a>, branch_conditional);</pstext>
    </ps>
    <ps name="aarch64/exceptions/ieeefp/AArch64.FPTrappedException" mylink="aarch64.exceptions.ieeefp.AArch64.FPTrappedException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.FPTrappedException()
// ============================

<anchor link="AArch64.FPTrappedException.2" hover="function: AArch64.FPTrappedException(boolean is_ase, bits(8) accumulated_exceptions)">AArch64.FPTrappedException</anchor>(boolean is_ase, bits(8) accumulated_exceptions)
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_FPTrappedException" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPTrappedException</a>);
    if is_ase then
        if boolean IMPLEMENTATION_DEFINED "vector instructions set TFV to 1" then
            exception.syndrome&lt;23&gt; = '1';                          // TFV
        else
            exception.syndrome&lt;23&gt; = '0';                          // TFV
    else
        exception.syndrome&lt;23&gt; = '1';                              // TFV
    exception.syndrome&lt;10:8&gt; = bits(3) UNKNOWN;                    // VECITR
    if exception.syndrome&lt;23&gt; == '1' then
        exception.syndrome&lt;7,4:0&gt; = accumulated_exceptions&lt;7,4:0&gt;; // IDF,IXF,UFF,OFF,DZF,IOF
    else
        exception.syndrome&lt;7,4:0&gt; = bits(6) UNKNOWN;

    route_to_el2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);
    elsif route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/syscalls/AArch64.CallHypervisor" mylink="aarch64.exceptions.syscalls.AArch64.CallHypervisor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CallHypervisor()
// ========================
// Performs a HVC call

<anchor link="AArch64.CallHypervisor.1" hover="function: AArch64.CallHypervisor(bits(16) immediate)">AArch64.CallHypervisor</anchor>(bits(16) immediate)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then <a link="AArch32.ITAdvance.0" file="shared_pseudocode.xml" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</a>();
    <a link="impl-shared.SSAdvance.0" file="shared_pseudocode.xml" hover="function: SSAdvance()">SSAdvance</a>();
    bits(64) preferred_exception_return = <a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_HypervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_HypervisorCall</a>);
    exception.syndrome&lt;15:0&gt; = immediate;

    if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/syscalls/AArch64.CallSecureMonitor" mylink="aarch64.exceptions.syscalls.AArch64.CallSecureMonitor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CallSecureMonitor()
// ===========================

<anchor link="AArch64.CallSecureMonitor.1" hover="function: AArch64.CallSecureMonitor(bits(16) immediate)">AArch64.CallSecureMonitor</anchor>(bits(16) immediate)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then <a link="AArch32.ITAdvance.0" file="shared_pseudocode.xml" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</a>();
    <a link="impl-shared.SSAdvance.0" file="shared_pseudocode.xml" hover="function: SSAdvance()">SSAdvance</a>();
    bits(64) preferred_exception_return = <a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_MonitorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</a>);
    exception.syndrome&lt;15:0&gt; = immediate;

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/syscalls/AArch64.CallSupervisor" mylink="aarch64.exceptions.syscalls.AArch64.CallSupervisor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CallSupervisor()
// ========================
// Calls the Supervisor

<anchor link="AArch64.CallSupervisor.1" hover="function: AArch64.CallSupervisor(bits(16) immediate_in)">AArch64.CallSupervisor</anchor>(bits(16) immediate_in)
    bits(16) immediate = immediate_in;
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then <a link="AArch32.ITAdvance.0" file="shared_pseudocode.xml" hover="function: AArch32.ITAdvance()">AArch32.ITAdvance</a>();
    <a link="impl-shared.SSAdvance.0" file="shared_pseudocode.xml" hover="function: SSAdvance()">SSAdvance</a>();
    route_to_el2 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';

    bits(64) preferred_exception_return = <a link="impl-shared.NextInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>);
    exception.syndrome&lt;15:0&gt; = immediate;

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);
    elsif route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/takeexception/AArch64.TakeException" mylink="aarch64.exceptions.takeexception.AArch64.TakeException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TakeException()
// =======================
// Take an exception to an Exception level using AArch64.

<anchor link="AArch64.TakeException.4" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</anchor>(bits(2) target_el, <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception_in,
                      bits(64) preferred_exception_return, integer vect_offset_in)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(target_el) &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);
    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        <a link="AArch64.TakeExceptionInDebugState.2" file="shared_pseudocode.xml" hover="function: AArch64.TakeExceptionInDebugState(bits(2) target_el, ExceptionRecord exception_in)">AArch64.TakeExceptionInDebugState</a>(target_el, exception_in);
        return;
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception = exception_in;
    boolean sync_errors;
    boolean iesb_req;
    if <a link="impl-shared.HaveIESB.0" file="shared_pseudocode.xml" hover="function: boolean HaveIESB()">HaveIESB</a>() then
        sync_errors = <a link="impl-aarch64.SCTLR.read.1" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[bits(2) regime]">SCTLR</a>[target_el].IESB == '1';
        if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() then
            sync_errors = sync_errors || (SCR_EL3.&lt;EA,NMEA&gt; == '11' &amp;&amp; target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        if sync_errors &amp;&amp; <a link="impl-shared.InsertIESBBeforeException.1" file="shared_pseudocode.xml" hover="function: boolean InsertIESBBeforeException(bits(2) el)">InsertIESBBeforeException</a>(target_el) then
            <a link="impl-shared.SynchronizeErrors.0" file="shared_pseudocode.xml" hover="function: SynchronizeErrors()">SynchronizeErrors</a>();
            iesb_req = FALSE;
            sync_errors = FALSE;
            <a link="impl-shared.TakeUnmaskedPhysicalSErrorInterrupts.1" file="shared_pseudocode.xml" hover="function: TakeUnmaskedPhysicalSErrorInterrupts(boolean iesb_req)">TakeUnmaskedPhysicalSErrorInterrupts</a>(iesb_req);
    else
        sync_errors = FALSE;

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then
        <a link="TMFailure" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure</a> cause;
        case exception.exceptype of
            when <a link="Exception_SoftwareBreakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</a> cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            when <a link="Exception_Breakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</a>         cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            when <a link="Exception_Watchpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</a>         cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            when <a link="Exception_SoftwareStep" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</a>       cause = <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>;
            otherwise                         cause = <a link="TMFailure_ERR" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</a>;
        <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(cause, FALSE);

    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();

    // If coming from AArch32 state, the top parts of the X[] registers might be set to zero
    from_32 = <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    if from_32 then <a link="AArch64.MaybeZeroRegisterUppers.0" file="shared_pseudocode.xml" hover="function: AArch64.MaybeZeroRegisterUppers()">AArch64.MaybeZeroRegisterUppers</a>();
    if from_32 &amp;&amp; <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then
        <a link="impl-aarch64.ResetSVEState.0" file="shared_pseudocode.xml" hover="function: ResetSVEState()">ResetSVEState</a>();
    else
        <a link="impl-aarch64.MaybeZeroSVEUppers.1" file="shared_pseudocode.xml" hover="function: MaybeZeroSVEUppers(bits(2) target_el)">MaybeZeroSVEUppers</a>(target_el);

    integer vect_offset = vect_offset_in;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) then
        boolean lower_32;
        if target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
                lower_32 = <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
            else
                lower_32 = <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
        elsif <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; target_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            lower_32 = <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>);
        else
            lower_32 = <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(target_el - 1);
        vect_offset = vect_offset + (if lower_32 then 0x600 else 0x400);

    elsif PSTATE.SP == '1' then
        vect_offset = vect_offset + 0x200;

    bits(64) spsr = <a link="impl-shared.GetPSRFromPSTATE.2" file="shared_pseudocode.xml" hover="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N)">GetPSRFromPSTATE</a>(<a link="AArch64_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch64_NonDebugState</a>, 64);

    if PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; (HCR_EL2.&lt;NV,NV1,NV2&gt; == '100' || HCR_EL2.&lt;NV,NV1,NV2&gt; == '111') then
            spsr&lt;3:2&gt; = '10';
        else
            if <a link="impl-shared.HaveNVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveNVExt()">HaveNVExt</a>() &amp;&amp; HCR_EL2.&lt;NV,NV1&gt; == '10' then
                spsr&lt;3:2&gt; = '10';

    if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        boolean zero_btype;
        // SPSR[].BTYPE is only guaranteed valid for these exception types
        if exception.exceptype IN {<a link="Exception_SError" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SError</a>, <a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>, <a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>,
                              <a link="Exception_SoftwareStep" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</a>, <a link="Exception_PCAlignment" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</a>,
                              <a link="Exception_InstructionAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</a>, <a link="Exception_Breakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</a>,
                              <a link="Exception_VectorCatch" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_VectorCatch</a>, <a link="Exception_SoftwareBreakpoint" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</a>,
                              <a link="Exception_IllegalState" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</a>, <a link="Exception_BranchTarget" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_BranchTarget</a>} then
            zero_btype = FALSE;
        else
            zero_btype = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ZEROBTYPE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ZEROBTYPE</a>);
        if zero_btype then spsr&lt;11:10&gt; = '00';

    if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; exception.exceptype == <a link="Exception_NV2DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</a> &amp;&amp; target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        // External aborts are configured to be taken to EL3
        exception.exceptype = <a link="Exception_DataAbort" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</a>;
    if !(exception.exceptype IN {<a link="Exception_IRQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</a>, <a link="Exception_FIQ" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</a>}) then
        <a link="AArch64.ReportException.2" file="shared_pseudocode.xml" hover="function: AArch64.ReportException(ExceptionRecord exception, bits(2) target_el)">AArch64.ReportException</a>(exception, target_el);

    if <a link="impl-shared.HaveBRBExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBExt()">HaveBRBExt</a>() then
        <a link="impl-aarch64.BRBEException.5" file="shared_pseudocode.xml" hover="function: BRBEException(ExceptionRecord erec, bits(64) preferred_exception_return, bits(64) target_address_in, bits(2) target_el, boolean trappedsyscallinst)">BRBEException</a>(exception, preferred_exception_return,
                      <a link="impl-aarch64.VBAR.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) VBAR[bits(2) regime]">VBAR</a>[target_el]&lt;63:11&gt;:vect_offset&lt;10:0&gt;, target_el,
                      exception.trappedsyscallinst);

    if PSTATE.EL == target_el then
        if <a link="impl-aarch64.GetCurrentEXLOCKEN.0" file="shared_pseudocode.xml" hover="function: boolean GetCurrentEXLOCKEN()">GetCurrentEXLOCKEN</a>() then
            PSTATE.EXLOCK = '1';
        else
            PSTATE.EXLOCK = '0';
    else
        PSTATE.EXLOCK = '0';

    PSTATE.EL = target_el;
    PSTATE.nRW = '0';
    PSTATE.SP = '1';

    <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = spsr;
    <a link="impl-aarch64.ELR.write.0" file="shared_pseudocode.xml" hover="accessor: ELR[] = bits(64) value">ELR</a>[] = preferred_exception_return;

    PSTATE.SS = '0';
    if <a link="impl-shared.HaveFeatNMI.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatNMI()">HaveFeatNMI</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(target_el) then PSTATE.ALLINT = NOT <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].SPINTMASK;
    PSTATE.&lt;D,A,I,F&gt; = '1111';
    PSTATE.IL = '0';
    if from_32 then                             // Coming from AArch32
        PSTATE.IT = '00000000';
        PSTATE.T = '0';                         // PSTATE.J is RES0
    if (<a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>))) &amp;&amp;
        <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].SPAN == '0') then
        PSTATE.PAN = '1';
    if <a link="impl-shared.HaveUAOExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveUAOExt()">HaveUAOExt</a>() then PSTATE.UAO = '0';
    if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then PSTATE.BTYPE = '00';
    if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].DSSBS;
    if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() then PSTATE.TCO = '1';

    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(<a link="impl-aarch64.VBAR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) VBAR[]">VBAR</a>[]&lt;63:11&gt;:vect_offset&lt;10:0&gt;, <a link="BranchType_EXCEPTION" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_EXCEPTION</a>, branch_conditional);

    <a link="impl-shared.CheckExceptionCatch.1" file="shared_pseudocode.xml" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</a>(TRUE);                  // Check for debug event on exception entry

    if sync_errors then
        <a link="impl-shared.SynchronizeErrors.0" file="shared_pseudocode.xml" hover="function: SynchronizeErrors()">SynchronizeErrors</a>();
        iesb_req = TRUE;
        <a link="impl-shared.TakeUnmaskedPhysicalSErrorInterrupts.1" file="shared_pseudocode.xml" hover="function: TakeUnmaskedPhysicalSErrorInterrupts(boolean iesb_req)">TakeUnmaskedPhysicalSErrorInterrupts</a>(iesb_req);

    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.AArch32SystemAccessTrap" mylink="aarch64.exceptions.traps.AArch64.AArch32SystemAccessTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AArch32SystemAccessTrap()
// =================================
// Trapped AARCH32 System register access.

<anchor link="AArch64.AArch32SystemAccessTrap.2" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</anchor>(bits(2) target_el, integer ec)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) &amp;&amp; target_el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="AArch64.AArch32SystemAccessTrapSyndrome.2" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.AArch32SystemAccessTrapSyndrome(bits(32) instr, integer ec)">AArch64.AArch32SystemAccessTrapSyndrome</a>(<a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>(), ec);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.AArch32SystemAccessTrapSyndrome" mylink="aarch64.exceptions.traps.AArch64.AArch32SystemAccessTrapSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AArch32SystemAccessTrapSyndrome()
// =========================================
// Returns the syndrome information for traps on AArch32 MCR, MCRR, MRC, MRRC, and VMRS,
// VMSR instructions, other than traps that are due to HCPTR or CPACR.

ExceptionRecord <anchor link="AArch64.AArch32SystemAccessTrapSyndrome.2" hover="function: ExceptionRecord AArch64.AArch32SystemAccessTrapSyndrome(bits(32) instr, integer ec)">AArch64.AArch32SystemAccessTrapSyndrome</anchor>(bits(32) instr, integer ec)
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;

    case ec of
        when 0x0    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);
        when 0x3    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>);
        when 0x4    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>);
        when 0x5    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>);
        when 0x6    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a>);
        when 0x7    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>);
        when 0x8    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>);
        when 0xC    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>);
        otherwise   <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    bits(20) iss = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(20);

    if exception.exceptype == <a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a> then
        return exception;
    elsif exception.exceptype IN {<a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a>, <a link="Exception_CP14RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</a>,
                                  <a link="Exception_CP15RTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</a>} then
        // Trapped MRC/MCR, VMRS on FPSID
        if exception.exceptype != <a link="Exception_FPIDTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</a> then    // When trap is not for VMRS
            iss&lt;19:17&gt; = instr&lt;7:5&gt;;           // opc2
            iss&lt;16:14&gt; = instr&lt;23:21&gt;;         // opc1
            iss&lt;13:10&gt; = instr&lt;19:16&gt;;         // CRn
            iss&lt;4:1&gt;   = instr&lt;3:0&gt;;           // CRm
        else
            iss&lt;19:17&gt; = '000';
            iss&lt;16:14&gt; = '111';
            iss&lt;13:10&gt; = instr&lt;19:16&gt;;         // reg
            iss&lt;4:1&gt;   = '0000';

        if instr&lt;20&gt; == '1' &amp;&amp; instr&lt;15:12&gt; == '1111' then    // MRC, Rt==15
            iss&lt;9:5&gt; = '11111';
        elsif instr&lt;20&gt; == '0' &amp;&amp; instr&lt;15:12&gt; == '1111' then // MCR, Rt==15
            iss&lt;9:5&gt; = bits(5) UNKNOWN;
        else
            iss&lt;9:5&gt; = LookUpRIndex(UInt(instr&lt;15:12&gt;), PSTATE.M)&lt;4:0&gt;;
    elsif exception.exceptype IN {<a link="Exception_CP14RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</a>, <a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>,
                                  <a link="Exception_CP15RRTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</a>} then
        // Trapped MRRC/MCRR, VMRS/VMSR
        iss&lt;19:16&gt; = instr&lt;7:4&gt;;          // opc1
        if instr&lt;19:16&gt; == '1111' then    // Rt2==15
            iss&lt;14:10&gt; = bits(5) UNKNOWN;
        else
            iss&lt;14:10&gt; = LookUpRIndex(UInt(instr&lt;19:16&gt;), PSTATE.M)&lt;4:0&gt;;

        if instr&lt;15:12&gt; == '1111' then    // Rt==15
            iss&lt;9:5&gt; = bits(5) UNKNOWN;
        else
            iss&lt;9:5&gt; = LookUpRIndex(UInt(instr&lt;15:12&gt;), PSTATE.M)&lt;4:0&gt;;
        iss&lt;4:1&gt;   = instr&lt;3:0&gt;;         // CRm
    elsif exception.exceptype == <a link="Exception_CP14DTTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</a> then
        // Trapped LDC/STC
        iss&lt;19:12&gt; = instr&lt;7:0&gt;;         // imm8
        iss&lt;4&gt;     = instr&lt;23&gt;;          // U
        iss&lt;2:1&gt;   = instr&lt;24,21&gt;;       // P,W
        if instr&lt;19:16&gt; == '1111' then   // Rn==15, LDC(Literal addressing)/STC
            iss&lt;9:5&gt; = bits(5) UNKNOWN;
            iss&lt;3&gt;   = '1';
    iss&lt;0&gt; = instr&lt;20&gt;;                  // Direction

    exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();
    exception.syndrome&lt;19:0&gt;  = iss;

    return exception;</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.AdvSIMDFPAccessTrap" mylink="aarch64.exceptions.traps.AArch64.AdvSIMDFPAccessTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AdvSIMDFPAccessTrap()
// =============================
// Trapped access to Advanced SIMD or FP registers due to CPACR[].

<anchor link="AArch64.AdvSIMDFPAccessTrap.1" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</anchor>(bits(2) target_el)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
    vect_offset = 0x0;

    route_to_el2 = (target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1');

    if route_to_el2 then
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>);
        exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);

    return;</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckCP15InstrCoarseTraps" mylink="aarch64.exceptions.traps.AArch64.CheckCP15InstrCoarseTraps" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckCP15InstrCoarseTraps()
// ===================================
// Check for coarse-grained AArch32  traps to System registers in the
// coproc=0b1111 encoding space by HSTR_EL2, HCR_EL2, and SCTLR_ELx.

<anchor link="AArch64.CheckCP15InstrCoarseTraps.3" hover="function: AArch64.CheckCP15InstrCoarseTraps(integer CRn, integer nreg, integer CRm)">AArch64.CheckCP15InstrCoarseTraps</anchor>(integer CRn, integer nreg, integer CRm)
    trapped_encoding = ((CRn == 9  &amp;&amp; CRm IN {0,1,2,    5,6,7,8   }) ||
                        (CRn == 10 &amp;&amp; CRm IN {0,1,    4,      8   }) ||
                        (CRn == 11 &amp;&amp; CRm IN {0,1,2,3,4,5,6,7,8,15}));

    // Check for MRC and MCR disabled by SCTLR_EL1.TIDCP.
    if (<a link="impl-shared.HaveFeatTIDCP1.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatTIDCP1()">HaveFeatTIDCP1</a>() &amp;&amp; PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp;
           !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; SCTLR_EL1.TIDCP == '1' &amp;&amp; trapped_encoding) then
        if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
            <a link="AArch64.AArch32SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, 0x3);
        else
            <a link="AArch64.AArch32SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, 0x3);

    // Check for coarse-grained Hyp traps
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        // Check for MRC and MCR disabled by SCTLR_EL2.TIDCP.
        if (<a link="impl-shared.HaveFeatTIDCP1.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatTIDCP1()">HaveFeatTIDCP1</a>() &amp;&amp; PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp;
                SCTLR_EL2.TIDCP == '1' &amp;&amp; trapped_encoding) then
            <a link="AArch64.AArch32SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, 0x3);

        major = if nreg == 1 then CRn else CRm;
        // Check for MCR, MRC, MCRR, and MRRC disabled by HSTR_EL2&lt;CRn/CRm&gt;
        // and MRC and MCR disabled by HCR_EL2.TIDCP.
        if ((!<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; !(major IN {4,14}) &amp;&amp; HSTR_EL2&lt;major&gt; == '1') ||
                (HCR_EL2.TIDCP == '1' &amp;&amp; nreg == 1 &amp;&amp; trapped_encoding)) then
            if (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp;
                    boolean IMPLEMENTATION_DEFINED "UNDEF unallocated CP15 access at <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>") then
                UNDEFINED;
            <a link="AArch64.AArch32SystemAccessTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.AArch32SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.AArch32SystemAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, 0x3);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckFPAdvSIMDEnabled" mylink="aarch64.exceptions.traps.AArch64.CheckFPAdvSIMDEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckFPAdvSIMDEnabled()
// ===============================

<anchor link="AArch64.CheckFPAdvSIMDEnabled.0" hover="function: AArch64.CheckFPAdvSIMDEnabled()">AArch64.CheckFPAdvSIMDEnabled</anchor>()
    <a link="AArch64.CheckFPEnabled.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPEnabled()">AArch64.CheckFPEnabled</a>();
    // Check for illegal use of Advanced
    // SIMD in Streaming SVE Mode
    if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' &amp;&amp; !<a link="impl-aarch64.IsFullA64Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsFullA64Enabled()">IsFullA64Enabled</a>() then
        <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_Streaming" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_Streaming</a>, PSTATE.EL);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckFPAdvSIMDTrap" mylink="aarch64.exceptions.traps.AArch64.CheckFPAdvSIMDTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckFPAdvSIMDTrap()
// ============================
// Check against CPTR_EL2 and CPTR_EL3.

<anchor link="AArch64.CheckFPAdvSIMDTrap.0" hover="function: AArch64.CheckFPAdvSIMDTrap()">AArch64.CheckFPAdvSIMDTrap</anchor>()
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; CPTR_EL3.TFP == '1' &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;

    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        // Check if access disabled in CPTR_EL2
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            boolean disabled;
            case CPTR_EL2.FPEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        else
            if CPTR_EL2.TFP == '1' then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        // Check if access disabled in CPTR_EL3
        if CPTR_EL3.TFP == '1' then
            if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
                UNDEFINED;
            else
                <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckFPEnabled" mylink="aarch64.exceptions.traps.AArch64.CheckFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckFPEnabled()
// ========================
// Check against CPACR[]

<anchor link="AArch64.CheckFPEnabled.0" hover="function: AArch64.CheckFPEnabled()">AArch64.CheckFPEnabled</anchor>()
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check if access disabled in CPACR_EL1
        boolean disabled;
        case CPACR_EL1.FPEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    <a link="AArch64.CheckFPAdvSIMDTrap.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPAdvSIMDTrap()">AArch64.CheckFPAdvSIMDTrap</a>();               // Also check against CPTR_EL2 and CPTR_EL3</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckForERetTrap" mylink="aarch64.exceptions.traps.AArch64.CheckForERetTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckForERetTrap()
// ==========================
// Check for trap on ERET, ERETAA, ERETAB instruction

<anchor link="AArch64.CheckForERetTrap.2" hover="function: AArch64.CheckForERetTrap(boolean eret_with_pac, boolean pac_uses_key_a)">AArch64.CheckForERetTrap</anchor>(boolean eret_with_pac, boolean pac_uses_key_a)

    route_to_el2 = FALSE;
    // Non-secure EL1 execution of ERET, ERETAA, ERETAB when either HCR_EL2.NV or
    // HFGITR_EL2.ERET is set, is trapped to EL2
    route_to_el2 = (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                    ((<a link="impl-shared.HaveNVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveNVExt()">HaveNVExt</a>() &amp;&amp; HCR_EL2.NV == '1') ||
                     (<a link="impl-shared.HaveFGTExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveFGTExt()">HaveFGTExt</a>() &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || SCR_EL3.FGTEn == '1') &amp;&amp;
                      HFGITR_EL2.ERET == '1')));
    if route_to_el2 then
        <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
        bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
        vect_offset = 0x0;
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_ERetTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_ERetTrap</a>);
        if !eret_with_pac then                             // ERET
            exception.syndrome&lt;1&gt; = '0';
            exception.syndrome&lt;0&gt; = '0';                   // RES0
        else
            exception.syndrome&lt;1&gt; = '1';
            if pac_uses_key_a then                         // ERETAA
                exception.syndrome&lt;0&gt; = '0';
            else    // ERETAB
                exception.syndrome&lt;0&gt; = '1';
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckForSMCUndefOrTrap" mylink="aarch64.exceptions.traps.AArch64.CheckForSMCUndefOrTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckForSMCUndefOrTrap()
// ================================
// Check for UNDEFINED or trap on SMC instruction

<anchor link="AArch64.CheckForSMCUndefOrTrap.1" hover="function: AArch64.CheckForSMCUndefOrTrap(bits(16) imm)">AArch64.CheckForSMCUndefOrTrap</anchor>(bits(16) imm)
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then UNDEFINED;
    if (!(PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TSC == '1') &amp;&amp;
        <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.SMD == '1') then
        UNDEFINED;
    route_to_el2 = FALSE;
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
            if <a link="impl-shared.HaveNVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveNVExt()">HaveNVExt</a>() &amp;&amp; HCR_EL2.NV == '1' &amp;&amp; HCR_EL2.TSC == '1' then
                route_to_el2 = TRUE;
            else
                UNDEFINED;
        else
            UNDEFINED;
    else
        route_to_el2 = PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TSC == '1';
    if route_to_el2 then
        bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
        vect_offset = 0x0;
        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_MonitorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</a>);
        exception.syndrome&lt;15:0&gt; = imm;
        exception.trappedsyscallinst = TRUE;
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckForSVCTrap" mylink="aarch64.exceptions.traps.AArch64.CheckForSVCTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckForSVCTrap()
// =========================
// Check for trap on SVC instruction

<anchor link="AArch64.CheckForSVCTrap.1" hover="function: AArch64.CheckForSVCTrap(bits(16) immediate)">AArch64.CheckForSVCTrap</anchor>(bits(16) immediate)
    if <a link="impl-shared.HaveFGTExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveFGTExt()">HaveFGTExt</a>() then
        route_to_el2 = FALSE;
        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            route_to_el2 = (!<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp;
                           <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HFGITR_EL2.SVC_EL0 == '1' &amp;&amp;
                           (HCR_EL2.&lt;E2H, TGE&gt; != '11' &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || SCR_EL3.FGTEn == '1')));

        elsif PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
            route_to_el2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HFGITR_EL2.SVC_EL1 == '1' &amp;&amp;
                           (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || SCR_EL3.FGTEn == '1'));

        if route_to_el2 then
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SupervisorCall" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</a>);
            exception.syndrome&lt;15:0&gt; = immediate;
            exception.trappedsyscallinst = TRUE;
            bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
            vect_offset = 0x0;

            <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckForWFxTrap" mylink="aarch64.exceptions.traps.AArch64.CheckForWFxTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckForWFxTrap()
// =========================
// Check for trap on WFE or WFI instruction

<anchor link="AArch64.CheckForWFxTrap.2" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</anchor>(bits(2) target_el, <a link="WFxType" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType</a> wfxtype)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el);

    boolean is_wfe = wfxtype IN {<a link="WFxType_WFE" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFE</a>, <a link="WFxType_WFET" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFET</a>};
    boolean trap;
    case target_el of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            trap = (if is_wfe then <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].nTWE else <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].nTWI) == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            trap = (if is_wfe then HCR_EL2.TWE else HCR_EL2.TWI) == '1';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            trap = (if is_wfe then SCR_EL3.TWE else SCR_EL3.TWI) == '1';

    if trap then
        <a link="AArch64.WFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.WFxTrap(WFxType wfxtype, bits(2) target_el)">AArch64.WFxTrap</a>(wfxtype, target_el);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.CheckIllegalState" mylink="aarch64.exceptions.traps.AArch64.CheckIllegalState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckIllegalState()
// ===========================
// Check PSTATE.IL bit and generate Illegal Execution state exception if set.

<anchor link="AArch64.CheckIllegalState.0" hover="function: AArch64.CheckIllegalState()">AArch64.CheckIllegalState</anchor>()
    if PSTATE.IL == '1' then
        route_to_el2 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';

        bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
        vect_offset = 0x0;

        exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_IllegalState" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</a>);

        if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
            <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);
        elsif route_to_el2 then
            <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
        else
            <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.MonitorModeTrap" mylink="aarch64.exceptions.traps.AArch64.MonitorModeTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MonitorModeTrap()
// =========================
// Trapped use of Monitor mode features in a Secure EL1 AArch32 mode

<anchor link="AArch64.MonitorModeTrap.0" hover="function: AArch64.MonitorModeTrap()">AArch64.MonitorModeTrap</anchor>()
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);

    if <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>() then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.SystemAccessTrap" mylink="aarch64.exceptions.traps.AArch64.SystemAccessTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SystemAccessTrap()
// ==========================
// Trapped access to AArch64 System register or system instruction.

<anchor link="AArch64.SystemAccessTrap.2" hover="function: AArch64.SystemAccessTrap(bits(2) target_el, integer ec)">AArch64.SystemAccessTrap</anchor>(bits(2) target_el, integer ec)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) &amp;&amp; target_el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="AArch64.SystemAccessTrapSyndrome.2" file="shared_pseudocode.xml" hover="function: ExceptionRecord AArch64.SystemAccessTrapSyndrome(bits(32) instr_in, integer ec)">AArch64.SystemAccessTrapSyndrome</a>(<a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>(), ec);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.SystemAccessTrapSyndrome" mylink="aarch64.exceptions.traps.AArch64.SystemAccessTrapSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SystemAccessTrapSyndrome()
// ==================================
// Returns the syndrome information for traps on AArch64 MSR/MRS instructions.

ExceptionRecord <anchor link="AArch64.SystemAccessTrapSyndrome.2" hover="function: ExceptionRecord AArch64.SystemAccessTrapSyndrome(bits(32) instr_in, integer ec)">AArch64.SystemAccessTrapSyndrome</anchor>(bits(32) instr_in, integer ec)
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
    bits(32) instr = instr_in;
    case ec of
        when 0x0                         // Trapped access due to unknown reason.
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);
        when 0x7                         // Trapped access to SVE, Advance SIMD&amp;FP System register.
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_AdvSIMDFPAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</a>);
            exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();
        when 0x14                        // Trapped access to 128-bit System register or
                                         // 128-bit System instruction.
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SystemRegister128Trap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegister128Trap</a>);
            instr = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>();
            exception.syndrome&lt;21:20&gt; = instr&lt;20:19&gt;; // Op0
            exception.syndrome&lt;19:17&gt; = instr&lt;7:5&gt;;   // Op2
            exception.syndrome&lt;16:14&gt; = instr&lt;18:16&gt;; // Op1
            exception.syndrome&lt;13:10&gt; = instr&lt;15:12&gt;; // CRn
            exception.syndrome&lt;9:6&gt;   = instr&lt;4:1&gt;;   // Rt
            exception.syndrome&lt;4:1&gt;   = instr&lt;11:8&gt;;  // CRm
            exception.syndrome&lt;0&gt;     = instr&lt;21&gt;;    // Direction
        when 0x18                        // Trapped access to System register or system instruction.
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SystemRegisterTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegisterTrap</a>);
            instr = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>();
            exception.syndrome&lt;21:20&gt; = instr&lt;20:19&gt;; // Op0
            exception.syndrome&lt;19:17&gt; = instr&lt;7:5&gt;;   // Op2
            exception.syndrome&lt;16:14&gt; = instr&lt;18:16&gt;; // Op1
            exception.syndrome&lt;13:10&gt; = instr&lt;15:12&gt;; // CRn
            exception.syndrome&lt;9:5&gt;   = instr&lt;4:0&gt;;   // Rt
            exception.syndrome&lt;4:1&gt;   = instr&lt;11:8&gt;;  // CRm
            exception.syndrome&lt;0&gt;     = instr&lt;21&gt;;    // Direction
        when 0x19                        // Trapped access to SVE System register
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SVEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SVEAccessTrap</a>);
        when 0x1D                        // Trapped access to SME System register
            exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SMEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SMEAccessTrap</a>);
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    return exception;</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.UndefinedFault" mylink="aarch64.exceptions.traps.AArch64.UndefinedFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.UndefinedFault()
// ========================

<anchor link="AArch64.UndefinedFault.0" hover="function: AArch64.UndefinedFault()">AArch64.UndefinedFault</anchor>()

    route_to_el2 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_Uncategorized" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</a>);

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);
    elsif route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/AArch64.WFxTrap" mylink="aarch64.exceptions.traps.AArch64.WFxTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.WFxTrap()
// =================

<anchor link="AArch64.WFxTrap.2" hover="function: AArch64.WFxTrap(WFxType wfxtype, bits(2) target_el)">AArch64.WFxTrap</anchor>(<a link="WFxType" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType</a> wfxtype, bits(2) target_el)
    assert <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_WFxTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_WFxTrap</a>);
    exception.syndrome&lt;24:20&gt; = <a link="impl-shared.ConditionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</a>();

    case wfxtype of
        when <a link="WFxType_WFI" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFI</a>
            exception.syndrome&lt;1:0&gt; = '00';
        when <a link="WFxType_WFE" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFE</a>
            exception.syndrome&lt;1:0&gt; = '01';
        when <a link="WFxType_WFIT" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFIT</a>
            exception.syndrome&lt;1:0&gt; = '10';
            exception.syndrome&lt;2&gt;   = '1';   // Register field is valid
            exception.syndrome&lt;9:5&gt; = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>()&lt;4:0&gt;;
        when <a link="WFxType_WFET" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFET</a>
            exception.syndrome&lt;1:0&gt; = '11';
            exception.syndrome&lt;2&gt;   = '1';   // Register field is valid
            exception.syndrome&lt;9:5&gt; = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>()&lt;4:0&gt;;

    if target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/CheckFPAdvSIMDEnabled64" mylink="aarch64.exceptions.traps.CheckFPAdvSIMDEnabled64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckFPAdvSIMDEnabled64()
// =========================
// AArch64 instruction wrapper

<anchor link="impl-aarch64.CheckFPAdvSIMDEnabled64.0" hover="function: CheckFPAdvSIMDEnabled64()">CheckFPAdvSIMDEnabled64</anchor>()
    <a link="AArch64.CheckFPAdvSIMDEnabled.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPAdvSIMDEnabled()">AArch64.CheckFPAdvSIMDEnabled</a>();</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/CheckFPEnabled64" mylink="aarch64.exceptions.traps.CheckFPEnabled64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckFPEnabled64()
// ==================
// AArch64 instruction wrapper

<anchor link="impl-aarch64.CheckFPEnabled64.0" hover="function: CheckFPEnabled64()">CheckFPEnabled64</anchor>()
    <a link="AArch64.CheckFPEnabled.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckFPEnabled()">AArch64.CheckFPEnabled</a>();</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/CheckLDST64BEnabled" mylink="aarch64.exceptions.traps.CheckLDST64BEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckLDST64BEnabled()
// =====================
// Checks for trap on ST64B and LD64B instructions

<anchor link="impl-aarch64.CheckLDST64BEnabled.0" hover="function: CheckLDST64BEnabled()">CheckLDST64BEnabled</anchor>()
    boolean trap = FALSE;
    bits(25) iss = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>('10', 25);  // 0x2
    bits(2) target_el;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        if !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            trap = SCTLR_EL1.EnALS == '0';
            target_el = if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
        else
            trap = SCTLR_EL2.EnALS == '0';
            target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    if (!trap &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
        ((PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) || PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) then
        trap = !<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.EnALS == '0';
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if trap then <a link="impl-aarch64.LDST64BTrap.2" file="shared_pseudocode.xml" hover="function: LDST64BTrap(bits(2) target_el, bits(25) iss)">LDST64BTrap</a>(target_el, iss);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/CheckST64BV0Enabled" mylink="aarch64.exceptions.traps.CheckST64BV0Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckST64BV0Enabled()
// =====================
// Checks for trap on ST64BV0 instruction

<anchor link="impl-aarch64.CheckST64BV0Enabled.0" hover="function: CheckST64BV0Enabled()">CheckST64BV0Enabled</anchor>()
    boolean trap = FALSE;
    bits(25) iss = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>('1', 25);  // 0x1
    bits(2) target_el;

    if (PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp;
        SCR_EL3.EnAS0 == '0' &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>()) then
        UNDEFINED;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        if !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            trap = SCTLR_EL1.EnAS0 == '0';
            target_el = if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
        else
            trap = SCTLR_EL2.EnAS0 == '0';
            target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if (!trap &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
        ((PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) || PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) then
        trap = !<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.EnAS0 == '0';
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if !trap &amp;&amp; PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        trap = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.EnAS0 == '0';
        target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    if trap then
        if target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.LDST64BTrap.2" file="shared_pseudocode.xml" hover="function: LDST64BTrap(bits(2) target_el, bits(25) iss)">LDST64BTrap</a>(target_el, iss);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/CheckST64BVEnabled" mylink="aarch64.exceptions.traps.CheckST64BVEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckST64BVEnabled()
// ====================
// Checks for trap on ST64BV instruction

<anchor link="impl-aarch64.CheckST64BVEnabled.0" hover="function: CheckST64BVEnabled()">CheckST64BVEnabled</anchor>()
    boolean trap = FALSE;
    bits(25) iss = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(25);
    bits(2) target_el;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        if !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            trap = SCTLR_EL1.EnASR == '0';
            target_el = if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
        else
            trap = SCTLR_EL2.EnASR == '0';
            target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if (!trap &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
        ((PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) || PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) then
        trap = !<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.EnASR == '0';
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;

    if trap then <a link="impl-aarch64.LDST64BTrap.2" file="shared_pseudocode.xml" hover="function: LDST64BTrap(bits(2) target_el, bits(25) iss)">LDST64BTrap</a>(target_el, iss);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/LDST64BTrap" mylink="aarch64.exceptions.traps.LDST64BTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LDST64BTrap()
// =============
// Trapped access to LD64B, ST64B, ST64BV and ST64BV0 instructions

<anchor link="impl-aarch64.LDST64BTrap.2" hover="function: LDST64BTrap(bits(2) target_el, bits(25) iss)">LDST64BTrap</anchor>(bits(2) target_el, bits(25) iss)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_LDST64BTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_LDST64BTrap</a>);
    exception.syndrome = iss;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);

    return;</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/WFETrapDelay" mylink="aarch64.exceptions.traps.WFETrapDelay" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// WFETrapDelay()
// ==============
// Returns TRUE when delay in trap to WFE is enabled with value to amount of delay,
// FALSE otherwise.

(boolean, integer) <anchor link="impl-aarch64.WFETrapDelay.1" hover="function: (boolean, integer) WFETrapDelay(bits(2) target_el)">WFETrapDelay</anchor>(bits(2) target_el)
    boolean delay_enabled;
    integer delay;
    case target_el of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            if !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
                delay_enabled = SCTLR_EL1.TWEDEn == '1';
                delay         = 1 &lt;&lt; (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SCTLR_EL1.TWEDEL) + 8);
            else
                delay_enabled = SCTLR_EL2.TWEDEn == '1';
                delay         = 1 &lt;&lt; (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SCTLR_EL2.TWEDEL) + 8);
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            assert <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
            delay_enabled = HCR_EL2.TWEDEn == '1';
            delay         = 1 &lt;&lt; (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(HCR_EL2.TWEDEL) + 8);
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            delay_enabled = SCR_EL3.TWEDEn == '1';
            delay         = 1 &lt;&lt; (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SCR_EL3.TWEDEL) + 8);

    return (delay_enabled, delay);</pstext>
    </ps>
    <ps name="aarch64/exceptions/traps/WaitForEventUntilDelay" mylink="aarch64.exceptions.traps.WaitForEventUntilDelay" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// WaitForEventUntilDelay()
// ========================
// Returns TRUE if WaitForEvent() returns before WFE trap delay expires,
// FALSE otherwise.

boolean <anchor link="impl-aarch64.WaitForEventUntilDelay.2" hover="function: boolean WaitForEventUntilDelay(boolean delay_enabled, integer delay)">WaitForEventUntilDelay</anchor>(boolean delay_enabled, integer delay);</pstext>
    </ps>
    <ps name="aarch64/functions/aborts/AArch64.FaultSyndrome" mylink="aarch64.functions.aborts.AArch64.FaultSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.FaultSyndrome()
// =======================
// Creates an exception syndrome value for Abort and Watchpoint exceptions taken to
// an Exception level using AArch64.

(bits(25), bits(24)) <anchor link="AArch64.FaultSyndrome.3" hover="function: (bits(25), bits(24)) AArch64.FaultSyndrome(boolean d_side, FaultRecord fault, boolean pavalid)">AArch64.FaultSyndrome</anchor>(boolean d_side, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault, boolean pavalid)
    assert fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    bits(25) iss  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(25);
    bits(24) iss2 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24);

    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; fault.statuscode == <a link="Fault_SyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</a> then
        <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errstate = <a link="AArch64.PEErrorState.1" file="shared_pseudocode.xml" hover="function: ErrorState AArch64.PEErrorState(FaultRecord fault)">AArch64.PEErrorState</a>(fault);
        iss&lt;12:11&gt; = <a link="AArch64.EncodeSyncErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(2) AArch64.EncodeSyncErrorSyndrome(ErrorState errorstate)">AArch64.EncodeSyncErrorSyndrome</a>(errstate);  // SET

    if d_side then
        if fault.access.acctype == <a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a> then
            iss2&lt;8&gt; = '1';
        if <a link="impl-shared.HaveFeatLS64.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatLS64()">HaveFeatLS64</a>() &amp;&amp; fault.access.ls64 then
            if (fault.statuscode IN {<a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>, <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>, <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>}) then
                (iss2, iss&lt;24:14&gt;) = <a link="impl-aarch64.LS64InstructionSyndrome.0" file="shared_pseudocode.xml" hover="function: (bits(24), bits(11)) LS64InstructionSyndrome()">LS64InstructionSyndrome</a>();
        elsif (<a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault) &amp;&amp; !fault.s2fs1walk &amp;&amp;
               (!<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) ||
               (!<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> &amp;&amp;
               boolean IMPLEMENTATION_DEFINED "ISV on second stage translation table walk"))) then
            iss&lt;24:14&gt; = <a link="impl-shared.LSInstructionSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(11) LSInstructionSyndrome()">LSInstructionSyndrome</a>();

        if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; fault.access.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
            iss&lt;13&gt; = '1';   // Fault is generated by use of VNCR_EL2

        if <a link="impl-shared.HaveFeatLS64.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatLS64()">HaveFeatLS64</a>() &amp;&amp; fault.statuscode IN {<a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>, <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>,
                                                  <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>} then
            iss&lt;12:11&gt; = <a link="impl-shared.GetLoadStoreType.0" file="shared_pseudocode.xml" hover="function: bits(2) GetLoadStoreType()">GetLoadStoreType</a>();

        if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
            iss&lt;8&gt; = '1';

        if fault.access.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>} then
            iss&lt;6&gt; = '1';
        elsif fault.statuscode IN {<a link="Fault_HWUpdateAccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_HWUpdateAccessFlag</a>, <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>} then
            iss&lt;6&gt; = bit UNKNOWN;
        elsif fault.access.atomicop &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then
            iss&lt;6&gt; = bit UNKNOWN;
        else
            iss&lt;6&gt; = if fault.write then '1' else '0';

        if fault.statuscode == <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a> then
            iss2&lt;5&gt; = if fault.dirtybit then '1' else '0';
            iss2&lt;6&gt; = if fault.overlay then '1' else '0';
            if iss&lt;24&gt; == '0' then
                iss&lt;21&gt; = if fault.toplevel then '1' else '0';
            iss2&lt;7&gt; = if fault.assuredonly then '1' else '0';
            iss2&lt;9&gt; = if fault.tagaccess then '1' else '0';
            iss2&lt;10&gt; = if fault.s1tagnotdata then '1' else '0';

    else
        if fault.access.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp; fault.statuscode == <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a> then
            iss&lt;21&gt; = if fault.toplevel then '1' else '0';
            iss2&lt;7&gt; = if fault.assuredonly then '1' else '0';
            iss2&lt;6&gt; = if fault.overlay then '1' else '0';
    if <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) then iss&lt;9&gt; = fault.extflag;
    iss&lt;7&gt; = if fault.s2fs1walk then '1' else '0';
    iss&lt;5:0&gt; = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level);

    return (iss, iss2);</pstext>
    </ps>
    <ps name="aarch64/functions/aborts/EncodeGPCSC" mylink="aarch64.functions.aborts.EncodeGPCSC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EncodeGPCSC()
// =============
// Function that gives the GPCSC code for types of GPT Fault

bits(6) <anchor link="impl-aarch64.EncodeGPCSC.1" hover="function: bits(6) EncodeGPCSC(GPCFRecord gpcf)">EncodeGPCSC</anchor>(<a link="GPCFRecord" file="shared_pseudocode.xml" hover="type GPCFRecord is ( GPCF gpf, integer level )">GPCFRecord</a> gpcf)
    assert gpcf.level IN {0,1};

    case gpcf.gpf of
        when <a link="GPCF_AddressSize" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_AddressSize</a> return '00000':gpcf.level&lt;0&gt;;
        when <a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>        return '00010':gpcf.level&lt;0&gt;;
        when <a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a>        return '00110':gpcf.level&lt;0&gt;;
        when <a link="GPCF_EABT" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</a>        return '01010':gpcf.level&lt;0&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/aborts/LS64InstructionSyndrome" mylink="aarch64.functions.aborts.LS64InstructionSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LS64InstructionSyndrome()
// =========================
// Returns the syndrome information and LST for a Data Abort by a
// ST64B, ST64BV, ST64BV0, or LD64B instruction. The syndrome information
// includes the ISS2, extended syndrome field.

(bits(24), bits(11)) <anchor link="impl-aarch64.LS64InstructionSyndrome.0" hover="function: (bits(24), bits(11)) LS64InstructionSyndrome()">LS64InstructionSyndrome</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/cache/AArch64.DataMemZero" mylink="aarch64.functions.cache.AArch64.DataMemZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.DataMemZero()
// =====================
// Write Zero to data memory.

<anchor link="AArch64.DataMemZero.4" hover="function: AArch64.DataMemZero(bits(64) regval, bits(64) vaddress, AccessDescriptor accdesc_in, integer size)">AArch64.DataMemZero</anchor>(bits(64) regval, bits(64) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in, integer size)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;

    // If the instruction targets tags as a payload, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagaccess then
        accdesc.tagaccess = <a link="AArch64.AllocationTagAccessIsEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</a>(accdesc.el);

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(vaddress, accdesc);

    boolean aligned = TRUE;
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(vaddress, accdesc, aligned, size);

    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        if <a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(memaddrdesc.fault) then
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(vaddress, memaddrdesc.fault);
        else
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(regval, memaddrdesc.fault);

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then
        if accdesc.transactional &amp;&amp; !<a link="impl-aarch64.MemHasTransactionalAccess.1" file="shared_pseudocode.xml" hover="function: boolean MemHasTransactionalAccess(MemoryAttributes memattrs)">MemHasTransactionalAccess</a>(memaddrdesc.memattrs) then
            <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_IMP" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_IMP</a>, FALSE);

    for i = 0 to size-1
        if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
            bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(vaddress);
            if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
                if (boolean IMPLEMENTATION_DEFINED
                      "DC_ZVA tag fault reported with lowest faulting address") then
                    <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(vaddress, accdesc);
                else
                    <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(regval, accdesc);
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, 1, accdesc, <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8));
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, 1, accdesc);

        memaddrdesc.paddress.address = memaddrdesc.paddress.address + 1;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/cache/AArch64.TagMemZero" mylink="aarch64.functions.cache.AArch64.TagMemZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TagMemZero()
// ====================
// Write Zero to tag memory.

<anchor link="AArch64.TagMemZero.4" hover="function: AArch64.TagMemZero(bits(64) regval, bits(64) vaddress, AccessDescriptor accdesc_in, integer size)">AArch64.TagMemZero</anchor>(bits(64) regval, bits(64) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in, integer size)
    assert accdesc_in.tagaccess &amp;&amp; !accdesc_in.tagchecked;

    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;

    integer count = size &gt;&gt; <a link="LOG2_TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer LOG2_TAG_GRANULE = 4">LOG2_TAG_GRANULE</a>;
    bits(4) tag = <a link="AArch64.AllocationTagFromAddress.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.AllocationTagFromAddress(bits(64) tagged_address)">AArch64.AllocationTagFromAddress</a>(vaddress);
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(vaddress, <a link="TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</a>);

    // Stores of allocation tags must be aligned
    if !aligned then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(vaddress, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then
        accdesc.tagaccess = <a link="AArch64.AllocationTagAccessIsEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</a>(accdesc.el);

    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(vaddress, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        if <a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(memaddrdesc.fault) then
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(vaddress, memaddrdesc.fault);
        else
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(regval, memaddrdesc.fault);

    if !accdesc.tagaccess || memaddrdesc.memattrs.tags != <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        return;

    for i = 0 to count-1
        memstatus = <a link="impl-aarch64.PhysMemTagWrite.3" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemTagWrite(AddressDescriptor desc, AccessDescriptor accdesc, bits (4) value)">PhysMemTagWrite</a>(memaddrdesc, accdesc, tag);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, 1, accdesc);

        memaddrdesc.paddress.address = memaddrdesc.paddress.address + <a link="TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</a>;

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/d128/IsD128Enabled" mylink="aarch64.functions.d128.IsD128Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsD128Enabled()
// ===============
// Returns true if 128-bit page descriptor is enabled

boolean <anchor link="impl-aarch64.IsD128Enabled.1" hover="function: boolean IsD128Enabled(bits(2) el)">IsD128Enabled</anchor>(bits(2) el)
    boolean d128enabled;
    if <a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() then
        case el of
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
                if !<a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>) then
                    d128enabled = <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() &amp;&amp; TCR2_EL1.D128 == '1';
                else
                    d128enabled = <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() &amp;&amp; TCR2_EL2.D128 == '1';
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                d128enabled = <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() &amp;&amp; TCR2_EL1.D128 == '1';
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
                d128enabled = <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() &amp;&amp; HCR_EL2.E2H == '1' &amp;&amp; TCR2_EL2.D128 == '1';
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
                d128enabled = TCR_EL3.D128 == '1';
    else
        d128enabled = FALSE;

    return d128enabled;</pstext>
    </ps>
    <ps name="aarch64/functions/exclusive/AArch64.ExclusiveMonitorsPass" mylink="aarch64.functions.exclusive.AArch64.ExclusiveMonitorsPass" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ExclusiveMonitorsPass()
// ===============================
// Return TRUE if the Exclusives monitors for the current PE include all of the addresses
// associated with the virtual address region of size bytes starting at address.
// The immediately following memory write must be to the same addresses.

boolean <anchor link="AArch64.ExclusiveMonitorsPass.2" hover="function: boolean AArch64.ExclusiveMonitorsPass(bits(64) address, integer size)">AArch64.ExclusiveMonitorsPass</anchor>(bits(64) address, integer size)

    // It is IMPLEMENTATION DEFINED whether the detection of memory aborts happens
    // before or after the check on the local Exclusives monitor. As a result a failure
    // of the local monitor can occur on some implementations even if the memory
    // access would give an memory abort.
    boolean acqrel = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescExLDST.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>, acqrel, tagchecked);
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if !<a link="AArch64.IsExclusiveVA.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.IsExclusiveVA(bits(64) address, integer processorid, integer size)">AArch64.IsExclusiveVA</a>(address, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size) then
        return FALSE;

    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    passed = <a link="impl-shared.IsExclusiveLocal.3" file="shared_pseudocode.xml" hover="function: boolean IsExclusiveLocal(FullAddress paddress, integer processorid, integer size)">IsExclusiveLocal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);
    <a link="impl-shared.ClearExclusiveLocal.1" file="shared_pseudocode.xml" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</a>(<a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>());

    if passed &amp;&amp; memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        passed = <a link="impl-shared.IsExclusiveGlobal.3" file="shared_pseudocode.xml" hover="function: boolean IsExclusiveGlobal(FullAddress paddress, integer processorid, integer size)">IsExclusiveGlobal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    return passed;</pstext>
    </ps>
    <ps name="aarch64/functions/exclusive/AArch64.IsExclusiveVA" mylink="aarch64.functions.exclusive.AArch64.IsExclusiveVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IsExclusiveVA()
// =======================
// An optional IMPLEMENTATION DEFINED test for an exclusive access to a virtual
// address region of size bytes starting at address.
//
// It is permitted (but not required) for this function to return FALSE and
// cause a store exclusive to fail if the virtual address region is not
// totally included within the region recorded by MarkExclusiveVA().
//
// It is always safe to return TRUE which will check the physical address only.

boolean <anchor link="AArch64.IsExclusiveVA.3" hover="function: boolean AArch64.IsExclusiveVA(bits(64) address, integer processorid, integer size)">AArch64.IsExclusiveVA</anchor>(bits(64) address, integer processorid, integer size);</pstext>
    </ps>
    <ps name="aarch64/functions/exclusive/AArch64.MarkExclusiveVA" mylink="aarch64.functions.exclusive.AArch64.MarkExclusiveVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MarkExclusiveVA()
// =========================
// Optionally record an exclusive access to the virtual address region of size bytes
// starting at address for processorid.

<anchor link="AArch64.MarkExclusiveVA.3" hover="function: AArch64.MarkExclusiveVA(bits(64) address, integer processorid, integer size)">AArch64.MarkExclusiveVA</anchor>(bits(64) address, integer processorid, integer size);</pstext>
    </ps>
    <ps name="aarch64/functions/exclusive/AArch64.SetExclusiveMonitors" mylink="aarch64.functions.exclusive.AArch64.SetExclusiveMonitors" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SetExclusiveMonitors()
// ==============================
// Sets the Exclusives monitors for the current PE to record the addresses associated
// with the virtual address region of size bytes starting at address.

<anchor link="AArch64.SetExclusiveMonitors.2" hover="function: AArch64.SetExclusiveMonitors(bits(64) address, integer size)">AArch64.SetExclusiveMonitors</anchor>(bits(64) address, integer size)
    boolean acqrel = FALSE;
    boolean tagchecked = FALSE;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescExLDST.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>, acqrel, tagchecked);
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        return;

    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.MarkExclusiveGlobal.3" file="shared_pseudocode.xml" hover="function: MarkExclusiveGlobal(FullAddress paddress, integer processorid, integer size)">MarkExclusiveGlobal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    <a link="impl-shared.MarkExclusiveLocal.3" file="shared_pseudocode.xml" hover="function: MarkExclusiveLocal(FullAddress paddress, integer processorid, integer size)">MarkExclusiveLocal</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    <a link="AArch64.MarkExclusiveVA.3" file="shared_pseudocode.xml" hover="function: AArch64.MarkExclusiveVA(bits(64) address, integer processorid, integer size)">AArch64.MarkExclusiveVA</a>(address, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);</pstext>
    </ps>
    <ps name="aarch64/functions/fusedrstep/FPRSqrtStepFused" mylink="aarch64.functions.fusedrstep.FPRSqrtStepFused" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRSqrtStepFused()
// ==================

bits(N) <anchor link="impl-aarch64.FPRSqrtStepFused.2" hover="function: bits(N) FPRSqrtStepFused(bits(N) op1_in, bits(N) op2)">FPRSqrtStepFused</anchor>(bits(N) op1_in, bits(N) op2)
    assert N IN {16, 32, 64};
    bits(N) result;
    bits(N) op1 = op1_in;
    boolean done;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
    op1 = <a link="impl-shared.FPNeg.1" file="shared_pseudocode.xml" hover="function: bits(N) FPNeg(bits(N) op)">FPNeg</a>(op1);
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; fpcr.AH == '1';
    boolean fpexc = !altfp;                         // Generate no floating-point exceptions
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';             // Flush denormal input and output to zero
    if altfp then fpcr.RMode = '00';                // Use RNE rounding mode

    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2, fpcr, fpexc);
    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr, fpexc);
    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);

    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            result = <a link="impl-shared.FPOnePointFive.2" file="shared_pseudocode.xml" hover="function: bits(N) FPOnePointFive(bit sign, integer N)">FPOnePointFive</a>('0', N);
        elsif inf1 || inf2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, N);
        else
            // Fully fused multiply-add and halve
            result_value = (3.0 + (value1 * value2)) / 2.0;
            if result_value == 0.0 then
                // Sign of exact zero result depends on rounding mode
                sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/fusedrstep/FPRecipStepFused" mylink="aarch64.functions.fusedrstep.FPRecipStepFused" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRecipStepFused()
// ==================

bits(N) <anchor link="impl-aarch64.FPRecipStepFused.2" hover="function: bits(N) FPRecipStepFused(bits(N) op1_in, bits(N) op2)">FPRecipStepFused</anchor>(bits(N) op1_in, bits(N) op2)
    assert N IN {16, 32, 64};
    bits(N) op1 = op1_in;
    bits(N) result;
    boolean done;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
    op1 = <a link="impl-shared.FPNeg.1" file="shared_pseudocode.xml" hover="function: bits(N) FPNeg(bits(N) op)">FPNeg</a>(op1);

    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; fpcr.AH == '1';
    boolean fpexc = !altfp;                         // Generate no floating-point exceptions
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';             // Flush denormal input and output to zero
    if altfp then fpcr.RMode    = '00';             // Use RNE rounding mode

    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2, fpcr, fpexc);
    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr, fpexc);
    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);

    if !done then
        inf1  = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2  = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            result = <a link="impl-shared.FPTwo.2" file="shared_pseudocode.xml" hover="function: bits(N) FPTwo(bit sign, integer N)">FPTwo</a>('0', N);
        elsif inf1 || inf2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, N);
        else
            // Fully fused multiply-add
            result_value = 2.0 + (value1 * value2);
            if result_value == 0.0 then
                // Sign of exact zero result depends on rounding mode
                sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/AddGCSExRecord" mylink="aarch64.functions.gcs.AddGCSExRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddGCSExRecord()
// ================
// Generates and then writes an exception record to the
// current Guarded control stack.

<anchor link="impl-aarch64.AddGCSExRecord.3" hover="function: AddGCSExRecord(bits(64) elr, bits(64) spsr, bits(64) lr)">AddGCSExRecord</anchor>(bits(64) elr, bits(64) spsr, bits(64) lr)
    bits(64) ptr;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>);

    ptr = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();

    // Store the record
    Mem[ptr-8, 8, accdesc] = lr;
    Mem[ptr-16, 8, accdesc] = spsr;
    Mem[ptr-24, 8, accdesc] = elr;
    Mem[ptr-32, 8, accdesc] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(60):'1001';

    // Decrement the pointer value
    ptr = ptr - 32;

    <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(ptr);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/AddGCSRecord" mylink="aarch64.functions.gcs.AddGCSRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddGCSRecord()
// ==============
// Generates and then writes a record to the current Guarded
// control stack.

<anchor link="impl-aarch64.AddGCSRecord.1" hover="function: AddGCSRecord(bits(64) vaddress)">AddGCSRecord</anchor>(bits(64) vaddress)
    bits(64) ptr;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>);

    ptr = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();

    // Store the record
    Mem[ptr-8, 8, accdesc] = vaddress;

    // Decrement the pointer value
    ptr = ptr - 8;

    <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(ptr);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/CheckGCSExRecord" mylink="aarch64.functions.gcs.CheckGCSExRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckGCSExRecord()
// ==================
// Validates the provided values against the top entry of the
// current Guarded control stack.

<anchor link="impl-aarch64.CheckGCSExRecord.4" hover="function: CheckGCSExRecord(bits(64) elr, bits(64) spsr, bits(64) lr, GCSInstruction gcsinst_type)">CheckGCSExRecord</anchor>(bits(64) elr, bits(64) spsr, bits(64) lr, <a link="GCSInstruction" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstruction</a> gcsinst_type)
    bits(64) ptr;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);
    ptr = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();

    // Check the lowest doubleword is correctly formatted
    bits(64) recorded_first_dword = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr, 8, accdesc];
    if recorded_first_dword != <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(60):'1001' then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(gcsinst_type);

    // Check the ELR matches the recorded value
    bits(64) recorded_elr = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr+8, 8, accdesc];
    if recorded_elr != elr then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(gcsinst_type);

    // Check the SPSR matches the recorded value
    bits(64) recorded_spsr = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr+16, 8, accdesc];
    if recorded_spsr != spsr then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(gcsinst_type);

    // Check the LR matches the recorded value
    bits(64) recorded_lr = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr+24, 8, accdesc];
    if recorded_lr != lr then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(gcsinst_type);

    // Increment the pointer value
    ptr = ptr + 32;

    <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(ptr);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/CheckGCSSTRTrap" mylink="aarch64.functions.gcs.CheckGCSSTRTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckGCSSTRTrap()
// =================
// Trap GCSSTR or GCSSTTR instruction if trapping is enabled.

<anchor link="impl-aarch64.CheckGCSSTRTrap.0" hover="function: CheckGCSSTRTrap()">CheckGCSSTRTrap</anchor>()
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            if GCSCRE0_EL1.STREn == '0' then
                if HCR_EL2.TGE == '0' then
                    <a link="impl-aarch64.GCSSTRTrapException.1" file="shared_pseudocode.xml" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
                else
                    <a link="impl-aarch64.GCSSTRTrapException.1" file="shared_pseudocode.xml" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            if GCSCR_EL1.STREn == '0' then
                <a link="impl-aarch64.GCSSTRTrapException.1" file="shared_pseudocode.xml" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
            elsif (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || SCR_EL3.FGTEn == '1') &amp;&amp;
                   HFGITR_EL2.nGCSSTR_EL1 == '0') then
                <a link="impl-aarch64.GCSSTRTrapException.1" file="shared_pseudocode.xml" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if GCSCR_EL2.STREn == '0' then
                <a link="impl-aarch64.GCSSTRTrapException.1" file="shared_pseudocode.xml" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            if GCSCR_EL3.STREn == '0' then
                <a link="impl-aarch64.GCSSTRTrapException.1" file="shared_pseudocode.xml" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/EXLOCKException" mylink="aarch64.functions.gcs.EXLOCKException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EXLOCKException()
// =================
// Handle an EXLOCK exception condition.

<anchor link="impl-aarch64.EXLOCKException.0" hover="function: EXLOCKException()">EXLOCKException</anchor>()
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_GCSFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GCSFail</a>);
    exception.syndrome&lt;24&gt; = Zeros();
    exception.syndrome&lt;23:20&gt; = '0001';
    exception.syndrome&lt;19:0&gt; = Zeros();
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSDataCheckException" mylink="aarch64.functions.gcs.GCSDataCheckException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSDataCheckException()
// =======================
// Handle a Guarded Control Stack data check fault condition.

<anchor link="impl-aarch64.GCSDataCheckException.1" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</anchor>(<a link="GCSInstruction" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstruction</a> gcsinst_type)
    bits(2) target_el;
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset = 0x0;
    boolean rn_unknown = FALSE;
    boolean is_ret = FALSE;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        target_el = if HCR_EL2.TGE == '0' then <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> else <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        target_el = PSTATE.EL;
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_GCSFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GCSFail</a>);
    case gcsinst_type of
        when <a link="GCSInstType_PRET" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_PRET</a>
            exception.syndrome&lt;4:0&gt; = '00000';
            is_ret = TRUE;
        when <a link="GCSInstType_POPM" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPM</a>
            exception.syndrome&lt;4:0&gt; = '00001';
        when <a link="GCSInstType_PRETAA" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_PRETAA</a>
            exception.syndrome&lt;4:0&gt; = '00010';
            is_ret = TRUE;
        when <a link="GCSInstType_PRETAB" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_PRETAB</a>
            exception.syndrome&lt;4:0&gt; = '00011';
            is_ret = TRUE;
        when <a link="GCSInstType_SS1" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_SS1</a>
            exception.syndrome&lt;4:0&gt; = '00100';
        when <a link="GCSInstType_SS2" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_SS2</a>
            exception.syndrome&lt;4:0&gt; = '00101';
            rn_unknown = TRUE;
        when <a link="GCSInstType_POPCX" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPCX</a>
            rn_unknown = TRUE;
            exception.syndrome&lt;4:0&gt; = '01000';
        when <a link="GCSInstType_POPX" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPX</a>
            exception.syndrome&lt;4:0&gt; = '01001';
    if rn_unknown == TRUE then
        exception.syndrome&lt;9:5&gt; = bits(5) UNKNOWN;
    elsif is_ret == TRUE then
        exception.syndrome&lt;9:5&gt; = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>()&lt;9:5&gt;;
    else
        exception.syndrome&lt;9:5&gt; = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>()&lt;4:0&gt;;
    exception.syndrome&lt;24:10&gt; = Zeros();
    exception.vaddress = bits(64) UNKNOWN;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSEnabled" mylink="aarch64.functions.gcs.GCSEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSEnabled()
// ============
// Returns TRUE if the Guarded control stack is enabled at
// the provided Exception level.

boolean <anchor link="impl-aarch64.GCSEnabled.1" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</anchor>(bits(2) el)
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        return FALSE;

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; SCR_EL3.GCSEn == '0' then
        return FALSE;

    if (el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
        (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0') &amp;&amp;
        (!<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.GCSEn == '0')) then
        return FALSE;

    return <a link="impl-aarch64.GCSPCRSelected.1" file="shared_pseudocode.xml" hover="function: boolean GCSPCRSelected(bits(2) el)">GCSPCRSelected</a>(el);</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSInstruction" mylink="aarch64.functions.gcs.GCSInstruction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSInstruction
// ==============

enumeration <anchor link="GCSInstruction" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstruction</anchor> {
    <anchor link="GCSInstType_PRET" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_PRET</anchor>,    // Procedure return without Pointer authentication
    <anchor link="GCSInstType_POPM" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPM</anchor>,    // GCSPOPM instruction
    <anchor link="GCSInstType_PRETAA" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_PRETAA</anchor>,  // Procedure return with Pointer authentication that used key A
    <anchor link="GCSInstType_PRETAB" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_PRETAB</anchor>,  // Procedure return with Pointer authentication that used key B
    <anchor link="GCSInstType_SS1" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_SS1</anchor>,     // GCSSS1 instruction
    <anchor link="GCSInstType_SS2" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_SS2</anchor>,     // GCSSS2 instruction
    <anchor link="GCSInstType_POPCX" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPCX</anchor>,   // GCSPOPCX instruction
    <anchor link="GCSInstType_POPX" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPX</anchor>     // GCSPOPX instruction
};</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPCREnabled" mylink="aarch64.functions.gcs.GCSPCREnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPCREnabled()
// ===============
// Returns TRUE if the Guarded control stack is PCR enabled
// at the provided Exception level.

boolean <anchor link="impl-aarch64.GCSPCREnabled.1" hover="function: boolean GCSPCREnabled(bits(2) el)">GCSPCREnabled</anchor>(bits(2) el)
    return <a link="impl-aarch64.GCSPCRSelected.1" file="shared_pseudocode.xml" hover="function: boolean GCSPCRSelected(bits(2) el)">GCSPCRSelected</a>(el) &amp;&amp; <a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(el);</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPCRSelected" mylink="aarch64.functions.gcs.GCSPCRSelected" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPCRSelected()
// ================
// Returns TRUE if the Guarded control stack is PCR selected
// at the provided Exception level.

boolean <anchor link="impl-aarch64.GCSPCRSelected.1" hover="function: boolean GCSPCRSelected(bits(2) el)">GCSPCRSelected</anchor>(bits(2) el)
    case el of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> return GCSCRE0_EL1.PCRSEL == '1';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> return GCSCR_EL1.PCRSEL == '1';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> return GCSCR_EL2.PCRSEL == '1';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> return GCSCR_EL3.PCRSEL == '1';
    <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPOPCX" mylink="aarch64.functions.gcs.GCSPOPCX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPOPCX()
// ==========
// Called to pop and compare a Guarded control stack exception return record.

<anchor link="impl-aarch64.GCSPOPCX.0" hover="function: GCSPOPCX()">GCSPOPCX</anchor>()
    bits(64) spsr = <a link="impl-shared.SPSR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(N) SPSR[]">SPSR</a>[];
    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then
        <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    CheckGCSExRecord(ELR[], spsr, X[30,64], GCSInstType_POPCX);
    PSTATE.EXLOCK = '1';
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPOPM" mylink="aarch64.functions.gcs.GCSPOPM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPOPM()
// =========
// Called to pop a Guarded control stack procedure return record.

bits(64) <anchor link="impl-aarch64.GCSPOPM.0" hover="function: bits(64) GCSPOPM()">GCSPOPM</anchor>()
    bits(64) ptr;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);

    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    ptr = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();
    bits(64) entry = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr, 8, accdesc];

    if entry&lt;1:0&gt; != '00' then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(<a link="GCSInstType_POPM" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPM</a>);

    ptr = ptr + 8;
    <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(ptr);
    return entry;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPOPX" mylink="aarch64.functions.gcs.GCSPOPX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPOPX()
// =========
// Called to pop a Guarded control stack exception return record.

<anchor link="impl-aarch64.GCSPOPX.0" hover="function: GCSPOPX()">GCSPOPX</anchor>()
    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();

    bits(64) ptr;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);
    ptr = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();

    // Check the lowest doubleword is correctly formatted
    bits(64) recorded_first_dword = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr, 8, accdesc];
    if recorded_first_dword != <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(60):'1001' then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(<a link="GCSInstType_POPX" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_POPX</a>);

    // Ignore these loaded values, however they might have
    // faulted which is why we load them anyway
    bits(64) recorded_elr = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr+8, 8, accdesc];
    bits(64) recorded_spsr = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr+16, 8, accdesc];
    bits(64) recorded_lr = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr+24, 8, accdesc];

    // Increment the pointer value
    ptr = ptr + 32;

    <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(ptr);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPUSHM" mylink="aarch64.functions.gcs.GCSPUSHM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPUSHM()
// ==========
// Called to push a Guarded control stack procedure return record.

<anchor link="impl-aarch64.GCSPUSHM.1" hover="function: GCSPUSHM(bits(64) value)">GCSPUSHM</anchor>(bits(64) value)
    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    <a link="impl-aarch64.AddGCSRecord.1" file="shared_pseudocode.xml" hover="function: AddGCSRecord(bits(64) vaddress)">AddGCSRecord</a>(value);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSPUSHX" mylink="aarch64.functions.gcs.GCSPUSHX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSPUSHX()
// ==========
// Called to push a Guarded control stack exception return record.

<anchor link="impl-aarch64.GCSPUSHX.0" hover="function: GCSPUSHX()">GCSPUSHX</anchor>()
    bits(64) spsr = <a link="impl-shared.SPSR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(N) SPSR[]">SPSR</a>[];
    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then
        <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    AddGCSExRecord(ELR[], spsr, X[30,64]);
    PSTATE.EXLOCK = '0';
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSReturnValueCheckEnabled" mylink="aarch64.functions.gcs.GCSReturnValueCheckEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSReturnValueCheckEnabled()
// ============================
// Returns TRUE if the Guarded control stack has return value
// checking enabled at the current Exception level.

boolean <anchor link="impl-aarch64.GCSReturnValueCheckEnabled.1" hover="function: boolean GCSReturnValueCheckEnabled(bits(2) el)">GCSReturnValueCheckEnabled</anchor>(bits(2) el)
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        return FALSE;
    case el of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> return GCSCRE0_EL1.RVCHKEN == '1';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> return GCSCR_EL1.RVCHKEN == '1';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> return GCSCR_EL2.RVCHKEN == '1';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> return GCSCR_EL3.RVCHKEN == '1';</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSSS1" mylink="aarch64.functions.gcs.GCSSS1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSSS1()
// ========
// Operational pseudocode for GCSSS1 instruction.

<anchor link="impl-aarch64.GCSSS1.1" hover="function: GCSSS1(bits(64) incoming_pointer)">GCSSS1</anchor>(bits(64) incoming_pointer)
    bits(64) outgoing_pointer, incoming_value, in_progress_entry;
    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCSSS1.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCSSS1(bits(2) el)">CreateAccDescGCSSS1</a>(PSTATE.EL);
    outgoing_pointer = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();

    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(incoming_pointer, 8);
    if !aligned then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(incoming_pointer, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(incoming_pointer, accdesc,
                                                             aligned, 64);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(incoming_pointer, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), 64);

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, incoming_value) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, 8, accdesc);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, 8, accdesc);
    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        incoming_value = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(incoming_value);

    if incoming_value == incoming_pointer[63:12]:'000000000001' then   // valid entry
        in_progress_entry = outgoing_pointer[63:3]:'101';    //in_progress_token
        if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
            in_progress_entry = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(in_progress_entry);
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, 8, accdesc, in_progress_entry);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, 8, accdesc);
        <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(incoming_pointer[63:3]:'000');
    else
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(<a link="GCSInstType_SS1" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_SS1</a>);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSSS2" mylink="aarch64.functions.gcs.GCSSS2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSSS2()
// ========
// Operational pseudocode for GCSSS2 instruction.

bits(64) <anchor link="impl-aarch64.GCSSS2.0" hover="function: bits(64) GCSSS2()">GCSSS2</anchor>()
    bits(64) outgoing_pointer, incoming_pointer, outgoing_value;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_ld = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_st = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>);
    if !<a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    incoming_pointer = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();
    outgoing_value = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[incoming_pointer, 8, accdesc_ld];

    if outgoing_value[2:0] == '101' then  //in_progress token
        outgoing_pointer[63:3] = outgoing_value[63:3] - 1;
        outgoing_pointer[2:0] = '000';
        outgoing_value = outgoing_pointer[63:12]: '000000000001';
        Mem[outgoing_pointer, 8, accdesc_st] = outgoing_value;
        <a link="impl-aarch64.SetCurrentGCSPointer.1" file="shared_pseudocode.xml" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</a>(incoming_pointer + 8);
        <a link="impl-aarch64.GCSSynchronizationBarrier.0" file="shared_pseudocode.xml" hover="function: GCSSynchronizationBarrier()">GCSSynchronizationBarrier</a>();
    else
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(<a link="GCSInstType_SS2" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstType_SS2</a>);
    return outgoing_pointer;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSSTRTrapException" mylink="aarch64.functions.gcs.GCSSTRTrapException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSSTRTrapException()
// =====================
// Handle a trap on GCSSTR instruction condition.

<anchor link="impl-aarch64.GCSSTRTrapException.1" hover="function: GCSSTRTrapException(bits(2) target_el)">GCSSTRTrapException</anchor>(bits(2) target_el)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_GCSFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GCSFail</a>);
    exception.syndrome&lt;24&gt; = Zeros();
    exception.syndrome&lt;23:20&gt; = '0010';
    exception.syndrome&lt;19:15&gt; = Zeros();
    exception.syndrome&lt;14:10&gt; = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>()&lt;9:5&gt;;
    exception.syndrome&lt;9:5&gt; = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>()&lt;4:0&gt;;
    exception.syndrome&lt;4:0&gt; = Zeros();
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GCSSynchronizationBarrier" mylink="aarch64.functions.gcs.GCSSynchronizationBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GCSSynchronizationBarrier()
// ===========================
// Barrier instruction that synchronizes Guarded Control Stack
// accesses in relation to other load and store accesses

<anchor link="impl-aarch64.GCSSynchronizationBarrier.0" hover="function: GCSSynchronizationBarrier()">GCSSynchronizationBarrier</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GetCurrentEXLOCKEN" mylink="aarch64.functions.gcs.GetCurrentEXLOCKEN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetCurrentEXLOCKEN()
// ====================

boolean <anchor link="impl-aarch64.GetCurrentEXLOCKEN.0" hover="function: boolean GetCurrentEXLOCKEN()">GetCurrentEXLOCKEN</anchor>()
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            return GCSCR_EL1.EXLOCKEN == '1';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            return GCSCR_EL2.EXLOCKEN == '1';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            return GCSCR_EL3.EXLOCKEN == '1';</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/GetCurrentGCSPointer" mylink="aarch64.functions.gcs.GetCurrentGCSPointer" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetCurrentGCSPointer()
// ======================
// Returns the value of the current Guarded control stack
// pointer register.

bits(64) <anchor link="impl-aarch64.GetCurrentGCSPointer.0" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</anchor>()
    bits(64) ptr;

    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            ptr = GCSPR_EL0.PTR:'000';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            ptr = GCSPR_EL1.PTR:'000';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            ptr = GCSPR_EL2.PTR:'000';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            ptr = GCSPR_EL3.PTR:'000';
    return ptr;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/LoadCheckGCSRecord" mylink="aarch64.functions.gcs.LoadCheckGCSRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LoadCheckGCSRecord()
// ====================
// Validates the provided address against the top entry of the
// current Guarded control stack.

bits(64) <anchor link="impl-aarch64.LoadCheckGCSRecord.2" hover="function: bits(64) LoadCheckGCSRecord(bits(64) vaddress, GCSInstruction gcsinst_type)">LoadCheckGCSRecord</anchor>(bits(64) vaddress, <a link="GCSInstruction" file="shared_pseudocode.xml" hover="enumeration GCSInstruction { GCSInstType_PRET, GCSInstType_POPM, GCSInstType_PRETAA, GCSInstType_PRETAB, GCSInstType_SS1, GCSInstType_SS2, GCSInstType_POPCX, GCSInstType_POPX }">GCSInstruction</a> gcsinst_type)
    bits(64) ptr;
    bits(64) recorded_va;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescGCS.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</a>(PSTATE.EL, <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);

    ptr = <a link="impl-aarch64.GetCurrentGCSPointer.0" file="shared_pseudocode.xml" hover="function: bits(64) GetCurrentGCSPointer()">GetCurrentGCSPointer</a>();
    recorded_va = <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[ptr, 8, accdesc];
    if <a link="impl-aarch64.GCSReturnValueCheckEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSReturnValueCheckEnabled(bits(2) el)">GCSReturnValueCheckEnabled</a>(PSTATE.EL) &amp;&amp; (recorded_va != vaddress) then
        <a link="impl-aarch64.GCSDataCheckException.1" file="shared_pseudocode.xml" hover="function: GCSDataCheckException(GCSInstruction gcsinst_type)">GCSDataCheckException</a>(gcsinst_type);

    return recorded_va;</pstext>
    </ps>
    <ps name="aarch64/functions/gcs/SetCurrentGCSPointer" mylink="aarch64.functions.gcs.SetCurrentGCSPointer" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetCurrentGCSPointer()
// ======================
// Writes a value to the current Guarded control stack pointer register.

<anchor link="impl-aarch64.SetCurrentGCSPointer.1" hover="function: SetCurrentGCSPointer(bits(64) ptr)">SetCurrentGCSPointer</anchor>(bits(64) ptr)
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            GCSPR_EL0.PTR = ptr&lt;63:3&gt;;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            GCSPR_EL1.PTR = ptr&lt;63:3&gt;;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            GCSPR_EL2.PTR = ptr&lt;63:3&gt;;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            GCSPR_EL3.PTR = ptr&lt;63:3&gt;;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/mec/AArch64.S1AMECFault" mylink="aarch64.functions.mec.AArch64.S1AMECFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1AMECFault()
// =====================
// Returns TRUE if a Translation fault should occur for Realm EL2 and Realm EL2&amp;0
// stage 1 translated addresses to Realm PA space.

boolean AArch64.S1AMECFault(S1TTWParams walkparams, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                            bits(N) descriptor)
    assert N IN {64,128};
    bit descriptor_amec = if walkparams.d128 == '1' then descriptor&lt;103&gt; else descriptor&lt;63&gt;;

    return (walkparams.&lt;emec,amec&gt; == '10' &amp;&amp;
            regime IN {<a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>, <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>} &amp;&amp;
            paspace == <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> &amp;&amp;
            descriptor_amec == '1');</pstext>
    </ps>
    <ps name="aarch64/functions/mec/AArch64.S1DisabledOutputMECID" mylink="aarch64.functions.mec.AArch64.S1DisabledOutputMECID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1DisabledOutputMECID()
// ===============================
// Returns the output MECID when stage 1 address translation is disabled.

bits(16) AArch64.S1DisabledOutputMECID(S1TTWParams walkparams, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace)
    if walkparams.emec == '0' then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    if !(regime IN {<a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>, <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>, <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>}) then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    if paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> then
        return VMECID_P_EL2.MECID;
    else
        return MECID_P0_EL2.MECID;</pstext>
    </ps>
    <ps name="aarch64/functions/mec/AArch64.S1OutputMECID" mylink="aarch64.functions.mec.AArch64.S1OutputMECID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1OutputMECID()
// =======================
// Returns the output MECID when stage 1 address translation is enabled.

bits(16) AArch64.S1OutputMECID(S1TTWParams walkparams, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange,
                               <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace, bits(N) descriptor)
    assert N IN {64,128};

    if walkparams.emec == '0' then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    if paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    bit descriptor_amec = if walkparams.d128 == '1' then descriptor&lt;103&gt; else descriptor&lt;63&gt;;
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>
            return MECID_RL_A_EL3.MECID;
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>
            if descriptor_amec == '0' then
                return MECID_P0_EL2.MECID;
            else
                return MECID_A0_EL2.MECID;
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>
            if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
                if descriptor_amec == '0' then
                    return MECID_P0_EL2.MECID;
                else
                    return MECID_A0_EL2.MECID;
            else
                if descriptor_amec == '0' then
                    return MECID_P1_EL2.MECID;
                else
                    return MECID_A1_EL2.MECID;
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>
            return VMECID_P_EL2.MECID;</pstext>
    </ps>
    <ps name="aarch64/functions/mec/AArch64.S2OutputMECID" mylink="aarch64.functions.mec.AArch64.S2OutputMECID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2OutputMECID()
// =======================
// Returns the output MECID for stage 2 address translation.

bits(16) AArch64.S2OutputMECID(S2TTWParams walkparams, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace, bits(N) descriptor)
    assert N IN {64,128};

    if walkparams.emec == '0' then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    if paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    bit descriptor_amec = if walkparams.d128 == '1' then descriptor&lt;103&gt; else descriptor&lt;63&gt;;
    if descriptor_amec == '0' then
        return VMECID_P_EL2.MECID;
    else
        return VMECID_A_EL2.MECID;</pstext>
    </ps>
    <ps name="aarch64/functions/mec/AArch64.TTWalkMECID" mylink="aarch64.functions.mec.AArch64.TTWalkMECID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TTWalkMECID()
// =====================
// Returns the associated MECID for the translation table walk of the given
// translation regime and Security state.

bits(16) <anchor link="AArch64.TTWalkMECID.3" hover="function: bits(16) AArch64.TTWalkMECID(bit emec, Regime regime, SecurityState ss)">AArch64.TTWalkMECID</anchor>(bit emec, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    if emec == '0' then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    if ss != <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> then
        return <a link="DEFAULT_MECID" file="shared_pseudocode.xml" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</a>;

    case regime of
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>
            return MECID_P0_EL2.MECID;
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>
            if TCR_EL2.A1 == '0' then
                return MECID_P1_EL2.MECID;
            else
                return MECID_P0_EL2.MECID;
        // This applies to stage 1 and stage 2 translation table walks for
        // Realm EL1&amp;0, but the stage 2 translation for a stage 1 walk
        // might later override the MECID according to AMEC configuration.
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>
            return VMECID_P_EL2.MECID;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/mec/DEFAULT_MECID" mylink="aarch64.functions.mec.DEFAULT_MECID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(16) <anchor link="DEFAULT_MECID" hover="constant bits(16) DEFAULT_MECID = Zeros(16)">DEFAULT_MECID</anchor> = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.AccessIsTagChecked" mylink="aarch64.functions.memory.AArch64.AccessIsTagChecked" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AccessIsTagChecked()
// ============================
// TRUE if a given access is tag-checked, FALSE otherwise.

boolean <anchor link="AArch64.AccessIsTagChecked.2" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</anchor>(bits(64) vaddr, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    assert accdesc.tagchecked;

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        return FALSE;

    boolean is_instr = FALSE;
    if (<a link="impl-shared.EffectiveMTX.3" file="shared_pseudocode.xml" hover="function: bit EffectiveMTX(bits(64) address, boolean is_instr, bits(2) el)">EffectiveMTX</a>(vaddr, is_instr, PSTATE.EL) == '0' &amp;&amp;
        <a link="impl-shared.EffectiveTBI.3" file="shared_pseudocode.xml" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</a>(vaddr, is_instr, PSTATE.EL) == '0') then
        return FALSE;

    if (<a link="impl-shared.EffectiveTCMA.2" file="shared_pseudocode.xml" hover="function: bit EffectiveTCMA(bits(64) address, bits(2) el)">EffectiveTCMA</a>(vaddr, PSTATE.EL) == '1' &amp;&amp;
            (vaddr&lt;59:55&gt; == '00000' || vaddr&lt;59:55&gt; == '11111')) then
        return FALSE;

    if !<a link="AArch64.AllocationTagAccessIsEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</a>(accdesc.el) then
        return FALSE;

    if PSTATE.TCO=='1' then
        return FALSE;

    if <a link="impl-shared.HaveMTEStoreOnlyExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</a>() &amp;&amp; !accdesc.write &amp;&amp; <a link="impl-aarch64.StoreOnlyTagCheckingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StoreOnlyTagCheckingEnabled()">StoreOnlyTagCheckingEnabled</a>() then
        return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.AddressWithAllocationTag" mylink="aarch64.functions.memory.AArch64.AddressWithAllocationTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AddressWithAllocationTag()
// ==================================
// Generate a 64-bit value containing a Logical Address Tag from a 64-bit
// virtual address and an Allocation Tag.
// If the extension is disabled, treats the Allocation Tag as '0000'.

bits(64) <anchor link="AArch64.AddressWithAllocationTag.2" hover="function: bits(64) AArch64.AddressWithAllocationTag(bits(64) address, bits(4) allocation_tag)">AArch64.AddressWithAllocationTag</anchor>(bits(64) address, bits(4) allocation_tag)
    bits(64) result = address;
    bits(4) tag;
    if <a link="AArch64.AllocationTagAccessIsEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</a>(PSTATE.EL) then
        tag = allocation_tag;
    else
        tag = '0000';
    result&lt;59:56&gt; = tag;
    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.AllocationTagCheck" mylink="aarch64.functions.memory.AArch64.AllocationTagCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AllocationTagCheck()
// ============================
// Performs an Allocation Tag Check operation for a memory access and
// returns whether the check passed.

boolean <anchor link="AArch64.AllocationTagCheck.3" hover="function: boolean AArch64.AllocationTagCheck(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.AllocationTagCheck</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                   bits(4) ptag)
    if memaddrdesc.memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        (memstatus, readtag) = <a link="impl-aarch64.PhysMemTagRead.2" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(4)) PhysMemTagRead(AddressDescriptor desc, AccessDescriptor accdesc)">PhysMemTagRead</a>(memaddrdesc, accdesc);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, 1, accdesc);

        return ptag == readtag;
    else
        return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.AllocationTagFromAddress" mylink="aarch64.functions.memory.AArch64.AllocationTagFromAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AllocationTagFromAddress()
// ==================================
// Generate an Allocation Tag from a 64-bit value containing a Logical Address Tag.

bits(4) <anchor link="AArch64.AllocationTagFromAddress.1" hover="function: bits(4) AArch64.AllocationTagFromAddress(bits(64) tagged_address)">AArch64.AllocationTagFromAddress</anchor>(bits(64) tagged_address)
    return tagged_address&lt;59:56&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.CanonicalTagCheck" mylink="aarch64.functions.memory.AArch64.CanonicalTagCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CanonicalTagCheck()
// ===========================
// Performs a Canonical Tag Check operation for a memory access and
// returns whether the check passed.

boolean <anchor link="AArch64.CanonicalTagCheck.2" hover="function: boolean AArch64.CanonicalTagCheck(AddressDescriptor memaddrdesc, bits(4) ptag)">AArch64.CanonicalTagCheck</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc, bits(4) ptag)
    expected_tag = if memaddrdesc.vaddress&lt;55&gt; == '0' then '0000' else '1111';
    return ptag == expected_tag;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.CheckTag" mylink="aarch64.functions.memory.AArch64.CheckTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckTag()
// ==================
// Performs a Tag Check operation for a memory access and returns
// whether the check passed

boolean <anchor link="AArch64.CheckTag.3" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, bits(4) ptag)
    if memaddrdesc.memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        return <a link="AArch64.AllocationTagCheck.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagCheck(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.AllocationTagCheck</a>(memaddrdesc, accdesc, ptag);
    elsif memaddrdesc.memattrs.tags == <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a> then
        return <a link="AArch64.CanonicalTagCheck.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.CanonicalTagCheck(AddressDescriptor memaddrdesc, bits(4) ptag)">AArch64.CanonicalTagCheck</a>(memaddrdesc, ptag);
    else
        return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.MemSingle" mylink="aarch64.functions.memory.AArch64.MemSingle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MemSingle[] - non-assignment (read) form
// ================================================
// Perform an atomic, little-endian read of 'size' bytes.

bits(size*8) <anchor link="AArch64.MemSingle.read.4" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</anchor>[bits(64) address, integer size,
                               <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned]
    boolean ispair = FALSE;
    return <a link="AArch64.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch64.MemSingle</a>[address, size, accdesc, aligned, ispair];

// AArch64.MemSingle[] - non-assignment (read) form
// ================================================
// Perform an atomic, little-endian read of 'size' bytes.

bits(size*8) <anchor link="AArch64.MemSingle.read.5" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch64.MemSingle</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in,
                               boolean aligned, boolean ispair]
    assert size IN {1, 2, 4, 8, 16};
    bits(size*8) value;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    if <a link="impl-shared.HaveLSE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</a>() then
        assert <a link="impl-aarch64.AllInAlignedQuantity.3" file="shared_pseudocode.xml" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</a>(address, size, 16);
    else
        assert <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Memory array access
    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then
        if accdesc.transactional &amp;&amp; !<a link="impl-aarch64.MemHasTransactionalAccess.1" file="shared_pseudocode.xml" hover="function: boolean MemHasTransactionalAccess(MemoryAttributes memattrs)">MemHasTransactionalAccess</a>(memaddrdesc.memattrs) then
            <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_IMP" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_IMP</a>, FALSE);

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    if SPESampleInFlight then
        boolean is_load = TRUE;
        <a link="impl-aarch64.SPESampleLoadStore.3" file="shared_pseudocode.xml" hover="function: SPESampleLoadStore(boolean is_load, AccessDescriptor accdesc, AddressDescriptor addrdesc)">SPESampleLoadStore</a>(is_load, accdesc, memaddrdesc);

    boolean atomic;
    if (memaddrdesc.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp;
            memaddrdesc.memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
            memaddrdesc.memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>) then
        atomic = TRUE;
    elsif (accdesc.exclusive || accdesc.atomicop ||
            accdesc.acqsc || accdesc.acqpc || accdesc.relsc) then
        if !aligned &amp;&amp; !<a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_MISALIGNEDATOMIC" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_MISALIGNEDATOMIC</a>) then
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));
        else
            atomic = TRUE;
    elsif aligned then
        atomic = !ispair;
    else
        // Misaligned accesses within 16 byte aligned memory but
        // not Normal Cacheable Writeback are Atomic
        atomic = boolean IMPLEMENTATION_DEFINED "FEAT_LSE2: access is atomic";

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    if atomic then
        (memstatus, value) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, size, accdesc);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, size, accdesc);
    elsif aligned &amp;&amp; ispair then
        assert size IN {8, 16};
        constant halfsize = size DIV 2;
        bits(halfsize * 8) lowhalf, highhalf;
        (memstatus, lowhalf) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, halfsize, accdesc);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, halfsize, accdesc);
        memaddrdesc.paddress.address = memaddrdesc.paddress.address + halfsize;
        (memstatus, highhalf) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, halfsize, accdesc);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, halfsize, accdesc);

        value = highhalf:lowhalf;
    else
        for i = 0 to size-1
            (memstatus, value&lt;8*i+7:8*i&gt;) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, 1, accdesc);
            if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
                <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, 1, accdesc);
            memaddrdesc.paddress.address = memaddrdesc.paddress.address + 1;
    return value;

// AArch64.MemSingle[] - assignment (write) form
// =============================================

<anchor link="AArch64.MemSingle.write.4" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch64.MemSingle</anchor>[bits(64) address, integer size,
                  <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned] = bits(size*8) value
    boolean ispair = FALSE;
    <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address, size, accdesc, aligned, ispair] = value;
    return;

// AArch64.MemSingle[] - assignment (write) form
// =============================================
// Perform an atomic, little-endian write of 'size' bytes.

<anchor link="AArch64.MemSingle.write.5" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in,
                  boolean aligned, boolean ispair] = bits(size*8) value
    assert size IN {1, 2, 4, 8, 16};
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    if <a link="impl-shared.HaveLSE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</a>() then
        assert <a link="impl-aarch64.AllInAlignedQuantity.3" file="shared_pseudocode.xml" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</a>(address, size, 16);
    else
        assert <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then
        if accdesc.transactional &amp;&amp; !<a link="impl-aarch64.MemHasTransactionalAccess.1" file="shared_pseudocode.xml" hover="function: boolean MemHasTransactionalAccess(MemoryAttributes memattrs)">MemHasTransactionalAccess</a>(memaddrdesc.memattrs) then
            <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_IMP" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_IMP</a>, FALSE);

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    if SPESampleInFlight then
        boolean is_load = FALSE;
        <a link="impl-aarch64.SPESampleLoadStore.3" file="shared_pseudocode.xml" hover="function: SPESampleLoadStore(boolean is_load, AccessDescriptor accdesc, AddressDescriptor addrdesc)">SPESampleLoadStore</a>(is_load, accdesc, memaddrdesc);

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    boolean atomic;
    if (memaddrdesc.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp;
            memaddrdesc.memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
            memaddrdesc.memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>) then
        atomic = TRUE;
    elsif (accdesc.exclusive || accdesc.atomicop ||
            accdesc.acqsc || accdesc.acqpc || accdesc.relsc) then
        if !aligned &amp;&amp; !<a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_MISALIGNEDATOMIC" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_MISALIGNEDATOMIC</a>) then
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));
        else
            atomic = TRUE;
    elsif aligned then
        atomic = !ispair;
    else
        // Misaligned accesses within 16 byte aligned memory but
        // not Normal Cacheable Writeback are Atomic
        atomic = boolean IMPLEMENTATION_DEFINED "FEAT_LSE2: access is atomic";

    if atomic then
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, size, accdesc, value);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, size, accdesc);
    elsif aligned &amp;&amp; ispair then
        assert size IN {8, 16};
        constant halfsize = size DIV 2;
        bits(halfsize*8) lowhalf, highhalf;
        &lt;highhalf, lowhalf&gt; = value;

        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, halfsize, accdesc, lowhalf);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, halfsize, accdesc);
        memaddrdesc.paddress.address = memaddrdesc.paddress.address + halfsize;
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, halfsize, accdesc, highhalf);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, halfsize, accdesc);
    else
        for i = 0 to size-1
            memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, 1, accdesc, value&lt;8*i+7:8*i&gt;);
            if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
                <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, 1, accdesc);
            memaddrdesc.paddress.address = memaddrdesc.paddress.address + 1;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.MemTag" mylink="aarch64.functions.memory.AArch64.MemTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MemTag[] - non-assignment (read) form
// =============================================
// Load an Allocation Tag from memory.

bits(4) <anchor link="AArch64.MemTag.read.2" hover="accessor: bits(4) AArch64.MemTag[bits(64) address, AccessDescriptor accdesc_in]">AArch64.MemTag</anchor>[bits(64) address, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in]
    assert accdesc_in.tagaccess &amp;&amp; !accdesc_in.tagchecked;

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    bits(4) value;

    boolean aligned = TRUE;

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then
        accdesc.tagaccess = <a link="AArch64.AllocationTagAccessIsEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</a>(accdesc.el);

    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, <a link="TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</a>);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Return the granule tag if tagging is enabled...
    if accdesc.tagaccess &amp;&amp; memaddrdesc.memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        (memstatus, tag) = <a link="impl-aarch64.PhysMemTagRead.2" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(4)) PhysMemTagRead(AddressDescriptor desc, AccessDescriptor accdesc)">PhysMemTagRead</a>(memaddrdesc, accdesc);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, 1, accdesc);
        return tag;
    elsif (<a link="impl-shared.HaveMTECanonicalTagCheckingExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTECanonicalTagCheckingExt()">HaveMTECanonicalTagCheckingExt</a>() &amp;&amp;
           accdesc.tagaccess &amp;&amp;
           memaddrdesc.memattrs.tags == <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a>) then
        return if address&lt;55&gt; == '0' then '0000' else '1111';
    else
        // ...otherwise read tag as zero.
        return '0000';

// AArch64.MemTag[] - assignment (write) form
// ==========================================
// Store an Allocation Tag to memory.

<anchor link="AArch64.MemTag.write.2" hover="accessor: AArch64.MemTag[bits(64) address, AccessDescriptor accdesc_in] = bits(4) value">AArch64.MemTag</anchor>[bits(64) address, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in] = bits(4) value
    assert accdesc_in.tagaccess &amp;&amp; !accdesc_in.tagchecked;

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;

    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, <a link="TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</a>);

    // Stores of allocation tags must be aligned
    if !aligned then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then
        accdesc.tagaccess = <a link="AArch64.AllocationTagAccessIsEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</a>(accdesc.el);

    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, <a link="TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</a>);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Memory array access
    if accdesc.tagaccess &amp;&amp; memaddrdesc.memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        memstatus = <a link="impl-aarch64.PhysMemTagWrite.3" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemTagWrite(AddressDescriptor desc, AccessDescriptor accdesc, bits (4) value)">PhysMemTagWrite</a>(memaddrdesc, accdesc, value);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, 1, accdesc);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.PhysicalTag" mylink="aarch64.functions.memory.AArch64.PhysicalTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PhysicalTag()
// =====================
// Generate a Physical Tag from a Logical Tag in an address

bits(4) <anchor link="AArch64.PhysicalTag.1" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</anchor>(bits(64) vaddr)
    return vaddr&lt;59:56&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AArch64.UnalignedAccessFaults" mylink="aarch64.functions.memory.AArch64.UnalignedAccessFaults" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.UnalignedAccessFaults()
// ===============================
// Determine whether the unaligned access generates an Alignment fault

boolean <anchor link="AArch64.UnalignedAccessFaults.3" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, bits(64) address, integer size)
    if <a link="impl-shared.AlignmentEnforced.0" file="shared_pseudocode.xml" hover="function: boolean AlignmentEnforced()">AlignmentEnforced</a>() then
        return TRUE;
    elsif accdesc.acctype == <a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a> then
        return TRUE;
    elsif accdesc.rcw then
        return TRUE;
    elsif accdesc.ls64 then
        return TRUE;
    elsif accdesc.exclusive || accdesc.atomicop then
        return !<a link="impl-shared.HaveLSE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</a>() || !<a link="impl-aarch64.AllInAlignedQuantity.3" file="shared_pseudocode.xml" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</a>(address, size, 16);
    elsif accdesc.acqsc || accdesc.acqpc || accdesc.relsc then
        return !<a link="impl-shared.HaveLSE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</a>() || (<a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].nAA == '0' &amp;&amp; !<a link="impl-aarch64.AllInAlignedQuantity.3" file="shared_pseudocode.xml" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</a>(address, size, 16));
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AddressSupportsLS64" mylink="aarch64.functions.memory.AddressSupportsLS64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddressSupportsLS64()
// =====================
// Returns TRUE if the 64-byte block following the given address supports the
// LD64B and ST64B instructions, and FALSE otherwise.

boolean <anchor link="impl-aarch64.AddressSupportsLS64.1" hover="function: boolean AddressSupportsLS64(bits(56) paddress)">AddressSupportsLS64</anchor>(bits(56) paddress);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/AllInAlignedQuantity" mylink="aarch64.functions.memory.AllInAlignedQuantity" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AllInAlignedQuantity()
// ======================
// Returns TRUE if all accessed bytes are within one aligned quantity, FALSE otherwise.

boolean <anchor link="impl-aarch64.AllInAlignedQuantity.3" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</anchor>(bits(64) address, integer size, integer alignment)
    assert(size &lt;= alignment);
    return <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>((address+size)-1, alignment) == <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(address, alignment);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/CheckSPAlignment" mylink="aarch64.functions.memory.CheckSPAlignment" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSPAlignment()
// ==================
// Check correct stack pointer alignment for AArch64 state.

<anchor link="impl-aarch64.CheckSPAlignment.0" hover="function: CheckSPAlignment()">CheckSPAlignment</anchor>()
    bits(64) sp = <a link="impl-aarch64.SP.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) SP[]">SP</a>[];
    boolean stack_align_check;
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        stack_align_check = (<a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].SA0 != '0');
    else
        stack_align_check = (<a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].SA != '0');

    if stack_align_check &amp;&amp; sp != <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(sp, 16) then
        <a link="AArch64.SPAlignmentFault.0" file="shared_pseudocode.xml" hover="function: AArch64.SPAlignmentFault()">AArch64.SPAlignmentFault</a>();

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/Mem" mylink="aarch64.functions.memory.Mem" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Mem[] - non-assignment (read) form
// ==================================
// Perform a read of 'size' bytes. The access byte order is reversed for a big-endian access.
// Instruction fetches would call AArch64.MemSingle directly.

bits(size*8) <anchor link="impl-aarch64.Mem.read.3" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc]
    boolean ispair = FALSE;
    boolean highestAddressfirst = FALSE;
    return <a link="impl-aarch64.Mem.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc, boolean ispair, boolean  highestAddressfirst]">Mem</a>[address, size, accdesc, ispair, highestAddressfirst];

bits(size*8) <anchor link="impl-aarch64.Mem.read.4" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc, boolean ispair]">Mem</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean ispair]
    boolean highestAddressfirst = FALSE;
    return <a link="impl-aarch64.Mem.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc, boolean ispair, boolean  highestAddressfirst]">Mem</a>[address, size, accdesc, ispair, highestAddressfirst];

bits(size*8) <anchor link="impl-aarch64.Mem.read.5" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc, boolean ispair, boolean  highestAddressfirst]">Mem</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                 boolean ispair, boolean  highestAddressfirst]
    assert size IN {1, 2, 4, 8, 16};
    constant halfsize = size DIV 2;
    bits(size * 8) value;
    bits(halfsize * 8) lowhalf, highhalf;

    // Check alignment on size of element accessed, not overall access size
    integer alignment = if ispair then halfsize else size;
    boolean aligned   = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, alignment);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if accdesc.acctype == <a link="AccessType_ASIMD" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_ASIMD</a> &amp;&amp; size == 16 &amp;&amp; <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, 8) then
        // If 128-bit SIMD&amp;FP ordered access are treated as a pair of
        // 64-bit single-copy atomic accesses, then these single copy atomic
        // access can be observed in any order.
        lowhalf = <a link="AArch64.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch64.MemSingle</a>[address, halfsize, accdesc, aligned, ispair];
        highhalf = <a link="AArch64.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch64.MemSingle</a>[address+halfsize, halfsize, accdesc, aligned, ispair];
        value = highhalf:lowhalf;
    elsif <a link="impl-shared.HaveLSE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</a>() &amp;&amp; <a link="impl-aarch64.AllInAlignedQuantity.3" file="shared_pseudocode.xml" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</a>(address, size, 16) then
        value = <a link="AArch64.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch64.MemSingle</a>[address, size, accdesc, aligned, ispair];
    elsif ispair &amp;&amp; aligned then
        if <a link="impl-shared.HaveLRCPC3Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLRCPC3Ext()">HaveLRCPC3Ext</a>() &amp;&amp; highestAddressfirst then
            highhalf = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address+halfsize, halfsize, accdesc, aligned];
            lowhalf  = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address, halfsize, accdesc, aligned];
        else
            lowhalf  = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address, halfsize, accdesc, aligned];
            highhalf = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address+halfsize, halfsize, accdesc, aligned];
        value = highhalf:lowhalf;
    elsif aligned then
        value = <a link="AArch64.MemSingle.read.5" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair]">AArch64.MemSingle</a>[address, size, accdesc, aligned, ispair];
    else
        assert size &gt; 1;
        if <a link="impl-shared.HaveLRCPC3Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLRCPC3Ext()">HaveLRCPC3Ext</a>() &amp;&amp; ispair &amp;&amp; highestAddressfirst then
            // Performing memory accesses from one load or store instruction to Device memory that
            // crosses a boundary corresponding to the smallest translation granule size of the
            // implementation causes CONSTRAINED UNPREDICTABLE behavior.

            for i = 0 to halfsize-1
                // Individual byte access can be observed in any order
                highhalf&lt;8*i+7:8*i&gt; = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address+halfsize +i, 1, accdesc, aligned];
            for i = 0 to halfsize-1
                // Individual byte access can be observed in any order
                lowhalf&lt;8*i+7:8*i&gt; = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address + i, 1, accdesc, aligned];

            value = highhalf:lowhalf;

        else
            value&lt;7:0&gt; = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address, 1, accdesc, aligned];

            // For subsequent bytes it is CONSTRAINED UNPREDICTABLE whether an unaligned Device
            // memory access will generate an Alignment Fault, as to get this far means the first
            // byte did not, so we must be changing to a new translation page.
            c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVPAGE2" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVPAGE2</a>);
            assert c IN {<a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>};
            if c == <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a> then aligned = TRUE;

            for i = 1 to size-1
                value&lt;8*i+7:8*i&gt; = <a link="AArch64.MemSingle.read.4" file="shared_pseudocode.xml" hover="accessor: bits(size*8) AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned]">AArch64.MemSingle</a>[address+i, 1, accdesc, aligned];

    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        value = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value);

    return value;

// Mem[] - assignment (write) form
// ===============================
// Perform a write of 'size' bytes. The byte order is reversed for a big-endian access.

Mem[bits(64) address, integer size, AccessDescriptor accdesc] = bits(size*8) value_in
    boolean ispair = FALSE;
    boolean highestAddressfirst = FALSE;
    Mem[address, size, accdesc, ispair, highestAddressfirst] = value_in;

Mem[bits(64) address, integer size, AccessDescriptor accdesc,
        boolean ispair] = bits(size*8) value_in
    boolean highestAddressfirst = FALSE;
    Mem[address, size, accdesc, ispair, highestAddressfirst] = value_in;

Mem[bits(64) address, integer size, AccessDescriptor accdesc,
        boolean ispair, boolean highestAddressfirst] = bits(size*8) value_in
    constant halfsize = size DIV 2;
    bits(size*8) value = value_in;
    bits(halfsize*8) lowhalf, highhalf;

    // Check alignment on size of element accessed, not overall access size
    integer alignment = if ispair then halfsize else size;
    boolean aligned   = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, alignment);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        value = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value);

    if accdesc.acctype == <a link="AccessType_ASIMD" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_ASIMD</a> &amp;&amp; size == 16 &amp;&amp; <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, 8) then
        // 128-bit SIMD&amp;FP stores are treated as a pair of 64-bit single-copy atomic accesses
        // 64-bit aligned.
        &lt;highhalf, lowhalf&gt; = value;
        <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address, halfsize, accdesc, aligned, ispair] = lowhalf;
        <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address+halfsize, halfsize, accdesc, aligned, ispair] = highhalf;
    elsif <a link="impl-shared.HaveLSE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</a>() &amp;&amp; <a link="impl-aarch64.AllInAlignedQuantity.3" file="shared_pseudocode.xml" hover="function: boolean AllInAlignedQuantity(bits(64) address, integer size, integer alignment)">AllInAlignedQuantity</a>(address, size, 16) then
        <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address, size, accdesc, aligned, ispair] = value;
    elsif ispair &amp;&amp; aligned then
        joinedpair = FALSE;
        &lt;highhalf, lowhalf&gt; = value;
        if <a link="impl-shared.HaveLRCPC3Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLRCPC3Ext()">HaveLRCPC3Ext</a>() &amp;&amp; highestAddressfirst then
            <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address+halfsize, halfsize, accdesc, aligned, joinedpair] = highhalf;
            <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address, halfsize, accdesc, aligned, joinedpair] = lowhalf;
        else
            <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address, halfsize, accdesc, aligned, joinedpair] = lowhalf;
            <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address+halfsize, halfsize, accdesc, aligned, joinedpair] = highhalf;
    elsif aligned then
        <a link="AArch64.MemSingle.write.5" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned, boolean ispair] = bits(size*8) value">AArch64.MemSingle</a>[address, size, accdesc, aligned, ispair] = value;
    else
        assert size &gt; 1;
        if <a link="impl-shared.HaveLRCPC3Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveLRCPC3Ext()">HaveLRCPC3Ext</a>() &amp;&amp; ispair &amp;&amp; highestAddressfirst then
            // Performing memory accesses from one load or store instruction to Device memory that
            // crosses a boundary corresponding to the smallest translation granule size of the
            // implementation causes CONSTRAINED UNPREDICTABLE behavior.
            &lt;highhalf, lowhalf&gt; = value;
            for i = 0 to halfsize-1
                // Individual byte access can be observed in any order
                <a link="AArch64.MemSingle.write.4" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch64.MemSingle</a>[address+halfsize+i, 1, accdesc, aligned] = highhalf&lt;8*i+7:8*i&gt;;
            for i = 0 to halfsize-1
                // Individual byte access can be observed in any order, but implies observability
                // of highhalf
                <a link="AArch64.MemSingle.write.4" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch64.MemSingle</a>[address+i, 1, accdesc, aligned] = lowhalf&lt;8*i+7:8*i&gt;;
        else
            <a link="AArch64.MemSingle.write.4" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch64.MemSingle</a>[address, 1, accdesc, aligned] = value&lt;7:0&gt;;

            // For subsequent bytes it is CONSTRAINED UNPREDICTABLE whether an unaligned Device
            // memory access will generate an Alignment Fault, as to get this far means the first
            // byte did not, so we must be changing to a new translation page.

            c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVPAGE2" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVPAGE2</a>);
            assert c IN {<a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>};
            if c == <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a> then aligned = TRUE;

            for i = 1 to size-1
                <a link="AArch64.MemSingle.write.4" file="shared_pseudocode.xml" hover="accessor: AArch64.MemSingle[bits(64) address, integer size, AccessDescriptor accdesc, boolean aligned] = bits(size*8) value">AArch64.MemSingle</a>[address+i, 1, accdesc, aligned] = value&lt;8*i+7:8*i&gt;;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/MemAtomic" mylink="aarch64.functions.memory.MemAtomic" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemAtomic()
// ===========
// Performs load and store memory operations for a given virtual address.

bits(size) <anchor link="impl-aarch64.MemAtomic.4" hover="function: bits(size) MemAtomic(bits(64) address, bits(size) cmpoperand, bits(size) operand, AccessDescriptor accdesc_in)">MemAtomic</anchor>(bits(64) address, bits(size) cmpoperand, bits(size) operand,
                     <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    assert accdesc_in.atomicop;

    constant integer bytes = size DIV 8;
    assert bytes IN {1, 2, 4, 8, 16};

    bits(size) newvalue;
    bits(size) oldvalue;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, bytes);

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, bytes) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    // MMU or MPU lookup
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    // For Store-only Tag checking, the tag check is performed on the store.
    if (<a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked &amp;&amp;
        (!<a link="impl-shared.HaveMTEStoreOnlyExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</a>() || !<a link="impl-aarch64.StoreOnlyTagCheckingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StoreOnlyTagCheckingEnabled()">StoreOnlyTagCheckingEnabled</a>())) then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    // All observers in the shareability domain observe the following load and store atomically.
    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, oldvalue) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, bytes, accdesc);

    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, bytes, accdesc);
    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        oldvalue = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(oldvalue);

    boolean cmpfail = FALSE;
    case accdesc.modop of
        when <a link="MemAtomicOp_ADD" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_ADD</a>   newvalue = oldvalue + operand;
        when <a link="MemAtomicOp_BIC" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_BIC</a>   newvalue = oldvalue AND NOT(operand);
        when <a link="MemAtomicOp_EOR" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_EOR</a>   newvalue = oldvalue EOR operand;
        when <a link="MemAtomicOp_ORR" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_ORR</a>   newvalue = oldvalue OR operand;
        when <a link="MemAtomicOp_SMAX" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SMAX</a>  newvalue = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>(<a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(oldvalue), <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(operand))&lt;size-1:0&gt;;
        when <a link="MemAtomicOp_SMIN" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SMIN</a>  newvalue = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(<a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(oldvalue), <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(operand))&lt;size-1:0&gt;;
        when <a link="MemAtomicOp_UMAX" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_UMAX</a>  newvalue = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(oldvalue), <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand))&lt;size-1:0&gt;;
        when <a link="MemAtomicOp_UMIN" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_UMIN</a>  newvalue = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(oldvalue), <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand))&lt;size-1:0&gt;;
        when <a link="MemAtomicOp_SWP" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SWP</a>   newvalue = operand;
        when <a link="MemAtomicOp_CAS" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_CAS</a>   newvalue = operand; cmpfail = cmpoperand != oldvalue;

    if <a link="impl-shared.HaveMTEStoreOnlyExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</a>() &amp;&amp; <a link="impl-aarch64.StoreOnlyTagCheckingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StoreOnlyTagCheckingEnabled()">StoreOnlyTagCheckingEnabled</a>() then
        // If the compare on a CAS fails, then it is CONSTRAINED UNPREDICTABLE whether the
        // Tag check is performed.
        if accdesc.tagchecked &amp;&amp; cmpfail then
            accdesc.tagchecked = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_STOREONLYTAGCHECKEDCAS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_STOREONLYTAGCHECKEDCAS</a>);

        if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
            bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
            if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
                accdesc.read = FALSE; // Tag Check Fault on a write.
                <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    if !cmpfail then
        if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
            newvalue = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(newvalue);
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, bytes, accdesc, newvalue);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, bytes, accdesc);

    if SPESampleInFlight then
        boolean is_load = FALSE;
        <a link="impl-aarch64.SPESampleLoadStore.3" file="shared_pseudocode.xml" hover="function: SPESampleLoadStore(boolean is_load, AccessDescriptor accdesc, AddressDescriptor addrdesc)">SPESampleLoadStore</a>(is_load, accdesc, memaddrdesc);

    // Load operations return the old (pre-operation) value
    return oldvalue;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/MemAtomicRCW" mylink="aarch64.functions.memory.MemAtomicRCW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemAtomicRCW()
// ==============
// Perform a single-copy-atomic access with Read-Check-Write operation

(bits(4), bits(size)) <anchor link="impl-aarch64.MemAtomicRCW.4" hover="function: (bits(4), bits(size)) MemAtomicRCW(bits(64) address, bits(size) cmpoperand, bits(size) operand, AccessDescriptor accdesc_in)">MemAtomicRCW</anchor>(bits(64) address, bits(size) cmpoperand, bits(size) operand,
                                   <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    assert accdesc_in.atomicop;
    assert accdesc_in.rcw;

    constant integer bytes = size DIV 8;
    assert bytes IN {8, 16};

    bits(4) nzcv;
    bits(size) oldvalue;
    bits(size) newvalue;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, bytes);

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, bytes) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    // MMU or MPU lookup
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    // For Store-only Tag checking, the tag check is performed on the store.
    if (<a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked &amp;&amp;
        (!<a link="impl-shared.HaveMTEStoreOnlyExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</a>() || !<a link="impl-aarch64.StoreOnlyTagCheckingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StoreOnlyTagCheckingEnabled()">StoreOnlyTagCheckingEnabled</a>())) then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    // All observers in the shareability domain observe the following load and store atomically.
    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, oldvalue) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, bytes, accdesc);

    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, bytes, accdesc);

    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        oldvalue = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(oldvalue);

    boolean cmpfail = FALSE;
    case accdesc.modop of
        when <a link="MemAtomicOp_BIC" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_BIC</a> newvalue = oldvalue AND NOT(operand);
        when <a link="MemAtomicOp_ORR" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_ORR</a> newvalue = oldvalue OR operand;
        when <a link="MemAtomicOp_SWP" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SWP</a> newvalue = operand;
        when <a link="MemAtomicOp_CAS" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_CAS</a> newvalue = operand; cmpfail = oldvalue != cmpoperand;

    if cmpfail then
        nzcv = '1010'; // N = 1 indicates compare failure
    else
        nzcv = <a link="impl-aarch64.RCWCheck.3" file="shared_pseudocode.xml" hover="function: bits(4) RCWCheck(bits(N) old, bits(N) new, boolean soft)">RCWCheck</a>(oldvalue, newvalue, accdesc.rcws);

    if <a link="impl-shared.HaveMTEStoreOnlyExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</a>() &amp;&amp; <a link="impl-aarch64.StoreOnlyTagCheckingEnabled.0" file="shared_pseudocode.xml" hover="function: boolean StoreOnlyTagCheckingEnabled()">StoreOnlyTagCheckingEnabled</a>() then
        // If the compare on a CAS fails, then it is CONSTRAINED UNPREDICTABLE whether the
        // Tag check is performed.
        if accdesc.tagchecked &amp;&amp; cmpfail then
            accdesc.tagchecked = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_STOREONLYTAGCHECKEDCAS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_STOREONLYTAGCHECKEDCAS</a>);

        if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
            bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
            if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
                accdesc.read = FALSE; // Tag Check Fault on a write.
                <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    if nzcv == '0010' then
        if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
            newvalue = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(newvalue);

        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, bytes, accdesc, newvalue);

        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, bytes, accdesc);

    return (nzcv, oldvalue);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/MemLoad64B" mylink="aarch64.functions.memory.MemLoad64B" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemLoad64B()
// ============
// Performs an atomic 64-byte read from a given virtual address.

bits(512) <anchor link="impl-aarch64.MemLoad64B.2" hover="function: bits(512) MemLoad64B(bits(64) address, AccessDescriptor accdesc_in)">MemLoad64B</anchor>(bits(64) address, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    bits(512) data;
    constant integer size = 64;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), size);

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    if !<a link="impl-aarch64.AddressSupportsLS64.1" file="shared_pseudocode.xml" hover="function: boolean AddressSupportsLS64(bits(56) paddress)">AddressSupportsLS64</a>(memaddrdesc.paddress.address) then
        c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_LS64UNSUPPORTED" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_LS64UNSUPPORTED</a>);
        assert c IN {<a link="Constraint_LIMITED_ATOMICITY" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_LIMITED_ATOMICITY</a>, <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>};

        if c == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a> then
            // Generate a stage 1 Data Abort reported using the DFSC code of 110101.
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.ExclusiveFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord ExclusiveFault(AccessDescriptor accdesc)">ExclusiveFault</a>(accdesc));
        else
            // Accesses are not single-copy atomic above the byte level.
            for i = 0 to size-1
                <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
                (memstatus, data&lt;8*i+7:8*i&gt;) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, 1, accdesc);
                if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
                    <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, 1, accdesc);

                memaddrdesc.paddress.address = memaddrdesc.paddress.address + 1;
    else
        <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
        (memstatus, data) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, size, accdesc);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalReadAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</a>(memstatus, memaddrdesc, size, accdesc);

    return data;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/MemStore64B" mylink="aarch64.functions.memory.MemStore64B" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemStore64B()
// =============
// Performs an atomic 64-byte store to a given virtual address. Function does
// not return the status of the store.

<anchor link="impl-aarch64.MemStore64B.3" hover="function: MemStore64B(bits(64) address, bits(512) value, AccessDescriptor accdesc_in)">MemStore64B</anchor>(bits(64) address, bits(512) value, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    constant integer size = 64;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), 64);

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);

    if !<a link="impl-aarch64.AddressSupportsLS64.1" file="shared_pseudocode.xml" hover="function: boolean AddressSupportsLS64(bits(56) paddress)">AddressSupportsLS64</a>(memaddrdesc.paddress.address) then
        c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_LS64UNSUPPORTED" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_LS64UNSUPPORTED</a>);
        assert c IN {<a link="Constraint_LIMITED_ATOMICITY" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_LIMITED_ATOMICITY</a>, <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>};

        if c == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a> then
            // Generate a Data Abort reported using the DFSC code of 110101.
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.ExclusiveFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord ExclusiveFault(AccessDescriptor accdesc)">ExclusiveFault</a>(accdesc));
        else
            // Accesses are not single-copy atomic above the byte level.
            for i = 0 to size-1
                memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, 1, accdesc, value&lt;8*i+7:8*i&gt;);
                if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
                    <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, 1, accdesc);

                memaddrdesc.paddress.address = memaddrdesc.paddress.address+1;
    else
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, size, accdesc, value);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, size, accdesc);

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/MemStore64BWithRet" mylink="aarch64.functions.memory.MemStore64BWithRet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemStore64BWithRet()
// ====================
// Performs an atomic 64-byte store to a given virtual address returning
// the status value of the operation.

bits(64) <anchor link="impl-aarch64.MemStore64BWithRet.3" hover="function: bits(64) MemStore64BWithRet(bits(64) address, bits(512) value, AccessDescriptor accdesc_in)">MemStore64BWithRet</anchor>(bits(64) address, bits(512) value, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    constant integer size = 64;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned &amp;&amp; <a link="AArch64.UnalignedAccessFaults.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.UnalignedAccessFaults(AccessDescriptor accdesc, bits(64) address, integer size)">AArch64.UnalignedAccessFaults</a>(accdesc, address, size) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, <a link="impl-shared.AlignmentFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</a>(accdesc));

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, memaddrdesc.fault);
        return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>('1', 64);

    // Effect on exclusives
    if memaddrdesc.memattrs.shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then
        <a link="impl-shared.ClearExclusiveByAddress.3" file="shared_pseudocode.xml" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</a>(memaddrdesc.paddress, <a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>(), 64);

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            <a link="AArch64.TagCheckFault.2" file="shared_pseudocode.xml" hover="function: AArch64.TagCheckFault(bits(64) vaddress, AccessDescriptor accdesc)">AArch64.TagCheckFault</a>(address, accdesc);
            return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>('1', 64);

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(memaddrdesc, size, accdesc, value);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        <a link="impl-shared.HandleExternalWriteAbort.4" file="shared_pseudocode.xml" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</a>(memstatus, memaddrdesc, size, accdesc);

    return memstatus.store64bstatus;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/MemStore64BWithRetStatus" mylink="aarch64.functions.memory.MemStore64BWithRetStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemStore64BWithRetStatus()
// ==========================
// Generates the return status of memory write with ST64BV or ST64BV0
// instructions. The status indicates if the operation succeeded, failed,
// or was not supported at this memory location.

bits(64) <anchor link="impl-aarch64.MemStore64BWithRetStatus.0" hover="function: bits(64) MemStore64BWithRetStatus()">MemStore64BWithRetStatus</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/memory/NVMem" mylink="aarch64.functions.memory.NVMem" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NVMem[] - non-assignment form
// =============================
// This function is the load memory access for the transformed System register read access
// when Enhanced Nested Virtualization is enabled with HCR_EL2.NV2 = 1.
// The address for the load memory access is calculated using
// the formula SignExtend(VNCR_EL2.BADDR : Offset&lt;11:0&gt;, 64) where,
//  * VNCR_EL2.BADDR holds the base address of the memory location, and
//  * Offset is the unique offset value defined architecturally for each System register that
//    supports transformation of register access to memory access.

bits(64) <anchor link="impl-aarch64.NVMem.read.1" hover="accessor: bits(64) NVMem[integer offset]">NVMem</anchor>[integer offset]
    assert offset &gt; 0;
    constant integer size = 64;
    return <a link="impl-aarch64.NVMem.read.2" file="shared_pseudocode.xml" hover="accessor: bits(N) NVMem[integer offset, integer N]">NVMem</a>[offset, size];

bits(N) <anchor link="impl-aarch64.NVMem.read.2" hover="accessor: bits(N) NVMem[integer offset, integer N]">NVMem</anchor>[integer offset, integer N]
    assert offset &gt; 0;
    assert N IN {64,128};
    bits(64) address = <a link="impl-shared.SignExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) SignExtend(bits(M) x, integer N)">SignExtend</a>(VNCR_EL2.BADDR:offset&lt;11:0&gt;, 64);
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescNV2.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescNV2(MemOp memop)">CreateAccDescNV2</a>(<a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>);
    return <a link="impl-aarch64.Mem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size*8) Mem[bits(64) address, integer size, AccessDescriptor accdesc]">Mem</a>[address, N DIV 8, accdesc];

// NVMem[] - assignment form
// =========================
// This function is the store memory access for the transformed System register write access
// when Enhanced Nested Virtualization is enabled with HCR_EL2.NV2 = 1.
// The address for the store memory access is calculated using
// the formula SignExtend(VNCR_EL2.BADDR : Offset&lt;11:0&gt;, 64) where,
//  * VNCR_EL2.BADDR holds the base address of the memory location, and
//  * Offset is the unique offset value defined architecturally for each System register that
//    supports transformation of register access to memory access.

<anchor link="impl-aarch64.NVMem.write.1" hover="accessor: NVMem[integer offset] = bits(64) value">NVMem</anchor>[integer offset] = bits(64) value
    assert offset &gt; 0;
    constant integer size = 64;
    <a link="impl-aarch64.NVMem.write.2" file="shared_pseudocode.xml" hover="accessor: NVMem[integer offset, integer N] = bits(N) value">NVMem</a>[offset, size] = value;
    return;

<anchor link="impl-aarch64.NVMem.write.2" hover="accessor: NVMem[integer offset, integer N] = bits(N) value">NVMem</anchor>[integer offset, integer N] = bits(N) value
    assert offset &gt; 0;
    assert N IN {64,128};
    bits(64) address = <a link="impl-shared.SignExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) SignExtend(bits(M) x, integer N)">SignExtend</a>(VNCR_EL2.BADDR:offset&lt;11:0&gt;, 64);
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescNV2.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescNV2(MemOp memop)">CreateAccDescNV2</a>(<a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>);
    Mem[address, N DIV 8, accdesc] = value;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/memory/PhysMemTagRead" mylink="aarch64.functions.memory.PhysMemTagRead" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysMemTagRead()
// ================
// This is the hardware operation which perform a single-copy atomic,
// Allocation Tag granule aligned, memory access from the tag in PA space.
//
// The function address the array using desc.paddress which supplies:
// * A 52-bit physical address
// * A single NS bit to select between Secure and Non-secure parts of the array.
//
// The accdesc descriptor describes the access type: normal, exclusive, ordered, streaming,
// etc and other parameters required to access the physical memory or for setting syndrome
// register in the event of an External abort.

(PhysMemRetStatus, bits(4)) <anchor link="impl-aarch64.PhysMemTagRead.2" hover="function: (PhysMemRetStatus, bits(4)) PhysMemTagRead(AddressDescriptor desc, AccessDescriptor accdesc)">PhysMemTagRead</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> desc, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/PhysMemTagWrite" mylink="aarch64.functions.memory.PhysMemTagWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysMemTagWrite()
// =================
// This is the hardware operation which perform a single-copy atomic,
// Allocation Tag granule aligned, memory access to the tag in PA space.
//
// The function address the array using desc.paddress which supplies:
// * A 52-bit physical address
// * A single NS bit to select between Secure and Non-secure parts of the array.
//
// The accdesc descriptor describes the access type: normal, exclusive, ordered, streaming,
// etc and other parameters required to access the physical memory or for setting syndrome
// register in the event of an External abort.

PhysMemRetStatus <anchor link="impl-aarch64.PhysMemTagWrite.3" hover="function: PhysMemRetStatus PhysMemTagWrite(AddressDescriptor desc, AccessDescriptor accdesc, bits (4) value)">PhysMemTagWrite</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> desc, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, bits (4) value);</pstext>
    </ps>
    <ps name="aarch64/functions/memory/StoreOnlyTagCheckingEnabled" mylink="aarch64.functions.memory.StoreOnlyTagCheckingEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StoreOnlyTagCheckingEnabled()
// =============================
// Returns TRUE if loads executed at the current Exception level are Tag unchecked.

boolean <anchor link="impl-aarch64.StoreOnlyTagCheckingEnabled.0" hover="function: boolean StoreOnlyTagCheckingEnabled()">StoreOnlyTagCheckingEnabled</anchor>()
    assert <a link="impl-shared.HaveMTEStoreOnlyExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</a>();
    bit tcso;

    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            if !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
                tcso = SCTLR_EL1.TCSO0;
            else
                tcso = SCTLR_EL2.TCSO0;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            tcso = SCTLR_EL1.TCSO;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            tcso = SCTLR_EL2.TCSO;
        otherwise
            tcso = SCTLR_EL3.TCSO;

    return tcso == '1';</pstext>
    </ps>
    <ps name="aarch64/functions/mops/CPYFOptionA" mylink="aarch64.functions.mops.CPYFOptionA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPYFOptionA()
// =============
// Returns TRUE if the implementation uses Option A for the
// CPYF* instructions, and FALSE otherwise.

boolean <anchor link="impl-aarch64.CPYFOptionA.0" hover="function: boolean CPYFOptionA()">CPYFOptionA</anchor>()
    return boolean IMPLEMENTATION_DEFINED "CPYF* instructions use Option A";</pstext>
    </ps>
    <ps name="aarch64/functions/mops/CPYOptionA" mylink="aarch64.functions.mops.CPYOptionA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPYOptionA()
// ============
// Returns TRUE if the implementation uses Option A for the
// CPY* instructions, and FALSE otherwise.

boolean <anchor link="impl-aarch64.CPYOptionA.0" hover="function: boolean CPYOptionA()">CPYOptionA</anchor>()
    return boolean IMPLEMENTATION_DEFINED "CPY* instructions use Option A";</pstext>
    </ps>
    <ps name="aarch64/functions/mops/CPYPostSizeChoice" mylink="aarch64.functions.mops.CPYPostSizeChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPYPostSizeChoice()
// ===================
// Returns the size of the copy that is performed by the CPYE* instructions for this
// implementation given the parameters of the destination, source and size of the copy.
// Postsize is encoded as -1*size for an option A implementation if cpysize is negative.

bits(64) <anchor link="impl-aarch64.CPYPostSizeChoice.3" hover="function: bits(64) CPYPostSizeChoice(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize)">CPYPostSizeChoice</anchor>(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/CPYPreSizeChoice" mylink="aarch64.functions.mops.CPYPreSizeChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPYPreSizeChoice()
// ==================
// Returns the size of the copy that is performed by the CPYP* instructions for this
// implementation given the parameters of the destination, source and size of the copy.
// Presize is encoded as -1*size for an option A implementation if cpysize is negative.

bits(64) <anchor link="impl-aarch64.CPYPreSizeChoice.3" hover="function: bits(64) CPYPreSizeChoice(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize)">CPYPreSizeChoice</anchor>(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/CPYSizeChoice" mylink="aarch64.functions.mops.CPYSizeChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPYSizeChoice()
// ===============
// Returns the size of the block this performed for an iteration of the copy given the
// parameters of the destination, source and size of the copy.

integer <anchor link="impl-aarch64.CPYSizeChoice.3" hover="function: integer CPYSizeChoice(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize)">CPYSizeChoice</anchor>(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/CheckMOPSEnabled" mylink="aarch64.functions.mops.CheckMOPSEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckMOPSEnabled()
// ==================
// Check for EL0 and EL1 access to the CPY* and SET* instructions.

<anchor link="impl-aarch64.CheckMOPSEnabled.0" hover="function: CheckMOPSEnabled()">CheckMOPSEnabled</anchor>()
    if (PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
        (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0') &amp;&amp;
        (!<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.MSCEn == '0')) then
        UNDEFINED;

    if (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; SCTLR_EL1.MSCEn == '0' &amp;&amp;
        (!<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() || HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0')) then
        UNDEFINED;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() &amp;&amp; SCTLR_EL2.MSCEn == '0' then
        UNDEFINED;</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MOPSStage" mylink="aarch64.functions.mops.MOPSStage" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MOPSStage
// =========

enumeration <anchor link="MOPSStage" hover="enumeration MOPSStage { MOPSStage_Prologue, MOPSStage_Main, MOPSStage_Epilogue }">MOPSStage</anchor> { <anchor link="MOPSStage_Prologue" hover="enumeration MOPSStage { MOPSStage_Prologue, MOPSStage_Main, MOPSStage_Epilogue }">MOPSStage_Prologue</anchor>, <anchor link="MOPSStage_Main" hover="enumeration MOPSStage { MOPSStage_Prologue, MOPSStage_Main, MOPSStage_Epilogue }">MOPSStage_Main</anchor>, <anchor link="MOPSStage_Epilogue" hover="enumeration MOPSStage { MOPSStage_Prologue, MOPSStage_Main, MOPSStage_Epilogue }">MOPSStage_Epilogue</anchor> };</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MaxBlockSizeCopiedBytes" mylink="aarch64.functions.mops.MaxBlockSizeCopiedBytes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MaxBlockSizeCopiedBytes()
// =========================
// Returns the maximum number of bytes that can used in a single block of the copy.

integer <anchor link="impl-aarch64.MaxBlockSizeCopiedBytes.0" hover="function: integer MaxBlockSizeCopiedBytes()">MaxBlockSizeCopiedBytes</anchor>()
    return integer IMPLEMENTATION_DEFINED "Maximum bytes used in a single block of a copy";</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemCpyDirectionChoice" mylink="aarch64.functions.mops.MemCpyDirectionChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemCpyDirectionChoice()
// =======================
// Returns true if in the non-overlapping case of a memcpy of size cpysize bytes
// from the source address fromaddress to destination address toaddress is done
// in the forward direction on this implementation.

boolean <anchor link="impl-aarch64.MemCpyDirectionChoice.3" hover="function: boolean MemCpyDirectionChoice(bits(64) fromaddress, bits(64) toaddress, bits(64) cpysize)">MemCpyDirectionChoice</anchor>(bits(64) fromaddress, bits(64) toaddress, bits(64) cpysize);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemCpyParametersIllformedE" mylink="aarch64.functions.mops.MemCpyParametersIllformedE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemCpyParametersIllformedE()
// ============================
// Returns TRUE if the inputs are not well formed (in terms of their size and/or alignment)
// for a CPYE* instruction for this implementation given the parameters of the destination,
// source and size of the copy.

boolean <anchor link="impl-aarch64.MemCpyParametersIllformedE.3" hover="function: boolean MemCpyParametersIllformedE(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize)">MemCpyParametersIllformedE</anchor>(bits(64) toaddress, bits(64) fromaddress,
                                   bits(64) cpysize);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemCpyParametersIllformedM" mylink="aarch64.functions.mops.MemCpyParametersIllformedM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemCpyParametersIllformedM()
// ============================
// Returns TRUE if the inputs are not well formed (in terms of their size and/or alignment)
// for a CPYM* instruction for this implementation given the parameters of the destination,
// source and size of the copy.

boolean <anchor link="impl-aarch64.MemCpyParametersIllformedM.3" hover="function: boolean MemCpyParametersIllformedM(bits(64) toaddress, bits(64) fromaddress, bits(64) cpysize)">MemCpyParametersIllformedM</anchor>(bits(64) toaddress, bits(64) fromaddress,
                                   bits(64) cpysize);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemCpyZeroSizeCheck" mylink="aarch64.functions.mops.MemCpyZeroSizeCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemCpyZeroSizeCheck()
// =====================
// Returns TRUE if the implementation option is checked on a copy of size zero remaining.

boolean <anchor link="impl-aarch64.MemCpyZeroSizeCheck.0" hover="function: boolean MemCpyZeroSizeCheck()">MemCpyZeroSizeCheck</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemSetParametersIllformedE" mylink="aarch64.functions.mops.MemSetParametersIllformedE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemSetParametersIllformedE()
// ============================
// Returns TRUE if the inputs are not well formed (in terms of their size and/or
// alignment) for a SETE* or SETGE* instruction for this implementation given the
// parameters of the destination and size of the set.

boolean <anchor link="impl-aarch64.MemSetParametersIllformedE.3" hover="function: boolean MemSetParametersIllformedE(bits(64) toaddress, bits(64) setsize, boolean IsSETGE)">MemSetParametersIllformedE</anchor>(bits(64) toaddress, bits(64) setsize,
                                   boolean IsSETGE);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemSetParametersIllformedM" mylink="aarch64.functions.mops.MemSetParametersIllformedM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemSetParametersIllformedM()
// ============================
// Returns TRUE if the inputs are not well formed (in terms of their size and/or
// alignment) for a SETM* or SETGM* instruction for this implementation given the
// parameters of the destination and size of the copy.

boolean <anchor link="impl-aarch64.MemSetParametersIllformedM.3" hover="function: boolean MemSetParametersIllformedM(bits(64) toaddress, bits(64) setsize, boolean IsSETGM)">MemSetParametersIllformedM</anchor>(bits(64) toaddress, bits(64) setsize,
                                   boolean IsSETGM);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MemSetZeroSizeCheck" mylink="aarch64.functions.mops.MemSetZeroSizeCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemSetZeroSizeCheck()
// =====================
// Returns TRUE if the implementation option is checked on a copy of size zero remaining.

boolean <anchor link="impl-aarch64.MemSetZeroSizeCheck.0" hover="function: boolean MemSetZeroSizeCheck()">MemSetZeroSizeCheck</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MismatchedCpySetTargetEL" mylink="aarch64.functions.mops.MismatchedCpySetTargetEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MismatchedCpySetTargetEL()
// ==========================
// Return the target exception level for an Exception_MemCpyMemSet.

bits(2) <anchor link="impl-aarch64.MismatchedCpySetTargetEL.0" hover="function: bits(2) MismatchedCpySetTargetEL()">MismatchedCpySetTargetEL</anchor>()
    bits(2) target_el;

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        target_el = PSTATE.EL;
    elsif PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    elsif (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
        <a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() &amp;&amp; HCRX_EL2.MCE2 == '1') then
        target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    return target_el;</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MismatchedMemCpyException" mylink="aarch64.functions.mops.MismatchedMemCpyException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MismatchedMemCpyException()
// ===========================
// Generates an exception for a CPY* instruction if the version
// is inconsistent with the state of the call.

<anchor link="impl-aarch64.MismatchedMemCpyException.7" hover="function: MismatchedMemCpyException(boolean option_a, integer destreg, integer srcreg, integer sizereg, boolean wrong_option, boolean from_epilogue, bits(4) options)">MismatchedMemCpyException</anchor>(boolean option_a, integer destreg, integer srcreg, integer sizereg,
                          boolean wrong_option, boolean from_epilogue, bits(4) options)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset = 0x0;
    bits(2) target_el = <a link="impl-aarch64.MismatchedCpySetTargetEL.0" file="shared_pseudocode.xml" hover="function: bits(2) MismatchedCpySetTargetEL()">MismatchedCpySetTargetEL</a>();

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_MemCpyMemSet" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MemCpyMemSet</a>);
    exception.syndrome&lt;24&gt;    = '0';
    exception.syndrome&lt;23&gt;    = '0';
    exception.syndrome&lt;22:19&gt; = options;
    exception.syndrome&lt;18&gt;    = if from_epilogue then '1' else '0';
    exception.syndrome&lt;17&gt;    = if wrong_option then '1' else '0';
    exception.syndrome&lt;16&gt;    = if option_a then '1' else '0';
    // exception.syndrome&lt;15&gt; is RES0
    exception.syndrome&lt;14:10&gt; = destreg&lt;4:0&gt;;
    exception.syndrome&lt;9:5&gt;   = srcreg&lt;4:0&gt;;
    exception.syndrome&lt;4:0&gt;   = sizereg&lt;4:0&gt;;

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/MismatchedMemSetException" mylink="aarch64.functions.mops.MismatchedMemSetException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MismatchedMemSetException()
// ===========================
// Generates an exception for a SET* instruction if the version
// is inconsistent with the state of the call.

<anchor link="impl-aarch64.MismatchedMemSetException.8" hover="function: MismatchedMemSetException(boolean option_a, integer destreg, integer datareg, integer sizereg, boolean wrong_option, boolean from_epilogue, bits(2) options, boolean is_SETG)">MismatchedMemSetException</anchor>(boolean option_a, integer destreg, integer datareg, integer sizereg,
                          boolean wrong_option, boolean from_epilogue, bits(2) options,
                          boolean is_SETG)
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    integer vect_offset = 0x0;
    bits(2) target_el = <a link="impl-aarch64.MismatchedCpySetTargetEL.0" file="shared_pseudocode.xml" hover="function: bits(2) MismatchedCpySetTargetEL()">MismatchedCpySetTargetEL</a>();

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_MemCpyMemSet" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MemCpyMemSet</a>);
    exception.syndrome&lt;24&gt;    = '1';
    exception.syndrome&lt;23&gt;    = if is_SETG then '1' else '0';
    // exception.syndrome&lt;22:21&gt; is RES0
    exception.syndrome&lt;20:19&gt; = options;
    exception.syndrome&lt;18&gt;    = if from_epilogue then '1' else '0';
    exception.syndrome&lt;17&gt;    = if wrong_option then '1' else '0';
    exception.syndrome&lt;16&gt;    = if option_a then '1' else '0';
    // exception.syndrome&lt;15&gt; is RES0
    exception.syndrome&lt;14:10&gt; = destreg&lt;4:0&gt;;
    exception.syndrome&lt;9:5&gt;   = datareg&lt;4:0&gt;;
    exception.syndrome&lt;4:0&gt;   = sizereg&lt;4:0&gt;;

    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/SETGOptionA" mylink="aarch64.functions.mops.SETGOptionA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SETGOptionA()
// =============
// Returns TRUE if the implementation uses Option A for the
// SETG* instructions, and FALSE otherwise.

boolean <anchor link="impl-aarch64.SETGOptionA.0" hover="function: boolean SETGOptionA()">SETGOptionA</anchor>()
    return boolean IMPLEMENTATION_DEFINED "SETG* instructions use Option A";</pstext>
    </ps>
    <ps name="aarch64/functions/mops/SETOptionA" mylink="aarch64.functions.mops.SETOptionA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SETOptionA()
// ============
// Returns TRUE if the implementation uses Option A for the
// SET* instructions, and FALSE otherwise.

boolean <anchor link="impl-aarch64.SETOptionA.0" hover="function: boolean SETOptionA()">SETOptionA</anchor>()
    return boolean IMPLEMENTATION_DEFINED "SET* instructions use Option A";</pstext>
    </ps>
    <ps name="aarch64/functions/mops/SETPostSizeChoice" mylink="aarch64.functions.mops.SETPostSizeChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SETPostSizeChoice()
// ===================
// Returns the size of the set that is performed by the SETE* or SETGE* instructions
// for this implementation, given the parameters of the destination and size of the set.
// Postsize is encoded as -1*size for an option A implementation if setsize is negative.

bits(64) <anchor link="impl-aarch64.SETPostSizeChoice.3" hover="function: bits(64) SETPostSizeChoice(bits(64) toaddress, bits(64) setsize, boolean IsSETGE)">SETPostSizeChoice</anchor>(bits(64) toaddress, bits(64) setsize, boolean IsSETGE);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/SETPreSizeChoice" mylink="aarch64.functions.mops.SETPreSizeChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SETPreSizeChoice()
// ==================
// Returns the size of the set that is performed by the SETP* or SETGP* instructions
// for this implementation, given the parameters of the destination and size of the set.
// Presize is encoded as -1*size for an option A implementation if setsize is negative.

bits(64) <anchor link="impl-aarch64.SETPreSizeChoice.3" hover="function: bits(64) SETPreSizeChoice(bits(64) toaddress, bits(64) setsize, boolean IsSETGP)">SETPreSizeChoice</anchor>(bits(64) toaddress, bits(64) setsize, boolean IsSETGP);</pstext>
    </ps>
    <ps name="aarch64/functions/mops/SETSizeChoice" mylink="aarch64.functions.mops.SETSizeChoice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SETSizeChoice()
// ===============
// Returns the size of the block thisperformed for an iteration of the set given
// the parameters of the destination and size of the set. The size of the block
// is an integer multiple of AlignSize.

integer <anchor link="impl-aarch64.SETSizeChoice.3" hover="function: integer SETSizeChoice(bits(64) toaddress, bits(64) setsize, integer AlignSize)">SETSizeChoice</anchor>(bits(64) toaddress, bits(64) setsize, integer AlignSize);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/addpac/AddPAC" mylink="aarch64.functions.pac.addpac.AddPAC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddPAC()
// ========
// Calculates the pointer authentication code for a 64-bit quantity and then
// inserts that into pointer authentication code field of that 64-bit quantity.

bits(64) <anchor link="impl-aarch64.AddPAC.4" hover="function: bits(64) AddPAC(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data)">AddPAC</anchor>(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data)
    bits(64) PAC;
    bits(64) result;
    bits(64) ext_ptr;
    bits(64) extfield;
    bit selbit;
    boolean isgeneric = FALSE;
    boolean tbi = <a link="impl-shared.EffectiveTBI.3" file="shared_pseudocode.xml" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</a>(ptr, !data, PSTATE.EL) == '1';
    boolean mtx = <a link="impl-shared.EffectiveMTX.3" file="shared_pseudocode.xml" hover="function: bit EffectiveMTX(bits(64) address, boolean is_instr, bits(2) el)">EffectiveMTX</a>(ptr, !data, PSTATE.EL) == '1';
    integer top_bit = if tbi then 55 else 63;

    // If tagged pointers are in use for a regime with two TTBRs, use bit&lt;55&gt; of
    // the pointer to select between upper and lower ranges, and preserve this.
    // This handles the awkward case where there is apparently no correct choice between
    // the upper and lower address range - ie an addr of 1xxxxxxx0... with TBI0=0 and TBI1=1
    // and 0xxxxxxx1 with TBI1=0 and TBI0=1:
    if <a link="impl-aarch64.PtrHasUpperAndLowerAddRanges.0" file="shared_pseudocode.xml" hover="function: boolean PtrHasUpperAndLowerAddRanges()">PtrHasUpperAndLowerAddRanges</a>() then
        assert <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};
        if <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
            // EL1 translation regime registers
            if data then
                if TCR_EL1.TBI1 == '1' || TCR_EL1.TBI0 == '1' then
                    selbit = ptr&lt;55&gt;;
                else
                    selbit = ptr&lt;63&gt;;
            else
                if ((TCR_EL1.TBI1 == '1' &amp;&amp; TCR_EL1.TBID1 == '0') ||
                    (TCR_EL1.TBI0 == '1' &amp;&amp; TCR_EL1.TBID0 == '0')) then
                    selbit = ptr&lt;55&gt;;
                else
                    selbit = ptr&lt;63&gt;;
        else
            // EL2 translation regime registers
            if data then
                if TCR_EL2.TBI1 == '1' || TCR_EL2.TBI0 == '1' then
                    selbit = ptr&lt;55&gt;;
                else
                    selbit = ptr&lt;63&gt;;
            else
                if ((TCR_EL2.TBI1 == '1' &amp;&amp; TCR_EL2.TBID1 == '0') ||
                    (TCR_EL2.TBI0 == '1' &amp;&amp; TCR_EL2.TBID0 == '0')) then
                    selbit = ptr&lt;55&gt;;
                else
                    selbit = ptr&lt;63&gt;;
    else selbit = if tbi then ptr&lt;55&gt; else ptr&lt;63&gt;;

    if <a link="impl-aarch64.HaveEnhancedPAC2.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</a>() &amp;&amp; <a link="impl-aarch64.ConstPACField.0" file="shared_pseudocode.xml" hover="function: boolean ConstPACField()">ConstPACField</a>() then selbit = ptr&lt;55&gt;;
    integer bottom_PAC_bit = <a link="impl-aarch64.CalculateBottomPACBit.1" file="shared_pseudocode.xml" hover="function: integer CalculateBottomPACBit(bit top_bit)">CalculateBottomPACBit</a>(selbit);

    // If the VA is 56 or 55 bits and Top Byte is Ignored,
    // there are no unused bits left to insert the PAC
    if tbi &amp;&amp; bottom_PAC_bit &gt;= 55 then
        return ptr;

    extfield = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(selbit, 64);

    // Compute the pointer authentication code for a ptr with good extension bits
    if tbi then
        ext_ptr = (ptr&lt;63:56&gt; :
                   extfield&lt;(56-bottom_PAC_bit)-1:0&gt; : ptr&lt;bottom_PAC_bit-1:0&gt;);
    elsif mtx then
        ext_ptr = (extfield&lt;63:60&gt; : ptr&lt;59:56&gt; :
                   extfield&lt;(56-bottom_PAC_bit)-1:0&gt; : ptr&lt;bottom_PAC_bit-1:0&gt;);
    else
        ext_ptr =  extfield&lt;(64-bottom_PAC_bit)-1:0&gt; : ptr&lt;bottom_PAC_bit-1:0&gt;;

    PAC = <a link="impl-aarch64.ComputePAC.5" file="shared_pseudocode.xml" hover="function: bits(64) ComputePAC(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isgeneric)">ComputePAC</a>(ext_ptr, modifier, K&lt;127:64&gt;, K&lt;63:0&gt;, isgeneric);

    // Check if the ptr has good extension bits and corrupt the pointer authentication code if not
    bits(64) unusedbits_mask = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    unusedbits_mask&lt;54:bottom_PAC_bit&gt; = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>((54-bottom_PAC_bit)+1);
    if tbi then
        unusedbits_mask&lt;63:56&gt; = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(8);
    elsif mtx then
        unusedbits_mask&lt;63:60&gt; = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(4);
    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(ptr AND unusedbits_mask) &amp;&amp; ((ptr AND unusedbits_mask) != unusedbits_mask) then
        if <a link="impl-aarch64.HaveEnhancedPAC.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC()">HaveEnhancedPAC</a>() then
            PAC = 0x0000000000000000&lt;63:0&gt;;
        elsif !<a link="impl-aarch64.HaveEnhancedPAC2.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</a>() then
            PAC&lt;top_bit-1&gt; = NOT(PAC&lt;top_bit-1&gt;);

    // Preserve the determination between upper and lower address at bit&lt;55&gt; and insert PAC into
    // bits that are not used for the address or the tag(s).
    if !<a link="impl-aarch64.HaveEnhancedPAC2.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</a>() then
        if tbi then
            result = ptr&lt;63:56&gt;:selbit:PAC&lt;54:bottom_PAC_bit&gt;:ptr&lt;bottom_PAC_bit-1:0&gt;;
        else
            result = PAC&lt;63:56&gt;:selbit:PAC&lt;54:bottom_PAC_bit&gt;:ptr&lt;bottom_PAC_bit-1:0&gt;;
            // A compliant implementation of FEAT_MTE4 also implements FEAT_PAuth2
            assert !mtx;
    else
        if tbi then
            result = (ptr&lt;63:56&gt;                               : selbit :
                      (ptr&lt;54:bottom_PAC_bit&gt; EOR PAC&lt;54:bottom_PAC_bit&gt;) :
                      ptr&lt;bottom_PAC_bit-1:0&gt;);
        elsif mtx then
            result = ((ptr&lt;63:60&gt; EOR PAC&lt;63:60&gt;) : ptr&lt;59:56&gt; : selbit :
                      (ptr&lt;54:bottom_PAC_bit&gt; EOR PAC&lt;54:bottom_PAC_bit&gt;) :
                      ptr&lt;bottom_PAC_bit-1:0&gt;);
        else
            result = ((ptr&lt;63:56&gt; EOR PAC&lt;63:56&gt;)              : selbit :
                      (ptr&lt;54:bottom_PAC_bit&gt; EOR PAC&lt;54:bottom_PAC_bit&gt;) :
                      ptr&lt;bottom_PAC_bit-1:0&gt;);
    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/addpacda/AddPACDA" mylink="aarch64.functions.pac.addpacda.AddPACDA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddPACDA()
// ==========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with a pointer authentication code, where the pointer authentication
// code is derived using a cryptographic algorithm as a combination of x, y and the
// APDAKey_EL1.

bits(64) <anchor link="impl-aarch64.AddPACDA.2" hover="function: bits(64) AddPACDA(bits(64) x, bits(64) y)">AddPACDA</anchor>(bits(64) x, bits(64) y)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APDAKey_EL1;

    APDAKey_EL1 = APDAKeyHi_EL1&lt;63:0&gt; : APDAKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnDA else SCTLR_EL2.EnDA;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                        (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnDA;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnDA;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnDA;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.AddPAC.4" file="shared_pseudocode.xml" hover="function: bits(64) AddPAC(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data)">AddPAC</a>(x, y, APDAKey_EL1, TRUE);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/addpacdb/AddPACDB" mylink="aarch64.functions.pac.addpacdb.AddPACDB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddPACDB()
// ==========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with a pointer authentication code, where the pointer authentication
// code is derived using a cryptographic algorithm as a combination of x, y and the
// APDBKey_EL1.

bits(64) <anchor link="impl-aarch64.AddPACDB.2" hover="function: bits(64) AddPACDB(bits(64) x, bits(64) y)">AddPACDB</anchor>(bits(64) x, bits(64) y)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APDBKey_EL1;

    APDBKey_EL1 = APDBKeyHi_EL1&lt;63:0&gt; : APDBKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnDB else SCTLR_EL2.EnDB;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                       (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnDB;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnDB;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnDB;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.AddPAC.4" file="shared_pseudocode.xml" hover="function: bits(64) AddPAC(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data)">AddPAC</a>(x, y, APDBKey_EL1, TRUE);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/addpacga/AddPACGA" mylink="aarch64.functions.pac.addpacga.AddPACGA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddPACGA()
// ==========
// Returns a 64-bit value where the lower 32 bits are 0, and the upper 32 bits contain
// a 32-bit pointer authentication code which is derived using a cryptographic
// algorithm as a combination of x, y and the APGAKey_EL1.

bits(64) <anchor link="impl-aarch64.AddPACGA.2" hover="function: bits(64) AddPACGA(bits(64) x, bits(64) y)">AddPACGA</anchor>(bits(64) x, bits(64) y)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(128) APGAKey_EL1;
    boolean isgeneric = TRUE;

    APGAKey_EL1 = APGAKeyHi_EL1&lt;63:0&gt; : APGAKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                        (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.ComputePAC.5" file="shared_pseudocode.xml" hover="function: bits(64) ComputePAC(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isgeneric)">ComputePAC</a>(x, y, APGAKey_EL1&lt;127:64&gt;, APGAKey_EL1&lt;63:0&gt;, isgeneric)&lt;63:32&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/addpacia/AddPACIA" mylink="aarch64.functions.pac.addpacia.AddPACIA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddPACIA()
// ==========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with a pointer authentication code, where the pointer authentication
// code is derived using a cryptographic algorithm as a combination of x, y, and the
// APIAKey_EL1.

bits(64) <anchor link="impl-aarch64.AddPACIA.2" hover="function: bits(64) AddPACIA(bits(64) x, bits(64) y)">AddPACIA</anchor>(bits(64) x, bits(64) y)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APIAKey_EL1;

    APIAKey_EL1 = APIAKeyHi_EL1&lt;63:0&gt;:APIAKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnIA else SCTLR_EL2.EnIA;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                       (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnIA;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnIA;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnIA;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.AddPAC.4" file="shared_pseudocode.xml" hover="function: bits(64) AddPAC(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data)">AddPAC</a>(x, y, APIAKey_EL1, FALSE);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/addpacib/AddPACIB" mylink="aarch64.functions.pac.addpacib.AddPACIB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddPACIB()
// ==========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with a pointer authentication code, where the pointer authentication
// code is derived using a cryptographic algorithm as a combination of x, y and the
// APIBKey_EL1.

bits(64) <anchor link="impl-aarch64.AddPACIB.2" hover="function: bits(64) AddPACIB(bits(64) x, bits(64) y)">AddPACIB</anchor>(bits(64) x, bits(64) y)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APIBKey_EL1;

    APIBKey_EL1 = APIBKeyHi_EL1&lt;63:0&gt; : APIBKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnIB else SCTLR_EL2.EnIB;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                       (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnIB;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnIB;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnIB;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.AddPAC.4" file="shared_pseudocode.xml" hover="function: bits(64) AddPAC(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data)">AddPAC</a>(x, y, APIBKey_EL1, FALSE);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/auth/AArch64.PACFailException" mylink="aarch64.functions.pac.auth.AArch64.PACFailException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PACFailException()
// ==========================
// Generates a PAC Fail Exception

<anchor link="AArch64.PACFailException.1" hover="function: AArch64.PACFailException(bits(2) syndrome)">AArch64.PACFailException</anchor>(bits(2) syndrome)
    route_to_el2 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_PACFail" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACFail</a>);
    exception.syndrome&lt;1:0&gt;   = syndrome;
    exception.syndrome&lt;24:2&gt;  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(23);                // RES0

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>) then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(PSTATE.EL, exception, preferred_exception_return, vect_offset);
    elsif route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/auth/Auth" mylink="aarch64.functions.pac.auth.Auth" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Auth()
// ======
// Restores the upper bits of the address to be all zeros or all ones (based on the
// value of bit[55]) and computes and checks the pointer authentication code. If the
// check passes, then the restored address is returned. If the check fails, the
// second-top and third-top bits of the extension bits in the pointer authentication code
// field are corrupted to ensure that accessing the address will give a translation fault.

bits(64) <anchor link="impl-aarch64.Auth.6" hover="function: bits(64) Auth(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data, bit key_number, boolean is_combined)">Auth</anchor>(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data, bit key_number,
              boolean is_combined)
    bits(64) PAC;
    bits(64) result;
    bits(64) original_ptr;
    bits(2) error_code;
    bits(64) extfield;
    boolean isgeneric = FALSE;

    // Reconstruct the extension field used of adding the PAC to the pointer
    boolean tbi = <a link="impl-shared.EffectiveTBI.3" file="shared_pseudocode.xml" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</a>(ptr, !data, PSTATE.EL) == '1';
    boolean mtx = <a link="impl-shared.EffectiveMTX.3" file="shared_pseudocode.xml" hover="function: bit EffectiveMTX(bits(64) address, boolean is_instr, bits(2) el)">EffectiveMTX</a>(ptr, !data, PSTATE.EL) == '1';
    integer bottom_PAC_bit = <a link="impl-aarch64.CalculateBottomPACBit.1" file="shared_pseudocode.xml" hover="function: integer CalculateBottomPACBit(bit top_bit)">CalculateBottomPACBit</a>(ptr&lt;55&gt;);
    extfield = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(ptr&lt;55&gt;, 64);

    // If the VA is 56 or 55 bits and Top Byte is Ignored,
    // there are no unused bits left for the PAC
    if tbi &amp;&amp; bottom_PAC_bit &gt;= 55 then
        return ptr;

    if tbi then
        original_ptr = (ptr&lt;63:56&gt; :
                        extfield&lt;(56-bottom_PAC_bit)-1:0&gt; : ptr&lt;bottom_PAC_bit-1:0&gt;);
    elsif mtx then
        original_ptr = (extfield&lt;63:60&gt; : ptr&lt;59:56&gt; :
                        extfield&lt;(56-bottom_PAC_bit)-1:0&gt; : ptr&lt;bottom_PAC_bit-1:0&gt;);
    else
        original_ptr =  extfield&lt;(64-bottom_PAC_bit)-1:0&gt; : ptr&lt;bottom_PAC_bit-1:0&gt;;

    PAC = <a link="impl-aarch64.ComputePAC.5" file="shared_pseudocode.xml" hover="function: bits(64) ComputePAC(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isgeneric)">ComputePAC</a>(original_ptr, modifier, K&lt;127:64&gt;, K&lt;63:0&gt;, isgeneric);
    // Check pointer authentication code
    if tbi then
        if !<a link="impl-aarch64.HaveEnhancedPAC2.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</a>() then
            if PAC&lt;54:bottom_PAC_bit&gt; == ptr&lt;54:bottom_PAC_bit&gt; then
                result = original_ptr;
            else
                error_code = key_number:NOT(key_number);
                result = original_ptr&lt;63:55&gt;:error_code:original_ptr&lt;52:0&gt;;
        else
            result = ptr;
            result&lt;54:bottom_PAC_bit&gt; = result&lt;54:bottom_PAC_bit&gt; EOR PAC&lt;54:bottom_PAC_bit&gt;;
            if <a link="impl-aarch64.HaveFPACCombined.0" file="shared_pseudocode.xml" hover="function: boolean HaveFPACCombined()">HaveFPACCombined</a>() || (<a link="impl-aarch64.HaveFPAC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFPAC()">HaveFPAC</a>() &amp;&amp; !is_combined) then
                if result&lt;54:bottom_PAC_bit&gt; != <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(result&lt;55&gt;, (55-bottom_PAC_bit)) then
                    error_code = (if data then '1' else '0'):key_number;
                    <a link="AArch64.PACFailException.1" file="shared_pseudocode.xml" hover="function: AArch64.PACFailException(bits(2) syndrome)">AArch64.PACFailException</a>(error_code);
    elsif mtx then
        assert <a link="impl-aarch64.HaveEnhancedPAC2.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</a>();
        result = ptr;
        result&lt;54:bottom_PAC_bit&gt; = result&lt;54:bottom_PAC_bit&gt; EOR PAC&lt;54:bottom_PAC_bit&gt;;
        result&lt;63:60&gt; = result&lt;63:60&gt; EOR PAC&lt;63:60&gt;;
        if <a link="impl-aarch64.HaveFPACCombined.0" file="shared_pseudocode.xml" hover="function: boolean HaveFPACCombined()">HaveFPACCombined</a>() || (<a link="impl-aarch64.HaveFPAC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFPAC()">HaveFPAC</a>() &amp;&amp; !is_combined) then
            if ((result&lt;54:bottom_PAC_bit&gt; != <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(result&lt;55&gt;, (55-bottom_PAC_bit))) ||
                (result&lt;63:60&gt; != <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(result&lt;55&gt;, 4))) then
                error_code = (if data then '1' else '0'):key_number;
                <a link="AArch64.PACFailException.1" file="shared_pseudocode.xml" hover="function: AArch64.PACFailException(bits(2) syndrome)">AArch64.PACFailException</a>(error_code);
    else
        if !<a link="impl-aarch64.HaveEnhancedPAC2.0" file="shared_pseudocode.xml" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</a>() then
            if PAC&lt;54:bottom_PAC_bit&gt; == ptr&lt;54:bottom_PAC_bit&gt; &amp;&amp; PAC&lt;63:56&gt; == ptr&lt;63:56&gt; then
                result = original_ptr;
            else
                error_code = key_number:NOT(key_number);
                result = original_ptr&lt;63&gt;:error_code:original_ptr&lt;60:0&gt;;
        else
            result = ptr;
            result&lt;54:bottom_PAC_bit&gt; = result&lt;54:bottom_PAC_bit&gt; EOR PAC&lt;54:bottom_PAC_bit&gt;;
            result&lt;63:56&gt; = result&lt;63:56&gt; EOR PAC&lt;63:56&gt;;
            if <a link="impl-aarch64.HaveFPACCombined.0" file="shared_pseudocode.xml" hover="function: boolean HaveFPACCombined()">HaveFPACCombined</a>() || (<a link="impl-aarch64.HaveFPAC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFPAC()">HaveFPAC</a>() &amp;&amp; !is_combined) then
                if result&lt;63:bottom_PAC_bit&gt; != <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(result&lt;55&gt;, (64-bottom_PAC_bit)) then
                    error_code = (if data then '1' else '0'):key_number;
                    <a link="AArch64.PACFailException.1" file="shared_pseudocode.xml" hover="function: AArch64.PACFailException(bits(2) syndrome)">AArch64.PACFailException</a>(error_code);
    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/authda/AuthDA" mylink="aarch64.functions.pac.authda.AuthDA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AuthDA()
// ========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with the extension of the address bits. The instruction checks a pointer
// authentication code in the pointer authentication code field bits of x, using the same
// algorithm and key as AddPACDA().

bits(64) <anchor link="impl-aarch64.AuthDA.3" hover="function: bits(64) AuthDA(bits(64) x, bits(64) y, boolean is_combined)">AuthDA</anchor>(bits(64) x, bits(64) y, boolean is_combined)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APDAKey_EL1;

    APDAKey_EL1 = APDAKeyHi_EL1&lt;63:0&gt; : APDAKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnDA else SCTLR_EL2.EnDA;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                       (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnDA;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnDA;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnDA;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.Auth.6" file="shared_pseudocode.xml" hover="function: bits(64) Auth(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data, bit key_number, boolean is_combined)">Auth</a>(x, y, APDAKey_EL1, TRUE, '0', is_combined);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/authdb/AuthDB" mylink="aarch64.functions.pac.authdb.AuthDB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AuthDB()
// ========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with the extension of the address bits. The instruction checks a
// pointer authentication code in the pointer authentication code field bits of x, using
// the same algorithm and key as AddPACDB().

bits(64) <anchor link="impl-aarch64.AuthDB.3" hover="function: bits(64) AuthDB(bits(64) x, bits(64) y, boolean is_combined)">AuthDB</anchor>(bits(64) x, bits(64) y, boolean is_combined)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APDBKey_EL1;

    APDBKey_EL1 = APDBKeyHi_EL1&lt;63:0&gt; : APDBKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnDB else SCTLR_EL2.EnDB;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                        (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnDB;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnDB;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnDB;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.Auth.6" file="shared_pseudocode.xml" hover="function: bits(64) Auth(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data, bit key_number, boolean is_combined)">Auth</a>(x, y, APDBKey_EL1, TRUE, '1', is_combined);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/authia/AuthIA" mylink="aarch64.functions.pac.authia.AuthIA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AuthIA()
// ========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with the extension of the address bits. The instruction checks a pointer
// authentication code in the pointer authentication code field bits of x, using the same
// algorithm and key as AddPACIA().

bits(64) <anchor link="impl-aarch64.AuthIA.3" hover="function: bits(64) AuthIA(bits(64) x, bits(64) y, boolean is_combined)">AuthIA</anchor>(bits(64) x, bits(64) y, boolean is_combined)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APIAKey_EL1;

    APIAKey_EL1 = APIAKeyHi_EL1&lt;63:0&gt; : APIAKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnIA else SCTLR_EL2.EnIA;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                       (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnIA;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnIA;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnIA;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.Auth.6" file="shared_pseudocode.xml" hover="function: bits(64) Auth(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data, bit key_number, boolean is_combined)">Auth</a>(x, y, APIAKey_EL1, FALSE, '0', is_combined);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/authib/AuthIB" mylink="aarch64.functions.pac.authib.AuthIB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AuthIB()
// ========
// Returns a 64-bit value containing x, but replacing the pointer authentication code
// field bits with the extension of the address bits. The instruction checks a pointer
// authentication code in the pointer authentication code field bits of x, using the same
// algorithm and key as AddPACIB().

bits(64) <anchor link="impl-aarch64.AuthIB.3" hover="function: bits(64) AuthIB(bits(64) x, bits(64) y, boolean is_combined)">AuthIB</anchor>(bits(64) x, bits(64) y, boolean is_combined)
    boolean TrapEL2;
    boolean TrapEL3;
    bits(1)  Enable;
    bits(128) APIBKey_EL1;

    APIBKey_EL1 = APIBKeyHi_EL1&lt;63:0&gt; : APIBKeyLo_EL1&lt;63:0&gt;;
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            boolean IsEL1Regime = <a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>() == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            Enable = if IsEL1Regime then SCTLR_EL1.EnIB else SCTLR_EL2.EnIB;
            TrapEL2 = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0' &amp;&amp;
                       (HCR_EL2.TGE == '0' || HCR_EL2.E2H == '0'));
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            Enable = SCTLR_EL1.EnIB;
            TrapEL2 = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.API == '0';
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            Enable = SCTLR_EL2.EnIB;
            TrapEL2 = FALSE;
            TrapEL3 = <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.API == '0';
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            Enable = SCTLR_EL3.EnIB;
            TrapEL2 = FALSE;
            TrapEL3 = FALSE;

    if Enable == '0' then
        return x;
    elsif TrapEL3 &amp;&amp; <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>() then
        UNDEFINED;
    elsif TrapEL2 then
        <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    elsif TrapEL3 then
        if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
            UNDEFINED;
        else
            <a link="impl-aarch64.TrapPACUse.1" file="shared_pseudocode.xml" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    else
        return <a link="impl-aarch64.Auth.6" file="shared_pseudocode.xml" hover="function: bits(64) Auth(bits(64) ptr, bits(64) modifier, bits(128) K, boolean data, bit key_number, boolean is_combined)">Auth</a>(x, y, APIBKey_EL1, FALSE, '1', is_combined);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/calcbottompacbit/AArch64.PACEffectiveTxSZ" mylink="aarch64.functions.pac.calcbottompacbit.AArch64.PACEffectiveTxSZ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PACEffectiveTxSZ()
// ==========================
// Compute the effective value for TxSZ used to determine the placement of the PAC field

bits(6) AArch64.PACEffectiveTxSZ(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams)
    constant integer s1maxtxsz = <a link="AArch64.MaxTxSZ.1" file="shared_pseudocode.xml" hover="function: integer AArch64.MaxTxSZ(TGx tgx)">AArch64.MaxTxSZ</a>(walkparams.tgx);
    constant integer s1mintxsz = <a link="AArch64.S1MinTxSZ.4" file="shared_pseudocode.xml" hover="function: integer AArch64.S1MinTxSZ(Regime regime, bit d128, bit ds, TGx tgx)">AArch64.S1MinTxSZ</a>(regime, walkparams.d128,
                                                   walkparams.ds, walkparams.tgx);

    if AArch64.S1TxSZFaults(regime, walkparams) then
        if <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_RESTnSZ" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTnSZ</a>) == <a link="Constraint_FORCE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FORCE</a> then
            if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &lt; s1mintxsz then
                return s1mintxsz&lt;5:0&gt;;
            if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &gt; s1maxtxsz then
                return s1maxtxsz&lt;5:0&gt;;
    elsif <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &lt; s1mintxsz then
        return s1mintxsz&lt;5:0&gt;;
    elsif <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &gt; s1maxtxsz then
        return s1maxtxsz&lt;5:0&gt;;

    return walkparams.txsz;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/calcbottompacbit/CalculateBottomPACBit" mylink="aarch64.functions.pac.calcbottompacbit.CalculateBottomPACBit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CalculateBottomPACBit()
// =======================

integer <anchor link="impl-aarch64.CalculateBottomPACBit.1" hover="function: integer CalculateBottomPACBit(bit top_bit)">CalculateBottomPACBit</anchor>(bit top_bit)
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime;
    S1TTWParams walkparams;
    integer bottom_PAC_bit;

    regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(PSTATE.EL);
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    walkparams = AArch64.GetS1TTWParams(regime, ss, <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(top_bit, 64));
    bottom_PAC_bit = 64 - <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(AArch64.PACEffectiveTxSZ(regime, walkparams));

    return bottom_PAC_bit;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/ComputePAC" mylink="aarch64.functions.pac.computepac.ComputePAC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ComputePAC()
// ============

bits(64) <anchor link="impl-aarch64.ComputePAC.5" hover="function: bits(64) ComputePAC(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isgeneric)">ComputePAC</anchor>(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1,
                    boolean isgeneric)
    if <a link="impl-aarch64.UsePACIMP.1" file="shared_pseudocode.xml" hover="function: boolean UsePACIMP(boolean isgeneric)">UsePACIMP</a>(isgeneric) then
        return <a link="impl-aarch64.ComputePACIMPDEF.4" file="shared_pseudocode.xml" hover="function: bits(64) ComputePACIMPDEF(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1)">ComputePACIMPDEF</a>(data, modifier, key0, key1);
    if <a link="impl-aarch64.UsePACQARMA3.1" file="shared_pseudocode.xml" hover="function: boolean UsePACQARMA3(boolean isgeneric)">UsePACQARMA3</a>(isgeneric) then
        boolean isqarma3 = TRUE;
        return <a link="impl-aarch64.ComputePACQARMA.5" file="shared_pseudocode.xml" hover="function: bits(64) ComputePACQARMA(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isqarma3)">ComputePACQARMA</a>(data, modifier, key0, key1, isqarma3);
    if <a link="impl-aarch64.UsePACQARMA5.1" file="shared_pseudocode.xml" hover="function: boolean UsePACQARMA5(boolean isgeneric)">UsePACQARMA5</a>(isgeneric) then
        boolean isqarma3 = FALSE;
        return <a link="impl-aarch64.ComputePACQARMA.5" file="shared_pseudocode.xml" hover="function: bits(64) ComputePACQARMA(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isqarma3)">ComputePACQARMA</a>(data, modifier, key0, key1, isqarma3);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/ComputePACIMPDEF" mylink="aarch64.functions.pac.computepac.ComputePACIMPDEF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ComputePACIMPDEF()
// ==================
// Compute IMPLEMENTATION DEFINED cryptographic algorithm to be used for PAC calculation.

bits(64) <anchor link="impl-aarch64.ComputePACIMPDEF.4" hover="function: bits(64) ComputePACIMPDEF(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1)">ComputePACIMPDEF</anchor>(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/ComputePACQARMA" mylink="aarch64.functions.pac.computepac.ComputePACQARMA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ComputePACQARMA()
// =================
// Compute QARMA3 or QARMA5 cryptographic algorithm for PAC calculation

bits(64) <anchor link="impl-aarch64.ComputePACQARMA.5" hover="function: bits(64) ComputePACQARMA(bits(64) data, bits(64) modifier, bits(64) key0, bits(64) key1, boolean isqarma3)">ComputePACQARMA</anchor>(bits(64) data, bits(64) modifier, bits(64) key0,
                         bits(64) key1, boolean isqarma3)
    bits(64)  workingval;
    bits(64)  runningmod;
    bits(64)  roundkey;
    bits(64)  modk0;
    constant bits(64) Alpha = 0xC0AC29B7C97C50DD&lt;63:0&gt;;

    integer iterations;
    RC[0] = 0x0000000000000000&lt;63:0&gt;;
    RC[1] = 0x13198A2E03707344&lt;63:0&gt;;
    RC[2] = 0xA4093822299F31D0&lt;63:0&gt;;

    if isqarma3 then
        iterations = 2;
    else // QARMA5
        iterations = 4;
        RC[3] = 0x082EFA98EC4E6C89&lt;63:0&gt;;
        RC[4] = 0x452821E638D01377&lt;63:0&gt;;

    modk0 = key0&lt;0&gt;:key0&lt;63:2&gt;:(key0&lt;63&gt; EOR key0&lt;1&gt;);
    runningmod = modifier;
    workingval = data EOR key0;

    for i = 0 to iterations
        roundkey = key1 EOR runningmod;
        workingval  = workingval EOR roundkey;
        workingval = workingval EOR RC[i];
        if i &gt; 0 then
            workingval = <a link="impl-aarch64.PACCellShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) PACCellShuffle(bits(64) indata)">PACCellShuffle</a>(workingval);
            workingval = <a link="impl-aarch64.PACMult.1" file="shared_pseudocode.xml" hover="function: bits(64) PACMult(bits(64) Sinput)">PACMult</a>(workingval);
        if isqarma3 then
            workingval = <a link="impl-aarch64.PACSub1.1" file="shared_pseudocode.xml" hover="function: bits(64) PACSub1(bits(64) Tinput)">PACSub1</a>(workingval);
        else
            workingval = <a link="impl-aarch64.PACSub.1" file="shared_pseudocode.xml" hover="function: bits(64) PACSub(bits(64) Tinput)">PACSub</a>(workingval);
        runningmod = <a link="impl-aarch64.TweakShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) TweakShuffle(bits(64) indata)">TweakShuffle</a>(runningmod&lt;63:0&gt;);
    roundkey = modk0 EOR runningmod;
    workingval = workingval EOR roundkey;
    workingval = <a link="impl-aarch64.PACCellShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) PACCellShuffle(bits(64) indata)">PACCellShuffle</a>(workingval);
    workingval = <a link="impl-aarch64.PACMult.1" file="shared_pseudocode.xml" hover="function: bits(64) PACMult(bits(64) Sinput)">PACMult</a>(workingval);
    if isqarma3 then
        workingval = <a link="impl-aarch64.PACSub1.1" file="shared_pseudocode.xml" hover="function: bits(64) PACSub1(bits(64) Tinput)">PACSub1</a>(workingval);
    else
        workingval = <a link="impl-aarch64.PACSub.1" file="shared_pseudocode.xml" hover="function: bits(64) PACSub(bits(64) Tinput)">PACSub</a>(workingval);
    workingval = <a link="impl-aarch64.PACCellShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) PACCellShuffle(bits(64) indata)">PACCellShuffle</a>(workingval);
    workingval = <a link="impl-aarch64.PACMult.1" file="shared_pseudocode.xml" hover="function: bits(64) PACMult(bits(64) Sinput)">PACMult</a>(workingval);
    workingval = key1 EOR workingval;
    workingval = <a link="impl-aarch64.PACCellInvShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) PACCellInvShuffle(bits(64) indata)">PACCellInvShuffle</a>(workingval);
    if isqarma3 then
        workingval = <a link="impl-aarch64.PACSub1.1" file="shared_pseudocode.xml" hover="function: bits(64) PACSub1(bits(64) Tinput)">PACSub1</a>(workingval);
    else
        workingval = <a link="impl-aarch64.PACInvSub.1" file="shared_pseudocode.xml" hover="function: bits(64) PACInvSub(bits(64) Tinput)">PACInvSub</a>(workingval);
    workingval = <a link="impl-aarch64.PACMult.1" file="shared_pseudocode.xml" hover="function: bits(64) PACMult(bits(64) Sinput)">PACMult</a>(workingval);
    workingval = <a link="impl-aarch64.PACCellInvShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) PACCellInvShuffle(bits(64) indata)">PACCellInvShuffle</a>(workingval);
    workingval = workingval EOR key0;
    workingval = workingval EOR runningmod;
    for i = 0 to iterations
        if isqarma3 then
            workingval = <a link="impl-aarch64.PACSub1.1" file="shared_pseudocode.xml" hover="function: bits(64) PACSub1(bits(64) Tinput)">PACSub1</a>(workingval);
        else
            workingval = <a link="impl-aarch64.PACInvSub.1" file="shared_pseudocode.xml" hover="function: bits(64) PACInvSub(bits(64) Tinput)">PACInvSub</a>(workingval);
        if i &lt; iterations then
            workingval = <a link="impl-aarch64.PACMult.1" file="shared_pseudocode.xml" hover="function: bits(64) PACMult(bits(64) Sinput)">PACMult</a>(workingval);
            workingval = <a link="impl-aarch64.PACCellInvShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) PACCellInvShuffle(bits(64) indata)">PACCellInvShuffle</a>(workingval);
        runningmod = <a link="impl-aarch64.TweakInvShuffle.1" file="shared_pseudocode.xml" hover="function: bits(64) TweakInvShuffle(bits(64) indata)">TweakInvShuffle</a>(runningmod&lt;63:0&gt;);
        roundkey = key1 EOR runningmod;
        workingval = workingval EOR RC[iterations-i];
        workingval = workingval EOR roundkey;
        workingval = workingval EOR Alpha;
    workingval = workingval EOR modk0;

    return workingval;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/PACCellInvShuffle" mylink="aarch64.functions.pac.computepac.PACCellInvShuffle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PACCellInvShuffle()
// ===================

bits(64) <anchor link="impl-aarch64.PACCellInvShuffle.1" hover="function: bits(64) PACCellInvShuffle(bits(64) indata)">PACCellInvShuffle</anchor>(bits(64) indata)
    bits(64) outdata;
    outdata&lt;3:0&gt; = indata&lt;15:12&gt;;
    outdata&lt;7:4&gt; = indata&lt;27:24&gt;;
    outdata&lt;11:8&gt; = indata&lt;51:48&gt;;
    outdata&lt;15:12&gt; = indata&lt;39:36&gt;;
    outdata&lt;19:16&gt; = indata&lt;59:56&gt;;
    outdata&lt;23:20&gt; = indata&lt;47:44&gt;;
    outdata&lt;27:24&gt; = indata&lt;7:4&gt;;
    outdata&lt;31:28&gt; = indata&lt;19:16&gt;;
    outdata&lt;35:32&gt; = indata&lt;35:32&gt;;
    outdata&lt;39:36&gt; = indata&lt;55:52&gt;;
    outdata&lt;43:40&gt; = indata&lt;31:28&gt;;
    outdata&lt;47:44&gt; = indata&lt;11:8&gt;;
    outdata&lt;51:48&gt; = indata&lt;23:20&gt;;
    outdata&lt;55:52&gt; = indata&lt;3:0&gt;;
    outdata&lt;59:56&gt; = indata&lt;43:40&gt;;
    outdata&lt;63:60&gt; = indata&lt;63:60&gt;;
    return outdata;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/PACCellShuffle" mylink="aarch64.functions.pac.computepac.PACCellShuffle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PACCellShuffle()
// ================

bits(64) <anchor link="impl-aarch64.PACCellShuffle.1" hover="function: bits(64) PACCellShuffle(bits(64) indata)">PACCellShuffle</anchor>(bits(64) indata)
    bits(64) outdata;
    outdata&lt;3:0&gt; = indata&lt;55:52&gt;;
    outdata&lt;7:4&gt; = indata&lt;27:24&gt;;
    outdata&lt;11:8&gt; = indata&lt;47:44&gt;;
    outdata&lt;15:12&gt; = indata&lt;3:0&gt;;
    outdata&lt;19:16&gt; = indata&lt;31:28&gt;;
    outdata&lt;23:20&gt; = indata&lt;51:48&gt;;
    outdata&lt;27:24&gt; = indata&lt;7:4&gt;;
    outdata&lt;31:28&gt; = indata&lt;43:40&gt;;
    outdata&lt;35:32&gt; = indata&lt;35:32&gt;;
    outdata&lt;39:36&gt; = indata&lt;15:12&gt;;
    outdata&lt;43:40&gt; = indata&lt;59:56&gt;;
    outdata&lt;47:44&gt; = indata&lt;23:20&gt;;
    outdata&lt;51:48&gt; = indata&lt;11:8&gt;;
    outdata&lt;55:52&gt; = indata&lt;39:36&gt;;
    outdata&lt;59:56&gt; = indata&lt;19:16&gt;;
    outdata&lt;63:60&gt; = indata&lt;63:60&gt;;
    return outdata;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/PACInvSub" mylink="aarch64.functions.pac.computepac.PACInvSub" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PACInvSub()
// ===========

bits(64) <anchor link="impl-aarch64.PACInvSub.1" hover="function: bits(64) PACInvSub(bits(64) Tinput)">PACInvSub</anchor>(bits(64) Tinput)
    // This is a 4-bit substitution from the PRINCE-family cipher
    bits(64) Toutput;
    for i = 0 to 15
        case Tinput&lt;4*i+3:4*i&gt; of
            when '0000'  Toutput&lt;4*i+3:4*i&gt; = '0101';
            when '0001'  Toutput&lt;4*i+3:4*i&gt; = '1110';
            when '0010'  Toutput&lt;4*i+3:4*i&gt; = '1101';
            when '0011'  Toutput&lt;4*i+3:4*i&gt; = '1000';
            when '0100'  Toutput&lt;4*i+3:4*i&gt; = '1010';
            when '0101'  Toutput&lt;4*i+3:4*i&gt; = '1011';
            when '0110'  Toutput&lt;4*i+3:4*i&gt; = '0001';
            when '0111'  Toutput&lt;4*i+3:4*i&gt; = '1001';
            when '1000'  Toutput&lt;4*i+3:4*i&gt; = '0010';
            when '1001'  Toutput&lt;4*i+3:4*i&gt; = '0110';
            when '1010'  Toutput&lt;4*i+3:4*i&gt; = '1111';
            when '1011'  Toutput&lt;4*i+3:4*i&gt; = '0000';
            when '1100'  Toutput&lt;4*i+3:4*i&gt; = '0100';
            when '1101'  Toutput&lt;4*i+3:4*i&gt; = '1100';
            when '1110'  Toutput&lt;4*i+3:4*i&gt; = '0111';
            when '1111'  Toutput&lt;4*i+3:4*i&gt; = '0011';
    return Toutput;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/PACMult" mylink="aarch64.functions.pac.computepac.PACMult" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PACMult()
// =========

bits(64) <anchor link="impl-aarch64.PACMult.1" hover="function: bits(64) PACMult(bits(64) Sinput)">PACMult</anchor>(bits(64) Sinput)
    bits(4)  t0;
    bits(4)  t1;
    bits(4)  t2;
    bits(4)  t3;
    bits(64) Soutput;

    for i = 0 to 3
        t0&lt;3:0&gt; = <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+8)+3:4*(i+8)&gt;, 1) EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+4)+3:4*(i+4)&gt;, 2);
        t0&lt;3:0&gt; = t0&lt;3:0&gt; EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i)+3:4*(i)&gt;, 1);
        t1&lt;3:0&gt; = <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+12)+3:4*(i+12)&gt;, 1) EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+4)+3:4*(i+4)&gt;, 1);
        t1&lt;3:0&gt; = t1&lt;3:0&gt; EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i)+3:4*(i)&gt;, 2);
        t2&lt;3:0&gt; = <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+12)+3:4*(i+12)&gt;, 2) EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+8)+3:4*(i+8)&gt;, 1);
        t2&lt;3:0&gt; = t2&lt;3:0&gt; EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i)+3:4*(i)&gt;, 1);
        t3&lt;3:0&gt; = <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+12)+3:4*(i+12)&gt;, 1) EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+8)+3:4*(i+8)&gt;, 2);
        t3&lt;3:0&gt; = t3&lt;3:0&gt; EOR <a link="impl-aarch64.RotCell.2" file="shared_pseudocode.xml" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</a>(Sinput&lt;4*(i+4)+3:4*(i+4)&gt;, 1);
        Soutput&lt;4*i+3:4*i&gt; = t3&lt;3:0&gt;;
        Soutput&lt;4*(i+4)+3:4*(i+4)&gt; = t2&lt;3:0&gt;;
        Soutput&lt;4*(i+8)+3:4*(i+8)&gt; = t1&lt;3:0&gt;;
        Soutput&lt;4*(i+12)+3:4*(i+12)&gt; = t0&lt;3:0&gt;;
    return Soutput;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/PACSub" mylink="aarch64.functions.pac.computepac.PACSub" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PACSub()
// ========

bits(64) <anchor link="impl-aarch64.PACSub.1" hover="function: bits(64) PACSub(bits(64) Tinput)">PACSub</anchor>(bits(64) Tinput)
    // This is a 4-bit substitution from the PRINCE-family cipher
    bits(64) Toutput;
    for i = 0 to 15
        case Tinput&lt;4*i+3:4*i&gt; of
            when '0000'  Toutput&lt;4*i+3:4*i&gt; = '1011';
            when '0001'  Toutput&lt;4*i+3:4*i&gt; = '0110';
            when '0010'  Toutput&lt;4*i+3:4*i&gt; = '1000';
            when '0011'  Toutput&lt;4*i+3:4*i&gt; = '1111';
            when '0100'  Toutput&lt;4*i+3:4*i&gt; = '1100';
            when '0101'  Toutput&lt;4*i+3:4*i&gt; = '0000';
            when '0110'  Toutput&lt;4*i+3:4*i&gt; = '1001';
            when '0111'  Toutput&lt;4*i+3:4*i&gt; = '1110';
            when '1000'  Toutput&lt;4*i+3:4*i&gt; = '0011';
            when '1001'  Toutput&lt;4*i+3:4*i&gt; = '0111';
            when '1010'  Toutput&lt;4*i+3:4*i&gt; = '0100';
            when '1011'  Toutput&lt;4*i+3:4*i&gt; = '0101';
            when '1100'  Toutput&lt;4*i+3:4*i&gt; = '1101';
            when '1101'  Toutput&lt;4*i+3:4*i&gt; = '0010';
            when '1110'  Toutput&lt;4*i+3:4*i&gt; = '0001';
            when '1111'  Toutput&lt;4*i+3:4*i&gt; = '1010';
    return Toutput;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/PacSub1" mylink="aarch64.functions.pac.computepac.PacSub1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PacSub1()
// =========

bits(64) <anchor link="impl-aarch64.PACSub1.1" hover="function: bits(64) PACSub1(bits(64) Tinput)">PACSub1</anchor>(bits(64) Tinput)
    // This is a 4-bit substitution from Qarma sigma1
    bits(64) Toutput;
    for i = 0 to 15
        case Tinput&lt;4*i+3:4*i&gt; of
            when '0000' Toutput&lt;4*i+3:4*i&gt; = '1010';
            when '0001' Toutput&lt;4*i+3:4*i&gt; = '1101';
            when '0010' Toutput&lt;4*i+3:4*i&gt; = '1110';
            when '0011' Toutput&lt;4*i+3:4*i&gt; = '0110';
            when '0100' Toutput&lt;4*i+3:4*i&gt; = '1111';
            when '0101' Toutput&lt;4*i+3:4*i&gt; = '0111';
            when '0110' Toutput&lt;4*i+3:4*i&gt; = '0011';
            when '0111' Toutput&lt;4*i+3:4*i&gt; = '0101';
            when '1000' Toutput&lt;4*i+3:4*i&gt; = '1001';
            when '1001' Toutput&lt;4*i+3:4*i&gt; = '1000';
            when '1010' Toutput&lt;4*i+3:4*i&gt; = '0000';
            when '1011' Toutput&lt;4*i+3:4*i&gt; = '1100';
            when '1100' Toutput&lt;4*i+3:4*i&gt; = '1011';
            when '1101' Toutput&lt;4*i+3:4*i&gt; = '0001';
            when '1110' Toutput&lt;4*i+3:4*i&gt; = '0010';
            when '1111' Toutput&lt;4*i+3:4*i&gt; = '0100';
    return Toutput;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/RC" mylink="aarch64.functions.pac.computepac.RC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RC[]
// ====

array bits(64) RC[0..4];</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/RotCell" mylink="aarch64.functions.pac.computepac.RotCell" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RotCell()
// =========

bits(4) <anchor link="impl-aarch64.RotCell.2" hover="function: bits(4) RotCell(bits(4) incell, integer amount)">RotCell</anchor>(bits(4) incell, integer amount)
    bits(8) tmp;
    bits(4) outcell;

    // assert amount&gt;3 || amount&lt;1;
    tmp&lt;7:0&gt; = incell&lt;3:0&gt;:incell&lt;3:0&gt;;
    outcell = tmp&lt;7-amount:4-amount&gt;;
    return outcell;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/TweakCellInvRot" mylink="aarch64.functions.pac.computepac.TweakCellInvRot" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TweakCellInvRot()
// =================

bits(4) <anchor link="impl-aarch64.TweakCellInvRot.1" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</anchor>(bits(4) incell)
    bits(4) outcell;
    outcell&lt;3&gt; = incell&lt;2&gt;;
    outcell&lt;2&gt; = incell&lt;1&gt;;
    outcell&lt;1&gt; = incell&lt;0&gt;;
    outcell&lt;0&gt; = incell&lt;0&gt; EOR incell&lt;3&gt;;
    return outcell;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/TweakCellRot" mylink="aarch64.functions.pac.computepac.TweakCellRot" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TweakCellRot()
// ==============

bits(4) <anchor link="impl-aarch64.TweakCellRot.1" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</anchor>(bits(4) incell)
    bits(4) outcell;
    outcell&lt;3&gt; = incell&lt;0&gt; EOR incell&lt;1&gt;;
    outcell&lt;2&gt; = incell&lt;3&gt;;
    outcell&lt;1&gt; = incell&lt;2&gt;;
    outcell&lt;0&gt; = incell&lt;1&gt;;
    return outcell;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/TweakInvShuffle" mylink="aarch64.functions.pac.computepac.TweakInvShuffle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TweakInvShuffle()
// =================

bits(64) <anchor link="impl-aarch64.TweakInvShuffle.1" hover="function: bits(64) TweakInvShuffle(bits(64) indata)">TweakInvShuffle</anchor>(bits(64) indata)
    bits(64) outdata;
    outdata&lt;3:0&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;51:48&gt;);
    outdata&lt;7:4&gt; = indata&lt;55:52&gt;;
    outdata&lt;11:8&gt; = indata&lt;23:20&gt;;
    outdata&lt;15:12&gt; = indata&lt;27:24&gt;;
    outdata&lt;19:16&gt; = indata&lt;3:0&gt;;
    outdata&lt;23:20&gt; = indata&lt;7:4&gt;;
    outdata&lt;27:24&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;11:8&gt;);
    outdata&lt;31:28&gt; = indata&lt;15:12&gt;;
    outdata&lt;35:32&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;31:28&gt;);
    outdata&lt;39:36&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;63:60&gt;);
    outdata&lt;43:40&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;59:56&gt;);
    outdata&lt;47:44&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;19:16&gt;);
    outdata&lt;51:48&gt; = indata&lt;35:32&gt;;
    outdata&lt;55:52&gt; = indata&lt;39:36&gt;;
    outdata&lt;59:56&gt; = indata&lt;43:40&gt;;
    outdata&lt;63:60&gt; = <a link="impl-aarch64.TweakCellInvRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellInvRot(bits(4) incell)">TweakCellInvRot</a>(indata&lt;47:44&gt;);
    return outdata;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/TweakShuffle" mylink="aarch64.functions.pac.computepac.TweakShuffle" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TweakShuffle()
// ==============

bits(64) <anchor link="impl-aarch64.TweakShuffle.1" hover="function: bits(64) TweakShuffle(bits(64) indata)">TweakShuffle</anchor>(bits(64) indata)
    bits(64) outdata;
    outdata&lt;3:0&gt; = indata&lt;19:16&gt;;
    outdata&lt;7:4&gt; = indata&lt;23:20&gt;;
    outdata&lt;11:8&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;27:24&gt;);
    outdata&lt;15:12&gt; = indata&lt;31:28&gt;;
    outdata&lt;19:16&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;47:44&gt;);
    outdata&lt;23:20&gt; = indata&lt;11:8&gt;;
    outdata&lt;27:24&gt; = indata&lt;15:12&gt;;
    outdata&lt;31:28&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;35:32&gt;);
    outdata&lt;35:32&gt; = indata&lt;51:48&gt;;
    outdata&lt;39:36&gt; = indata&lt;55:52&gt;;
    outdata&lt;43:40&gt; = indata&lt;59:56&gt;;
    outdata&lt;47:44&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;63:60&gt;);
    outdata&lt;51:48&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;3:0&gt;);
    outdata&lt;55:52&gt; = indata&lt;7:4&gt;;
    outdata&lt;59:56&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;43:40&gt;);
    outdata&lt;63:60&gt; = <a link="impl-aarch64.TweakCellRot.1" file="shared_pseudocode.xml" hover="function: bits(4) TweakCellRot(bits(4) incell)">TweakCellRot</a>(indata&lt;39:36&gt;);
    return outdata;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/UsePACIMP" mylink="aarch64.functions.pac.computepac.UsePACIMP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UsePACIMP()
// ===========
// Checks whether IMPLEMENTATION DEFINED cryptographic algorithm to be used for PAC
// calculation.

boolean <anchor link="impl-aarch64.UsePACIMP.1" hover="function: boolean UsePACIMP(boolean isgeneric)">UsePACIMP</anchor>(boolean isgeneric)
    return if isgeneric then <a link="impl-aarch64.HavePACIMPGeneric.0" file="shared_pseudocode.xml" hover="function: boolean HavePACIMPGeneric()">HavePACIMPGeneric</a>() else <a link="impl-aarch64.HavePACIMPAuth.0" file="shared_pseudocode.xml" hover="function: boolean HavePACIMPAuth()">HavePACIMPAuth</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/UsePACQARMA3" mylink="aarch64.functions.pac.computepac.UsePACQARMA3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UsePACQARMA3()
// ==============
// Checks whether QARMA3 cryptographic algorithm to be used for PAC calculation.

boolean <anchor link="impl-aarch64.UsePACQARMA3.1" hover="function: boolean UsePACQARMA3(boolean isgeneric)">UsePACQARMA3</anchor>(boolean isgeneric)
    return if isgeneric then <a link="impl-aarch64.HavePACQARMA3Generic.0" file="shared_pseudocode.xml" hover="function: boolean HavePACQARMA3Generic()">HavePACQARMA3Generic</a>() else <a link="impl-aarch64.HavePACQARMA3Auth.0" file="shared_pseudocode.xml" hover="function: boolean HavePACQARMA3Auth()">HavePACQARMA3Auth</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/pac/computepac/UsePACQARMA5" mylink="aarch64.functions.pac.computepac.UsePACQARMA5" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UsePACQARMA5()
// ==============
// Checks whether QARMA5 cryptographic algorithm to be used for PAC calculation.

boolean <anchor link="impl-aarch64.UsePACQARMA5.1" hover="function: boolean UsePACQARMA5(boolean isgeneric)">UsePACQARMA5</anchor>(boolean isgeneric)
    return if isgeneric then <a link="impl-aarch64.HavePACQARMA5Generic.0" file="shared_pseudocode.xml" hover="function: boolean HavePACQARMA5Generic()">HavePACQARMA5Generic</a>() else <a link="impl-aarch64.HavePACQARMA5Auth.0" file="shared_pseudocode.xml" hover="function: boolean HavePACQARMA5Auth()">HavePACQARMA5Auth</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/ConstPACField" mylink="aarch64.functions.pac.pac.ConstPACField" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConstPACField()
// ===============
// Returns TRUE if bit&lt;55&gt; can be used to determine the size of the PAC field, FALSE otherwise.

boolean <anchor link="impl-aarch64.ConstPACField.0" hover="function: boolean ConstPACField()">ConstPACField</anchor>()
    return IsFeatureImplemented(FEAT_CONSTPACFIELD);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HaveEnhancedPAC" mylink="aarch64.functions.pac.pac.HaveEnhancedPAC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveEnhancedPAC()
// =================
// Returns TRUE if support for EnhancedPAC is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveEnhancedPAC.0" hover="function: boolean HaveEnhancedPAC()">HaveEnhancedPAC</anchor>()
    return IsFeatureImplemented(FEAT_EPAC);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HaveEnhancedPAC2" mylink="aarch64.functions.pac.pac.HaveEnhancedPAC2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveEnhancedPAC2()
// ==================
// Returns TRUE if support for EnhancedPAC2 is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveEnhancedPAC2.0" hover="function: boolean HaveEnhancedPAC2()">HaveEnhancedPAC2</anchor>()
    return IsFeatureImplemented(FEAT_PAuth2);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HaveFPAC" mylink="aarch64.functions.pac.pac.HaveFPAC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFPAC()
// ==========
// Returns TRUE if support for FPAC is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveFPAC.0" hover="function: boolean HaveFPAC()">HaveFPAC</anchor>()
    return IsFeatureImplemented(FEAT_FPAC);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HaveFPACCombined" mylink="aarch64.functions.pac.pac.HaveFPACCombined" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFPACCombined()
// ==================
// Returns TRUE if support for FPACCombined is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveFPACCombined.0" hover="function: boolean HaveFPACCombined()">HaveFPACCombined</anchor>()
    return IsFeatureImplemented(FEAT_FPACCOMBINE);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACExt" mylink="aarch64.functions.pac.pac.HavePACExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACExt()
// ============
// Returns TRUE if support for the PAC extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACExt.0" hover="function: boolean HavePACExt()">HavePACExt</anchor>()
    return IsFeatureImplemented(FEAT_PAuth);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACIMPAuth" mylink="aarch64.functions.pac.pac.HavePACIMPAuth" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACIMPAuth()
// ================
// Returns TRUE if support for PAC IMP Auth is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACIMPAuth.0" hover="function: boolean HavePACIMPAuth()">HavePACIMPAuth</anchor>()
    return IsFeatureImplemented(FEAT_PACIMP);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACIMPGeneric" mylink="aarch64.functions.pac.pac.HavePACIMPGeneric" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACIMPGeneric()
// ===================
// Returns TRUE if support for PAC IMP Generic is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACIMPGeneric.0" hover="function: boolean HavePACIMPGeneric()">HavePACIMPGeneric</anchor>()
    return IsFeatureImplemented(FEAT_PACIMP);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACQARMA3Auth" mylink="aarch64.functions.pac.pac.HavePACQARMA3Auth" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACQARMA3Auth()
// ===================
// Returns TRUE if support for PAC QARMA3 Auth is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACQARMA3Auth.0" hover="function: boolean HavePACQARMA3Auth()">HavePACQARMA3Auth</anchor>()
    return IsFeatureImplemented(FEAT_PACQARMA3);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACQARMA3Generic" mylink="aarch64.functions.pac.pac.HavePACQARMA3Generic" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACQARMA3Generic()
// ======================
// Returns TRUE if support for PAC QARMA3 Generic is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACQARMA3Generic.0" hover="function: boolean HavePACQARMA3Generic()">HavePACQARMA3Generic</anchor>()
    return IsFeatureImplemented(FEAT_PACQARMA3);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACQARMA5Auth" mylink="aarch64.functions.pac.pac.HavePACQARMA5Auth" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACQARMA5Auth()
// ===================
// Returns TRUE if support for PAC QARMA5 Auth is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACQARMA5Auth.0" hover="function: boolean HavePACQARMA5Auth()">HavePACQARMA5Auth</anchor>()
    return IsFeatureImplemented(FEAT_PACQARMA5);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/HavePACQARMA5Generic" mylink="aarch64.functions.pac.pac.HavePACQARMA5Generic" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePACQARMA5Generic()
// ======================
// Returns TRUE if support for PAC QARMA5 Generic is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HavePACQARMA5Generic.0" hover="function: boolean HavePACQARMA5Generic()">HavePACQARMA5Generic</anchor>()
    return IsFeatureImplemented(FEAT_PACQARMA5);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/pac/PtrHasUpperAndLowerAddRanges" mylink="aarch64.functions.pac.pac.PtrHasUpperAndLowerAddRanges" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PtrHasUpperAndLowerAddRanges()
// ==============================
// Returns TRUE if the pointer has upper and lower address ranges, FALSE otherwise.

boolean <anchor link="impl-aarch64.PtrHasUpperAndLowerAddRanges.0" hover="function: boolean PtrHasUpperAndLowerAddRanges()">PtrHasUpperAndLowerAddRanges</anchor>()
    regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(PSTATE.EL);
    return <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime);</pstext>
    </ps>
    <ps name="aarch64/functions/pac/strip/Strip" mylink="aarch64.functions.pac.strip.Strip" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Strip()
// =======
// Strip() returns a 64-bit value containing A, but replacing the pointer authentication
// code field bits with the extension of the address bits. This can apply to either
// instructions or data, where, as the use of tagged pointers is distinct, it might be
// handled differently.

bits(64) <anchor link="impl-aarch64.Strip.2" hover="function: bits(64) Strip(bits(64) A, boolean data)">Strip</anchor>(bits(64) A, boolean data)
    bits(64) original_ptr;
    bits(64) extfield;
    boolean tbi = <a link="impl-shared.EffectiveTBI.3" file="shared_pseudocode.xml" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</a>(A, !data, PSTATE.EL) == '1';
    boolean mtx = <a link="impl-shared.EffectiveMTX.3" file="shared_pseudocode.xml" hover="function: bit EffectiveMTX(bits(64) address, boolean is_instr, bits(2) el)">EffectiveMTX</a>(A, !data, PSTATE.EL) == '1';
    integer bottom_PAC_bit = <a link="impl-aarch64.CalculateBottomPACBit.1" file="shared_pseudocode.xml" hover="function: integer CalculateBottomPACBit(bit top_bit)">CalculateBottomPACBit</a>(A&lt;55&gt;);
    extfield = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(A&lt;55&gt;, 64);

    // If the VA is 56 or 55 bits and Top Byte is Ignored,
    // there are no unused bits left for the PAC
    if tbi &amp;&amp; bottom_PAC_bit &gt;= 55 then
        return A;

    if tbi then
        original_ptr = (A&lt;63:56&gt; :
                        extfield&lt;(56-bottom_PAC_bit)-1:0&gt; : A&lt;bottom_PAC_bit-1:0&gt;);
    elsif mtx then
        original_ptr = (extfield&lt;63:60&gt; : A&lt;59:56&gt; :
                        extfield&lt;(56-bottom_PAC_bit)-1:0&gt; : A&lt;bottom_PAC_bit-1:0&gt;);
    else
        original_ptr =  extfield&lt;(64-bottom_PAC_bit)-1:0&gt; : A&lt;bottom_PAC_bit-1:0&gt;;

    return original_ptr;</pstext>
    </ps>
    <ps name="aarch64/functions/pac/trappacuse/TrapPACUse" mylink="aarch64.functions.pac.trappacuse.TrapPACUse" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TrapPACUse()
// ============
// Used for the trapping of the pointer authentication functions by higher exception
// levels.

<anchor link="impl-aarch64.TrapPACUse.1" hover="function: TrapPACUse(bits(2) target_el)">TrapPACUse</anchor>(bits(2) target_el)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) &amp;&amp; target_el !=  <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);

    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> exception;
    vect_offset = 0;
    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_PACTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACTrap</a>);
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/ras/AArch64.ESBOperation" mylink="aarch64.functions.ras.AArch64.ESBOperation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ESBOperation()
// ======================
// Perform the AArch64 ESB operation, either for ESB executed in AArch64 state, or for
// ESB in AArch32 state when SError interrupts are routed to an Exception level using
// AArch64

<anchor link="AArch64.ESBOperation.0" hover="function: AArch64.ESBOperation()">AArch64.ESBOperation</anchor>()
    bits(2) target_el;
    boolean masked;

    (masked, target_el) = <a link="AArch64.PhysicalSErrorTarget.0" file="shared_pseudocode.xml" hover="function: (boolean, bits(2)) AArch64.PhysicalSErrorTarget()">AArch64.PhysicalSErrorTarget</a>();

    intdis = <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() || <a link="impl-shared.ExternalDebugInterruptsDisabled.1" file="shared_pseudocode.xml" hover="function: boolean ExternalDebugInterruptsDisabled(bits(2) target)">ExternalDebugInterruptsDisabled</a>(target_el);
    masked = masked || intdis;

    // Check for a masked Physical SError pending that can be synchronized
    // by an Error synchronization event.
    if masked &amp;&amp; <a link="impl-shared.IsSynchronizablePhysicalSErrorPending.0" file="shared_pseudocode.xml" hover="function: boolean IsSynchronizablePhysicalSErrorPending()">IsSynchronizablePhysicalSErrorPending</a>() then
        // This function might be called for an interworking case, and INTdis is masking
        // the SError interrupt.
        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()) then
            bits(32) syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
            syndrome&lt;31&gt; = '1'; // A
            syndrome&lt;15:0&gt; = <a link="AArch32.PhysicalSErrorSyndrome.0" file="shared_pseudocode.xml" hover="function: bits(16) AArch32.PhysicalSErrorSyndrome()">AArch32.PhysicalSErrorSyndrome</a>();
            DISR = syndrome;
        else
            implicit_esb = FALSE;
            bits(64) syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
            syndrome&lt;31&gt; = '1'; // A
            syndrome&lt;24:0&gt; = <a link="AArch64.PhysicalSErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(25) AArch64.PhysicalSErrorSyndrome(boolean implicit_esb)">AArch64.PhysicalSErrorSyndrome</a>(implicit_esb);
            DISR_EL1 = syndrome;
        <a link="impl-shared.ClearPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: ClearPendingPhysicalSError()">ClearPendingPhysicalSError</a>();               // Set ISR_EL1.A to 0

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/ras/AArch64.EncodeAsyncErrorSyndrome" mylink="aarch64.functions.ras.AArch64.EncodeAsyncErrorSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.EncodeAsyncErrorSyndrome()
// ==================================
// Return the encoding for corresponding ErrorState.

bits(3) <anchor link="AArch64.EncodeAsyncErrorSyndrome.1" hover="function: bits(3) AArch64.EncodeAsyncErrorSyndrome(ErrorState errorstate)">AArch64.EncodeAsyncErrorSyndrome</anchor>(<a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errorstate)
    case errorstate of
        when <a link="ErrorState_UC" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</a>  return '000';
        when <a link="ErrorState_UEU" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEU</a> return '001';
        when <a link="ErrorState_UEO" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEO</a> return '010';
        when <a link="ErrorState_UER" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UER</a> return '011';
        when <a link="ErrorState_CE" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_CE</a>  return '110';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/ras/AArch64.EncodeSyncErrorSyndrome" mylink="aarch64.functions.ras.AArch64.EncodeSyncErrorSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.EncodeSyncErrorSyndrome()
// =================================
// Return the encoding for corresponding ErrorState.

bits(2) <anchor link="AArch64.EncodeSyncErrorSyndrome.1" hover="function: bits(2) AArch64.EncodeSyncErrorSyndrome(ErrorState errorstate)">AArch64.EncodeSyncErrorSyndrome</anchor>(<a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errorstate)
    case errorstate of
        when <a link="ErrorState_UC" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</a>  return '10';
        when <a link="ErrorState_UEO" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEO</a> return '11';
        when <a link="ErrorState_UER" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UER</a> return '00';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/ras/AArch64.PhysicalSErrorSyndrome" mylink="aarch64.functions.ras.AArch64.PhysicalSErrorSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PhysicalSErrorSyndrome()
// ================================
// Generate SError syndrome.

bits(25) <anchor link="AArch64.PhysicalSErrorSyndrome.1" hover="function: bits(25) AArch64.PhysicalSErrorSyndrome(boolean implicit_esb)">AArch64.PhysicalSErrorSyndrome</anchor>(boolean implicit_esb)
    bits(25) syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(25);
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.GetPendingPhysicalSError.0" file="shared_pseudocode.xml" hover="function: FaultRecord GetPendingPhysicalSError()">GetPendingPhysicalSError</a>();
    <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a> errorstate = <a link="AArch64.PEErrorState.1" file="shared_pseudocode.xml" hover="function: ErrorState AArch64.PEErrorState(FaultRecord fault)">AArch64.PEErrorState</a>(fault);
    if errorstate == <a link="ErrorState_Uncategorized" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_Uncategorized</a> then
        syndrome = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(25);
    elsif errorstate == <a link="ErrorState_IMPDEF" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_IMPDEF</a> then
        syndrome&lt;24&gt; = '1';                                             // IDS
        syndrome&lt;23:0&gt; = bits(24) IMPLEMENTATION_DEFINED "IMPDEF <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a>";
    else
        syndrome&lt;24&gt; = '0';                                             // IDS
        syndrome&lt;13&gt; = (if implicit_esb then '1' else '0');             // IESB
        syndrome&lt;12:10&gt; = <a link="AArch64.EncodeAsyncErrorSyndrome.1" file="shared_pseudocode.xml" hover="function: bits(3) AArch64.EncodeAsyncErrorSyndrome(ErrorState errorstate)">AArch64.EncodeAsyncErrorSyndrome</a>(errorstate); // AET
        syndrome&lt;9&gt; = fault.extflag;                                    // EA
        syndrome&lt;5:0&gt; = '010001';                                       // DFSC
    return syndrome;</pstext>
    </ps>
    <ps name="aarch64/functions/ras/AArch64.vESBOperation" mylink="aarch64.functions.ras.AArch64.vESBOperation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.vESBOperation()
// =======================
// Perform the AArch64 ESB operation for virtual SError interrupts, either for ESB
// executed in AArch64 state, or for ESB in AArch32 state with EL2 using AArch64 state

<anchor link="AArch64.vESBOperation.0" hover="function: AArch64.vESBOperation()">AArch64.vESBOperation</anchor>()
    assert PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    // If physical SError interrupts are routed to EL2, and TGE is not set, then a virtual
    // SError interrupt might be pending
    vSEI_enabled = HCR_EL2.TGE == '0' &amp;&amp; HCR_EL2.AMO == '1';
    vSEI_pending = vSEI_enabled &amp;&amp; HCR_EL2.VSE == '1';
    vintdis      = <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() || <a link="impl-shared.ExternalDebugInterruptsDisabled.1" file="shared_pseudocode.xml" hover="function: boolean ExternalDebugInterruptsDisabled(bits(2) target)">ExternalDebugInterruptsDisabled</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    vmasked      = vintdis || PSTATE.A == '1';

    // Check for a masked virtual SError pending
    if vSEI_pending &amp;&amp; vmasked then
        // This function might be called for the interworking case, and INTdis is masking
        // the virtual SError interrupt.
        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
            bits(32) target = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);
            target&lt;31&gt; = '1';              // A
            target&lt;15:14&gt; = VDFSR&lt;15:14&gt;;  // AET
            target&lt;12&gt;    = VDFSR&lt;12&gt;;     // ExT
            target&lt;9&gt;     = TTBCR.EAE;     // LPAE
            if TTBCR.EAE == '1' then       // Long-descriptor format
                target&lt;5:0&gt;    = '010001'; // STATUS
            else                           // Short-descriptor format
                target&lt;10,3:0&gt; = '10110';  // FS
            VDISR = target;
        else
            bits(64) target = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
            target&lt;31&gt; = '1';              // A
            target&lt;24:0&gt; = VSESR_EL2&lt;24:0&gt;;
            VDISR_EL2 = target;
        HCR_EL2.VSE = '0';                       // Clear pending virtual SError

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/rcw/ProtectionEnabled" mylink="aarch64.functions.rcw.ProtectionEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ProtectionEnabled()
// ===================
// Returns TRUE if the ProtectedBit is
// enabled in the current Exception level.

boolean <anchor link="impl-aarch64.ProtectionEnabled.1" hover="function: boolean ProtectionEnabled(bits(2) el)">ProtectionEnabled</anchor>(bits(2) el)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el);
    regime = <a link="impl-shared.S1TranslationRegime.1" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</a>(el);
    assert(!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(regime));
    if (!<a link="impl-aarch64.IsD128Enabled.1" file="shared_pseudocode.xml" hover="function: boolean IsD128Enabled(bits(2) el)">IsD128Enabled</a>(el)) then
        case regime of
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                return <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() &amp;&amp; TCR2_EL1.PnCH == '1';
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
                return <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() &amp;&amp; TCR2_EL2.PnCH == '1';
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
                return TCR_EL3.PnCH == '1';
    else
        return TRUE;
    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/functions/rcw/RCW128_PROTECTED_BIT" mylink="aarch64.functions.rcw.RCW128_PROTECTED_BIT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="RCW128_PROTECTED_BIT" hover="constant integer RCW128_PROTECTED_BIT = 114">RCW128_PROTECTED_BIT</anchor> = 114;</pstext>
    </ps>
    <ps name="aarch64/functions/rcw/RCW64_PROTECTED_BIT" mylink="aarch64.functions.rcw.RCW64_PROTECTED_BIT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="RCW64_PROTECTED_BIT" hover="constant integer RCW64_PROTECTED_BIT = 52">RCW64_PROTECTED_BIT</anchor> = 52;</pstext>
    </ps>
    <ps name="aarch64/functions/rcw/RCWCheck" mylink="aarch64.functions.rcw.RCWCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RCWCheck()
// ==========
// Returns nzcv based on : if the new value for RCW/RCWS instructions satisfy RCW and/or RCWS checks
// Z is set to 1 if RCW checks fail
// C is set to 0 if RCWS checks fail

bits(4) <anchor link="impl-aarch64.RCWCheck.3" hover="function: bits(4) RCWCheck(bits(N) old, bits(N) new, boolean soft)">RCWCheck</anchor>(bits(N) old, bits(N) new, boolean soft)
    assert N IN {64,128};
    integer protectedbit = if N == 128 then <a link="RCW128_PROTECTED_BIT" file="shared_pseudocode.xml" hover="constant integer RCW128_PROTECTED_BIT = 114">RCW128_PROTECTED_BIT</a> else <a link="RCW64_PROTECTED_BIT" file="shared_pseudocode.xml" hover="constant integer RCW64_PROTECTED_BIT = 52">RCW64_PROTECTED_BIT</a>;
    boolean rcw_fail = FALSE;
    boolean rcws_fail = FALSE;
    boolean rcw_state_fail = FALSE;
    boolean rcws_state_fail = FALSE;
    boolean rcw_mask_fail = FALSE;
    boolean rcws_mask_fail = FALSE;

    //Effective RCWMask calculation
    bits(N) rcwmask = RCWMASK_EL1&lt;N-1:0&gt;;
    if N == 64 then
        rcwmask&lt;49:18&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(rcwmask&lt;17&gt;,32);
    else
        rcwmask&lt;55:17&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(rcwmask&lt;16&gt;,39);
        rcwmask&lt;126:125,120:119,108:101,90:56,1&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(48);

    //Effective RCWSMask calculation
    bits(N) rcwsoftmask = RCWSMASK_EL1&lt;N-1:0&gt;;
    if N == 64 then
        rcwsoftmask&lt;49:18&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(rcwsoftmask&lt;17&gt;,32);
        if(<a link="impl-aarch64.ProtectionEnabled.1" file="shared_pseudocode.xml" hover="function: boolean ProtectionEnabled(bits(2) el)">ProtectionEnabled</a>(PSTATE.EL)) then
            rcwsoftmask&lt;52&gt; = '0';
    else
        rcwsoftmask&lt;55:17&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(rcwsoftmask&lt;16&gt;,39);
        rcwsoftmask&lt;126:125,120:119,108:101,90:56,1&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(48);
        rcwsoftmask&lt;114&gt; = '0';

    //RCW Checks
    //State Check
    if (<a link="impl-aarch64.ProtectionEnabled.1" file="shared_pseudocode.xml" hover="function: boolean ProtectionEnabled(bits(2) el)">ProtectionEnabled</a>(PSTATE.EL)) then
        if old&lt;protectedbit&gt; == '1' then
            rcw_state_fail = new&lt;protectedbit,0&gt; != old&lt;protectedbit,0&gt;;
        elsif old&lt;protectedbit&gt; == '0' then
            rcw_state_fail = new&lt;protectedbit&gt; != old&lt;protectedbit&gt;;

    //Mask Check
    if (<a link="impl-aarch64.ProtectionEnabled.1" file="shared_pseudocode.xml" hover="function: boolean ProtectionEnabled(bits(2) el)">ProtectionEnabled</a>(PSTATE.EL)) then
        if old&lt;protectedbit,0&gt; == '11' then
            rcw_mask_fail = !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>((new EOR old) AND NOT(rcwmask));

    //RCWS Checks
    if soft then
        //State Check
        if old&lt;0&gt; == '1' then
            rcws_state_fail = new&lt;0&gt; != old&lt;0&gt;;
        elsif (!<a link="impl-aarch64.ProtectionEnabled.1" file="shared_pseudocode.xml" hover="function: boolean ProtectionEnabled(bits(2) el)">ProtectionEnabled</a>(PSTATE.EL) ||
              (<a link="impl-aarch64.ProtectionEnabled.1" file="shared_pseudocode.xml" hover="function: boolean ProtectionEnabled(bits(2) el)">ProtectionEnabled</a>(PSTATE.EL) &amp;&amp; old&lt;protectedbit&gt; == '0')) then
            rcws_state_fail = new&lt;0&gt; != old&lt;0&gt; ;
        //Mask Check
        if old&lt;0&gt; == '1' then
            rcws_mask_fail = !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>((new EOR old) AND NOT(rcwsoftmask));

    rcw_fail = rcw_state_fail  || rcw_mask_fail ;
    rcws_fail = rcws_state_fail || rcws_mask_fail;

    bit n = '0';
    bit z = if rcw_fail then '1' else '0';
    bit c = if rcws_fail then '0' else '1';
    bit v = '0';
    return &lt;n, z, c, v&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/AArch64.MaybeZeroRegisterUppers" mylink="aarch64.functions.registers.AArch64.MaybeZeroRegisterUppers" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MaybeZeroRegisterUppers()
// =================================
// On taking an exception to  AArch64 from AArch32, it is CONSTRAINED UNPREDICTABLE whether the top
// 32 bits of registers visible at any lower Exception level using AArch32 are set to zero.

<anchor link="AArch64.MaybeZeroRegisterUppers.0" hover="function: AArch64.MaybeZeroRegisterUppers()">AArch64.MaybeZeroRegisterUppers</anchor>()
    assert <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();         // Always called from AArch32 state before entering AArch64 state

    integer first;
    integer last;
    boolean include_R15;
    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        first = 0;  last = 14;  include_R15 = FALSE;
    elsif PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        first = 0;  last = 30;  include_R15 = FALSE;
    else
        first = 0;  last = 30;  include_R15 = TRUE;

    for n = first to last
        if (n != 15 || include_R15) &amp;&amp; <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ZEROUPPER</a>) then
            _R[n]&lt;63:32&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32);

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/AArch64.ResetGeneralRegisters" mylink="aarch64.functions.registers.AArch64.ResetGeneralRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ResetGeneralRegisters()
// ===============================

<anchor link="AArch64.ResetGeneralRegisters.0" hover="function: AArch64.ResetGeneralRegisters()">AArch64.ResetGeneralRegisters</anchor>()

    for i = 0 to 30
        <a link="impl-aarch64.X.write.2" file="shared_pseudocode.xml" hover="accessor: X[integer n, integer width] = bits(width) value">X</a>[i, 64] = bits(64) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/AArch64.ResetSIMDFPRegisters" mylink="aarch64.functions.registers.AArch64.ResetSIMDFPRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ResetSIMDFPRegisters()
// ==============================

<anchor link="AArch64.ResetSIMDFPRegisters.0" hover="function: AArch64.ResetSIMDFPRegisters()">AArch64.ResetSIMDFPRegisters</anchor>()

    for i = 0 to 31
        <a link="impl-aarch64.V.write.2" file="shared_pseudocode.xml" hover="accessor: V[integer n, integer width] = bits(width) value">V</a>[i, 128] = bits(128) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/AArch64.ResetSpecialRegisters" mylink="aarch64.functions.registers.AArch64.ResetSpecialRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ResetSpecialRegisters()
// ===============================

<anchor link="AArch64.ResetSpecialRegisters.0" hover="function: AArch64.ResetSpecialRegisters()">AArch64.ResetSpecialRegisters</anchor>()

    // AArch64 special registers
    SP_EL0 = bits(64) UNKNOWN;
    SP_EL1 = bits(64) UNKNOWN;
    SPSR_EL1 = bits(64) UNKNOWN;
    ELR_EL1  = bits(64) UNKNOWN;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        SP_EL2 = bits(64) UNKNOWN;
        SPSR_EL2 = bits(64) UNKNOWN;
        ELR_EL2  = bits(64) UNKNOWN;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        SP_EL3 = bits(64) UNKNOWN;
        SPSR_EL3 = bits(64) UNKNOWN;
        ELR_EL3  = bits(64) UNKNOWN;

    // AArch32 special registers that are not architecturally mapped to AArch64 registers
    if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        SPSR_fiq&lt;31:0&gt; = bits(32) UNKNOWN;
        SPSR_irq&lt;31:0&gt; = bits(32) UNKNOWN;
        SPSR_abt&lt;31:0&gt; = bits(32) UNKNOWN;
        SPSR_und&lt;31:0&gt; = bits(32) UNKNOWN;

    // External debug special registers
    DLR_EL0 = bits(64) UNKNOWN;
    DSPSR_EL0 = bits(64) UNKNOWN;

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/AArch64.ResetSystemRegisters" mylink="aarch64.functions.registers.AArch64.ResetSystemRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ResetSystemRegisters()
// ==============================

<anchor link="AArch64.ResetSystemRegisters.1" hover="function: AArch64.ResetSystemRegisters(boolean cold_reset)">AArch64.ResetSystemRegisters</anchor>(boolean cold_reset);</pstext>
    </ps>
    <ps name="aarch64/functions/registers/PC" mylink="aarch64.functions.registers.PC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PC - non-assignment form
// ========================
// Read program counter.

bits(64) <anchor link="impl-aarch64.PC.read.0" hover="accessor: bits(64) PC[]">PC</anchor>[]
    return _PC;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SP" mylink="aarch64.functions.registers.SP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SP[] - assignment form
// ======================
// Write to stack pointer from a 64-bit value.

<anchor link="impl-aarch64.SP.write.0" hover="accessor: SP[] = bits(64) value">SP</anchor>[] = bits(64) value
    if PSTATE.SP == '0' then
        SP_EL0 = value;
    else
        case PSTATE.EL of
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>  SP_EL0 = value;
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  SP_EL1 = value;
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  SP_EL2 = value;
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  SP_EL3 = value;
    return;

// SP[] - non-assignment form
// ==========================
// Read stack pointer with slice of 64 bits.

bits(64) <anchor link="impl-aarch64.SP.read.0" hover="accessor: bits(64) SP[]">SP</anchor>[]
    if PSTATE.SP == '0' then
        return SP_EL0;
    else
        case PSTATE.EL of
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>  return SP_EL0;
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  return SP_EL1;
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  return SP_EL2;
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  return SP_EL3;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMCFGR_EL1" mylink="aarch64.functions.registers.SPMCFGR_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMCFGR_EL1[] - non-assignment form
// =====================================
// Read the current configuration of System Performance monitor for
// System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMCFGR_EL1.read.1" hover="accessor: bits(64) SPMCFGR_EL1[integer s]">SPMCFGR_EL1</anchor>[integer s];</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMCGCR_EL1" mylink="aarch64.functions.registers.SPMCGCR_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMCGCR_EL1[] - non-assignment form
// =====================================
// Read the counter group configuration of System Performance monitor
// 's'.

bits(64) <anchor link="impl-aarch64.SPMCGCR_EL1.read.1" hover="accessor: bits(64) SPMCGCR_EL1[integer s]">SPMCGCR_EL1</anchor>[integer s];</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMCNTENCLR_EL0" mylink="aarch64.functions.registers.SPMCNTENCLR_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMCNTENCLR_EL0[] - non-assignment form
// =======================================
// Read the current mapping of disabled event counters for an 's'.

bits(64) <anchor link="impl-aarch64.SPMCNTENCLR_EL0.read.1" hover="accessor: bits(64) SPMCNTENCLR_EL0[integer s]">SPMCNTENCLR_EL0</anchor>[integer s];

// SPMCNTENCLR_EL0[] - assignment form
// ===================================
// Disable event counters for System PMU 's'.

<anchor link="impl-aarch64.SPMCNTENCLR_EL0.write.1" hover="accessor: SPMCNTENCLR_EL0[integer s] = bits(64) value">SPMCNTENCLR_EL0</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMCNTENSET_EL0" mylink="aarch64.functions.registers.SPMCNTENSET_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMCNTENSET_EL0[] - non-assignment form
// =======================================
// Read the current mapping for enabled event counters of System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMCNTENSET_EL0.read.1" hover="accessor: bits(64) SPMCNTENSET_EL0[integer s]">SPMCNTENSET_EL0</anchor>[integer s];

// SPMCNTENSET_EL0[] - assignment form
// ===================================
// Enable event counters of System PMU 's'.

<anchor link="impl-aarch64.SPMCNTENSET_EL0.write.1" hover="accessor: SPMCNTENSET_EL0[integer s] = bits(64) value">SPMCNTENSET_EL0</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMCR_EL0" mylink="aarch64.functions.registers.SPMCR_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMCR_EL0[] - non-assignment form
// ==================================
// Read the control register for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMCR_EL0.read.1" hover="accessor: bits(64) SPMCR_EL0[integer s]">SPMCR_EL0</anchor>[integer s];

// SPMCR_EL0[] - assignment form
// =============================
// Write to the control register for System PMU 's'.

<anchor link="impl-aarch64.SPMCR_EL0.write.1" hover="accessor: SPMCR_EL0[integer s] = bits(64) value">SPMCR_EL0</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMDEVAFF_EL1" mylink="aarch64.functions.registers.SPMDEVAFF_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMDEVAFF_EL1[] - non-assignment form
// =====================================
// Read the discovery information for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMDEVAFF_EL1.read.1" hover="accessor: bits(64) SPMDEVAFF_EL1[integer s]">SPMDEVAFF_EL1</anchor>[integer s];</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMDEVARCH_EL1" mylink="aarch64.functions.registers.SPMDEVARCH_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMDEVARCH_EL1[] - non-assignment form
// ======================================
// Read the discovery information for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMDEVARCH_EL1.read.1" hover="accessor: bits(64) SPMDEVARCH_EL1[integer s]">SPMDEVARCH_EL1</anchor>[integer s];</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMEVCNTR_EL0" mylink="aarch64.functions.registers.SPMEVCNTR_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMEVCNTR_EL0[] - non-assignment form
// =====================================
// Read a System PMU Event Counter register for counter 'n' of a given
// System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMEVCNTR_EL0.read.2" hover="accessor: bits(64) SPMEVCNTR_EL0[integer s, integer n]">SPMEVCNTR_EL0</anchor>[integer s, integer n];

// SPMEVCNTR_EL0[] - assignment form
// =================================
// Write to a System PMU Event Counter register for counter 'n' of a given
// System PMU 's'.

<anchor link="impl-aarch64.SPMEVCNTR_EL0.write.2" hover="accessor: SPMEVCNTR_EL0[integer s, integer n] = bits(64) value">SPMEVCNTR_EL0</anchor>[integer s, integer n] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMEVFILT2R_EL0" mylink="aarch64.functions.registers.SPMEVFILT2R_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMEVFILT2R_EL0[] - non-assignment form
// =======================================
// Read the additional event selection controls for
// counter 'n' of a given System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMEVFILT2R_EL0.read.2" hover="accessor: bits(64) SPMEVFILT2R_EL0[integer s, integer n]">SPMEVFILT2R_EL0</anchor>[integer s, integer n];

// SPMEVFILT2R_EL0[] - assignment form
// ===================================
// Configure the additional event selection controls for
// counter 'n' of a given System PMU 's'.

<anchor link="impl-aarch64.SPMEVFILT2R_EL0.write.2" hover="accessor: SPMEVFILT2R_EL0[integer s, integer n] = bits(64) value">SPMEVFILT2R_EL0</anchor>[integer s, integer n] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMEVFILTR_EL0" mylink="aarch64.functions.registers.SPMEVFILTR_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMEVFILTR_EL0[] - non-assignment form
// ======================================
// Read the additional event selection controls for
// counter 'n' of a given System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMEVFILTR_EL0.read.2" hover="accessor: bits(64) SPMEVFILTR_EL0[integer s, integer n]">SPMEVFILTR_EL0</anchor>[integer s, integer n];

// SPMEVFILTR_EL0[] - assignment form
// ==================================
// Configure the additional event selection controls for
// counter 'n' of a given System PMU 's'.

<anchor link="impl-aarch64.SPMEVFILTR_EL0.write.2" hover="accessor: SPMEVFILTR_EL0[integer s, integer n] = bits(64) value">SPMEVFILTR_EL0</anchor>[integer s, integer n] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMEVTYPER_EL0" mylink="aarch64.functions.registers.SPMEVTYPER_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMEVTYPER_EL0[] - non-assignment form
// ======================================
// Read the current mapping of event with event counter SPMEVCNTR_EL0
// for counter 'n' of a given System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMEVTYPER_EL0.read.2" hover="accessor: bits(64) SPMEVTYPER_EL0[integer s, integer n]">SPMEVTYPER_EL0</anchor>[integer s, integer n];

// SPMEVTYPER_EL0[] - assignment form
// ==================================
// Configure which event increments the event counter SPMEVCNTR_EL0, for
// counter 'n' of a given System PMU 's'.

<anchor link="impl-aarch64.SPMEVTYPER_EL0.write.2" hover="accessor: SPMEVTYPER_EL0[integer s, integer n] = bits(64) value">SPMEVTYPER_EL0</anchor>[integer s, integer n] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMIIDR_EL1" mylink="aarch64.functions.registers.SPMIIDR_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMIIDR_EL1[] - non-assignment form
// ===================================
// Read the discovery information for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMIIDR_EL1.read.1" hover="accessor: bits(64) SPMIIDR_EL1[integer s]">SPMIIDR_EL1</anchor>[integer s];</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMINTENCLR_EL1" mylink="aarch64.functions.registers.SPMINTENCLR_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMINTENCLR_EL1[] - non-assignment form
// =======================================
// Read the masking information for interrupt requests on overflows of
// implemented counters of System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMINTENCLR_EL1.read.1" hover="accessor: bits(64) SPMINTENCLR_EL1[integer s]">SPMINTENCLR_EL1</anchor>[integer s];

// SPMINTENCLR_EL1[] - assignment form
// ===================================
// Disable the generation of interrupt requests on overflows of
// implemented counters of System PMU 's'.

<anchor link="impl-aarch64.SPMINTENCLR_EL1.write.1" hover="accessor: SPMINTENCLR_EL1[integer s] = bits(64) value">SPMINTENCLR_EL1</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMINTENSET_EL1" mylink="aarch64.functions.registers.SPMINTENSET_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMINTENSET_EL1[] - non-assignment form
// =======================================
// Read the masking information for interrupt requests on overflows of
// implemented counters of System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMINTENSET_EL1.read.1" hover="accessor: bits(64) SPMINTENSET_EL1[integer s]">SPMINTENSET_EL1</anchor>[integer s];

// SPMINTENSET_EL1[] - assignment form
// ===================================
// Disable the generation of interrupt requests on overflows of
// implemented counters for System PMU 's'.

<anchor link="impl-aarch64.SPMINTENSET_EL1.write.1" hover="accessor: SPMINTENSET_EL1[integer s] = bits(64) value">SPMINTENSET_EL1</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMOVSCLR_EL0" mylink="aarch64.functions.registers.SPMOVSCLR_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMOVSCLR_EL0[] - non-assignment form
// =====================================
// Read the overflow bit clear status of implemented counters for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMOVSCLR_EL0.read.1" hover="accessor: bits(64) SPMOVSCLR_EL0[integer s]">SPMOVSCLR_EL0</anchor>[integer s];

// SPMOVSCLR_EL0[] - assignment form
// =================================
// Clear the overflow bit clear status of implemented counters for
// System PMU 's'.

<anchor link="impl-aarch64.SPMOVSCLR_EL0.write.1" hover="accessor: SPMOVSCLR_EL0[integer s] = bits(64) value">SPMOVSCLR_EL0</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMOVSSET_EL0" mylink="aarch64.functions.registers.SPMOVSSET_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMOVSSET_EL0[] - non-assignment form
// =====================================
// Read state of the overflow bit for the implemented event counters
// of System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMOVSSET_EL0.read.1" hover="accessor: bits(64) SPMOVSSET_EL0[integer s]">SPMOVSSET_EL0</anchor>[integer s];

// SPMOVSSET_EL0[] - assignment form
// =================================
// Sets the state of the overflow bit for the implemented event counters
// of System PMU 's'.

<anchor link="impl-aarch64.SPMOVSSET_EL0.write.1" hover="accessor: SPMOVSSET_EL0[integer s] = bits(64) value">SPMOVSSET_EL0</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMROOTCR_EL3" mylink="aarch64.functions.registers.SPMROOTCR_EL3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMROOTCR_EL3[] - non-assignment form
// =====================================
// Read the observability of Root and Realm events by System Performance
// Monitor for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMROOTCR_EL3.read.1" hover="accessor: bits(64) SPMROOTCR_EL3[integer s]">SPMROOTCR_EL3</anchor>[integer s];

// SPMROOTCR_EL3[] - assignment form
// =================================
// Configure the observability of Root and Realm events by System
// Performance Monitor for System PMU 's'.

<anchor link="impl-aarch64.SPMROOTCR_EL3.write.1" hover="accessor: SPMROOTCR_EL3[integer s] = bits(64) value">SPMROOTCR_EL3</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/SPMSCR_EL1" mylink="aarch64.functions.registers.SPMSCR_EL1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPMSCR_EL1[] - non-assignment form
// ===================================
// Read the observability of Secure events by System Performance Monitor
// for System PMU 's'.

bits(64) <anchor link="impl-aarch64.SPMSCR_EL1.read.1" hover="accessor: bits(64) SPMSCR_EL1[integer s]">SPMSCR_EL1</anchor>[integer s];

// SPMSCR_EL1[] - assignment form
// ==============================
// Configure the observability of secure events by System Performance
// Monitor for System PMU 's'.

<anchor link="impl-aarch64.SPMSCR_EL1.write.1" hover="accessor: SPMSCR_EL1[integer s] = bits(64) value">SPMSCR_EL1</anchor>[integer s] = bits(64) value;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/V" mylink="aarch64.functions.registers.V" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// V[] - assignment form
// =====================
// Write to SIMD&amp;FP register with implicit extension from
// 8, 16, 32, 64 or 128 bits.

<anchor link="impl-aarch64.V.write.2" hover="accessor: V[integer n, integer width] = bits(width) value">V</anchor>[integer n, integer width] = bits(width) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width IN {8,16,32,64,128};
    integer vlen = if <a link="impl-aarch64.IsSVEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsSVEEnabled(bits(2) el)">IsSVEEnabled</a>(PSTATE.EL) then <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> else 128;
    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
        _Z[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, <a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
    else
        _Z[n]&lt;vlen-1:0&gt; = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, vlen);

// V[] - non-assignment form
// =========================
// Read from SIMD&amp;FP register with implicit slice of 8, 16
// 32, 64 or 128 bits.

bits(width) <anchor link="impl-aarch64.V.read.2" hover="accessor: bits(width) V[integer n, integer width]">V</anchor>[integer n, integer width]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width IN {8,16,32,64,128};
    return _Z[n]&lt;width-1:0&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/Vpart" mylink="aarch64.functions.registers.Vpart" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Vpart[] - non-assignment form
// =============================
// Reads a 128-bit SIMD&amp;FP register in up to two parts:
//  part 0 returns the bottom 8, 16, 32 or 64 bits of a value held in the register;
//  part 1 returns the top half of the bottom 64 bits or the top half of the 128-bit
//  value held in the register.

bits(width) <anchor link="impl-aarch64.Vpart.read.3" hover="accessor: bits(width) Vpart[integer n, integer part, integer width]">Vpart</anchor>[integer n, integer part, integer width]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert part IN {0, 1};
    if part == 0 then
        assert width &lt; 128;
        return <a link="impl-aarch64.V.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) V[integer n, integer width]">V</a>[n, width];
    else
        assert width IN {32,64};
        bits(128) vreg = <a link="impl-aarch64.V.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) V[integer n, integer width]">V</a>[n, 128];
        return vreg&lt;(width * 2)-1:width&gt;;

// Vpart[] - assignment form
// =========================
// Writes a 128-bit SIMD&amp;FP register in up to two parts:
//  part 0 zero extends a 8, 16, 32, or 64-bit value to fill the whole register;
//  part 1 inserts a 64-bit value into the top half of the register.

<anchor link="impl-aarch64.Vpart.write.3" hover="accessor: Vpart[integer n, integer part, integer width] = bits(width) value">Vpart</anchor>[integer n, integer part, integer width] = bits(width) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert part IN {0, 1};
    if part == 0 then
        assert width &lt; 128;
        <a link="impl-aarch64.V.write.2" file="shared_pseudocode.xml" hover="accessor: V[integer n, integer width] = bits(width) value">V</a>[n, width] = value;
    else
        assert width == 64;
        bits(64) vreg = <a link="impl-aarch64.V.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) V[integer n, integer width]">V</a>[n, 64];
        <a link="impl-aarch64.V.write.2" file="shared_pseudocode.xml" hover="accessor: V[integer n, integer width] = bits(width) value">V</a>[n, 128] = value&lt;63:0&gt; : vreg;</pstext>
    </ps>
    <ps name="aarch64/functions/registers/X" mylink="aarch64.functions.registers.X" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// X[] - assignment form
// =====================
// Write to general-purpose register from either a 32-bit or a 64-bit value,
// where the size of the value is passed as an argument.

<anchor link="impl-aarch64.X.write.2" hover="accessor: X[integer n, integer width] = bits(width) value">X</anchor>[integer n, integer width] = bits(width) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width IN {32,64};
    if n != 31 then
        _R[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, 64);
    return;

// X[] - non-assignment form
// =========================
// Read from general-purpose register with an explicit slice of 8, 16, 32 or 64 bits.

bits(width) <anchor link="impl-aarch64.X.read.2" hover="accessor: bits(width) X[integer n, integer width]">X</anchor>[integer n, integer width]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width IN {8,16,32,64};
    if n != 31 then
        return _R[n]&lt;width-1:0&gt;;
    else
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(width);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/CounterToPredicate" mylink="aarch64.functions.sme.CounterToPredicate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CounterToPredicate()
// ====================

bits(width) <anchor link="impl-aarch64.CounterToPredicate.2" hover="function: bits(width) CounterToPredicate(bits(16) pred, integer width)">CounterToPredicate</anchor>(bits(16) pred, integer width)
    integer count;
    integer esize;
    integer elements;
    constant integer VL = <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a>;
    constant integer PL = VL DIV 8;
    integer maxbit = <a link="impl-shared.HighestSetBit.1" file="shared_pseudocode.xml" hover="function: integer HighestSetBit(bits(N) x)">HighestSetBit</a>(<a link="impl-aarch64.CeilPow2.1" file="shared_pseudocode.xml" hover="function: integer CeilPow2(integer x)">CeilPow2</a>(PL * 4)&lt;15:0&gt;);
    assert maxbit &lt;= 14;
    bits(PL*4) result;
    boolean invert = pred&lt;15&gt; == '1';

    assert width == PL || width == PL*2 || width == PL*3 || width == PL*4;

    if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(pred&lt;3:0&gt;) then
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(width);

    case pred&lt;3:0&gt; of
        when 'xxx1'
            count = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pred&lt;maxbit:1&gt;);
            esize = 8;
        when 'xx10'
            count = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pred&lt;maxbit:2&gt;);
            esize = 16;
        when 'x100'
            count = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pred&lt;maxbit:3&gt;);
            esize = 32;
        when '1000'
            count = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pred&lt;maxbit:4&gt;);
            esize = 64;

    elements = (VL * 4) DIV esize;
    result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(PL*4);
    constant integer psize = esize DIV 8;
    for e = 0 to elements-1
        bit pbit = if e &lt; count then '1' else '0';
        if invert then
            pbit = NOT(pbit);
        <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, e, psize] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(pbit, psize);

    return result&lt;width-1:0&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/EncodePredCount" mylink="aarch64.functions.sme.EncodePredCount" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EncodePredCount()
// =================

bits(width) <anchor link="impl-aarch64.EncodePredCount.5" hover="function: bits(width) EncodePredCount(integer esize, integer elements, integer count_in, boolean invert_in, integer width)">EncodePredCount</anchor>(integer esize, integer elements,
                            integer count_in, boolean invert_in, integer width)
    integer count = count_in;
    boolean invert = invert_in;
    constant integer PL = <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV 8;
    assert width == PL;
    assert esize IN {8, 16, 32, 64};
    assert count &gt;=0 &amp;&amp; count &lt;= elements;
    bits(16) pred;

    if count == 0 then
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(width);

    if invert then
        count = elements - count;
    elsif count == elements then
        count = 0;
        invert = TRUE;

    bit inv = (if invert then '1' else '0');
    case esize of
        when 8  pred = inv : count&lt;13:0&gt; :    '1';
        when 16 pred = inv : count&lt;12:0&gt; :   '10';
        when 32 pred = inv : count&lt;11:0&gt; :  '100';
        when 64 pred = inv : count&lt;10:0&gt; : '1000';

    return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(pred, width);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSME" mylink="aarch64.functions.sme.HaveSME" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSME()
// =========
// Returns TRUE if the SME extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSME.0" hover="function: boolean HaveSME()">HaveSME</anchor>()
    return IsFeatureImplemented(FEAT_SME);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSME2" mylink="aarch64.functions.sme.HaveSME2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSME2()
// ==========
// Returns TRUE if the SME2 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSME2.0" hover="function: boolean HaveSME2()">HaveSME2</anchor>()
    return IsFeatureImplemented(FEAT_SME2);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSME2p1" mylink="aarch64.functions.sme.HaveSME2p1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSME2p1()
// ============
// Returns TRUE if the SME2.1 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSME2p1.0" hover="function: boolean HaveSME2p1()">HaveSME2p1</anchor>()
    return IsFeatureImplemented(FEAT_SME2p1);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSMEB16B16" mylink="aarch64.functions.sme.HaveSMEB16B16" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSMEB16B16()
// ===============
// Returns TRUE if the SME2.1 non-widening BFloat16 instructions are implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSMEB16B16.0" hover="function: boolean HaveSMEB16B16()">HaveSMEB16B16</anchor>()
    return IsFeatureImplemented(FEAT_B16B16);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSMEF16F16" mylink="aarch64.functions.sme.HaveSMEF16F16" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSMEF16F16()
// ===============
// Returns TRUE if the SME2.1 half-precision instructions are implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSMEF16F16.0" hover="function: boolean HaveSMEF16F16()">HaveSMEF16F16</anchor>()
    return IsFeatureImplemented(FEAT_SME_F16F16);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSMEF64F64" mylink="aarch64.functions.sme.HaveSMEF64F64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSMEF64F64()
// ===============
// Returns TRUE if the SMEF64F64 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSMEF64F64.0" hover="function: boolean HaveSMEF64F64()">HaveSMEF64F64</anchor>()
    return IsFeatureImplemented(FEAT_SME_F64F64);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/HaveSMEI16I64" mylink="aarch64.functions.sme.HaveSMEI16I64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSMEI16I64()
// ===============
// Returns TRUE if the SMEI16I64 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSMEI16I64.0" hover="function: boolean HaveSMEI16I64()">HaveSMEI16I64</anchor>()
    return IsFeatureImplemented(FEAT_SME_I16I64);</pstext>
    </ps>
    <ps name="aarch64/functions/sme/Lookup" mylink="aarch64.functions.sme.Lookup" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(512) _ZT0;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/PredCountTest" mylink="aarch64.functions.sme.PredCountTest" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PredCountTest()
// ===============

bits(4) <anchor link="impl-aarch64.PredCountTest.3" hover="function: bits(4) PredCountTest(integer elements, integer count, boolean invert)">PredCountTest</anchor>(integer elements, integer count, boolean invert)
    bit n, z, c, v;
    z = (if count == 0 then '1' else '0');              // none active
    if !invert then
        n = (if count != 0 then '1' else '0');          // first active
        c = (if count == elements then '0' else '1');   // NOT last active
    else
        n = (if count == elements then '1' else '0');   // first active
        c = (if count != 0 then '0' else '1');          // NOT last active
    v = '0';

    return n:z:c:v;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/System" mylink="aarch64.functions.sme.System" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// System Registers
// ================

array bits(<a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>) _ZA[0..255];</pstext>
    </ps>
    <ps name="aarch64/functions/sme/ZAhslice" mylink="aarch64.functions.sme.ZAhslice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZAhslice[] - non-assignment form
// ================================

bits(width) <anchor link="impl-aarch64.ZAhslice.read.4" hover="accessor: bits(width) ZAhslice[integer tile, integer esize, integer slice, integer width]">ZAhslice</anchor>[integer tile, integer esize, integer slice, integer width]
    assert esize IN {8, 16, 32, 64, 128};
    integer tiles = esize DIV 8;
    assert tile &gt;= 0 &amp;&amp; tile &lt; tiles;
    integer slices = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a> DIV esize;
    assert slice &gt;= 0 &amp;&amp; slice &lt; slices;

    return <a link="impl-aarch64.ZAvector.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) ZAvector[integer index, integer width]">ZAvector</a>[tile + slice * tiles, width];

// ZAhslice[] - assignment form
// ============================

<anchor link="impl-aarch64.ZAhslice.write.4" hover="accessor: ZAhslice[integer tile, integer esize, integer slice, integer width] = bits(width) value">ZAhslice</anchor>[integer tile, integer esize, integer slice, integer width] = bits(width) value
    assert esize IN {8, 16, 32, 64, 128};
    integer tiles = esize DIV 8;
    assert tile &gt;= 0 &amp;&amp; tile &lt; tiles;
    integer slices = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a> DIV esize;
    assert slice &gt;= 0 &amp;&amp; slice &lt; slices;

    <a link="impl-aarch64.ZAvector.write.2" file="shared_pseudocode.xml" hover="accessor: ZAvector[integer index, integer width] = bits(width) value">ZAvector</a>[tile + slice * tiles, width] = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/ZAslice" mylink="aarch64.functions.sme.ZAslice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZAslice[] - non-assignment form
// ===============================

bits(width) <anchor link="impl-aarch64.ZAslice.read.5" hover="accessor: bits(width) ZAslice[integer tile, integer esize, boolean vertical, integer slice, integer width]">ZAslice</anchor>[integer tile, integer esize, boolean vertical, integer slice, integer width]
    bits(width) result;

    if vertical then
        result = <a link="impl-aarch64.ZAvslice.read.4" file="shared_pseudocode.xml" hover="accessor: bits(width) ZAvslice[integer tile, integer esize, integer slice, integer width]">ZAvslice</a>[tile, esize, slice, width];
    else
        result = <a link="impl-aarch64.ZAhslice.read.4" file="shared_pseudocode.xml" hover="accessor: bits(width) ZAhslice[integer tile, integer esize, integer slice, integer width]">ZAhslice</a>[tile, esize, slice, width];

    return result;

// ZAslice[] - assignment form
// ===========================

<anchor link="impl-aarch64.ZAslice.write.5" hover="accessor: ZAslice[integer tile, integer esize, boolean vertical, integer slice, integer width] = bits(width) value">ZAslice</anchor>[integer tile, integer esize, boolean vertical,
        integer slice, integer width] = bits(width) value
    if vertical then
        <a link="impl-aarch64.ZAvslice.write.4" file="shared_pseudocode.xml" hover="accessor: ZAvslice[integer tile, integer esize, integer slice, integer width] = bits(width) value">ZAvslice</a>[tile, esize, slice, width] = value;
    else
        <a link="impl-aarch64.ZAhslice.write.4" file="shared_pseudocode.xml" hover="accessor: ZAhslice[integer tile, integer esize, integer slice, integer width] = bits(width) value">ZAhslice</a>[tile, esize, slice, width] = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/ZAtile" mylink="aarch64.functions.sme.ZAtile" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZAtile[] - non-assignment form
// ==============================

bits(width) <anchor link="impl-aarch64.ZAtile.read.3" hover="accessor: bits(width) ZAtile[integer tile, integer esize, integer width]">ZAtile</anchor>[integer tile, integer esize, integer width]
    constant integer SVL = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a>;
    integer slices = SVL DIV esize;
    assert width == SVL * slices;
    bits(width) result;

    for slice = 0 to slices-1
        <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, slice, SVL] = <a link="impl-aarch64.ZAhslice.read.4" file="shared_pseudocode.xml" hover="accessor: bits(width) ZAhslice[integer tile, integer esize, integer slice, integer width]">ZAhslice</a>[tile, esize, slice, SVL];

    return result;

// ZAtile[] - assignment form
// ==========================

<anchor link="impl-aarch64.ZAtile.write.3" hover="accessor: ZAtile[integer tile, integer esize, integer width] = bits(width) value">ZAtile</anchor>[integer tile, integer esize, integer width] = bits(width) value
    constant integer SVL = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a>;
    integer slices = SVL DIV esize;
    assert width == SVL * slices;

    for slice = 0 to slices-1
        <a link="impl-aarch64.ZAhslice.write.4" file="shared_pseudocode.xml" hover="accessor: ZAhslice[integer tile, integer esize, integer slice, integer width] = bits(width) value">ZAhslice</a>[tile, esize, slice, SVL] = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[value, slice, SVL];</pstext>
    </ps>
    <ps name="aarch64/functions/sme/ZAvector" mylink="aarch64.functions.sme.ZAvector" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZAvector[] - non-assignment form
// ================================

bits(width) <anchor link="impl-aarch64.ZAvector.read.2" hover="accessor: bits(width) ZAvector[integer index, integer width]">ZAvector</anchor>[integer index, integer width]
    assert width == <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a>;
    assert index &gt;= 0 &amp;&amp; index &lt; (width DIV 8);

    return _ZA[index]&lt;width-1:0&gt;;

// ZAvector[] - assignment form
// ============================

<anchor link="impl-aarch64.ZAvector.write.2" hover="accessor: ZAvector[integer index, integer width] = bits(width) value">ZAvector</anchor>[integer index, integer width] = bits(width) value
    assert width == <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a>;
    assert index &gt;= 0 &amp;&amp; index &lt; (width DIV 8);

    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SMEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SMEZEROUPPER</a>) then
        _ZA[index] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, <a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
    else
        _ZA[index]&lt;width-1:0&gt; = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/ZAvslice" mylink="aarch64.functions.sme.ZAvslice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZAvslice[] - non-assignment form
// ================================

bits(width) <anchor link="impl-aarch64.ZAvslice.read.4" hover="accessor: bits(width) ZAvslice[integer tile, integer esize, integer slice, integer width]">ZAvslice</anchor>[integer tile, integer esize, integer slice, integer width]
    integer slices = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a> DIV esize;
    bits(width) result;

    for s = 0 to slices-1
        bits(width) hslice = <a link="impl-aarch64.ZAhslice.read.4" file="shared_pseudocode.xml" hover="accessor: bits(width) ZAhslice[integer tile, integer esize, integer slice, integer width]">ZAhslice</a>[tile, esize, s, width];
        <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, s, esize] = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[hslice, slice, esize];

    return result;

// ZAvslice[] - assignment form
// ============================

<anchor link="impl-aarch64.ZAvslice.write.4" hover="accessor: ZAvslice[integer tile, integer esize, integer slice, integer width] = bits(width) value">ZAvslice</anchor>[integer tile, integer esize, integer slice, integer width] = bits(width) value
    integer slices = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a> DIV esize;

    for s = 0 to slices-1
        bits(width) hslice = <a link="impl-aarch64.ZAhslice.read.4" file="shared_pseudocode.xml" hover="accessor: bits(width) ZAhslice[integer tile, integer esize, integer slice, integer width]">ZAhslice</a>[tile, esize, s, width];
        <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[hslice, slice, esize] = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[value, s, esize];
        <a link="impl-aarch64.ZAhslice.write.4" file="shared_pseudocode.xml" hover="accessor: ZAhslice[integer tile, integer esize, integer slice, integer width] = bits(width) value">ZAhslice</a>[tile, esize, s, width] = hslice;</pstext>
    </ps>
    <ps name="aarch64/functions/sme/ZT0" mylink="aarch64.functions.sme.ZT0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZT0[] - non-assignment form
// ===========================

bits(width) <anchor link="impl-aarch64.ZT0.read.1" hover="accessor: bits(width) ZT0[integer width]">ZT0</anchor>[integer width]
    assert width == 512;
    return _ZT0&lt;width-1:0&gt;;

// ZT0[] - assignment form
// =======================

<anchor link="impl-aarch64.ZT0.write.1" hover="accessor: ZT0[integer width] = bits(width) value">ZT0</anchor>[integer width] = bits(width) value
    assert width == 512;
    _ZT0&lt;width-1:0&gt; = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/AArch32.IsFPEnabled" mylink="aarch64.functions.sve.AArch32.IsFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.IsFPEnabled()
// =====================
// Returns TRUE if access to the SIMD&amp;FP instructions or System registers are
// enabled at the target exception level in AArch32 state and FALSE otherwise.

boolean <anchor link="AArch32.IsFPEnabled.1" hover="function: boolean AArch32.IsFPEnabled(bits(2) el)">AArch32.IsFPEnabled</anchor>(bits(2) el)
    if el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        return <a link="AArch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.IsFPEnabled(bits(2) el)">AArch64.IsFPEnabled</a>(el);

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
        // Check if access disabled in NSACR
        if NSACR.cp10 == '0' then return FALSE;

    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
        // Check if access disabled in CPACR
        boolean disabled;
        case CPACR.cp10 of
            when '00' disabled = TRUE;
            when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '10' disabled = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_RESCPACR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESCPACR</a>);
            when '11' disabled = FALSE;
        if disabled then return FALSE;

    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            return <a link="AArch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.IsFPEnabled(bits(2) el)">AArch64.IsFPEnabled</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        if HCPTR.TCP10 == '1' then return FALSE;

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        // Check if access disabled in CPTR_EL3
        if CPTR_EL3.TFP == '1' then return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/AArch64.IsFPEnabled" mylink="aarch64.functions.sve.AArch64.IsFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IsFPEnabled()
// =====================
// Returns TRUE if access to the SIMD&amp;FP instructions or System registers are
// enabled at the target exception level in AArch64 state and FALSE otherwise.

boolean <anchor link="AArch64.IsFPEnabled.1" hover="function: boolean AArch64.IsFPEnabled(bits(2) el)">AArch64.IsFPEnabled</anchor>(bits(2) el)
    // Check if access disabled in CPACR_EL1
    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check SIMD&amp;FP at EL0/EL1
        boolean disabled;
        case CPACR_EL1.FPEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then return FALSE;

    // Check if access disabled in CPTR_EL2
    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            boolean disabled;
            case CPTR_EL2.FPEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then return FALSE;
        else
            if CPTR_EL2.TFP == '1' then return FALSE;

    // Check if access disabled in CPTR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CPTR_EL3.TFP == '1' then return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ActivePredicateElement" mylink="aarch64.functions.sve.ActivePredicateElement" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ActivePredicateElement()
// ========================
// Returns TRUE if the predicate bit is 1 and FALSE otherwise

boolean <anchor link="impl-aarch64.ActivePredicateElement.3" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</anchor>(bits(N) pred, integer e, integer esize)
    assert esize IN {8, 16, 32, 64, 128};
    integer n = e * (esize DIV 8);
    assert n &gt;= 0 &amp;&amp; n &lt; N;
    return pred&lt;n&gt; == '1';</pstext>
    </ps>
    <ps name="aarch64/functions/sve/AnyActiveElement" mylink="aarch64.functions.sve.AnyActiveElement" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AnyActiveElement()
// ==================
// Return TRUE if there is at least one active element in mask. Otherwise,
// return FALSE.

boolean <anchor link="impl-aarch64.AnyActiveElement.2" hover="function: boolean AnyActiveElement(bits(N) mask, integer esize)">AnyActiveElement</anchor>(bits(N) mask, integer esize)
    return <a link="impl-aarch64.LastActiveElement.2" file="shared_pseudocode.xml" hover="function: integer LastActiveElement(bits(N) mask, integer esize)">LastActiveElement</a>(mask, esize) &gt;= 0;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/BitDeposit" mylink="aarch64.functions.sve.BitDeposit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BitDeposit()
// ============
// Deposit the least significant bits from DATA into result positions
// selected by non-zero bits in MASK, setting other result bits to zero.

bits(N) <anchor link="impl-aarch64.BitDeposit.2" hover="function: bits(N) BitDeposit (bits(N) data, bits(N) mask)">BitDeposit</anchor> (bits(N) data, bits(N) mask)
    bits(N) res = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);
    integer db = 0;
    for rb = 0 to N-1
        if mask&lt;rb&gt; == '1' then
            res&lt;rb&gt; = data&lt;db&gt;;
            db = db + 1;
    return res;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/BitExtract" mylink="aarch64.functions.sve.BitExtract" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BitExtract()
// ============
// Extract and pack DATA bits selected by the non-zero bits in MASK into
// the least significant result bits, setting other result bits to zero.

bits(N) <anchor link="impl-aarch64.BitExtract.2" hover="function: bits(N) BitExtract (bits(N) data, bits(N) mask)">BitExtract</anchor> (bits(N) data, bits(N) mask)
    bits(N) res = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);
    integer rb = 0;
    for db = 0 to N-1
        if mask&lt;db&gt; == '1' then
            res&lt;rb&gt; = data&lt;db&gt;;
            rb = rb + 1;
    return res;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/BitGroup" mylink="aarch64.functions.sve.BitGroup" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BitGroup()
// ==========
// Extract and pack DATA bits selected by the non-zero bits in MASK into
// the least significant result bits, and pack unselected bits into the
// most significant result bits.

bits(N) <anchor link="impl-aarch64.BitGroup.2" hover="function: bits(N) BitGroup (bits(N) data, bits(N) mask)">BitGroup</anchor> (bits(N) data, bits(N) mask)
    bits(N) res;
    integer rb = 0;

    // compress masked bits to right
    for db = 0 to N-1
        if mask&lt;db&gt; == '1' then
            res&lt;rb&gt; = data&lt;db&gt;;
            rb = rb + 1;
    // compress unmasked bits to left
    for db = 0 to N-1
        if mask&lt;db&gt; == '0' then
            res&lt;rb&gt; = data&lt;db&gt;;
            rb = rb + 1;
    return res;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CeilPow2" mylink="aarch64.functions.sve.CeilPow2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CeilPow2()
// ==========
// For a positive integer X, return the smallest power of 2 &gt;= X

integer <anchor link="impl-aarch64.CeilPow2.1" hover="function: integer CeilPow2(integer x)">CeilPow2</anchor>(integer x)
    if x == 0 then return 0;
    if x == 1 then return 2;
    return <a link="impl-aarch64.FloorPow2.1" file="shared_pseudocode.xml" hover="function: integer FloorPow2(integer x)">FloorPow2</a>(x - 1) * 2;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckNonStreamingSVEEnabled" mylink="aarch64.functions.sve.CheckNonStreamingSVEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckNonStreamingSVEEnabled()
// =============================
// Checks for traps on SVE instructions that are not legal in streaming mode.

<anchor link="impl-aarch64.CheckNonStreamingSVEEnabled.0" hover="function: CheckNonStreamingSVEEnabled()">CheckNonStreamingSVEEnabled</anchor>()
    <a link="impl-aarch64.CheckSVEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckSVEEnabled()">CheckSVEEnabled</a>();

    if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' &amp;&amp; !<a link="impl-aarch64.IsFullA64Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsFullA64Enabled()">IsFullA64Enabled</a>() then
        <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_Streaming" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_Streaming</a>, PSTATE.EL);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckOriginalSVEEnabled" mylink="aarch64.functions.sve.CheckOriginalSVEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckOriginalSVEEnabled()
// =========================
// Checks for traps on SVE instructions and instructions that access SVE System
// registers.

<anchor link="impl-aarch64.CheckOriginalSVEEnabled.0" hover="function: CheckOriginalSVEEnabled()">CheckOriginalSVEEnabled</anchor>()
    assert <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>();
    boolean disabled;

    if (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; (CPTR_EL3.EZ == '0' || CPTR_EL3.TFP == '1') &amp;&amp;
        <a link="impl-shared.EL3SDDUndefPriority.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</a>()) then
        UNDEFINED;

    // Check if access disabled in CPACR_EL1
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check SVE at EL0/EL1
        case CPACR_EL1.ZEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then <a link="impl-aarch64.SVEAccessTrap.1" file="shared_pseudocode.xml" hover="function: SVEAccessTrap(bits(2) target_el)">SVEAccessTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

        // Check SIMD&amp;FP at EL0/EL1
        case CPACR_EL1.FPEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    // Check if access disabled in CPTR_EL2
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            // Check SVE at EL2
            case CPTR_EL2.ZEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then <a link="impl-aarch64.SVEAccessTrap.1" file="shared_pseudocode.xml" hover="function: SVEAccessTrap(bits(2) target_el)">SVEAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

            // Check SIMD&amp;FP at EL2
            case CPTR_EL2.FPEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        else
            if CPTR_EL2.TZ == '1' then <a link="impl-aarch64.SVEAccessTrap.1" file="shared_pseudocode.xml" hover="function: SVEAccessTrap(bits(2) target_el)">SVEAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
            if CPTR_EL2.TFP == '1' then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    // Check if access disabled in CPTR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CPTR_EL3.EZ == '0' then
            if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
                UNDEFINED;
            else
                <a link="impl-aarch64.SVEAccessTrap.1" file="shared_pseudocode.xml" hover="function: SVEAccessTrap(bits(2) target_el)">SVEAccessTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);

        if CPTR_EL3.TFP == '1' then
            if <a link="impl-shared.EL3SDDUndef.0" file="shared_pseudocode.xml" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</a>() then
                UNDEFINED;
            else
                <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckSMEAccess" mylink="aarch64.functions.sve.CheckSMEAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSMEAccess()
// ================
// Check that access to SME System registers is enabled.

<anchor link="impl-aarch64.CheckSMEAccess.0" hover="function: CheckSMEAccess()">CheckSMEAccess</anchor>()
    boolean disabled;
    // Check if access disabled in CPACR_EL1
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check SME at EL0/EL1
        case CPACR_EL1.SMEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            // Check SME at EL2
            case CPTR_EL2.SMEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        else
            if CPTR_EL2.TSM == '1' then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    // Check if access disabled in CPTR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CPTR_EL3.ESM == '0' then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckSMEAndZAEnabled" mylink="aarch64.functions.sve.CheckSMEAndZAEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSMEAndZAEnabled()
// ======================

<anchor link="impl-aarch64.CheckSMEAndZAEnabled.0" hover="function: CheckSMEAndZAEnabled()">CheckSMEAndZAEnabled</anchor>()
    <a link="impl-aarch64.CheckSMEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckSMEEnabled()">CheckSMEEnabled</a>();

    if PSTATE.ZA == '0' then
        <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_InactiveZA" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InactiveZA</a>, PSTATE.EL);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckSMEEnabled" mylink="aarch64.functions.sve.CheckSMEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSMEEnabled()
// =================

<anchor link="impl-aarch64.CheckSMEEnabled.0" hover="function: CheckSMEEnabled()">CheckSMEEnabled</anchor>()
    boolean disabled;
    // Check if access disabled in CPACR_EL1
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check SME at EL0/EL1
        case CPACR_EL1.SMEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

        // Check SIMD&amp;FP at EL0/EL1
        case CPACR_EL1.FPEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            // Check SME at EL2
            case CPTR_EL2.SMEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

            // Check SIMD&amp;FP at EL2
            case CPTR_EL2.FPEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        else
            if CPTR_EL2.TSM == '1' then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
            if CPTR_EL2.TFP == '1' then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    // Check if access disabled in CPTR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CPTR_EL3.ESM == '0' then <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>, <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        if CPTR_EL3.TFP == '1' then <a link="AArch64.AdvSIMDFPAccessTrap.1" file="shared_pseudocode.xml" hover="function: AArch64.AdvSIMDFPAccessTrap(bits(2) target_el)">AArch64.AdvSIMDFPAccessTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckSMEZT0Enabled" mylink="aarch64.functions.sve.CheckSMEZT0Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSMEZT0Enabled()
// ====================
// Checks for ZT0 enabled.

<anchor link="impl-aarch64.CheckSMEZT0Enabled.0" hover="function: CheckSMEZT0Enabled()">CheckSMEZT0Enabled</anchor>()
    // Check if ZA and ZT0 are inactive in PSTATE
    if PSTATE.ZA == '0' then
        <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_InactiveZA" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InactiveZA</a>, PSTATE.EL);

    // Check if EL0/EL1 accesses to ZT0 are disabled in SMCR_EL1
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        if SMCR_EL1.EZT0 == '0' then
            <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_InaccessibleZT0" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InaccessibleZT0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    // Check if EL0/EL1/EL2 accesses to ZT0 are disabled in SMCR_EL2
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if SMCR_EL2.EZT0 == '0' then
            <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_InaccessibleZT0" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InaccessibleZT0</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    // Check if all accesses to ZT0 are disabled in SMCR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if SMCR_EL3.EZT0 == '0' then
            <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_InaccessibleZT0" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InaccessibleZT0</a>, <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckSVEEnabled" mylink="aarch64.functions.sve.CheckSVEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSVEEnabled()
// =================
// Checks for traps on SVE instructions and instructions that
// access SVE System registers.

<anchor link="impl-aarch64.CheckSVEEnabled.0" hover="function: CheckSVEEnabled()">CheckSVEEnabled</anchor>()
    if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then
        <a link="impl-aarch64.CheckSMEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckSMEEnabled()">CheckSMEEnabled</a>();
    elsif <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; !<a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() then
        <a link="impl-aarch64.CheckStreamingSVEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckStreamingSVEEnabled()">CheckStreamingSVEEnabled</a>();
    else
        <a link="impl-aarch64.CheckOriginalSVEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckOriginalSVEEnabled()">CheckOriginalSVEEnabled</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckStreamingSVEAndZAEnabled" mylink="aarch64.functions.sve.CheckStreamingSVEAndZAEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckStreamingSVEAndZAEnabled()
// ===============================

<anchor link="impl-aarch64.CheckStreamingSVEAndZAEnabled.0" hover="function: CheckStreamingSVEAndZAEnabled()">CheckStreamingSVEAndZAEnabled</anchor>()
    <a link="impl-aarch64.CheckStreamingSVEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckStreamingSVEEnabled()">CheckStreamingSVEEnabled</a>();

    if PSTATE.ZA == '0' then
        <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_InactiveZA" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InactiveZA</a>, PSTATE.EL);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CheckStreamingSVEEnabled" mylink="aarch64.functions.sve.CheckStreamingSVEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckStreamingSVEEnabled()
// ==========================

<anchor link="impl-aarch64.CheckStreamingSVEEnabled.0" hover="function: CheckStreamingSVEEnabled()">CheckStreamingSVEEnabled</anchor>()
    <a link="impl-aarch64.CheckSMEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckSMEEnabled()">CheckSMEEnabled</a>();

    if PSTATE.SM == '0' then
        <a link="impl-aarch64.SMEAccessTrap.2" file="shared_pseudocode.xml" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</a>(<a link="SMEExceptionType_NotStreaming" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_NotStreaming</a>, PSTATE.EL);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CurrentNSVL" mylink="aarch64.functions.sve.CurrentNSVL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentNSVL - non-assignment form
// =================================
// Non-Streaming VL

integer <anchor link="impl-aarch64.CurrentNSVL.read.none" hover="accessor: integer CurrentNSVL">CurrentNSVL</anchor>
    integer vl;

    if PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) then
        vl = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ZCR_EL1.LEN);

    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) then
        vl = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ZCR_EL2.LEN);
    elsif PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        vl = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(vl, <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ZCR_EL2.LEN));

    if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        vl = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ZCR_EL3.LEN);
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        vl = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(vl, <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ZCR_EL3.LEN));

    vl = (vl + 1) * 128;
    vl = <a link="impl-aarch64.ImplementedSVEVectorLength.1" file="shared_pseudocode.xml" hover="function: integer ImplementedSVEVectorLength(integer nbits_in)">ImplementedSVEVectorLength</a>(vl);

    return vl;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CurrentSVL" mylink="aarch64.functions.sve.CurrentSVL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentSVL - non-assignment form
// ================================
// Streaming SVL

integer <anchor link="impl-aarch64.CurrentSVL.read.none" hover="accessor: integer CurrentSVL">CurrentSVL</anchor>
    integer vl;

    if PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) then
        vl = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SMCR_EL1.LEN);

    if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) then
        vl = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SMCR_EL2.LEN);
    elsif PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        vl = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(vl, <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SMCR_EL2.LEN));

    if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        vl = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SMCR_EL3.LEN);
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        vl = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(vl, <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(SMCR_EL3.LEN));

    vl = (vl + 1) * 128;
    vl = <a link="impl-aarch64.ImplementedSMEVectorLength.1" file="shared_pseudocode.xml" hover="function: integer ImplementedSMEVectorLength(integer nbits_in)">ImplementedSMEVectorLength</a>(vl);

    return vl;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/CurrentVL" mylink="aarch64.functions.sve.CurrentVL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentVL - non-assignment form
// ===============================

integer <anchor link="impl-aarch64.CurrentVL.read.none" hover="accessor: integer CurrentVL">CurrentVL</anchor>
    return if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a> else <a link="impl-aarch64.CurrentNSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentNSVL">CurrentNSVL</a>;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/DecodePredCount" mylink="aarch64.functions.sve.DecodePredCount" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodePredCount()
// =================

integer <anchor link="impl-aarch64.DecodePredCount.2" hover="function: integer DecodePredCount(bits(5) pattern, integer esize)">DecodePredCount</anchor>(bits(5) pattern, integer esize)
    integer elements = <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV esize;
    integer numElem;
    case pattern of
        when '00000' numElem = <a link="impl-aarch64.FloorPow2.1" file="shared_pseudocode.xml" hover="function: integer FloorPow2(integer x)">FloorPow2</a>(elements);
        when '00001' numElem = if elements &gt;= 1 then 1 else 0;
        when '00010' numElem = if elements &gt;= 2 then 2 else 0;
        when '00011' numElem = if elements &gt;= 3 then 3 else 0;
        when '00100' numElem = if elements &gt;= 4 then 4 else 0;
        when '00101' numElem = if elements &gt;= 5 then 5 else 0;
        when '00110' numElem = if elements &gt;= 6 then 6 else 0;
        when '00111' numElem = if elements &gt;= 7 then 7 else 0;
        when '01000' numElem = if elements &gt;= 8 then 8 else 0;
        when '01001' numElem = if elements &gt;= 16 then 16 else 0;
        when '01010' numElem = if elements &gt;= 32 then 32 else 0;
        when '01011' numElem = if elements &gt;= 64 then 64 else 0;
        when '01100' numElem = if elements &gt;= 128 then 128 else 0;
        when '01101' numElem = if elements &gt;= 256 then 256 else 0;
        when '11101' numElem = elements - (elements MOD 4);
        when '11110' numElem = elements - (elements MOD 3);
        when '11111' numElem = elements;
        otherwise    numElem = 0;
    return numElem;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ElemFFR" mylink="aarch64.functions.sve.ElemFFR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ElemFFR[] - non-assignment form
// ===============================

bit <anchor link="impl-aarch64.ElemFFR.read.2" hover="accessor: bit ElemFFR[integer e, integer esize]">ElemFFR</anchor>[integer e, integer esize]
    return <a link="impl-aarch64.PredicateElement.3" file="shared_pseudocode.xml" hover="function: bit PredicateElement(bits(N) pred, integer e, integer esize)">PredicateElement</a>(_FFR, e, esize);

// ElemFFR[] - assignment form
// ===========================

<anchor link="impl-aarch64.ElemFFR.write.2" hover="accessor: ElemFFR[integer e, integer esize] = bit value">ElemFFR</anchor>[integer e, integer esize] = bit value
    integer psize = esize DIV 8;
    integer n = e * psize;
    assert n &gt;= 0 &amp;&amp; (n + psize) &lt;= <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV 8;
    _FFR&lt;(n+psize)-1:n&gt; = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, psize);
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FFR" mylink="aarch64.functions.sve.FFR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFR[] - non-assignment form
// ===========================

bits(width) <anchor link="impl-aarch64.FFR.read.1" hover="accessor: bits(width) FFR[integer width]">FFR</anchor>[integer width]
    assert width == <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV 8;
    return _FFR&lt;width-1:0&gt;;

// FFR[] - assignment form
// =======================

<anchor link="impl-aarch64.FFR.write.1" hover="accessor: FFR[integer width] = bits(width) value">FFR</anchor>[integer width] = bits(width) value
    assert width == <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV 8;
    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
        _FFR = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, <a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>);
    else
        _FFR&lt;width-1:0&gt; = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPCompareNE" mylink="aarch64.functions.sve.FPCompareNE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPCompareNE()
// =============

boolean <anchor link="impl-aarch64.FPCompareNE.3" hover="function: boolean FPCompareNE(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPCompareNE</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    boolean result;
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);
    op1_nan = type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    op2_nan = type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};

    if op1_nan || op2_nan then
        result = TRUE;
        if type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    else // All non-NaN cases can be evaluated on the values produced by FPUnpack()
        result = (value1 != value2);
        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPCompareUN" mylink="aarch64.functions.sve.FPCompareUN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPCompareUN()
// =============

boolean <anchor link="impl-aarch64.FPCompareUN.3" hover="function: boolean FPCompareUN(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPCompareUN</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    if type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

    result = type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    if !result then
        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPConvertSVE" mylink="aarch64.functions.sve.FPConvertSVE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPConvertSVE()
// ==============

bits(M) <anchor link="impl-aarch64.FPConvertSVE.4" hover="function: bits(M) FPConvertSVE(bits(N) op, FPCRType fpcr_in, FPRounding rounding, integer M)">FPConvertSVE</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer M)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.AHP = '0';
    return <a link="impl-shared.FPConvert.4" file="shared_pseudocode.xml" hover="function: bits(M) FPConvert(bits(N) op, FPCRType fpcr, FPRounding rounding, integer M)">FPConvert</a>(op, fpcr, rounding, M);

// FPConvertSVE()
// ==============

bits(M) <anchor link="impl-aarch64.FPConvertSVE.3" hover="function: bits(M) FPConvertSVE(bits(N) op, FPCRType fpcr_in, integer M)">FPConvertSVE</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, integer M)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.AHP = '0';
    return <a link="impl-shared.FPConvert.4" file="shared_pseudocode.xml" hover="function: bits(M) FPConvert(bits(N) op, FPCRType fpcr, FPRounding rounding, integer M)">FPConvert</a>(op, fpcr, <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr), M);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPExpA" mylink="aarch64.functions.sve.FPExpA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPExpA()
// ========

bits(N) <anchor link="impl-aarch64.FPExpA.1" hover="function: bits(N) FPExpA(bits(N) op)">FPExpA</anchor>(bits(N) op)
    assert N IN {16,32,64};
    bits(N) result;
    bits(N) coeff;
    integer idx = if N == 16 then <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(op&lt;4:0&gt;) else <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(op&lt;5:0&gt;);
    coeff = <a link="impl-aarch64.FPExpCoefficient.read.2" file="shared_pseudocode.xml" hover="accessor: bits(N) FPExpCoefficient[integer index, integer N]">FPExpCoefficient</a>[idx, N];
    if N == 16 then
        result&lt;15:0&gt; = '0':op&lt;9:5&gt;:coeff&lt;9:0&gt;;
    elsif N == 32 then
        result&lt;31:0&gt; = '0':op&lt;13:6&gt;:coeff&lt;22:0&gt;;
    else // N == 64
        result&lt;63:0&gt; = '0':op&lt;16:6&gt;:coeff&lt;51:0&gt;;

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPExpCoefficient" mylink="aarch64.functions.sve.FPExpCoefficient" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPExpCoefficient()
// ==================

bits(N) <anchor link="impl-aarch64.FPExpCoefficient.read.2" hover="accessor: bits(N) FPExpCoefficient[integer index, integer N]">FPExpCoefficient</anchor>[integer index, integer N]
    assert N IN {16,32,64};
    integer result;

    if N == 16 then
        case index of
            when  0 result = 0x0000;
            when  1 result = 0x0016;
            when  2 result = 0x002d;
            when  3 result = 0x0045;
            when  4 result = 0x005d;
            when  5 result = 0x0075;
            when  6 result = 0x008e;
            when  7 result = 0x00a8;
            when  8 result = 0x00c2;
            when  9 result = 0x00dc;
            when 10 result = 0x00f8;
            when 11 result = 0x0114;
            when 12 result = 0x0130;
            when 13 result = 0x014d;
            when 14 result = 0x016b;
            when 15 result = 0x0189;
            when 16 result = 0x01a8;
            when 17 result = 0x01c8;
            when 18 result = 0x01e8;
            when 19 result = 0x0209;
            when 20 result = 0x022b;
            when 21 result = 0x024e;
            when 22 result = 0x0271;
            when 23 result = 0x0295;
            when 24 result = 0x02ba;
            when 25 result = 0x02e0;
            when 26 result = 0x0306;
            when 27 result = 0x032e;
            when 28 result = 0x0356;
            when 29 result = 0x037f;
            when 30 result = 0x03a9;
            when 31 result = 0x03d4;

    elsif N == 32 then
        case index of
            when  0 result = 0x000000;
            when  1 result = 0x0164d2;
            when  2 result = 0x02cd87;
            when  3 result = 0x043a29;
            when  4 result = 0x05aac3;
            when  5 result = 0x071f62;
            when  6 result = 0x08980f;
            when  7 result = 0x0a14d5;
            when  8 result = 0x0b95c2;
            when  9 result = 0x0d1adf;
            when 10 result = 0x0ea43a;
            when 11 result = 0x1031dc;
            when 12 result = 0x11c3d3;
            when 13 result = 0x135a2b;
            when 14 result = 0x14f4f0;
            when 15 result = 0x16942d;
            when 16 result = 0x1837f0;
            when 17 result = 0x19e046;
            when 18 result = 0x1b8d3a;
            when 19 result = 0x1d3eda;
            when 20 result = 0x1ef532;
            when 21 result = 0x20b051;
            when 22 result = 0x227043;
            when 23 result = 0x243516;
            when 24 result = 0x25fed7;
            when 25 result = 0x27cd94;
            when 26 result = 0x29a15b;
            when 27 result = 0x2b7a3a;
            when 28 result = 0x2d583f;
            when 29 result = 0x2f3b79;
            when 30 result = 0x3123f6;
            when 31 result = 0x3311c4;
            when 32 result = 0x3504f3;
            when 33 result = 0x36fd92;
            when 34 result = 0x38fbaf;
            when 35 result = 0x3aff5b;
            when 36 result = 0x3d08a4;
            when 37 result = 0x3f179a;
            when 38 result = 0x412c4d;
            when 39 result = 0x4346cd;
            when 40 result = 0x45672a;
            when 41 result = 0x478d75;
            when 42 result = 0x49b9be;
            when 43 result = 0x4bec15;
            when 44 result = 0x4e248c;
            when 45 result = 0x506334;
            when 46 result = 0x52a81e;
            when 47 result = 0x54f35b;
            when 48 result = 0x5744fd;
            when 49 result = 0x599d16;
            when 50 result = 0x5bfbb8;
            when 51 result = 0x5e60f5;
            when 52 result = 0x60ccdf;
            when 53 result = 0x633f89;
            when 54 result = 0x65b907;
            when 55 result = 0x68396a;
            when 56 result = 0x6ac0c7;
            when 57 result = 0x6d4f30;
            when 58 result = 0x6fe4ba;
            when 59 result = 0x728177;
            when 60 result = 0x75257d;
            when 61 result = 0x77d0df;
            when 62 result = 0x7a83b3;
            when 63 result = 0x7d3e0c;

    else // N == 64
        case index of
            when  0 result = 0x0000000000000;
            when  1 result = 0x02C9A3E778061;
            when  2 result = 0x059B0D3158574;
            when  3 result = 0x0874518759BC8;
            when  4 result = 0x0B5586CF9890F;
            when  5 result = 0x0E3EC32D3D1A2;
            when  6 result = 0x11301D0125B51;
            when  7 result = 0x1429AAEA92DE0;
            when  8 result = 0x172B83C7D517B;
            when  9 result = 0x1A35BEB6FCB75;
            when 10 result = 0x1D4873168B9AA;
            when 11 result = 0x2063B88628CD6;
            when 12 result = 0x2387A6E756238;
            when 13 result = 0x26B4565E27CDD;
            when 14 result = 0x29E9DF51FDEE1;
            when 15 result = 0x2D285A6E4030B;
            when 16 result = 0x306FE0A31B715;
            when 17 result = 0x33C08B26416FF;
            when 18 result = 0x371A7373AA9CB;
            when 19 result = 0x3A7DB34E59FF7;
            when 20 result = 0x3DEA64C123422;
            when 21 result = 0x4160A21F72E2A;
            when 22 result = 0x44E086061892D;
            when 23 result = 0x486A2B5C13CD0;
            when 24 result = 0x4BFDAD5362A27;
            when 25 result = 0x4F9B2769D2CA7;
            when 26 result = 0x5342B569D4F82;
            when 27 result = 0x56F4736B527DA;
            when 28 result = 0x5AB07DD485429;
            when 29 result = 0x5E76F15AD2148;
            when 30 result = 0x6247EB03A5585;
            when 31 result = 0x6623882552225;
            when 32 result = 0x6A09E667F3BCD;
            when 33 result = 0x6DFB23C651A2F;
            when 34 result = 0x71F75E8EC5F74;
            when 35 result = 0x75FEB564267C9;
            when 36 result = 0x7A11473EB0187;
            when 37 result = 0x7E2F336CF4E62;
            when 38 result = 0x82589994CCE13;
            when 39 result = 0x868D99B4492ED;
            when 40 result = 0x8ACE5422AA0DB;
            when 41 result = 0x8F1AE99157736;
            when 42 result = 0x93737B0CDC5E5;
            when 43 result = 0x97D829FDE4E50;
            when 44 result = 0x9C49182A3F090;
            when 45 result = 0xA0C667B5DE565;
            when 46 result = 0xA5503B23E255D;
            when 47 result = 0xA9E6B5579FDBF;
            when 48 result = 0xAE89F995AD3AD;
            when 49 result = 0xB33A2B84F15FB;
            when 50 result = 0xB7F76F2FB5E47;
            when 51 result = 0xBCC1E904BC1D2;
            when 52 result = 0xC199BDD85529C;
            when 53 result = 0xC67F12E57D14B;
            when 54 result = 0xCB720DCEF9069;
            when 55 result = 0xD072D4A07897C;
            when 56 result = 0xD5818DCFBA487;
            when 57 result = 0xDA9E603DB3285;
            when 58 result = 0xDFC97337B9B5F;
            when 59 result = 0xE502EE78B3FF6;
            when 60 result = 0xEA4AFA2A490DA;
            when 61 result = 0xEFA1BEE615A27;
            when 62 result = 0xF50765B6E4540;
            when 63 result = 0xFA7C1819E90D8;

    return result&lt;N-1:0&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPLogB" mylink="aarch64.functions.sve.FPLogB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPLogB()
// ========

bits(N) <anchor link="impl-aarch64.FPLogB.2" hover="function: bits(N) FPLogB(bits(N) op, FPCRType fpcr)">FPLogB</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    integer result;
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op, fpcr);

    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> || fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        result = -(2^(N-1));            // MinInt, 100..00
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        result = 2^(N-1) - 1;           // MaxInt, 011..11
    else
        // FPUnpack has already scaled a subnormal input
        value = <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value);
        result = 0;
        while value &lt; 1.0 do
            value = value * 2.0;
            result = result - 1;
        while value &gt;= 2.0 do
            value = value / 2.0;
            result = result + 1;

        <a link="impl-shared.FPProcessDenorm.3" file="shared_pseudocode.xml" hover="function: FPProcessDenorm(FPType fptype, integer N, FPCRType fpcr)">FPProcessDenorm</a>(fptype, N, fpcr);

    return result&lt;N-1:0&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPMinNormal" mylink="aarch64.functions.sve.FPMinNormal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMinNormal()
// =============

bits(N) <anchor link="impl-aarch64.FPMinNormal.2" hover="function: bits(N) FPMinNormal(bit sign, integer N)">FPMinNormal</anchor>(bit sign, integer N)
    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(E-1):'1';
    frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
    return sign : exp : frac;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPOne" mylink="aarch64.functions.sve.FPOne" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPOne()
// =======

bits(N) <anchor link="impl-aarch64.FPOne.2" hover="function: bits(N) FPOne(bit sign, integer N)">FPOne</anchor>(bit sign, integer N)
    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp = '0':<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(E-1);
    frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
    return sign : exp : frac;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPPointFive" mylink="aarch64.functions.sve.FPPointFive" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPPointFive()
// =============

bits(N) <anchor link="impl-aarch64.FPPointFive.2" hover="function: bits(N) FPPointFive(bit sign, integer N)">FPPointFive</anchor>(bit sign, integer N)
    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp = '0':<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(E-2):'0';
    frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
    return sign : exp : frac;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPScale" mylink="aarch64.functions.sve.FPScale" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPScale()
// =========

bits(N) <anchor link="impl-aarch64.FPScale.3" hover="function: bits(N) FPScale(bits (N) op, integer scale, FPCRType fpcr)">FPScale</anchor>(bits (N) op, integer scale, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    bits(N) result;
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op, fpcr);

    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPProcessNaN.3" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr)">FPProcessNaN</a>(fptype, op, fpcr);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
    else
        result = <a link="impl-shared.FPRound.3" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</a>(value * (2.0^scale), fpcr, N);
        <a link="impl-shared.FPProcessDenorm.3" file="shared_pseudocode.xml" hover="function: FPProcessDenorm(FPType fptype, integer N, FPCRType fpcr)">FPProcessDenorm</a>(fptype, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPTrigMAdd" mylink="aarch64.functions.sve.FPTrigMAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPTrigMAdd()
// ============

bits(N) <anchor link="impl-aarch64.FPTrigMAdd.4" hover="function: bits(N) FPTrigMAdd(integer x_in, bits(N) op1, bits(N) op2_in, FPCRType fpcr)">FPTrigMAdd</anchor>(integer x_in, bits(N) op1, bits(N) op2_in, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    bits(N) coeff;
    bits(N) op2 = op2_in;
    integer x = x_in;
    assert x &gt;= 0;
    assert x &lt; 8;

    if op2&lt;N-1&gt; == '1' then
        x = x + 8;

    coeff    = <a link="impl-aarch64.FPTrigMAddCoefficient.read.2" file="shared_pseudocode.xml" hover="accessor: bits(N) FPTrigMAddCoefficient[integer index, integer N]">FPTrigMAddCoefficient</a>[x, N];
    op2      = <a link="impl-shared.FPAbs.1" file="shared_pseudocode.xml" hover="function: bits(N) FPAbs(bits(N) op)">FPAbs</a>(op2);
    result   = <a link="impl-shared.FPMulAdd.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMulAdd</a>(coeff, op1, op2, fpcr);
    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPTrigMAddCoefficient" mylink="aarch64.functions.sve.FPTrigMAddCoefficient" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPTrigMAddCoefficient()
// =======================

bits(N) <anchor link="impl-aarch64.FPTrigMAddCoefficient.read.2" hover="accessor: bits(N) FPTrigMAddCoefficient[integer index, integer N]">FPTrigMAddCoefficient</anchor>[integer index, integer N]
    assert N IN {16,32,64};
    integer result;

    if N == 16 then
        case index of
            when  0 result = 0x3c00;
            when  1 result = 0xb155;
            when  2 result = 0x2030;
            when  3 result = 0x0000;
            when  4 result = 0x0000;
            when  5 result = 0x0000;
            when  6 result = 0x0000;
            when  7 result = 0x0000;
            when  8 result = 0x3c00;
            when  9 result = 0xb800;
            when 10 result = 0x293a;
            when 11 result = 0x0000;
            when 12 result = 0x0000;
            when 13 result = 0x0000;
            when 14 result = 0x0000;
            when 15 result = 0x0000;
    elsif N == 32 then
        case index of
            when  0 result = 0x3f800000;
            when  1 result = 0xbe2aaaab;
            when  2 result = 0x3c088886;
            when  3 result = 0xb95008b9;
            when  4 result = 0x36369d6d;
            when  5 result = 0x00000000;
            when  6 result = 0x00000000;
            when  7 result = 0x00000000;
            when  8 result = 0x3f800000;
            when  9 result = 0xbf000000;
            when 10 result = 0x3d2aaaa6;
            when 11 result = 0xbab60705;
            when 12 result = 0x37cd37cc;
            when 13 result = 0x00000000;
            when 14 result = 0x00000000;
            when 15 result = 0x00000000;
    else // N == 64
        case index of
            when  0 result = 0x3ff0000000000000;
            when  1 result = 0xbfc5555555555543;
            when  2 result = 0x3f8111111110f30c;
            when  3 result = 0xbf2a01a019b92fc6;
            when  4 result = 0x3ec71de351f3d22b;
            when  5 result = 0xbe5ae5e2b60f7b91;
            when  6 result = 0x3de5d8408868552f;
            when  7 result = 0x0000000000000000;
            when  8 result = 0x3ff0000000000000;
            when  9 result = 0xbfe0000000000000;
            when 10 result = 0x3fa5555555555536;
            when 11 result = 0xbf56c16c16c13a0b;
            when 12 result = 0x3efa01a019b1e8d8;
            when 13 result = 0xbe927e4f7282f468;
            when 14 result = 0x3e21ee96d2641b13;
            when 15 result = 0xbda8f76380fbb401;

    return result&lt;N-1:0&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPTrigSMul" mylink="aarch64.functions.sve.FPTrigSMul" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPTrigSMul()
// ============

bits(N) <anchor link="impl-aarch64.FPTrigSMul.3" hover="function: bits(N) FPTrigSMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPTrigSMul</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N IN {16,32,64};
    result = <a link="impl-shared.FPMul.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMul</a>(op1, op1, fpcr);
    fpexc = FALSE;
    (fptype, sign, value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(result, fpcr, fpexc);

    if !(fptype IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>}) then
        result&lt;N-1&gt; = op2&lt;0&gt;;

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FPTrigSSel" mylink="aarch64.functions.sve.FPTrigSSel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPTrigSSel()
// ============

bits(N) <anchor link="impl-aarch64.FPTrigSSel.2" hover="function: bits(N) FPTrigSSel(bits(N) op1, bits(N) op2)">FPTrigSSel</anchor>(bits(N) op1, bits(N) op2)
    assert N IN {16,32,64};
    bits(N) result;

    if op2&lt;0&gt; == '1' then
        result = <a link="impl-aarch64.FPOne.2" file="shared_pseudocode.xml" hover="function: bits(N) FPOne(bit sign, integer N)">FPOne</a>(op2&lt;1&gt;, N);
    elsif op2&lt;1&gt; == '1' then
        result = <a link="impl-shared.FPNeg.1" file="shared_pseudocode.xml" hover="function: bits(N) FPNeg(bits(N) op)">FPNeg</a>(op1);
    else
        result = op1;

    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FirstActive" mylink="aarch64.functions.sve.FirstActive" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FirstActive()
// =============

bit <anchor link="impl-aarch64.FirstActive.3" hover="function: bit FirstActive(bits(N) mask, bits(N) x, integer esize)">FirstActive</anchor>(bits(N) mask, bits(N) x, integer esize)
    integer elements = N DIV (esize DIV 8);
    for e = 0 to elements-1
        if <a link="impl-aarch64.ActivePredicateElement.3" file="shared_pseudocode.xml" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</a>(mask, e, esize) then
            return <a link="impl-aarch64.PredicateElement.3" file="shared_pseudocode.xml" hover="function: bit PredicateElement(bits(N) pred, integer e, integer esize)">PredicateElement</a>(x, e, esize);
    return '0';</pstext>
    </ps>
    <ps name="aarch64/functions/sve/FloorPow2" mylink="aarch64.functions.sve.FloorPow2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FloorPow2()
// ===========
// For a positive integer X, return the largest power of 2 &lt;= X

integer <anchor link="impl-aarch64.FloorPow2.1" hover="function: integer FloorPow2(integer x)">FloorPow2</anchor>(integer x)
    assert x &gt;= 0;
    integer n = 1;
    if x == 0 then return 0;
    while x &gt;= 2^n do
        n = n + 1;
    return 2^(n - 1);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSMEFullA64" mylink="aarch64.functions.sve.HaveSMEFullA64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSMEFullA64()
// ================
// Returns TRUE if the SME FA64 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSMEFullA64.0" hover="function: boolean HaveSMEFullA64()">HaveSMEFullA64</anchor>()
    return IsFeatureImplemented(FEAT_SME_FA64);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE" mylink="aarch64.functions.sve.HaveSVE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE()
// =========

boolean <anchor link="impl-aarch64.HaveSVE.0" hover="function: boolean HaveSVE()">HaveSVE</anchor>()
    return IsFeatureImplemented(FEAT_SVE);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2" mylink="aarch64.functions.sve.HaveSVE2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2()
// ==========
// Returns TRUE if the SVE2 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2.0" hover="function: boolean HaveSVE2()">HaveSVE2</anchor>()
    return IsFeatureImplemented(FEAT_SVE2);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2AES" mylink="aarch64.functions.sve.HaveSVE2AES" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2AES()
// =============
// Returns TRUE if the SVE2 AES extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2AES.0" hover="function: boolean HaveSVE2AES()">HaveSVE2AES</anchor>()
    return IsFeatureImplemented(FEAT_SVE_AES);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2BitPerm" mylink="aarch64.functions.sve.HaveSVE2BitPerm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2BitPerm()
// =================
// Returns TRUE if the SVE2 Bit Permissions extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2BitPerm.0" hover="function: boolean HaveSVE2BitPerm()">HaveSVE2BitPerm</anchor>()
    return IsFeatureImplemented(FEAT_SVE_BitPerm);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2PMULL128" mylink="aarch64.functions.sve.HaveSVE2PMULL128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2PMULL128()
// ==================
// Returns TRUE if the SVE2 128 bit PMULL extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2PMULL128.0" hover="function: boolean HaveSVE2PMULL128()">HaveSVE2PMULL128</anchor>()
    return IsFeatureImplemented(FEAT_SVE_PMULL128);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2SHA256" mylink="aarch64.functions.sve.HaveSVE2SHA256" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2SHA256()
// ================
// Returns TRUE if the SVE2 SHA256 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2SHA256.0" hover="function: boolean HaveSVE2SHA256()">HaveSVE2SHA256</anchor>()
    return <a link="impl-aarch64.HaveSVE2.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE2()">HaveSVE2</a>() &amp;&amp; boolean IMPLEMENTATION_DEFINED "Have SVE2 SHA256 extension";</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2SHA3" mylink="aarch64.functions.sve.HaveSVE2SHA3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2SHA3()
// ==============
// Returns TRUE if the SVE2 SHA3 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2SHA3.0" hover="function: boolean HaveSVE2SHA3()">HaveSVE2SHA3</anchor>()
    return IsFeatureImplemented(FEAT_SVE_SHA3);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2SHA512" mylink="aarch64.functions.sve.HaveSVE2SHA512" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2SHA512()
// ================
// Returns TRUE if the SVE2 SHA512 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2SHA512.0" hover="function: boolean HaveSVE2SHA512()">HaveSVE2SHA512</anchor>()
    return <a link="impl-aarch64.HaveSVE2.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE2()">HaveSVE2</a>() &amp;&amp; boolean IMPLEMENTATION_DEFINED "Have SVE2 SHA512 extension";</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2SM3" mylink="aarch64.functions.sve.HaveSVE2SM3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2SM3()
// =============
// Returns TRUE if the SVE2 SM3 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2SM3.0" hover="function: boolean HaveSVE2SM3()">HaveSVE2SM3</anchor>()
    return <a link="impl-aarch64.HaveSVE2.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE2()">HaveSVE2</a>() &amp;&amp; boolean IMPLEMENTATION_DEFINED "Have SVE2 SM3 extension";</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2SM4" mylink="aarch64.functions.sve.HaveSVE2SM4" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2SM4()
// =============
// Returns TRUE if the SVE2 SM4 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2SM4.0" hover="function: boolean HaveSVE2SM4()">HaveSVE2SM4</anchor>()
    return IsFeatureImplemented(FEAT_SVE_SM4);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVE2p1" mylink="aarch64.functions.sve.HaveSVE2p1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVE2p1()
// ============
// Returns TRUE if the SVE2.1 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVE2p1.0" hover="function: boolean HaveSVE2p1()">HaveSVE2p1</anchor>()
    return IsFeatureImplemented(FEAT_SVE2p1);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVEB16B16" mylink="aarch64.functions.sve.HaveSVEB16B16" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVEB16B16()
// ===============
// Returns TRUE if the SVE2.1 non-widening BFloat16 instructions are implemented, FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVEB16B16.0" hover="function: boolean HaveSVEB16B16()">HaveSVEB16B16</anchor>()
    return IsFeatureImplemented(FEAT_B16B16);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVEFP32MatMulExt" mylink="aarch64.functions.sve.HaveSVEFP32MatMulExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVEFP32MatMulExt()
// ======================
// Returns TRUE if single-precision floating-point matrix multiply instruction support implemented
// and FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVEFP32MatMulExt.0" hover="function: boolean HaveSVEFP32MatMulExt()">HaveSVEFP32MatMulExt</anchor>()
    return IsFeatureImplemented(FEAT_F32MM);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/HaveSVEFP64MatMulExt" mylink="aarch64.functions.sve.HaveSVEFP64MatMulExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSVEFP64MatMulExt()
// ======================
// Returns TRUE if double-precision floating-point matrix multiply instruction support implemented
// and FALSE otherwise.

boolean <anchor link="impl-aarch64.HaveSVEFP64MatMulExt.0" hover="function: boolean HaveSVEFP64MatMulExt()">HaveSVEFP64MatMulExt</anchor>()
    return IsFeatureImplemented(FEAT_F64MM);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ImplementedSMEVectorLength" mylink="aarch64.functions.sve.ImplementedSMEVectorLength" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ImplementedSMEVectorLength()
// ============================
// Reduce SVE/SME vector length to a supported value (power of two)

integer <anchor link="impl-aarch64.ImplementedSMEVectorLength.1" hover="function: integer ImplementedSMEVectorLength(integer nbits_in)">ImplementedSMEVectorLength</anchor>(integer nbits_in)
    integer maxbits = <a link="impl-aarch64.MaxImplementedSVL.0" file="shared_pseudocode.xml" hover="function: integer MaxImplementedSVL()">MaxImplementedSVL</a>();
    assert 128 &lt;= maxbits &amp;&amp; maxbits &lt;= 2048 &amp;&amp; <a link="impl-aarch64.IsPow2.1" file="shared_pseudocode.xml" hover="function: boolean IsPow2(integer x)">IsPow2</a>(maxbits);
    integer nbits = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(nbits_in, maxbits);
    assert 128 &lt;= nbits &amp;&amp; nbits &lt;= 2048 &amp;&amp; <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(nbits, 128) == nbits;

    // Search for a supported power-of-two VL less than or equal to nbits
    while nbits &gt; 128 do
        if <a link="impl-aarch64.IsPow2.1" file="shared_pseudocode.xml" hover="function: boolean IsPow2(integer x)">IsPow2</a>(nbits) &amp;&amp; <a link="impl-aarch64.SupportedPowerTwoSVL.1" file="shared_pseudocode.xml" hover="function: boolean SupportedPowerTwoSVL(integer nbits)">SupportedPowerTwoSVL</a>(nbits) then return nbits;
        nbits = nbits - 128;

    // Return the smallest supported power-of-two VL
    nbits = 128;
    while nbits &lt; maxbits do
        if <a link="impl-aarch64.SupportedPowerTwoSVL.1" file="shared_pseudocode.xml" hover="function: boolean SupportedPowerTwoSVL(integer nbits)">SupportedPowerTwoSVL</a>(nbits) then return nbits;
        nbits = nbits * 2;

    // The only option is maxbits
    return maxbits;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ImplementedSVEVectorLength" mylink="aarch64.functions.sve.ImplementedSVEVectorLength" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ImplementedSVEVectorLength()
// ============================
// Reduce SVE vector length to a supported value (power of two)

integer <anchor link="impl-aarch64.ImplementedSVEVectorLength.1" hover="function: integer ImplementedSVEVectorLength(integer nbits_in)">ImplementedSVEVectorLength</anchor>(integer nbits_in)
    integer maxbits = <a link="impl-aarch64.MaxImplementedVL.0" file="shared_pseudocode.xml" hover="function: integer MaxImplementedVL()">MaxImplementedVL</a>();
    assert 128 &lt;= maxbits &amp;&amp; maxbits &lt;= 2048 &amp;&amp; <a link="impl-aarch64.IsPow2.1" file="shared_pseudocode.xml" hover="function: boolean IsPow2(integer x)">IsPow2</a>(maxbits);
    integer nbits = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(nbits_in, maxbits);
    assert 128 &lt;= nbits &amp;&amp; nbits &lt;= 2048 &amp;&amp; <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(nbits, 128) == nbits;

    while nbits &gt; 128 do
        if <a link="impl-aarch64.IsPow2.1" file="shared_pseudocode.xml" hover="function: boolean IsPow2(integer x)">IsPow2</a>(nbits) then return nbits;
        nbits = nbits - 128;
    return nbits;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/InStreamingMode" mylink="aarch64.functions.sve.InStreamingMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InStreamingMode()
// =================

boolean <anchor link="impl-aarch64.InStreamingMode.0" hover="function: boolean InStreamingMode()">InStreamingMode</anchor>()
    return <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1';</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsEven" mylink="aarch64.functions.sve.IsEven" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsEven()
// ========

boolean <anchor link="impl-aarch64.IsEven.1" hover="function: boolean IsEven(integer val)">IsEven</anchor>(integer val)
    return val MOD 2 == 0;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsFPEnabled" mylink="aarch64.functions.sve.IsFPEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsFPEnabled()
// =============
// Returns TRUE if accesses to the Advanced SIMD and floating-point
// registers are enabled at the target exception level in the current
// execution state and FALSE otherwise.

boolean <anchor link="impl-aarch64.IsFPEnabled.1" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</anchor>(bits(2) el)
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el) then
        return <a link="AArch32.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch32.IsFPEnabled(bits(2) el)">AArch32.IsFPEnabled</a>(el);
    else
        return <a link="AArch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.IsFPEnabled(bits(2) el)">AArch64.IsFPEnabled</a>(el);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsFullA64Enabled" mylink="aarch64.functions.sve.IsFullA64Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsFullA64Enabled()
// ==================
// Returns TRUE is full A64 is enabled in Streaming mode and FALSE othersise.

boolean <anchor link="impl-aarch64.IsFullA64Enabled.0" hover="function: boolean IsFullA64Enabled()">IsFullA64Enabled</anchor>()
    if !<a link="impl-aarch64.HaveSMEFullA64.0" file="shared_pseudocode.xml" hover="function: boolean HaveSMEFullA64()">HaveSMEFullA64</a>() then return FALSE;

    // Check if full SVE disabled in SMCR_EL1
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check full SVE at EL0/EL1
        if SMCR_EL1.FA64 == '0' then return FALSE;

    // Check if full SVE disabled in SMCR_EL2
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if SMCR_EL2.FA64 == '0' then return FALSE;

    // Check if full SVE disabled in SMCR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if SMCR_EL3.FA64 == '0' then return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsOdd" mylink="aarch64.functions.sve.IsOdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsOdd()
// =======

boolean <anchor link="impl-aarch64.IsOdd.1" hover="function: boolean IsOdd(integer val)">IsOdd</anchor>(integer val)
    return val MOD 2 == 1;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsOriginalSVEEnabled" mylink="aarch64.functions.sve.IsOriginalSVEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsOriginalSVEEnabled()
// ======================
// Returns TRUE if access to SVE functionality is enabled at the target
// exception level and FALSE otherwise.

boolean <anchor link="impl-aarch64.IsOriginalSVEEnabled.1" hover="function: boolean IsOriginalSVEEnabled(bits(2) el)">IsOriginalSVEEnabled</anchor>(bits(2) el)
    boolean disabled;
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el) then
        return FALSE;

    // Check if access disabled in CPACR_EL1
    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check SVE at EL0/EL1
        case CPACR_EL1.ZEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then return FALSE;

    // Check if access disabled in CPTR_EL2
    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            case CPTR_EL2.ZEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then return FALSE;
        else
            if CPTR_EL2.TZ == '1' then return FALSE;

    // Check if access disabled in CPTR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CPTR_EL3.EZ == '0' then return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsPow2" mylink="aarch64.functions.sve.IsPow2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsPow2()
// ========
// Return TRUE if positive integer X is a power of 2. Otherwise,
// return FALSE.

boolean <anchor link="impl-aarch64.IsPow2.1" hover="function: boolean IsPow2(integer x)">IsPow2</anchor>(integer x)
    if x &lt;= 0 then return FALSE;
    return <a link="impl-aarch64.FloorPow2.1" file="shared_pseudocode.xml" hover="function: integer FloorPow2(integer x)">FloorPow2</a>(x) == <a link="impl-aarch64.CeilPow2.1" file="shared_pseudocode.xml" hover="function: integer CeilPow2(integer x)">CeilPow2</a>(x);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsSMEEnabled" mylink="aarch64.functions.sve.IsSMEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSMEEnabled()
// ==============
// Returns TRUE if access to SME functionality is enabled at the target
// exception level and FALSE otherwise.

boolean <anchor link="impl-aarch64.IsSMEEnabled.1" hover="function: boolean IsSMEEnabled(bits(2) el)">IsSMEEnabled</anchor>(bits(2) el)
    boolean disabled;
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el) then
        return FALSE;

    // Check if access disabled in CPACR_EL1
    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        // Check SME at EL0/EL1
        case CPACR_EL1.SMEN of
            when 'x0' disabled = TRUE;
            when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
            when '11' disabled = FALSE;
        if disabled then return FALSE;

    // Check if access disabled in CPTR_EL2
    if el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.E2H == '1' then
            case CPTR_EL2.SMEN of
                when 'x0' disabled = TRUE;
                when '01' disabled = el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; HCR_EL2.TGE == '1';
                when '11' disabled = FALSE;
            if disabled then return FALSE;
        else
            if CPTR_EL2.TSM == '1' then return FALSE;

    // Check if access disabled in CPTR_EL3
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CPTR_EL3.ESM == '0' then return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/IsSVEEnabled" mylink="aarch64.functions.sve.IsSVEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSVEEnabled()
// ==============
// Returns TRUE if access to SVE registers is enabled at the target exception
// level and FALSE otherwise.

boolean <anchor link="impl-aarch64.IsSVEEnabled.1" hover="function: boolean IsSVEEnabled(bits(2) el)">IsSVEEnabled</anchor>(bits(2) el)
    if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then
        return <a link="impl-aarch64.IsSMEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsSMEEnabled(bits(2) el)">IsSMEEnabled</a>(el);
    elsif <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() then
        return <a link="impl-aarch64.IsOriginalSVEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsOriginalSVEEnabled(bits(2) el)">IsOriginalSVEEnabled</a>(el);
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/LastActive" mylink="aarch64.functions.sve.LastActive" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LastActive()
// ============

bit <anchor link="impl-aarch64.LastActive.3" hover="function: bit LastActive(bits(N) mask, bits(N) x, integer esize)">LastActive</anchor>(bits(N) mask, bits(N) x, integer esize)
    integer elements = N DIV (esize DIV 8);
    for e = elements-1 downto 0
        if <a link="impl-aarch64.ActivePredicateElement.3" file="shared_pseudocode.xml" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</a>(mask, e, esize) then
            return <a link="impl-aarch64.PredicateElement.3" file="shared_pseudocode.xml" hover="function: bit PredicateElement(bits(N) pred, integer e, integer esize)">PredicateElement</a>(x, e, esize);
    return '0';</pstext>
    </ps>
    <ps name="aarch64/functions/sve/LastActiveElement" mylink="aarch64.functions.sve.LastActiveElement" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LastActiveElement()
// ===================

integer <anchor link="impl-aarch64.LastActiveElement.2" hover="function: integer LastActiveElement(bits(N) mask, integer esize)">LastActiveElement</anchor>(bits(N) mask, integer esize)
    integer elements = N DIV (esize DIV 8);
    for e = elements-1 downto 0
        if <a link="impl-aarch64.ActivePredicateElement.3" file="shared_pseudocode.xml" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</a>(mask, e, esize) then return e;
    return -1;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/MaxImplementedSVL" mylink="aarch64.functions.sve.MaxImplementedSVL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MaxImplementedSVL()
// ===================

integer <anchor link="impl-aarch64.MaxImplementedSVL.0" hover="function: integer MaxImplementedSVL()">MaxImplementedSVL</anchor>()
    return integer IMPLEMENTATION_DEFINED "Max implemented SVL";</pstext>
    </ps>
    <ps name="aarch64/functions/sve/MaxImplementedVL" mylink="aarch64.functions.sve.MaxImplementedVL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MaxImplementedVL()
// ==================

integer <anchor link="impl-aarch64.MaxImplementedVL.0" hover="function: integer MaxImplementedVL()">MaxImplementedVL</anchor>()
    return integer IMPLEMENTATION_DEFINED "Max implemented VL";</pstext>
    </ps>
    <ps name="aarch64/functions/sve/MaybeZeroSVEUppers" mylink="aarch64.functions.sve.MaybeZeroSVEUppers" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MaybeZeroSVEUppers()
// ====================

<anchor link="impl-aarch64.MaybeZeroSVEUppers.1" hover="function: MaybeZeroSVEUppers(bits(2) target_el)">MaybeZeroSVEUppers</anchor>(bits(2) target_el)
    boolean lower_enabled;

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &lt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) || !<a link="impl-aarch64.IsSVEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsSVEEnabled(bits(2) el)">IsSVEEnabled</a>(target_el) then
        return;

    if target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
            lower_enabled = <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        else
            lower_enabled = <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
    elsif target_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        assert !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        if HCR_EL2.TGE == '0' then
            lower_enabled = <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
        else
            lower_enabled = <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>);
    else
        assert target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
        lower_enabled = <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>);

    if lower_enabled then
        constant integer VL = if <a link="impl-aarch64.IsSVEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsSVEEnabled(bits(2) el)">IsSVEEnabled</a>(PSTATE.EL) then <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> else 128;
        constant integer PL = VL DIV 8;
        for n = 0 to 31
            if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
                _Z[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(_Z[n]&lt;VL-1:0&gt;, <a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
        for n = 0 to 15
            if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
                _P[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(_P[n]&lt;PL-1:0&gt;, <a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>);
        if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
            _FFR = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(_FFR&lt;PL-1:0&gt;, <a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>);
        if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.ZA == '1' then
            constant integer SVL = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a>;
            constant integer accessiblevecs = SVL DIV 8;
            constant integer allvecs = <a link="impl-aarch64.MaxImplementedSVL.0" file="shared_pseudocode.xml" hover="function: integer MaxImplementedSVL()">MaxImplementedSVL</a>() DIV 8;

            for n = 0 to accessiblevecs - 1
                if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SMEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SMEZEROUPPER</a>) then
                    _ZA[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(_ZA[n]&lt;SVL-1:0&gt;, <a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
            for n = accessiblevecs to allvecs - 1
                if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SMEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SMEZEROUPPER</a>) then
                    _ZA[n] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(<a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/MemNF" mylink="aarch64.functions.sve.MemNF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemNF[] - non-assignment form
// =============================

(bits(8*size), boolean) <anchor link="impl-aarch64.MemNF.read.3" hover="accessor: (bits(8*size), boolean) MemNF[bits(64) address, integer size, AccessDescriptor accdesc]">MemNF</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc]
    assert size IN {1, 2, 4, 8, 16};
    bits(8*size) value;
    boolean bad;

    boolean aligned = <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(address, size);

    if !aligned &amp;&amp; <a link="impl-shared.AlignmentEnforced.0" file="shared_pseudocode.xml" hover="function: boolean AlignmentEnforced()">AlignmentEnforced</a>() then
        return (bits(8*size) UNKNOWN, TRUE);

    boolean atomic = aligned || size == 1;

    if !atomic then
        (value&lt;7:0&gt;, bad) = <a link="impl-aarch64.MemSingleNF.read.4" file="shared_pseudocode.xml" hover="accessor: (bits(8*size), boolean) MemSingleNF[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned]">MemSingleNF</a>[address, 1, accdesc, aligned];

        if bad then
            return (bits(8*size) UNKNOWN, TRUE);

        // For subsequent bytes it is CONSTRAINED UNPREDICTABLE whether an unaligned Device memory
        // access will generate an Alignment Fault, as to get this far means the first byte did
        // not, so we must be changing to a new translation page.
        if !aligned then
            c = <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVPAGE2" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVPAGE2</a>);
            assert c IN {<a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>, <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>};
            if c == <a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a> then aligned = TRUE;

        for i = 1 to size-1
            (value&lt;8*i+7:8*i&gt;, bad) = <a link="impl-aarch64.MemSingleNF.read.4" file="shared_pseudocode.xml" hover="accessor: (bits(8*size), boolean) MemSingleNF[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned]">MemSingleNF</a>[address+i, 1, accdesc, aligned];

            if bad then
                return (bits(8*size) UNKNOWN, TRUE);
    else
        (value, bad) = <a link="impl-aarch64.MemSingleNF.read.4" file="shared_pseudocode.xml" hover="accessor: (bits(8*size), boolean) MemSingleNF[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned]">MemSingleNF</a>[address, size, accdesc, aligned];
        if bad then
            return (bits(8*size) UNKNOWN, TRUE);

    if <a link="impl-shared.BigEndian.1" file="shared_pseudocode.xml" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</a>(accdesc.acctype) then
        value = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value);

    return (value, FALSE);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/MemSingleNF" mylink="aarch64.functions.sve.MemSingleNF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemSingleNF[] - non-assignment form
// ===================================

(bits(8*size), boolean) <anchor link="impl-aarch64.MemSingleNF.read.4" hover="accessor: (bits(8*size), boolean) MemSingleNF[bits(64) address, integer size, AccessDescriptor accdesc_in, boolean aligned]">MemSingleNF</anchor>[bits(64) address, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in,
                                    boolean aligned]
    assert accdesc_in.acctype == <a link="AccessType_SVE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SVE</a>;
    assert accdesc_in.nonfault || (accdesc_in.firstfault &amp;&amp; !accdesc_in.first);

    bits(8*size) value;
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = accdesc_in;
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);

    // Implementation may suppress NF load for any reason
    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_NONFAULT" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_NONFAULT</a>) then
        return (bits(8*size) UNKNOWN, TRUE);

    // If the instruction encoding permits tag checking, confer with system register configuration
    // which may override this.
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        accdesc.tagchecked = <a link="AArch64.AccessIsTagChecked.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.AccessIsTagChecked(bits(64) vaddr, AccessDescriptor accdesc)">AArch64.AccessIsTagChecked</a>(address, accdesc);

    // MMU or MPU
    memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(address, accdesc, aligned, size);

    // Non-fault load from Device memory must not be performed externally
    if memaddrdesc.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
        return (bits(8*size) UNKNOWN, TRUE);

    // Check for aborts or debug exceptions
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
        return (bits(8*size) UNKNOWN, TRUE);

    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; accdesc.tagchecked then
        bits(4) ptag = <a link="AArch64.PhysicalTag.1" file="shared_pseudocode.xml" hover="function: bits(4) AArch64.PhysicalTag(bits(64) vaddr)">AArch64.PhysicalTag</a>(address);
        if !<a link="AArch64.CheckTag.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.CheckTag(AddressDescriptor memaddrdesc, AccessDescriptor accdesc, bits(4) ptag)">AArch64.CheckTag</a>(memaddrdesc, accdesc, ptag) then
            return (bits(8*size) UNKNOWN, TRUE);

    (memstatus, value) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(memaddrdesc, size, accdesc);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        boolean iswrite = FALSE;
        if <a link="impl-shared.IsExternalAbortTakenSynchronously.5" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbortTakenSynchronously(PhysMemRetStatus memstatus, boolean iswrite, AddressDescriptor desc, integer size, AccessDescriptor accdesc)">IsExternalAbortTakenSynchronously</a>(memstatus, iswrite, memaddrdesc, size, accdesc) then
            return (bits(8*size) UNKNOWN, TRUE);
        fault.merrorstate = memstatus.merrorstate;
        fault.extflag    = memstatus.extflag;
        fault.statuscode = memstatus.statuscode;
        <a link="impl-shared.PendSErrorInterrupt.1" file="shared_pseudocode.xml" hover="function: PendSErrorInterrupt(FaultRecord fault)">PendSErrorInterrupt</a>(fault);

    return (value, FALSE);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/NoneActive" mylink="aarch64.functions.sve.NoneActive" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NoneActive()
// ============

bit <anchor link="impl-aarch64.NoneActive.3" hover="function: bit NoneActive(bits(N) mask, bits(N) x, integer esize)">NoneActive</anchor>(bits(N) mask, bits(N) x, integer esize)
    integer elements = N DIV (esize DIV 8);
    for e = 0 to elements-1
        if <a link="impl-aarch64.ActivePredicateElement.3" file="shared_pseudocode.xml" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</a>(mask, e, esize) &amp;&amp; <a link="impl-aarch64.ActivePredicateElement.3" file="shared_pseudocode.xml" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</a>(x, e, esize) then
            return '0';
    return '1';</pstext>
    </ps>
    <ps name="aarch64/functions/sve/P" mylink="aarch64.functions.sve.P" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// P[] - non-assignment form
// =========================

bits(width) <anchor link="impl-aarch64.P.read.2" hover="accessor: bits(width) P[integer n, integer width]">P</anchor>[integer n, integer width]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width == <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV 8;
    return _P[n]&lt;width-1:0&gt;;

// P[] - assignment form
// =====================

<anchor link="impl-aarch64.P.write.2" hover="accessor: P[integer n, integer width] = bits(width) value">P</anchor>[integer n, integer width] = bits(width) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width == <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a> DIV 8;
    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
        _P[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, <a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>);
    else
        _P[n]&lt;width-1:0&gt; = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/PredTest" mylink="aarch64.functions.sve.PredTest" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PredTest()
// ==========

bits(4) <anchor link="impl-aarch64.PredTest.3" hover="function: bits(4) PredTest(bits(N) mask, bits(N) result, integer esize)">PredTest</anchor>(bits(N) mask, bits(N) result, integer esize)
    bit n = <a link="impl-aarch64.FirstActive.3" file="shared_pseudocode.xml" hover="function: bit FirstActive(bits(N) mask, bits(N) x, integer esize)">FirstActive</a>(mask, result, esize);
    bit z = <a link="impl-aarch64.NoneActive.3" file="shared_pseudocode.xml" hover="function: bit NoneActive(bits(N) mask, bits(N) x, integer esize)">NoneActive</a>(mask, result, esize);
    bit c = NOT <a link="impl-aarch64.LastActive.3" file="shared_pseudocode.xml" hover="function: bit LastActive(bits(N) mask, bits(N) x, integer esize)">LastActive</a>(mask, result, esize);
    bit v = '0';
    return n:z:c:v;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/PredicateElement" mylink="aarch64.functions.sve.PredicateElement" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PredicateElement()
// ==================
// Returns the predicate bit

bit <anchor link="impl-aarch64.PredicateElement.3" hover="function: bit PredicateElement(bits(N) pred, integer e, integer esize)">PredicateElement</anchor>(bits(N) pred, integer e, integer esize)
    assert esize IN {8, 16, 32, 64, 128};
    integer n = e * (esize DIV 8);
    assert n &gt;= 0 &amp;&amp; n &lt; N;
    return pred&lt;n&gt;;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ReducePredicated" mylink="aarch64.functions.sve.ReducePredicated" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReducePredicated()
// ==================

bits(esize) <anchor link="impl-aarch64.ReducePredicated.4" hover="function: bits(esize) ReducePredicated(ReduceOp op, bits(N) input, bits(M) mask, bits(esize) identity)">ReducePredicated</anchor>(<a link="ReduceOp" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp</a> op, bits(N) input, bits(M) mask, bits(esize) identity)
    assert(N == M * 8);
    integer p2bits = <a link="impl-aarch64.CeilPow2.1" file="shared_pseudocode.xml" hover="function: integer CeilPow2(integer x)">CeilPow2</a>(N);
    bits(p2bits) operand;
    integer elements = p2bits DIV esize;

    for e = 0 to elements-1
        if e * esize &lt; N &amp;&amp; <a link="impl-aarch64.ActivePredicateElement.3" file="shared_pseudocode.xml" hover="function: boolean ActivePredicateElement(bits(N) pred, integer e, integer esize)">ActivePredicateElement</a>(mask, e, esize) then
            <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[operand, e, esize] = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[input, e, esize];
        else
            <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[operand, e, esize] = identity;

    return <a link="impl-aarch64.Reduce.3" file="shared_pseudocode.xml" hover="function: bits(esize) Reduce(ReduceOp op, bits(N) input, integer esize)">Reduce</a>(op, operand, esize);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ResetSMEState" mylink="aarch64.functions.sve.ResetSMEState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ResetSMEState()
// ===============

<anchor link="impl-aarch64.ResetSMEState.0" hover="function: ResetSMEState()">ResetSMEState</anchor>()
    integer vectors = <a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a> DIV 8;
    for n = 0 to vectors - 1
        _ZA[n] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(<a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
    _ZT0 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(<a link="ZT0_LEN" file="shared_pseudocode.xml" hover="constant integer ZT0_LEN = 512">ZT0_LEN</a>);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ResetSVEState" mylink="aarch64.functions.sve.ResetSVEState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ResetSVEState()
// ===============

<anchor link="impl-aarch64.ResetSVEState.0" hover="function: ResetSVEState()">ResetSVEState</anchor>()
    for n = 0 to 31
        _Z[n] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(<a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
    for n = 0 to 15
        _P[n] = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(<a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>);
    _FFR = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(<a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>);
    FPSR = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(0x0800009f&lt;31:0&gt;, 64);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/Reverse" mylink="aarch64.functions.sve.Reverse" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Reverse()
// =========
// Reverse subwords of M bits in an N-bit word

bits(N) <anchor link="impl-aarch64.Reverse.2" hover="function: bits(N) Reverse(bits(N) word, integer M)">Reverse</anchor>(bits(N) word, integer M)
    bits(N) result;
    integer sw = N DIV M;
    assert N == sw * M;
    for s = 0 to sw-1
        <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, (sw - 1) - s, M] = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[word, s, M];
    return result;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SMEAccessTrap" mylink="aarch64.functions.sve.SMEAccessTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SMEAccessTrap()
// ===============
// Trapped access to SME registers due to CPACR_EL1, CPTR_EL2, or CPTR_EL3.

<anchor link="impl-aarch64.SMEAccessTrap.2" hover="function: SMEAccessTrap(SMEExceptionType etype, bits(2) target_el_in)">SMEAccessTrap</anchor>(<a link="SMEExceptionType" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType</a> etype, bits(2) target_el_in)
    bits(2) target_el = target_el_in;
    assert <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL);
    if target_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    boolean route_to_el2;
    route_to_el2 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SMEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SMEAccessTrap</a>);
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    case etype of
        when <a link="SMEExceptionType_AccessTrap" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</a>
            exception.syndrome&lt;2:0&gt; = '000';
        when <a link="SMEExceptionType_Streaming" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_Streaming</a>
            exception.syndrome&lt;2:0&gt; = '001';
        when <a link="SMEExceptionType_NotStreaming" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_NotStreaming</a>
            exception.syndrome&lt;2:0&gt; = '010';
        when <a link="SMEExceptionType_InactiveZA" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InactiveZA</a>
            exception.syndrome&lt;2:0&gt; = '011';
        when <a link="SMEExceptionType_InaccessibleZT0" file="shared_pseudocode.xml" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InaccessibleZT0</a>
            exception.syndrome&lt;2:0&gt; = '100';

    if route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SMEExceptionType" mylink="aarch64.functions.sve.SMEExceptionType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SMEExceptionType
// ================
enumeration <anchor link="SMEExceptionType" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType</anchor> {
    <anchor link="SMEExceptionType_AccessTrap" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_AccessTrap</anchor>,        // SME functionality trapped or disabled
    <anchor link="SMEExceptionType_Streaming" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_Streaming</anchor>,         // Illegal instruction in Streaming SVE mode
    <anchor link="SMEExceptionType_NotStreaming" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_NotStreaming</anchor>,      // Illegal instruction not in Streaming SVE mode
    <anchor link="SMEExceptionType_InactiveZA" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InactiveZA</anchor>,        // Illegal instruction when ZA is inactive
    <anchor link="SMEExceptionType_InaccessibleZT0" hover="enumeration SMEExceptionType { SMEExceptionType_AccessTrap, SMEExceptionType_Streaming, SMEExceptionType_NotStreaming, SMEExceptionType_InactiveZA, SMEExceptionType_InaccessibleZT0, }">SMEExceptionType_InaccessibleZT0</anchor>,   // Access to ZT0 is disabled
};</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SVEAccessTrap" mylink="aarch64.functions.sve.SVEAccessTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SVEAccessTrap()
// ===============
// Trapped access to SVE registers due to CPACR_EL1, CPTR_EL2, or CPTR_EL3.

<anchor link="impl-aarch64.SVEAccessTrap.1" hover="function: SVEAccessTrap(bits(2) target_el)">SVEAccessTrap</anchor>(bits(2) target_el)
    assert <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &amp;&amp; target_el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el);
    route_to_el2 = target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1';

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_SVEAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SVEAccessTrap</a>);
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    if route_to_el2 then
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, exception, preferred_exception_return, vect_offset);
    else
        <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(target_el, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SVECmp" mylink="aarch64.functions.sve.SVECmp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SVECmp
// ======

enumeration <anchor link="SVECmp" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">SVECmp</anchor> { <anchor link="Cmp_EQ" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_EQ</anchor>, <anchor link="Cmp_NE" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_NE</anchor>, <anchor link="Cmp_GE" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_GE</anchor>, <anchor link="Cmp_GT" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_GT</anchor>, <anchor link="Cmp_LT" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_LT</anchor>, <anchor link="Cmp_LE" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_LE</anchor>, <anchor link="Cmp_UN" hover="enumeration SVECmp { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN }">Cmp_UN</anchor> };</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SVEMoveMaskPreferred" mylink="aarch64.functions.sve.SVEMoveMaskPreferred" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SVEMoveMaskPreferred()
// ======================
// Return FALSE if a bitmask immediate encoding would generate an immediate
// value that could also be represented by a single DUP instruction.
// Used as a condition for the preferred MOV&lt;-DUPM alias.

boolean <anchor link="impl-aarch64.SVEMoveMaskPreferred.1" hover="function: boolean SVEMoveMaskPreferred(bits(13) imm13)">SVEMoveMaskPreferred</anchor>(bits(13) imm13)
    bits(64) imm;
    (imm, -) = <a link="impl-aarch64.DecodeBitMasks.5" file="shared_pseudocode.xml" hover="function: (bits(M), bits(M)) DecodeBitMasks(bit immN, bits(6) imms, bits(6) immr, boolean immediate, integer M)">DecodeBitMasks</a>(imm13&lt;12&gt;, imm13&lt;5:0&gt;, imm13&lt;11:6&gt;, TRUE, 64);

    // Check for 8 bit immediates
    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(imm&lt;7:0&gt;) then
        // Check for 'ffffffffffffffxy' or '00000000000000xy'
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(imm&lt;63:7&gt;) || <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(imm&lt;63:7&gt;) then
            return FALSE;

        // Check for 'ffffffxyffffffxy' or '000000xy000000xy'
        if imm&lt;63:32&gt; == imm&lt;31:0&gt; &amp;&amp; (<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(imm&lt;31:7&gt;) || <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(imm&lt;31:7&gt;)) then
            return FALSE;

        // Check for 'ffxyffxyffxyffxy' or '00xy00xy00xy00xy'
        if (imm&lt;63:32&gt; == imm&lt;31:0&gt; &amp;&amp; imm&lt;31:16&gt; == imm&lt;15:0&gt; &amp;&amp;
              (<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(imm&lt;15:7&gt;) || <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(imm&lt;15:7&gt;))) then
            return FALSE;

        // Check for 'xyxyxyxyxyxyxyxy'
        if imm&lt;63:32&gt; == imm&lt;31:0&gt; &amp;&amp; imm&lt;31:16&gt; == imm&lt;15:0&gt; &amp;&amp; (imm&lt;15:8&gt; == imm&lt;7:0&gt;) then
            return FALSE;

    // Check for 16 bit immediates
    else
        // Check for 'ffffffffffffxy00' or '000000000000xy00'
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(imm&lt;63:15&gt;) || <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(imm&lt;63:15&gt;) then
            return FALSE;

        // Check for 'ffffxy00ffffxy00' or '0000xy000000xy00'
        if imm&lt;63:32&gt; == imm&lt;31:0&gt; &amp;&amp; (<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(imm&lt;31:7&gt;) || <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(imm&lt;31:7&gt;)) then
            return FALSE;

        // Check for 'xy00xy00xy00xy00'
        if imm&lt;63:32&gt; == imm&lt;31:0&gt; &amp;&amp; imm&lt;31:16&gt; == imm&lt;15:0&gt; then
            return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SetPSTATE_SM" mylink="aarch64.functions.sve.SetPSTATE_SM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetPSTATE_SM()
// ==============

<anchor link="impl-aarch64.SetPSTATE_SM.1" hover="function: SetPSTATE_SM(bit value)">SetPSTATE_SM</anchor>(bit value)
    if PSTATE.SM != value then
        <a link="impl-aarch64.ResetSVEState.0" file="shared_pseudocode.xml" hover="function: ResetSVEState()">ResetSVEState</a>();
        PSTATE.SM = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SetPSTATE_SVCR" mylink="aarch64.functions.sve.SetPSTATE_SVCR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetPSTATE_SVCR
// ==============

<anchor link="impl-aarch64.SetPSTATE_SVCR.1" hover="function: SetPSTATE_SVCR(bits(32) svcr)">SetPSTATE_SVCR</anchor>(bits(32) svcr)
    <a link="impl-aarch64.SetPSTATE_SM.1" file="shared_pseudocode.xml" hover="function: SetPSTATE_SM(bit value)">SetPSTATE_SM</a>(svcr&lt;0&gt;);
    <a link="impl-aarch64.SetPSTATE_ZA.1" file="shared_pseudocode.xml" hover="function: SetPSTATE_ZA(bit value)">SetPSTATE_ZA</a>(svcr&lt;1&gt;);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SetPSTATE_ZA" mylink="aarch64.functions.sve.SetPSTATE_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetPSTATE_ZA()
// ==============

<anchor link="impl-aarch64.SetPSTATE_ZA.1" hover="function: SetPSTATE_ZA(bit value)">SetPSTATE_ZA</anchor>(bit value)
    if PSTATE.ZA != value then
        <a link="impl-aarch64.ResetSMEState.0" file="shared_pseudocode.xml" hover="function: ResetSMEState()">ResetSMEState</a>();
        PSTATE.ZA = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/ShiftSat" mylink="aarch64.functions.sve.ShiftSat" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ShiftSat()
// ==========

integer <anchor link="impl-aarch64.ShiftSat.2" hover="function: integer ShiftSat(integer shift, integer esize)">ShiftSat</anchor>(integer shift, integer esize)
    if shift &gt; esize+1 then return esize+1;
    elsif shift &lt; -(esize+1) then return -(esize+1);
    return shift;</pstext>
    </ps>
    <ps name="aarch64/functions/sve/SupportedPowerTwoSVL" mylink="aarch64.functions.sve.SupportedPowerTwoSVL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SupportedPowerTwoSVL()
// ======================
// Return an IMPLEMENTATION DEFINED specific value
// returns TRUE if SVL is supported and is a power of two, FALSE otherwise

boolean <anchor link="impl-aarch64.SupportedPowerTwoSVL.1" hover="function: boolean SupportedPowerTwoSVL(integer nbits)">SupportedPowerTwoSVL</anchor>(integer nbits);</pstext>
    </ps>
    <ps name="aarch64/functions/sve/System" mylink="aarch64.functions.sve.System" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="MAX_VL" hover="constant integer MAX_VL = 2048">MAX_VL</anchor> = 2048;
constant integer <anchor link="MAX_PL" hover="constant integer MAX_PL = 256">MAX_PL</anchor> = 256;
constant integer <anchor link="ZT0_LEN" hover="constant integer ZT0_LEN = 512">ZT0_LEN</anchor> =  512;
bits(<a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>) _FFR;

array bits(<a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>) _Z[0..31];

array bits(<a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>) _P[0..15];</pstext>
    </ps>
    <ps name="aarch64/functions/sve/Z" mylink="aarch64.functions.sve.Z" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Z[] - non-assignment form
// =========================

bits(width) <anchor link="impl-aarch64.Z.read.2" hover="accessor: bits(width) Z[integer n, integer width]">Z</anchor>[integer n, integer width]
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width == <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a>;
    return _Z[n]&lt;width-1:0&gt;;

// Z[] - assignment form
// =====================

<anchor link="impl-aarch64.Z.write.2" hover="accessor: Z[integer n, integer width] = bits(width) value">Z</anchor>[integer n, integer width] = bits(width) value
    assert n &gt;= 0 &amp;&amp; n &lt;= 31;
    assert width == <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a>;
    if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_SVEZEROUPPER" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</a>) then
        _Z[n] = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(value, <a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>);
    else
        _Z[n]&lt;width-1:0&gt; = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/CNTKCTL" mylink="aarch64.functions.sysregisters.CNTKCTL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CNTKCTL[] - non-assignment form
// ===============================

CNTKCTLType <anchor link="impl-aarch64.CNTKCTL.read.0" hover="accessor: CNTKCTLType CNTKCTL[]">CNTKCTL</anchor>[]
    bits(64) r;
    if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        r = CNTHCTL_EL2;
        return r;
    r = CNTKCTL_EL1;
    return r;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/CNTKCTLType" mylink="aarch64.functions.sysregisters.CNTKCTLType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="CNTKCTLType" hover="type CNTKCTLType">CNTKCTLType</anchor>;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/CPACR" mylink="aarch64.functions.sysregisters.CPACR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPACR[] - non-assignment form
// =============================

CPACRType <anchor link="impl-aarch64.CPACR.read.0" hover="accessor: CPACRType CPACR[]">CPACR</anchor>[]
    bits(64) r;
    if <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        r = CPTR_EL2;
        return r;
    r = CPACR_EL1;
    return r;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/CPACRType" mylink="aarch64.functions.sysregisters.CPACRType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="CPACRType" hover="type CPACRType">CPACRType</anchor>;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/ELR" mylink="aarch64.functions.sysregisters.ELR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELR[] - non-assignment form
// ===========================

bits(64) <anchor link="impl-aarch64.ELR.read.1" hover="accessor: bits(64) ELR[bits(2) el]">ELR</anchor>[bits(2) el]
    bits(64) r;
    case el of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  r = ELR_EL1;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  r = ELR_EL2;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  r = ELR_EL3;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return r;

// ELR[] - non-assignment form
// ===========================

bits(64) <anchor link="impl-aarch64.ELR.read.0" hover="accessor: bits(64) ELR[]">ELR</anchor>[]
    assert PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
    return <a link="impl-aarch64.ELR.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) ELR[bits(2) el]">ELR</a>[PSTATE.EL];

// ELR[] - assignment form
// =======================

<anchor link="impl-aarch64.ELR.write.1" hover="accessor: ELR[bits(2) el] = bits(64) value">ELR</anchor>[bits(2) el] = bits(64) value
    bits(64) r = value;
    case el of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  ELR_EL1 = r;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  ELR_EL2 = r;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  ELR_EL3 = r;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return;

// ELR[] - assignment form
// =======================

<anchor link="impl-aarch64.ELR.write.0" hover="accessor: ELR[] = bits(64) value">ELR</anchor>[] = bits(64) value
    assert PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
    <a link="impl-aarch64.ELR.write.1" file="shared_pseudocode.xml" hover="accessor: ELR[bits(2) el] = bits(64) value">ELR</a>[PSTATE.EL] = value;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/ESR" mylink="aarch64.functions.sysregisters.ESR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ESR[] - non-assignment form
// ===========================

ESRType <anchor link="impl-aarch64.ESR.read.1" hover="accessor: ESRType ESR[bits(2) regime]">ESR</anchor>[bits(2) regime]
    bits(64) r;
    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  r = ESR_EL1;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  r = ESR_EL2;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  r = ESR_EL3;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return r;

// ESR[] - non-assignment form
// ===========================

ESRType <anchor link="impl-aarch64.ESR.read.0" hover="accessor: ESRType ESR[]">ESR</anchor>[]
    return <a link="impl-aarch64.ESR.read.1" file="shared_pseudocode.xml" hover="accessor: ESRType ESR[bits(2) regime]">ESR</a>[<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()];

// ESR[] - assignment form
// =======================

<anchor link="impl-aarch64.ESR.write.1" hover="accessor: ESR[bits(2) regime] = ESRType value">ESR</anchor>[bits(2) regime] = <a link="ESRType" file="shared_pseudocode.xml" hover="type ESRType">ESRType</a> value
    bits(64) r = value;
    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  ESR_EL1 = r;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  ESR_EL2 = r;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  ESR_EL3 = r;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return;

// ESR[] - assignment form
// =======================

<anchor link="impl-aarch64.ESR.write.0" hover="accessor: ESR[] = ESRType value">ESR</anchor>[] = <a link="ESRType" file="shared_pseudocode.xml" hover="type ESRType">ESRType</a> value
    <a link="impl-aarch64.ESR.write.1" file="shared_pseudocode.xml" hover="accessor: ESR[bits(2) regime] = ESRType value">ESR</a>[<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()] = value;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/ESRType" mylink="aarch64.functions.sysregisters.ESRType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="ESRType" hover="type ESRType">ESRType</anchor>;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/FAR" mylink="aarch64.functions.sysregisters.FAR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FAR[] - non-assignment form
// ===========================

bits(64) <anchor link="impl-aarch64.FAR.read.1" hover="accessor: bits(64) FAR[bits(2) regime]">FAR</anchor>[bits(2) regime]
    bits(64) r;
    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  r = FAR_EL1;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  r = FAR_EL2;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  r = FAR_EL3;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return r;

// FAR[] - non-assignment form
// ===========================

bits(64) <anchor link="impl-aarch64.FAR.read.0" hover="accessor: bits(64) FAR[]">FAR</anchor>[]
    return <a link="impl-aarch64.FAR.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) FAR[bits(2) regime]">FAR</a>[<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()];

// FAR[] - assignment form
// =======================

<anchor link="impl-aarch64.FAR.write.1" hover="accessor: FAR[bits(2) regime] = bits(64) value">FAR</anchor>[bits(2) regime] = bits(64) value
    bits(64) r = value;
    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  FAR_EL1 = r;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  FAR_EL2 = r;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  FAR_EL3 = r;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return;

// FAR[] - assignment form
// =======================

<anchor link="impl-aarch64.FAR.write.0" hover="accessor: FAR[] = bits(64) value">FAR</anchor>[] = bits(64) value
    <a link="impl-aarch64.FAR.write.1" file="shared_pseudocode.xml" hover="accessor: FAR[bits(2) regime] = bits(64) value">FAR</a>[<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()] = value;
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/SCTLR" mylink="aarch64.functions.sysregisters.SCTLR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SCTLR[] - non-assignment form
// =============================

SCTLRType <anchor link="impl-aarch64.SCTLR.read.1" hover="accessor: SCTLRType SCTLR[bits(2) regime]">SCTLR</anchor>[bits(2) regime]
    bits(64) r;
    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  r = SCTLR_EL1;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  r = SCTLR_EL2;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  r = SCTLR_EL3;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return r;

// SCTLR[] - non-assignment form
// =============================

SCTLRType <anchor link="impl-aarch64.SCTLR.read.0" hover="accessor: SCTLRType SCTLR[]">SCTLR</anchor>[]
    return <a link="impl-aarch64.SCTLR.read.1" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[bits(2) regime]">SCTLR</a>[<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()];</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/SCTLRType" mylink="aarch64.functions.sysregisters.SCTLRType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="SCTLRType" hover="type SCTLRType">SCTLRType</anchor>;</pstext>
    </ps>
    <ps name="aarch64/functions/sysregisters/VBAR" mylink="aarch64.functions.sysregisters.VBAR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VBAR[] - non-assignment form
// ============================

bits(64) <anchor link="impl-aarch64.VBAR.read.1" hover="accessor: bits(64) VBAR[bits(2) regime]">VBAR</anchor>[bits(2) regime]
    bits(64) r;
    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  r = VBAR_EL1;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  r = VBAR_EL2;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  r = VBAR_EL3;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return r;

// VBAR[] - non-assignment form
// ============================

bits(64) <anchor link="impl-aarch64.VBAR.read.0" hover="accessor: bits(64) VBAR[]">VBAR</anchor>[]
    return <a link="impl-aarch64.VBAR.read.1" file="shared_pseudocode.xml" hover="accessor: bits(64) VBAR[bits(2) regime]">VBAR</a>[<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>()];</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.AllocationTagAccessIsEnabled" mylink="aarch64.functions.system.AArch64.AllocationTagAccessIsEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AllocationTagAccessIsEnabled()
// ======================================
// Check whether access to Allocation Tags is enabled.

boolean <anchor link="AArch64.AllocationTagAccessIsEnabled.1" hover="function: boolean AArch64.AllocationTagAccessIsEnabled(bits(2) el)">AArch64.AllocationTagAccessIsEnabled</anchor>(bits(2) el)
    if SCR_EL3.ATA == '0' &amp;&amp; el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} then
        return FALSE;
    if HCR_EL2.ATA == '0' &amp;&amp; el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.&lt;E2H,TGE&gt; != '11' then
        return FALSE;

    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(el);
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return SCTLR_EL3.ATA == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return SCTLR_EL2.ATA == '1';
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return if el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then SCTLR_EL2.ATA0 == '1' else SCTLR_EL2.ATA == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return if el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then SCTLR_EL1.ATA0 == '1' else SCTLR_EL1.ATA == '1';
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.CheckSystemAccess" mylink="aarch64.functions.system.AArch64.CheckSystemAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckSystemAccess()
// ===========================

<anchor link="AArch64.CheckSystemAccess.7" hover="function: AArch64.CheckSystemAccess(bits(2) op0, bits(3) op1, bits(4) crn, bits(4) crm, bits(3) op2, bits(5) rt, bit read)">AArch64.CheckSystemAccess</anchor>(bits(2) op0, bits(3) op1, bits(4) crn,
                          bits(4) crm, bits(3) op2, bits(5) rt, bit read)
    if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then
        <a link="impl-shared.BranchTargetCheck.0" file="shared_pseudocode.xml" hover="function: BranchTargetCheck()">BranchTargetCheck</a>();

    if (<a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 &amp;&amp;
          !<a link="impl-aarch64.CheckTransactionalSystemAccess.6" file="shared_pseudocode.xml" hover="function: boolean CheckTransactionalSystemAccess(bits(2) op0, bits(3) op1, bits(4) crn, bits(4) crm, bits(3) op2, bit read)">CheckTransactionalSystemAccess</a>(op0, op1, crn, crm, op2, read)) then
        <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_ERR" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</a>, FALSE);

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ChooseNonExcludedTag" mylink="aarch64.functions.system.AArch64.ChooseNonExcludedTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ChooseNonExcludedTag()
// ==============================
// Return a tag derived from the start and the offset values, excluding
// any tags in the given mask.

bits(4) <anchor link="AArch64.ChooseNonExcludedTag.3" hover="function: bits(4) AArch64.ChooseNonExcludedTag(bits(4) tag_in, bits(4) offset_in, bits(16) exclude)">AArch64.ChooseNonExcludedTag</anchor>(bits(4) tag_in, bits(4) offset_in, bits(16) exclude)
    bits(4) tag = tag_in;
    bits(4) offset = offset_in;

    if <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(exclude) then
        return '0000';

    if offset == '0000' then
        while exclude&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tag)&gt; == '1' do
            tag = tag + '0001';

    while offset != '0000' do
        offset = offset - '0001';
        tag = tag + '0001';
        while exclude&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tag)&gt; == '1' do
            tag = tag + '0001';

    return tag;</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ExecutingBROrBLROrRetInstr" mylink="aarch64.functions.system.AArch64.ExecutingBROrBLROrRetInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ExecutingBROrBLROrRetInstr()
// ====================================
// Returns TRUE if current instruction is a BR, BLR, RET, B[L]RA[B][Z], or RETA[B].

boolean <anchor link="AArch64.ExecutingBROrBLROrRetInstr.0" hover="function: boolean AArch64.ExecutingBROrBLROrRetInstr()">AArch64.ExecutingBROrBLROrRetInstr</anchor>()
    if !<a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then return FALSE;

    instr = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>();
    if instr&lt;31:25&gt; == '1101011' &amp;&amp; instr&lt;20:16&gt; == '11111' then
        opc = instr&lt;24:21&gt;;
        return opc != '0101';
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ExecutingBTIInstr" mylink="aarch64.functions.system.AArch64.ExecutingBTIInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ExecutingBTIInstr()
// ===========================
// Returns TRUE if current instruction is a BTI.

boolean <anchor link="AArch64.ExecutingBTIInstr.0" hover="function: boolean AArch64.ExecutingBTIInstr()">AArch64.ExecutingBTIInstr</anchor>()
    if !<a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then return FALSE;

    instr = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>();
    if instr&lt;31:22&gt; == '1101010100' &amp;&amp; instr&lt;21:12&gt; == '0000110010' &amp;&amp; instr&lt;4:0&gt; == '11111' then
        CRm  = instr&lt;11:8&gt;;
        op2  = instr&lt;7:5&gt;;
        return (CRm == '0100' &amp;&amp; op2&lt;0&gt; == '0');
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ExecutingERETInstr" mylink="aarch64.functions.system.AArch64.ExecutingERETInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ExecutingERETInstr()
// ============================
// Returns TRUE if current instruction is ERET.

boolean <anchor link="AArch64.ExecutingERETInstr.0" hover="function: boolean AArch64.ExecutingERETInstr()">AArch64.ExecutingERETInstr</anchor>()
    instr = <a link="impl-shared.ThisInstr.0" file="shared_pseudocode.xml" hover="function: bits(32) ThisInstr()">ThisInstr</a>();
    return instr&lt;31:12&gt; == '11010110100111110000';</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysInstr" mylink="aarch64.functions.system.AArch64.ImpDefSysInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysInstr()
// ========================
// Execute an implementation-defined system instruction with write (source operand).

<anchor link="AArch64.ImpDefSysInstr.6" hover="function: AArch64.ImpDefSysInstr(integer el, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t)">AArch64.ImpDefSysInstr</anchor>(integer el, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysInstr128" mylink="aarch64.functions.system.AArch64.ImpDefSysInstr128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysInstr128()
// ===========================
// Execute an implementation-defined system instruction with write (128-bit source operand).

<anchor link="AArch64.ImpDefSysInstr128.7" hover="function: AArch64.ImpDefSysInstr128(integer el, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t, integer t2)">AArch64.ImpDefSysInstr128</anchor>(integer el, bits(3) op1, bits(4) CRn,
                          bits(4) CRm, bits(3) op2,
                          integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysInstrWithResult" mylink="aarch64.functions.system.AArch64.ImpDefSysInstrWithResult" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysInstrWithResult()
// ==================================
// Execute an implementation-defined system instruction with read (result operand).

<anchor link="AArch64.ImpDefSysInstrWithResult.5" hover="function: AArch64.ImpDefSysInstrWithResult(integer el, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2)">AArch64.ImpDefSysInstrWithResult</anchor>(integer el, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysRegRead" mylink="aarch64.functions.system.AArch64.ImpDefSysRegRead" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysRegRead()
// ==========================
// Read from an implementation-defined System register and write the contents of the register
// to X[t].

<anchor link="AArch64.ImpDefSysRegRead.6" hover="function: AArch64.ImpDefSysRegRead(bits(2) op0, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t)">AArch64.ImpDefSysRegRead</anchor>(bits(2) op0, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2,
                         integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysRegRead128" mylink="aarch64.functions.system.AArch64.ImpDefSysRegRead128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysRegRead128()
// =============================
// Read from an 128-bit implementation-defined System register
// and write the contents of the register to X[t], X[t+1].

<anchor link="AArch64.ImpDefSysRegRead128.7" hover="function: AArch64.ImpDefSysRegRead128(bits(2) op0, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t, integer t2)">AArch64.ImpDefSysRegRead128</anchor>(bits(2) op0, bits(3) op1, bits(4) CRn,
                            bits(4) CRm, bits(3) op2,
                            integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysRegWrite" mylink="aarch64.functions.system.AArch64.ImpDefSysRegWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysRegWrite()
// ===========================
// Write to an implementation-defined System register.

<anchor link="AArch64.ImpDefSysRegWrite.6" hover="function: AArch64.ImpDefSysRegWrite(bits(2) op0, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t)">AArch64.ImpDefSysRegWrite</anchor>(bits(2) op0, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2,
                          integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.ImpDefSysRegWrite128" mylink="aarch64.functions.system.AArch64.ImpDefSysRegWrite128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ImpDefSysRegWrite128()
// ==============================
// Write the contents of X[t], X[t+1] to an 128-bit implementation-defined System register.

<anchor link="AArch64.ImpDefSysRegWrite128.7" hover="function: AArch64.ImpDefSysRegWrite128(bits(2) op0, bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2, integer t, integer t2)">AArch64.ImpDefSysRegWrite128</anchor>(bits(2) op0, bits(3) op1, bits(4) CRn,
                             bits(4) CRm, bits(3) op2,
                             integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.NextRandomTagBit" mylink="aarch64.functions.system.AArch64.NextRandomTagBit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.NextRandomTagBit()
// ==========================
// Generate a random bit suitable for generating a random Allocation Tag.

bit <anchor link="AArch64.NextRandomTagBit.0" hover="function: bit AArch64.NextRandomTagBit()">AArch64.NextRandomTagBit</anchor>()
    assert GCR_EL1.RRND == '0';
    bits(16) lfsr = RGSR_EL1.SEED&lt;15:0&gt;;
    bit top = lfsr&lt;5&gt; EOR lfsr&lt;3&gt; EOR lfsr&lt;2&gt; EOR lfsr&lt;0&gt;;
    RGSR_EL1.SEED&lt;15:0&gt; = top:lfsr&lt;15:1&gt;;
    return top;</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.RandomTag" mylink="aarch64.functions.system.AArch64.RandomTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.RandomTag()
// ===================
// Generate a random Allocation Tag.

bits(4) <anchor link="AArch64.RandomTag.0" hover="function: bits(4) AArch64.RandomTag()">AArch64.RandomTag</anchor>()
    bits(4) tag;
    for i = 0 to 3
        tag&lt;i&gt; = <a link="AArch64.NextRandomTagBit.0" file="shared_pseudocode.xml" hover="function: bit AArch64.NextRandomTagBit()">AArch64.NextRandomTagBit</a>();
    return tag;</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.SysInstr" mylink="aarch64.functions.system.AArch64.SysInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysInstr()
// ==================
// Execute a system instruction with write (source operand).

<anchor link="AArch64.SysInstr.6" hover="function: AArch64.SysInstr(integer op0, integer op1, integer crn, integer crm, integer op2, integer t)">AArch64.SysInstr</anchor>(integer op0, integer op1, integer crn, integer crm, integer op2, integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.SysInstrWithResult" mylink="aarch64.functions.system.AArch64.SysInstrWithResult" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysInstrWithResult()
// ============================
// Execute a system instruction with read (result operand).
// Writes the result of the instruction to X[t].

<anchor link="AArch64.SysInstrWithResult.6" hover="function: AArch64.SysInstrWithResult(integer op0, integer op1, integer crn, integer crm, integer op2, integer t)">AArch64.SysInstrWithResult</anchor>(integer op0, integer op1, integer crn, integer crm, integer op2,
                           integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.SysRegRead" mylink="aarch64.functions.system.AArch64.SysRegRead" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysRegRead()
// ====================
// Read from a System register and write the contents of the register to X[t].

<anchor link="AArch64.SysRegRead.6" hover="function: AArch64.SysRegRead(integer op0, integer op1, integer crn, integer crm, integer op2, integer t)">AArch64.SysRegRead</anchor>(integer op0, integer op1, integer crn, integer crm, integer op2, integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/AArch64.SysRegWrite" mylink="aarch64.functions.system.AArch64.SysRegWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysRegWrite()
// =====================
// Write to a System register.

<anchor link="AArch64.SysRegWrite.6" hover="function: AArch64.SysRegWrite(integer op0, integer op1, integer crn, integer crm, integer op2, integer t)">AArch64.SysRegWrite</anchor>(integer op0, integer op1, integer crn, integer crm, integer op2, integer t);</pstext>
    </ps>
    <ps name="aarch64/functions/system/BTypeCompatible" mylink="aarch64.functions.system.BTypeCompatible" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">boolean BTypeCompatible;</pstext>
    </ps>
    <ps name="aarch64/functions/system/BTypeCompatible_BTI" mylink="aarch64.functions.system.BTypeCompatible_BTI" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BTypeCompatible_BTI
// ===================
// This function determines whether a given hint encoding is compatible with the current value of
// PSTATE.BTYPE. A value of TRUE here indicates a valid Branch Target Identification instruction.

boolean <anchor link="impl-aarch64.BTypeCompatible_BTI.1" hover="function: boolean BTypeCompatible_BTI(bits(2) hintcode)">BTypeCompatible_BTI</anchor>(bits(2) hintcode)
    case hintcode of
        when '00'
            return FALSE;
        when '01'
            return PSTATE.BTYPE != '11';
        when '10'
            return PSTATE.BTYPE != '10';
        when '11'
            return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/system/BTypeCompatible_PACIXSP" mylink="aarch64.functions.system.BTypeCompatible_PACIXSP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BTypeCompatible_PACIXSP()
// =========================
// Returns TRUE if PACIASP, PACIBSP instruction is implicit compatible with PSTATE.BTYPE,
// FALSE otherwise.

boolean <anchor link="impl-aarch64.BTypeCompatible_PACIXSP.0" hover="function: boolean BTypeCompatible_PACIXSP()">BTypeCompatible_PACIXSP</anchor>()
    if PSTATE.BTYPE IN {'01', '10'} then
        return TRUE;
    elsif PSTATE.BTYPE == '11' then
        index = if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then 35 else 36;
        return <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[]&lt;index&gt; == '0';
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/functions/system/BTypeNext" mylink="aarch64.functions.system.BTypeNext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(2) BTypeNext;</pstext>
    </ps>
    <ps name="aarch64/functions/system/ChooseRandomNonExcludedTag" mylink="aarch64.functions.system.ChooseRandomNonExcludedTag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ChooseRandomNonExcludedTag()
// ============================
// The ChooseRandomNonExcludedTag function is used when GCR_EL1.RRND == '1' to generate random
// Allocation Tags.
//
// The resulting Allocation Tag is selected from the set [0,15], excluding any Allocation Tag where
// exclude[tag_value] == 1. If 'exclude' is all Ones, the returned Allocation Tag is '0000'.
//
// This function is permitted to generate a non-deterministic selection from the set of non-excluded
// Allocation Tags. A reasonable implementation is described by the Pseudocode used when
// GCR_EL1.RRND is 0, but with a non-deterministic implementation of NextRandomTagBit().
// Implementations may choose to behave the same as GCR_EL1.RRND=0.
//
// This function can read RGSR_EL1 and/or write RGSR_EL1 to an IMPLEMENTATION DEFINED value.
// If it is not capable of writing RGSR_EL1.SEED[15:0] to zero from a previous non-zero
// RGSR_EL1.SEED value, it is IMPLEMENTATION DEFINED whether the randomness is significantly
// impacted if RGSR_EL1.SEED[15:0] is set to zero.

bits(4) <anchor link="impl-aarch64.ChooseRandomNonExcludedTag.1" hover="function: bits(4) ChooseRandomNonExcludedTag(bits(16) exclude_in)">ChooseRandomNonExcludedTag</anchor>(bits(16) exclude_in);</pstext>
    </ps>
    <ps name="aarch64/functions/system/InGuardedPage" mylink="aarch64.functions.system.InGuardedPage" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">boolean InGuardedPage;</pstext>
    </ps>
    <ps name="aarch64/functions/system/IsHCRXEL2Enabled" mylink="aarch64.functions.system.IsHCRXEL2Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsHCRXEL2Enabled()
// ==================
// Returns TRUE if access to HCRX_EL2 register is enabled, and FALSE otherwise.
// Indirect read of HCRX_EL2 returns 0 when access is not enabled.

boolean <anchor link="impl-aarch64.IsHCRXEL2Enabled.0" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</anchor>()
    if !<a link="impl-shared.HaveFeatHCX.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatHCX()">HaveFeatHCX</a>() then return FALSE;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.HXEn == '0' then
        return FALSE;

    return <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/system/IsSCTLR2EL1Enabled" mylink="aarch64.functions.system.IsSCTLR2EL1Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSCTLR2EL1Enabled()
// ====================
// Returns TRUE if access to SCTLR2_EL1 register is enabled, and FALSE otherwise.
// Indirect read of SCTLR2_EL1 returns 0 when access is not enabled.

boolean <anchor link="impl-aarch64.IsSCTLR2EL1Enabled.0" hover="function: boolean IsSCTLR2EL1Enabled()">IsSCTLR2EL1Enabled</anchor>()
    if !<a link="impl-shared.HaveFeatSCTLR2.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatSCTLR2()">HaveFeatSCTLR2</a>() then return FALSE;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.SCTLR2En == '0' then
        return FALSE;
    elsif (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; (!<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.SCTLR2En == '0')) then
        return FALSE;
    else
        return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/system/IsSCTLR2EL2Enabled" mylink="aarch64.functions.system.IsSCTLR2EL2Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSCTLR2EL2Enabled()
// ====================
// Returns TRUE if access to SCTLR2_EL2 register is enabled, and FALSE otherwise.
// Indirect read of SCTLR2_EL2 returns 0 when access is not enabled.

boolean <anchor link="impl-aarch64.IsSCTLR2EL2Enabled.0" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</anchor>()
    if !<a link="impl-shared.HaveFeatSCTLR2.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatSCTLR2()">HaveFeatSCTLR2</a>() then return FALSE;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.SCTLR2En == '0' then
        return FALSE;

    return <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/system/IsTCR2EL1Enabled" mylink="aarch64.functions.system.IsTCR2EL1Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsTCR2EL1Enabled()
// ==================
// Returns TRUE if access to TCR2_EL1 register is enabled, and FALSE otherwise.
// Indirect read of TCR2_EL1 returns 0 when access is not enabled.

boolean <anchor link="impl-aarch64.IsTCR2EL1Enabled.0" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</anchor>()
    if !<a link="impl-shared.HaveFeatTCR2.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatTCR2()">HaveFeatTCR2</a>() then return FALSE;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.TCR2En == '0' then
        return FALSE;
    elsif (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; (!<a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() || HCRX_EL2.TCR2En == '0')) then
        return FALSE;
    else
        return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/system/IsTCR2EL2Enabled" mylink="aarch64.functions.system.IsTCR2EL2Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsTCR2EL2Enabled()
// ==================
// Returns TRUE if access to TCR2_EL2 register is enabled, and FALSE otherwise.
// Indirect read of TCR2_EL2 returns 0 when access is not enabled.

boolean <anchor link="impl-aarch64.IsTCR2EL2Enabled.0" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</anchor>()
    if !<a link="impl-shared.HaveFeatTCR2.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatTCR2()">HaveFeatTCR2</a>() then return FALSE;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.TCR2En == '0' then
        return FALSE;

    return <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();</pstext>
    </ps>
    <ps name="aarch64/functions/system/SetBTypeCompatible" mylink="aarch64.functions.system.SetBTypeCompatible" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetBTypeCompatible()
// ====================
// Sets the value of BTypeCompatible global variable used by BTI

<anchor link="impl-aarch64.SetBTypeCompatible.1" hover="function: SetBTypeCompatible(boolean x)">SetBTypeCompatible</anchor>(boolean x)
    BTypeCompatible = x;</pstext>
    </ps>
    <ps name="aarch64/functions/system/SetBTypeNext" mylink="aarch64.functions.system.SetBTypeNext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetBTypeNext()
// ==============
// Set the value of BTypeNext global variable used by BTI

<anchor link="impl-aarch64.SetBTypeNext.1" hover="function: SetBTypeNext(bits(2) x)">SetBTypeNext</anchor>(bits(2) x)
    BTypeNext = x;</pstext>
    </ps>
    <ps name="aarch64/functions/system/SetInGuardedPage" mylink="aarch64.functions.system.SetInGuardedPage" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetInGuardedPage()
// ==================
// Global state updated to denote if memory access is from a guarded page.

<anchor link="impl-aarch64.SetInGuardedPage.1" hover="function: SetInGuardedPage(boolean guardedpage)">SetInGuardedPage</anchor>(boolean guardedpage)
    InGuardedPage = guardedpage;</pstext>
    </ps>
    <ps name="aarch64/functions/system128/AArch64.SysInstr128" mylink="aarch64.functions.system128.AArch64.SysInstr128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysInstr128()
// =====================
// Execute a system instruction with write (2 64-bit source operands).

<anchor link="AArch64.SysInstr128.7" hover="function: AArch64.SysInstr128(integer op0, integer op1, integer crn, integer crm, integer op2, integer t, integer t2)">AArch64.SysInstr128</anchor>(integer op0, integer op1, integer crn, integer crm,
                    integer op2, integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch64/functions/system128/AArch64.SysRegRead128" mylink="aarch64.functions.system128.AArch64.SysRegRead128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysRegRead128()
// =======================
// Read from a 128-bit System register and write the contents of the register to X[t] and X[t2].

<anchor link="AArch64.SysRegRead128.7" hover="function: AArch64.SysRegRead128(integer op0, integer op1, integer crn, integer crm, integer op2, integer t, integer t2)">AArch64.SysRegRead128</anchor>(integer op0, integer op1, integer crn, integer crm,
                      integer op2, integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch64/functions/system128/AArch64.SysRegWrite128" mylink="aarch64.functions.system128.AArch64.SysRegWrite128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SysRegWrite128()
// ========================
// Read the contents of X[t] and X[t2] and write the contents to a 128-bit System register.

<anchor link="AArch64.SysRegWrite128.7" hover="function: AArch64.SysRegWrite128(integer op0, integer op1, integer crn, integer crm, integer op2, integer t, integer t2)">AArch64.SysRegWrite128</anchor>(integer op0, integer op1, integer crn, integer crm,
                       integer op2, integer t, integer t2);</pstext>
    </ps>
    <ps name="aarch64/functions/tme/CheckTransactionalSystemAccess" mylink="aarch64.functions.tme.CheckTransactionalSystemAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckTransactionalSystemAccess()
// ================================
// Returns TRUE if an AArch64 MSR, MRS, or SYS instruction is permitted in
// Transactional state, based on the opcode's encoding, and FALSE otherwise.

boolean <anchor link="impl-aarch64.CheckTransactionalSystemAccess.6" hover="function: boolean CheckTransactionalSystemAccess(bits(2) op0, bits(3) op1, bits(4) crn, bits(4) crm, bits(3) op2, bit read)">CheckTransactionalSystemAccess</anchor>(bits(2) op0, bits(3) op1, bits(4) crn, bits(4) crm,
                                       bits(3) op2, bit read)
    case read:op0:op1:crn:crm:op2 of
        when '0 00 011 0100 xxxx 11x' return TRUE;      // MSR (imm): DAIFSet, DAIFClr
        when '0 01 011 0111 0100 001' return TRUE;      // DC ZVA
        when '0 11 011 0100 0010 00x' return TRUE;      // MSR: NZCV, DAIF
        when '0 11 011 0100 0100 00x' return TRUE;      // MSR: FPCR, FPSR
        when '0 11 000 0100 0110 000' return TRUE;      // MSR: ICC_PMR_EL1
        when '0 11 011 1001 1100 100' return TRUE;      // MRS: PMSWINC_EL0
        when '1 11 xxx 0xxx xxxx xxx' return TRUE;      // MRS: op1=3, CRn=0..7
        when '1 11 xxx 100x xxxx xxx' return TRUE;      // MRS: op1=3, CRn=8..9
        when '1 11 xxx 1010 xxxx xxx' return TRUE;      // MRS: op1=3, CRn=10
        when '1 11 000 1100 1x00 010' return TRUE;      // MRS: op1=3, CRn=12 - ICC_HPPIRx_EL1
        when '1 11 000 1100 1011 011' return TRUE;      // MRS: op1=3, CRn=12 - ICC_RPR_EL1
        when '1 11 xxx 1101 xxxx xxx' return TRUE;      // MRS: op1=3, CRn=13
        when '1 11 xxx 1110 xxxx xxx' return TRUE;      // MRS: op1=3, CRn=14
        when '0 01 011 0111 0011 111' return TRUE;      // CPP RCTX
        when '0 01 011 0111 0011 10x' return TRUE;      // CFP RCTX, DVP RCTX
        when '1 11 011 0010 0101 001' return PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;     // MRS: GCSPR_EL0, at EL0
        // MRS: GCSPR_EL1 at EL1 OR at EL2 when E2H is '1'
        when '1 11 000 0010 0101 001'
            return (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> || (PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; HCR_EL2.E2H == '1'));
        // MRS: GCSPR_EL2, at EL2 when E2H is '0'
        when '1 11 100 0010 0101 001' return PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; HCR_EL2.E2H == '0';
        when '1 11 110 0010 0101 001' return PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;     // MRS: GCSPR_EL3, at EL3
        when '0 01 011 0111 0111 000' return TRUE;     // GCSPUSHM
        when '1 01 011 0111 0111 001' return TRUE;     // GCSPOPM
        when '0 01 011 0111 0111 010' return TRUE;     // GCSSS1
        when '1 01 011 0111 0111 011' return TRUE;     // GCSSS2
        when '0 01 000 0111 0111 110' return TRUE;     // GCSPOPX
        when 'x 11 xxx 1x11 xxxx xxx'                   // MRS: op1=3, CRn=11,15
            return boolean IMPLEMENTATION_DEFINED;
        otherwise return FALSE;                         // all other SYS, SYSL, MRS, MSR</pstext>
    </ps>
    <ps name="aarch64/functions/tme/CommitTransactionalWrites" mylink="aarch64.functions.tme.CommitTransactionalWrites" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CommitTransactionalWrites()
// ===========================
// Makes all transactional writes to memory observable by other PEs and reset
// the transactional read and write sets.

<anchor link="impl-aarch64.CommitTransactionalWrites.0" hover="function: CommitTransactionalWrites()">CommitTransactionalWrites</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/tme/DiscardTransactionalWrites" mylink="aarch64.functions.tme.DiscardTransactionalWrites" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DiscardTransactionalWrites()
// ============================
// Discards all transactional writes to memory and reset the transactional
// read and write sets.

<anchor link="impl-aarch64.DiscardTransactionalWrites.0" hover="function: DiscardTransactionalWrites()">DiscardTransactionalWrites</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/tme/FailTransaction" mylink="aarch64.functions.tme.FailTransaction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FailTransaction()
// =================

<anchor link="impl-aarch64.FailTransaction.2" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</anchor>(<a link="TMFailure" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure</a> cause, boolean retry)
    <a link="impl-aarch64.FailTransaction.4" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry, boolean interrupt, bits(15) reason)">FailTransaction</a>(cause, retry, FALSE, <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(15));
    return;

// FailTransaction()
// =================
// Exits Transactional state and discards transactional updates to registers
// and memory.

<anchor link="impl-aarch64.FailTransaction.4" hover="function: FailTransaction(TMFailure cause, boolean retry, boolean interrupt, bits(15) reason)">FailTransaction</anchor>(<a link="TMFailure" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure</a> cause, boolean retry, boolean interrupt, bits(15) reason)
    assert !retry || !interrupt;

    if <a link="impl-shared.HaveBRBExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBExt()">HaveBRBExt</a>() &amp;&amp; <a link="impl-aarch64.BranchRecordAllowed.1" file="shared_pseudocode.xml" hover="function: boolean BranchRecordAllowed(bits(2) el)">BranchRecordAllowed</a>(PSTATE.EL) then BRBFCR_EL1.LASTFAILED = '1';

    <a link="impl-aarch64.DiscardTransactionalWrites.0" file="shared_pseudocode.xml" hover="function: DiscardTransactionalWrites()">DiscardTransactionalWrites</a>();
    // For trivial implementation no transaction checkpoint was taken
    if cause != <a link="TMFailure_TRIVIAL" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_TRIVIAL</a> then
        <a link="impl-aarch64.RestoreTransactionCheckpoint.0" file="shared_pseudocode.xml" hover="function: RestoreTransactionCheckpoint()">RestoreTransactionCheckpoint</a>();
    <a link="impl-shared.ClearExclusiveLocal.1" file="shared_pseudocode.xml" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</a>(<a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>());

    bits(64) result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

    result&lt;23&gt; = if interrupt then '1' else '0';
    result&lt;15&gt; = if retry &amp;&amp; !interrupt then '1' else '0';
    case cause of
        when <a link="TMFailure_TRIVIAL" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_TRIVIAL</a> result&lt;24&gt; = '1';
        when <a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>     result&lt;22&gt; = '1';
        when <a link="TMFailure_NEST" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_NEST</a>    result&lt;21&gt; = '1';
        when <a link="TMFailure_SIZE" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_SIZE</a>    result&lt;20&gt; = '1';
        when <a link="TMFailure_ERR" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</a>     result&lt;19&gt; = '1';
        when <a link="TMFailure_IMP" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_IMP</a>     result&lt;18&gt; = '1';
        when <a link="TMFailure_MEM" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_MEM</a>     result&lt;17&gt; = '1';
        when <a link="TMFailure_CNCL" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_CNCL</a>    result&lt;16&gt; = '1'; result&lt;14:0&gt; = reason;

    TSTATE.depth = 0;
    <a link="impl-aarch64.X.write.2" file="shared_pseudocode.xml" hover="accessor: X[integer n, integer width] = bits(width) value">X</a>[TSTATE.Rt, 64] = result;
    boolean branch_conditional = FALSE;
    <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(TSTATE.nPC, <a link="BranchType_TMFAIL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_TMFAIL</a>, branch_conditional);
    <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    return;</pstext>
    </ps>
    <ps name="aarch64/functions/tme/IsTMEEnabled" mylink="aarch64.functions.tme.IsTMEEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsTMEEnabled()
// ==============
// Returns TRUE if access to TME instruction is enabled, FALSE otherwise.

boolean <anchor link="impl-aarch64.IsTMEEnabled.0" hover="function: boolean IsTMEEnabled()">IsTMEEnabled</anchor>()
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>} &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if SCR_EL3.TME == '0' then
            return FALSE;
    if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if HCR_EL2.TME == '0' then
            return FALSE;
    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/functions/tme/MemHasTransactionalAccess" mylink="aarch64.functions.tme.MemHasTransactionalAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemHasTransactionalAccess()
// ===========================
// Function checks if transactional accesses are not supported for an address
// range or memory type.

boolean <anchor link="impl-aarch64.MemHasTransactionalAccess.1" hover="function: boolean MemHasTransactionalAccess(MemoryAttributes memattrs)">MemHasTransactionalAccess</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if ((memattrs.shareability == <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a> ||
            memattrs.shareability == <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>) &amp;&amp;
            memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp;
            memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
            memattrs.inner.hints == <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a> &amp;&amp;
            memattrs.inner.transient == FALSE &amp;&amp;
            memattrs.outer.hints == <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a> &amp;&amp;
            memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
            memattrs.outer.transient == FALSE) then
        return TRUE;
    else
        return boolean IMPLEMENTATION_DEFINED "Memory Region does not support Transactional access";</pstext>
    </ps>
    <ps name="aarch64/functions/tme/RestoreTransactionCheckpoint" mylink="aarch64.functions.tme.RestoreTransactionCheckpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RestoreTransactionCheckpoint()
// ==============================
// Restores part of the PE registers from the transaction checkpoint.

<anchor link="impl-aarch64.RestoreTransactionCheckpoint.0" hover="function: RestoreTransactionCheckpoint()">RestoreTransactionCheckpoint</anchor>()
    <a link="impl-aarch64.SP.write.0" file="shared_pseudocode.xml" hover="accessor: SP[] = bits(64) value">SP</a>[]             = TSTATE.SP;
    ICC_PMR_EL1      = TSTATE.ICC_PMR_EL1;
    PSTATE.&lt;N,Z,C,V&gt; = TSTATE.nzcv;
    PSTATE.&lt;D,A,I,F&gt; = TSTATE.&lt;D,A,I,F&gt;;

    for n = 0 to 30
        <a link="impl-aarch64.X.write.2" file="shared_pseudocode.xml" hover="accessor: X[integer n, integer width] = bits(width) value">X</a>[n, 64] = TSTATE.X[n];

    if <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(PSTATE.EL) then
        if <a link="impl-aarch64.IsSVEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsSVEEnabled(bits(2) el)">IsSVEEnabled</a>(PSTATE.EL) then
            constant integer VL = <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a>;
            constant integer PL = VL DIV 8;
            for n = 0 to 31
                <a link="impl-aarch64.Z.write.2" file="shared_pseudocode.xml" hover="accessor: Z[integer n, integer width] = bits(width) value">Z</a>[n, VL] = TSTATE.Z[n]&lt;VL-1:0&gt;;
            for n = 0 to 15
                <a link="impl-aarch64.P.write.2" file="shared_pseudocode.xml" hover="accessor: P[integer n, integer width] = bits(width) value">P</a>[n, PL] = TSTATE.P[n]&lt;PL-1:0&gt;;
            <a link="impl-aarch64.FFR.write.1" file="shared_pseudocode.xml" hover="accessor: FFR[integer width] = bits(width) value">FFR</a>[PL] = TSTATE.FFR&lt;PL-1:0&gt;;
        else
            for n = 0 to 31
                <a link="impl-aarch64.V.write.2" file="shared_pseudocode.xml" hover="accessor: V[integer n, integer width] = bits(width) value">V</a>[n, 128] = TSTATE.Z[n]&lt;127:0&gt;;
        FPCR = TSTATE.FPCR;
        FPSR = TSTATE.FPSR;

    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> GCSPR_EL0 = TSTATE.GCSPR_ELx;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> GCSPR_EL1 = TSTATE.GCSPR_ELx;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> GCSPR_EL2 = TSTATE.GCSPR_ELx;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> GCSPR_EL3 = TSTATE.GCSPR_ELx;

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/tme/StartTrackingTransactionalReadsWrites" mylink="aarch64.functions.tme.StartTrackingTransactionalReadsWrites" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StartTrackingTransactionalReadsWrites()
// =======================================
// Starts tracking transactional reads and writes to memory.

<anchor link="impl-aarch64.StartTrackingTransactionalReadsWrites.0" hover="function: StartTrackingTransactionalReadsWrites()">StartTrackingTransactionalReadsWrites</anchor>();</pstext>
    </ps>
    <ps name="aarch64/functions/tme/TMFailure" mylink="aarch64.functions.tme.TMFailure" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TMFailure
// =========
// Transactional failure causes

enumeration <anchor link="TMFailure" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure</anchor> {
    <anchor link="TMFailure_CNCL" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_CNCL</anchor>,    // Executed a TCANCEL instruction
    <anchor link="TMFailure_DBG" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</anchor>,     // A debug event was generated
    <anchor link="TMFailure_ERR" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</anchor>,     // A non-permissible operation was attempted
    <anchor link="TMFailure_NEST" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_NEST</anchor>,    // The maximum transactional nesting level was exceeded
    <anchor link="TMFailure_SIZE" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_SIZE</anchor>,    // The transactional read or write set limit was exceeded
    <anchor link="TMFailure_MEM" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_MEM</anchor>,     // A transactional conflict occurred
    <anchor link="TMFailure_TRIVIAL" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_TRIVIAL</anchor>, // Only a TRIVIAL version of TM is available
    <anchor link="TMFailure_IMP" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_IMP</anchor>      // Any other failure cause
};</pstext>
    </ps>
    <ps name="aarch64/functions/tme/TMState" mylink="aarch64.functions.tme.TMState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TMState
// =======
// Transactional execution state bits.
// There is no significance to the field order.

type TMState is (
    integer       depth,              // Transaction nesting depth
    integer       Rt,                 // TSTART destination register
    bits(64)      nPC,                // Fallback instruction address
    array[0..30] of bits(64)     X,   // General purpose registers
    array[0..31] of bits(<a link="MAX_VL" file="shared_pseudocode.xml" hover="constant integer MAX_VL = 2048">MAX_VL</a>) Z,   // Vector registers
    array[0..15] of bits(<a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>) P,   // Predicate registers
    bits(<a link="MAX_PL" file="shared_pseudocode.xml" hover="constant integer MAX_PL = 256">MAX_PL</a>)  FFR,                // First Fault Register
    bits(64)      SP,                 // Stack Pointer at current EL
    bits(64)      FPCR,               // Floating-point Control Register
    bits(64)      FPSR,               // Floating-point Status Register
    bits(64)      ICC_PMR_EL1,        // Interrupt Controller Interrupt Priority Mask Register
    bits(64)      GCSPR_ELx,          // GCS pointer for current EL
    bits(4)       nzcv,               // Condition flags
    bits(1)       D,                  // Debug mask bit
    bits(1)       A,                  // SError interrupt mask bit
    bits(1)       I,                  // IRQ mask bit
    bits(1)       F                   // FIQ mask bit
)</pstext>
    </ps>
    <ps name="aarch64/functions/tme/TSTATE" mylink="aarch64.functions.tme.TSTATE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">TMState TSTATE;</pstext>
    </ps>
    <ps name="aarch64/functions/tme/TakeTransactionCheckpoint" mylink="aarch64.functions.tme.TakeTransactionCheckpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TakeTransactionCheckpoint()
// ===========================
// Captures part of the PE registers into the transaction checkpoint.

<anchor link="impl-aarch64.TakeTransactionCheckpoint.0" hover="function: TakeTransactionCheckpoint()">TakeTransactionCheckpoint</anchor>()
    TSTATE.SP             = <a link="impl-aarch64.SP.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) SP[]">SP</a>[];
    TSTATE.ICC_PMR_EL1    = ICC_PMR_EL1;
    TSTATE.nzcv           = PSTATE.&lt;N,Z,C,V&gt;;
    TSTATE.&lt;D,A,I,F&gt;      = PSTATE.&lt;D,A,I,F&gt;;

    for n = 0 to 30
        TSTATE.X[n] = <a link="impl-aarch64.X.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) X[integer n, integer width]">X</a>[n, 64];

    if <a link="impl-aarch64.IsFPEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsFPEnabled(bits(2) el)">IsFPEnabled</a>(PSTATE.EL) then
        if <a link="impl-aarch64.IsSVEEnabled.1" file="shared_pseudocode.xml" hover="function: boolean IsSVEEnabled(bits(2) el)">IsSVEEnabled</a>(PSTATE.EL) then
            constant integer VL = <a link="impl-aarch64.CurrentVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentVL">CurrentVL</a>;
            constant integer PL = VL DIV 8;
            for n = 0 to 31
                TSTATE.Z[n]&lt;VL-1:0&gt; = <a link="impl-aarch64.Z.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) Z[integer n, integer width]">Z</a>[n, VL];
            for n = 0 to 15
                TSTATE.P[n]&lt;PL-1:0&gt; = <a link="impl-aarch64.P.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) P[integer n, integer width]">P</a>[n, PL];
            TSTATE.FFR&lt;PL-1:0&gt; = <a link="impl-aarch64.FFR.read.1" file="shared_pseudocode.xml" hover="accessor: bits(width) FFR[integer width]">FFR</a>[PL];
        else
            for n = 0 to 31
                TSTATE.Z[n]&lt;127:0&gt; = <a link="impl-aarch64.V.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) V[integer n, integer width]">V</a>[n, 128];
        TSTATE.FPCR = FPCR;
        TSTATE.FPSR = FPSR;

    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> TSTATE.GCSPR_ELx = GCSPR_EL0;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> TSTATE.GCSPR_ELx = GCSPR_EL1;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> TSTATE.GCSPR_ELx = GCSPR_EL2;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> TSTATE.GCSPR_ELx = GCSPR_EL3;

    return;</pstext>
    </ps>
    <ps name="aarch64/functions/tme/TransactionStartTrap" mylink="aarch64.functions.tme.TransactionStartTrap" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TransactionStartTrap()
// ======================
// Traps the execution of TSTART instruction.

<anchor link="impl-aarch64.TransactionStartTrap.1" hover="function: TransactionStartTrap(integer dreg)">TransactionStartTrap</anchor>(integer dreg)
    bits(2) targetEL;
    bits(64) preferred_exception_return = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    vect_offset = 0x0;

    exception = <a link="impl-shared.ExceptionSyndrome.1" file="shared_pseudocode.xml" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</a>(<a link="Exception_TSTARTAccessTrap" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_TSTARTAccessTrap</a>);
    exception.syndrome&lt;9:5&gt; = dreg&lt;4:0&gt;;

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        targetEL = PSTATE.EL;
    elsif <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
        targetEL = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        targetEL = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    <a link="AArch64.TakeException.4" file="shared_pseudocode.xml" hover="function: AArch64.TakeException(bits(2) target_el, ExceptionRecord exception_in, bits(64) preferred_exception_return, integer vect_offset_in)">AArch64.TakeException</a>(targetEL, exception, preferred_exception_return, vect_offset);</pstext>
    </ps>
    <ps name="aarch64/instrs/branch/eret/AArch64.ExceptionReturn" mylink="aarch64.instrs.branch.eret.AArch64.ExceptionReturn" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ExceptionReturn()
// =========================

<anchor link="AArch64.ExceptionReturn.2" hover="function: AArch64.ExceptionReturn(bits(64) new_pc_in, bits(64) spsr)">AArch64.ExceptionReturn</anchor>(bits(64) new_pc_in, bits(64) spsr)
    bits(64) new_pc = new_pc_in;
    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then
        <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_ERR" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</a>, FALSE);

    if <a link="impl-shared.HaveIESB.0" file="shared_pseudocode.xml" hover="function: boolean HaveIESB()">HaveIESB</a>() then
        sync_errors = <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].IESB == '1';
        if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() then
            sync_errors = sync_errors || (SCR_EL3.&lt;EA,NMEA&gt; == '11' &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        if sync_errors then
            <a link="impl-shared.SynchronizeErrors.0" file="shared_pseudocode.xml" hover="function: SynchronizeErrors()">SynchronizeErrors</a>();
            iesb_req = TRUE;
            <a link="impl-shared.TakeUnmaskedPhysicalSErrorInterrupts.1" file="shared_pseudocode.xml" hover="function: TakeUnmaskedPhysicalSErrorInterrupts(boolean iesb_req)">TakeUnmaskedPhysicalSErrorInterrupts</a>(iesb_req);
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();

    // Attempts to change to an illegal state will invoke the Illegal Execution state mechanism
    bits(2) source_el = PSTATE.EL;
    boolean illegal_psr_state = <a link="impl-shared.IllegalExceptionReturn.1" file="shared_pseudocode.xml" hover="function: boolean IllegalExceptionReturn(bits(N) spsr)">IllegalExceptionReturn</a>(spsr);
    <a link="impl-shared.SetPSTATEFromPSR.2" file="shared_pseudocode.xml" hover="function: SetPSTATEFromPSR(bits(N) spsr_in, boolean illegal_psr_state)">SetPSTATEFromPSR</a>(spsr, illegal_psr_state);
    <a link="impl-shared.ClearExclusiveLocal.1" file="shared_pseudocode.xml" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</a>(<a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>());
    <a link="impl-shared.SendEventLocal.0" file="shared_pseudocode.xml" hover="function: SendEventLocal()">SendEventLocal</a>();

    if illegal_psr_state &amp;&amp; spsr&lt;4&gt; == '1' then
        // If the exception return is illegal, PC[63:32,1:0] are UNKNOWN
        new_pc&lt;63:32&gt; = bits(32) UNKNOWN;
        new_pc&lt;1:0&gt; = bits(2) UNKNOWN;
    elsif <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then                // Return to AArch32
        // ELR_ELx[1:0] or ELR_ELx[0] are treated as being 0, depending on the
        // target instruction set state
        if PSTATE.T == '1' then
            new_pc&lt;0&gt; = '0';                 // T32
        else
            new_pc&lt;1:0&gt; = '00';              // A32
    else                                     // Return to AArch64
        // ELR_ELx[63:56] might include a tag
        new_pc = <a link="AArch64.BranchAddr.2" file="shared_pseudocode.xml" hover="function: bits(64) AArch64.BranchAddr(bits(64) vaddress, bits(2) el)">AArch64.BranchAddr</a>(new_pc, PSTATE.EL);

    if <a link="impl-shared.HaveBRBExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBExt()">HaveBRBExt</a>() then
        <a link="impl-aarch64.BRBEExceptionReturn.2" file="shared_pseudocode.xml" hover="function: BRBEExceptionReturn(bits(64) target_address_in, bits(2) source_el)">BRBEExceptionReturn</a>(new_pc, source_el);

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then <a link="impl-aarch64.ResetSVEState.0" file="shared_pseudocode.xml" hover="function: ResetSVEState()">ResetSVEState</a>();

        // 32 most significant bits are ignored.
        boolean branch_conditional = FALSE;
        <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(new_pc&lt;31:0&gt;, <a link="BranchType_ERET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_ERET</a>, branch_conditional);
    else
        <a link="impl-shared.BranchToAddr.2" file="shared_pseudocode.xml" hover="function: BranchToAddr(bits(N) target, BranchType branch_type)">BranchToAddr</a>(new_pc, <a link="BranchType_ERET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_ERET</a>);

    <a link="impl-shared.CheckExceptionCatch.1" file="shared_pseudocode.xml" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</a>(FALSE);              // Check for debug event on exception return</pstext>
    </ps>
    <ps name="aarch64/instrs/countop/CountOp" mylink="aarch64.instrs.countop.CountOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CountOp
// =======
// Bit counting instruction types.

enumeration <anchor link="CountOp" hover="enumeration CountOp     {CountOp_CLZ, CountOp_CLS, CountOp_CNT}">CountOp</anchor>     {<anchor link="CountOp_CLZ" hover="enumeration CountOp     {CountOp_CLZ, CountOp_CLS, CountOp_CNT}">CountOp_CLZ</anchor>, <anchor link="CountOp_CLS" hover="enumeration CountOp     {CountOp_CLZ, CountOp_CLS, CountOp_CNT}">CountOp_CLS</anchor>, <anchor link="CountOp_CNT" hover="enumeration CountOp     {CountOp_CLZ, CountOp_CLS, CountOp_CNT}">CountOp_CNT</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/extendreg/DecodeRegExtend" mylink="aarch64.instrs.extendreg.DecodeRegExtend" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeRegExtend()
// =================
// Decode a register extension option

ExtendType <anchor link="impl-aarch64.DecodeRegExtend.1" hover="function: ExtendType DecodeRegExtend(bits(3) op)">DecodeRegExtend</anchor>(bits(3) op)
    case op of
        when '000' return <a link="ExtendType_UXTB" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTB</a>;
        when '001' return <a link="ExtendType_UXTH" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTH</a>;
        when '010' return <a link="ExtendType_UXTW" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTW</a>;
        when '011' return <a link="ExtendType_UXTX" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTX</a>;
        when '100' return <a link="ExtendType_SXTB" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTB</a>;
        when '101' return <a link="ExtendType_SXTH" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTH</a>;
        when '110' return <a link="ExtendType_SXTW" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTW</a>;
        when '111' return <a link="ExtendType_SXTX" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTX</a>;</pstext>
    </ps>
    <ps name="aarch64/instrs/extendreg/ExtendReg" mylink="aarch64.instrs.extendreg.ExtendReg" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExtendReg()
// ===========
// Perform a register extension and shift

bits(N) <anchor link="impl-aarch64.ExtendReg.4" hover="function: bits(N) ExtendReg(integer reg, ExtendType exttype, integer shift, integer N)">ExtendReg</anchor>(integer reg, <a link="ExtendType" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType</a> exttype, integer shift, integer N)
    assert shift &gt;= 0 &amp;&amp; shift &lt;= 4;
    bits(N) val = <a link="impl-aarch64.X.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) X[integer n, integer width]">X</a>[reg, N];
    boolean unsigned;
    integer len;

    case exttype of
        when <a link="ExtendType_SXTB" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTB</a> unsigned = FALSE; len = 8;
        when <a link="ExtendType_SXTH" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTH</a> unsigned = FALSE; len = 16;
        when <a link="ExtendType_SXTW" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTW</a> unsigned = FALSE; len = 32;
        when <a link="ExtendType_SXTX" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTX</a> unsigned = FALSE; len = 64;
        when <a link="ExtendType_UXTB" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTB</a> unsigned = TRUE;  len = 8;
        when <a link="ExtendType_UXTH" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTH</a> unsigned = TRUE;  len = 16;
        when <a link="ExtendType_UXTW" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTW</a> unsigned = TRUE;  len = 32;
        when <a link="ExtendType_UXTX" file="shared_pseudocode.xml" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTX</a> unsigned = TRUE;  len = 64;

    // Note the extended width of the intermediate value and
    // that sign extension occurs from bit &lt;len+shift-1&gt;, not
    // from bit &lt;len-1&gt;. This is equivalent to the instruction
    //   [SU]BFIZ Rtmp, Rreg, #shift, #len
    // It may also be seen as a sign/zero extend followed by a shift:
    //   LSL(Extend(val&lt;len-1:0&gt;, N, unsigned), shift);

    len = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(len, N - shift);
    return <a link="impl-shared.Extend.3" file="shared_pseudocode.xml" hover="function: bits(N) Extend(bits(M) x, integer N, boolean unsigned)">Extend</a>(val&lt;len-1:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(shift), N, unsigned);</pstext>
    </ps>
    <ps name="aarch64/instrs/extendreg/ExtendType" mylink="aarch64.instrs.extendreg.ExtendType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExtendType
// ==========
// AArch64 register extend and shift.

enumeration <anchor link="ExtendType" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType</anchor>  {<anchor link="ExtendType_SXTB" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTB</anchor>, <anchor link="ExtendType_SXTH" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTH</anchor>, <anchor link="ExtendType_SXTW" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTW</anchor>, <anchor link="ExtendType_SXTX" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_SXTX</anchor>,
                         <anchor link="ExtendType_UXTB" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTB</anchor>, <anchor link="ExtendType_UXTH" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTH</anchor>, <anchor link="ExtendType_UXTW" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTW</anchor>, <anchor link="ExtendType_UXTX" hover="enumeration ExtendType  {ExtendType_SXTB, ExtendType_SXTH, ExtendType_SXTW, ExtendType_SXTX, ExtendType_UXTB, ExtendType_UXTH, ExtendType_UXTW, ExtendType_UXTX}">ExtendType_UXTX</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/float/arithmetic/max-min/fpmaxminop/FPMaxMinOp" mylink="aarch64.instrs.float.arithmetic.max-min.fpmaxminop.FPMaxMinOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMaxMinOp
// ==========
// Floating-point min/max instruction types.

enumeration <anchor link="FPMaxMinOp" hover="enumeration FPMaxMinOp  {FPMaxMinOp_MAX, FPMaxMinOp_MIN, FPMaxMinOp_MAXNUM, FPMaxMinOp_MINNUM}">FPMaxMinOp</anchor>  {<anchor link="FPMaxMinOp_MAX" hover="enumeration FPMaxMinOp  {FPMaxMinOp_MAX, FPMaxMinOp_MIN, FPMaxMinOp_MAXNUM, FPMaxMinOp_MINNUM}">FPMaxMinOp_MAX</anchor>, <anchor link="FPMaxMinOp_MIN" hover="enumeration FPMaxMinOp  {FPMaxMinOp_MAX, FPMaxMinOp_MIN, FPMaxMinOp_MAXNUM, FPMaxMinOp_MINNUM}">FPMaxMinOp_MIN</anchor>,
                         <anchor link="FPMaxMinOp_MAXNUM" hover="enumeration FPMaxMinOp  {FPMaxMinOp_MAX, FPMaxMinOp_MIN, FPMaxMinOp_MAXNUM, FPMaxMinOp_MINNUM}">FPMaxMinOp_MAXNUM</anchor>, <anchor link="FPMaxMinOp_MINNUM" hover="enumeration FPMaxMinOp  {FPMaxMinOp_MAX, FPMaxMinOp_MIN, FPMaxMinOp_MAXNUM, FPMaxMinOp_MINNUM}">FPMaxMinOp_MINNUM</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/float/arithmetic/unary/fpunaryop/FPUnaryOp" mylink="aarch64.instrs.float.arithmetic.unary.fpunaryop.FPUnaryOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPUnaryOp
// =========
// Floating-point unary instruction types.

enumeration <anchor link="FPUnaryOp" hover="enumeration FPUnaryOp   {FPUnaryOp_ABS, FPUnaryOp_MOV, FPUnaryOp_NEG, FPUnaryOp_SQRT}">FPUnaryOp</anchor>   {<anchor link="FPUnaryOp_ABS" hover="enumeration FPUnaryOp   {FPUnaryOp_ABS, FPUnaryOp_MOV, FPUnaryOp_NEG, FPUnaryOp_SQRT}">FPUnaryOp_ABS</anchor>, <anchor link="FPUnaryOp_MOV" hover="enumeration FPUnaryOp   {FPUnaryOp_ABS, FPUnaryOp_MOV, FPUnaryOp_NEG, FPUnaryOp_SQRT}">FPUnaryOp_MOV</anchor>,
                         <anchor link="FPUnaryOp_NEG" hover="enumeration FPUnaryOp   {FPUnaryOp_ABS, FPUnaryOp_MOV, FPUnaryOp_NEG, FPUnaryOp_SQRT}">FPUnaryOp_NEG</anchor>, <anchor link="FPUnaryOp_SQRT" hover="enumeration FPUnaryOp   {FPUnaryOp_ABS, FPUnaryOp_MOV, FPUnaryOp_NEG, FPUnaryOp_SQRT}">FPUnaryOp_SQRT</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/float/convert/fpconvop/FPConvOp" mylink="aarch64.instrs.float.convert.fpconvop.FPConvOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPConvOp
// ========
// Floating-point convert/move instruction types.

enumeration <anchor link="FPConvOp" hover="enumeration FPConvOp    {FPConvOp_CVT_FtoI, FPConvOp_CVT_ItoF, FPConvOp_MOV_FtoI, FPConvOp_MOV_ItoF , FPConvOp_CVT_FtoI_JS }">FPConvOp</anchor>    {<anchor link="FPConvOp_CVT_FtoI" hover="enumeration FPConvOp    {FPConvOp_CVT_FtoI, FPConvOp_CVT_ItoF, FPConvOp_MOV_FtoI, FPConvOp_MOV_ItoF , FPConvOp_CVT_FtoI_JS }">FPConvOp_CVT_FtoI</anchor>, <anchor link="FPConvOp_CVT_ItoF" hover="enumeration FPConvOp    {FPConvOp_CVT_FtoI, FPConvOp_CVT_ItoF, FPConvOp_MOV_FtoI, FPConvOp_MOV_ItoF , FPConvOp_CVT_FtoI_JS }">FPConvOp_CVT_ItoF</anchor>,
                         <anchor link="FPConvOp_MOV_FtoI" hover="enumeration FPConvOp    {FPConvOp_CVT_FtoI, FPConvOp_CVT_ItoF, FPConvOp_MOV_FtoI, FPConvOp_MOV_ItoF , FPConvOp_CVT_FtoI_JS }">FPConvOp_MOV_FtoI</anchor>, <anchor link="FPConvOp_MOV_ItoF" hover="enumeration FPConvOp    {FPConvOp_CVT_FtoI, FPConvOp_CVT_ItoF, FPConvOp_MOV_FtoI, FPConvOp_MOV_ItoF , FPConvOp_CVT_FtoI_JS }">FPConvOp_MOV_ItoF</anchor>
                         , <anchor link="FPConvOp_CVT_FtoI_JS" hover="enumeration FPConvOp    {FPConvOp_CVT_FtoI, FPConvOp_CVT_ItoF, FPConvOp_MOV_FtoI, FPConvOp_MOV_ItoF , FPConvOp_CVT_FtoI_JS }">FPConvOp_CVT_FtoI_JS</anchor>
};</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/bitfield/bfxpreferred/BFXPreferred" mylink="aarch64.instrs.integer.bitfield.bfxpreferred.BFXPreferred" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFXPreferred()
// ==============
//
// Return TRUE if UBFX or SBFX is the preferred disassembly of a
// UBFM or SBFM bitfield instruction. Must exclude more specific
// aliases UBFIZ, SBFIZ, UXT[BH], SXT[BHW], LSL, LSR and ASR.

boolean <anchor link="impl-aarch64.BFXPreferred.4" hover="function: boolean BFXPreferred(bit sf, bit uns, bits(6) imms, bits(6) immr)">BFXPreferred</anchor>(bit sf, bit uns, bits(6) imms, bits(6) immr)

    // must not match UBFIZ/SBFIX alias
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imms) &lt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(immr) then
        return FALSE;

    // must not match LSR/ASR/LSL alias (imms == 31 or 63)
    if imms == sf:'11111' then
        return FALSE;

    // must not match UXTx/SXTx alias
    if immr == '000000' then
        // must not match 32-bit UXT[BH] or SXT[BH]
        if sf == '0' &amp;&amp; imms IN {'000111', '001111'} then
            return FALSE;
        // must not match 64-bit SXT[BHW]
        if sf:uns == '10' &amp;&amp; imms IN {'000111', '001111', '011111'} then
            return FALSE;

    // must be UBFX/SBFX alias
    return TRUE;</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/bitmasks/AltDecodeBitMasks" mylink="aarch64.instrs.integer.bitmasks.AltDecodeBitMasks" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AltDecodeBitMasks()
// ===================
// Alternative but logically equivalent implementation of DecodeBitMasks() that
// uses simpler primitives to compute tmask and wmask.

(bits(M), bits(M)) <anchor link="impl-aarch64.AltDecodeBitMasks.5" hover="function: (bits(M), bits(M)) AltDecodeBitMasks(bit immN, bits(6) imms, bits(6) immr, boolean immediate, integer M)">AltDecodeBitMasks</anchor>(bit immN, bits(6) imms, bits(6) immr,
                                     boolean immediate, integer M)
    bits(64) tmask, wmask;
    bits(6) tmask_and, wmask_and;
    bits(6) tmask_or, wmask_or;
    bits(6) levels;

    // Compute log2 of element size
    // 2^len must be in range [2, M]
    len = <a link="impl-shared.HighestSetBit.1" file="shared_pseudocode.xml" hover="function: integer HighestSetBit(bits(N) x)">HighestSetBit</a>(immN:NOT(imms));
    if len &lt; 1 then UNDEFINED;
    assert M &gt;= (1 &lt;&lt; len);

    // Determine s, r and s - r parameters
    levels = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(len), 6);

    // For logical immediates an all-ones value of s is reserved
    // since it would generate a useless all-ones result (many times)
    if immediate &amp;&amp; (imms AND levels) == levels then
        UNDEFINED;

    s = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imms AND levels);
    r = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(immr AND levels);
    diff = s - r;    // 6-bit subtract with borrow

    // Compute "top mask"
    tmask_and = diff&lt;5:0&gt; OR NOT(levels);
    tmask_or  = diff&lt;5:0&gt; AND levels;

    tmask = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(64);
    tmask = ((tmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_and&lt;0&gt;, 1) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(1), 32))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(1) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_or&lt;0&gt;, 1), 32));
    // optimization of first step:
    // tmask = Replicate(tmask_and&lt;0&gt; : '1', 32);
    tmask = ((tmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_and&lt;1&gt;, 2) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(2), 16))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(2) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_or&lt;1&gt;, 2), 16));
    tmask = ((tmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_and&lt;2&gt;, 4) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(4), 8))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(4) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_or&lt;2&gt;, 4), 8));
    tmask = ((tmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_and&lt;3&gt;, 8) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(8), 4))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_or&lt;3&gt;, 8), 4));
    tmask = ((tmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_and&lt;4&gt;, 16) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(16), 2))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_or&lt;4&gt;, 16), 2));
    tmask = ((tmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_and&lt;5&gt;, 32) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(32), 1))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(tmask_or&lt;5&gt;, 32), 1));

    // Compute "wraparound mask"
    wmask_and = immr OR NOT(levels);
    wmask_or  = immr AND levels;

    wmask = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    wmask = ((wmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(1) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_and&lt;0&gt;, 1), 32))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_or&lt;0&gt;, 1) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(1), 32));
    // optimization of first step:
    // wmask = Replicate(wmask_or&lt;0&gt; : '0', 32);
    wmask = ((wmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(2) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_and&lt;1&gt;, 2), 16))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_or&lt;1&gt;, 2) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(2), 16));
    wmask = ((wmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(4) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_and&lt;2&gt;, 4), 8))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_or&lt;2&gt;, 4) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(4), 8));
    wmask = ((wmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(8) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_and&lt;3&gt;, 8), 4))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_or&lt;3&gt;, 8) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8), 4));
    wmask = ((wmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(16) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_and&lt;4&gt;, 16), 2))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_or&lt;4&gt;, 16) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16), 2));
    wmask = ((wmask
              AND <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(32) : <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_and&lt;5&gt;, 32), 1))
               OR  <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(wmask_or&lt;5&gt;, 32) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32), 1));

    if diff&lt;6&gt; != '0' then // borrow from s - r
        wmask = wmask AND tmask;
    else
        wmask = wmask OR tmask;

    return (wmask&lt;M-1:0&gt;, tmask&lt;M-1:0&gt;);</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/bitmasks/DecodeBitMasks" mylink="aarch64.instrs.integer.bitmasks.DecodeBitMasks" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeBitMasks()
// ================
// Decode AArch64 bitfield and logical immediate masks which use a similar encoding structure

(bits(M), bits(M)) <anchor link="impl-aarch64.DecodeBitMasks.5" hover="function: (bits(M), bits(M)) DecodeBitMasks(bit immN, bits(6) imms, bits(6) immr, boolean immediate, integer M)">DecodeBitMasks</anchor>(bit immN, bits(6) imms, bits(6) immr,
                                  boolean immediate, integer M)
    bits(M) tmask, wmask;
    bits(6) levels;

    // Compute log2 of element size
    // 2^len must be in range [2, M]
    len = <a link="impl-shared.HighestSetBit.1" file="shared_pseudocode.xml" hover="function: integer HighestSetBit(bits(N) x)">HighestSetBit</a>(immN:NOT(imms));
    if len &lt; 1 then UNDEFINED;
    assert M &gt;= (1 &lt;&lt; len);

    // Determine s, r and s - r parameters
    levels = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(len), 6);

    // For logical immediates an all-ones value of s is reserved
    // since it would generate a useless all-ones result (many times)
    if immediate &amp;&amp; (imms AND levels) == levels then
        UNDEFINED;

    s = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imms AND levels);
    r = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(immr AND levels);
    diff = s - r;    // 6-bit subtract with borrow

    esize = 1 &lt;&lt; len;
    d = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(diff&lt;len-1:0&gt;);
    welem = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(s + 1), esize);
    telem = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(d + 1), esize);
    wmask = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(welem, r), M DIV esize);
    tmask = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(telem, M DIV esize);
    return (wmask, tmask);</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/ins-ext/insert/movewide/movewideop/MoveWideOp" mylink="aarch64.instrs.integer.ins-ext.insert.movewide.movewideop.MoveWideOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MoveWideOp
// ==========
// Move wide 16-bit immediate instruction types.

enumeration <anchor link="MoveWideOp" hover="enumeration MoveWideOp  {MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K}">MoveWideOp</anchor>  {<anchor link="MoveWideOp_N" hover="enumeration MoveWideOp  {MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K}">MoveWideOp_N</anchor>, <anchor link="MoveWideOp_Z" hover="enumeration MoveWideOp  {MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K}">MoveWideOp_Z</anchor>, <anchor link="MoveWideOp_K" hover="enumeration MoveWideOp  {MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K}">MoveWideOp_K</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/logical/movwpreferred/MoveWidePreferred" mylink="aarch64.instrs.integer.logical.movwpreferred.MoveWidePreferred" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MoveWidePreferred()
// ===================
//
// Return TRUE if a bitmask immediate encoding would generate an immediate
// value that could also be represented by a single MOVZ or MOVN instruction.
// Used as a condition for the preferred MOV&lt;-ORR alias.

boolean <anchor link="impl-aarch64.MoveWidePreferred.4" hover="function: boolean MoveWidePreferred(bit sf, bit immN, bits(6) imms, bits(6) immr)">MoveWidePreferred</anchor>(bit sf, bit immN, bits(6) imms, bits(6) immr)
    integer s = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(imms);
    integer r = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(immr);
    integer width = if sf == '1' then 64 else 32;

    // element size must equal total immediate size
    if sf == '1' &amp;&amp; !((immN:imms) IN {'1xxxxxx'}) then
        return FALSE;
    if sf == '0' &amp;&amp; !((immN:imms) IN {'00xxxxx'}) then
        return FALSE;

    // for MOVZ must contain no more than 16 ones
    if s &lt; 16 then
        // ones must not span halfword boundary when rotated
        return (-r MOD 16) &lt;= (15 - s);

    // for MOVN must contain no more than 16 zeros
    if s &gt;= width - 15 then
        // zeros must not span halfword boundary when rotated
        return (r MOD 16) &lt;= (s - (width - 15));

    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/shiftreg/DecodeShift" mylink="aarch64.instrs.integer.shiftreg.DecodeShift" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeShift()
// =============
// Decode shift encodings

ShiftType <anchor link="impl-aarch64.DecodeShift.1" hover="function: ShiftType DecodeShift(bits(2) op)">DecodeShift</anchor>(bits(2) op)
    case op of
        when '00'  return <a link="ShiftType_LSL" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_LSL</a>;
        when '01'  return <a link="ShiftType_LSR" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_LSR</a>;
        when '10'  return <a link="ShiftType_ASR" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_ASR</a>;
        when '11'  return <a link="ShiftType_ROR" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_ROR</a>;</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/shiftreg/ShiftReg" mylink="aarch64.instrs.integer.shiftreg.ShiftReg" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ShiftReg()
// ==========
// Perform shift of a register operand

bits(N) <anchor link="impl-aarch64.ShiftReg.4" hover="function: bits(N) ShiftReg(integer reg, ShiftType shiftype, integer amount, integer N)">ShiftReg</anchor>(integer reg, <a link="ShiftType" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType</a> shiftype, integer amount, integer N)
    bits(N) result = <a link="impl-aarch64.X.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) X[integer n, integer width]">X</a>[reg, N];
    case shiftype of
        when <a link="ShiftType_LSL" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_LSL</a> result = <a link="impl-shared.LSL.2" file="shared_pseudocode.xml" hover="function: bits(N) LSL(bits(N) x, integer shift)">LSL</a>(result, amount);
        when <a link="ShiftType_LSR" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_LSR</a> result = <a link="impl-shared.LSR.2" file="shared_pseudocode.xml" hover="function: bits(N) LSR(bits(N) x, integer shift)">LSR</a>(result, amount);
        when <a link="ShiftType_ASR" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_ASR</a> result = <a link="impl-shared.ASR.2" file="shared_pseudocode.xml" hover="function: bits(N) ASR(bits(N) x, integer shift)">ASR</a>(result, amount);
        when <a link="ShiftType_ROR" file="shared_pseudocode.xml" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_ROR</a> result = <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(result, amount);
    return result;</pstext>
    </ps>
    <ps name="aarch64/instrs/integer/shiftreg/ShiftType" mylink="aarch64.instrs.integer.shiftreg.ShiftType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ShiftType
// =========
// AArch64 register shifts.

enumeration <anchor link="ShiftType" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType</anchor>   {<anchor link="ShiftType_LSL" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_LSL</anchor>, <anchor link="ShiftType_LSR" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_LSR</anchor>, <anchor link="ShiftType_ASR" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_ASR</anchor>, <anchor link="ShiftType_ROR" hover="enumeration ShiftType   {ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR}">ShiftType_ROR</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/logicalop/LogicalOp" mylink="aarch64.instrs.logicalop.LogicalOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LogicalOp
// =========
// Logical instruction types.

enumeration <anchor link="LogicalOp" hover="enumeration LogicalOp   {LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR}">LogicalOp</anchor>   {<anchor link="LogicalOp_AND" hover="enumeration LogicalOp   {LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR}">LogicalOp_AND</anchor>, <anchor link="LogicalOp_EOR" hover="enumeration LogicalOp   {LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR}">LogicalOp_EOR</anchor>, <anchor link="LogicalOp_ORR" hover="enumeration LogicalOp   {LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR}">LogicalOp_ORR</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/memory/prefetch/Prefetch" mylink="aarch64.instrs.memory.prefetch.Prefetch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Prefetch()
// ==========

// Decode and execute the prefetch hint on ADDRESS specified by PRFOP

<anchor link="impl-aarch64.Prefetch.2" hover="function: Prefetch(bits(64) address, bits(5) prfop)">Prefetch</anchor>(bits(64) address, bits(5) prfop)
    <a link="PrefetchHint" file="shared_pseudocode.xml" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">PrefetchHint</a> hint;
    integer target;
    boolean stream;

    case prfop&lt;4:3&gt; of
        when '00' hint = <a link="Prefetch_READ" file="shared_pseudocode.xml" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">Prefetch_READ</a>;         // PLD: prefetch for load
        when '01' hint = <a link="Prefetch_EXEC" file="shared_pseudocode.xml" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">Prefetch_EXEC</a>;         // PLI: preload instructions
        when '10' hint = <a link="Prefetch_WRITE" file="shared_pseudocode.xml" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">Prefetch_WRITE</a>;        // PST: prepare for store
        when '11' return;                       // unallocated hint
    target = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(prfop&lt;2:1&gt;);                  // target cache level
    stream = (prfop&lt;0&gt; != '0');                 // streaming (non-temporal)
    <a link="impl-shared.Hint_Prefetch.4" file="shared_pseudocode.xml" hover="function: Hint_Prefetch(bits(64) address, PrefetchHint hint, integer target, boolean stream)">Hint_Prefetch</a>(address, hint, target, stream);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/barriers/barrierop/MemBarrierOp" mylink="aarch64.instrs.system.barriers.barrierop.MemBarrierOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemBarrierOp
// ============
// Memory barrier instruction types.

enumeration <anchor link="MemBarrierOp" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp</anchor>   {  <anchor link="MemBarrierOp_DSB" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp_DSB</anchor>         // Data Synchronization Barrier
                            , <anchor link="MemBarrierOp_DMB" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp_DMB</anchor>         // Data Memory Barrier
                            , <anchor link="MemBarrierOp_ISB" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp_ISB</anchor>         // Instruction Synchronization Barrier
                            , <anchor link="MemBarrierOp_SSBB" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp_SSBB</anchor>        // Speculative Synchronization Barrier to VA
                            , <anchor link="MemBarrierOp_PSSBB" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp_PSSBB</anchor>       // Speculative Synchronization Barrier to PA
                            , <anchor link="MemBarrierOp_SB" hover="enumeration MemBarrierOp   {  MemBarrierOp_DSB , MemBarrierOp_DMB , MemBarrierOp_ISB , MemBarrierOp_SSBB , MemBarrierOp_PSSBB , MemBarrierOp_SB }">MemBarrierOp_SB</anchor>          // Speculation Barrier
                           };</pstext>
    </ps>
    <ps name="aarch64/instrs/system/hints/syshintop/SystemHintOp" mylink="aarch64.instrs.system.hints.syshintop.SystemHintOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SystemHintOp
// ============
// System Hint instruction types.

enumeration <anchor link="SystemHintOp" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp</anchor> {
    <anchor link="SystemHintOp_NOP" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_NOP</anchor>,
    <anchor link="SystemHintOp_YIELD" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_YIELD</anchor>,
    <anchor link="SystemHintOp_WFE" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_WFE</anchor>,
    <anchor link="SystemHintOp_WFI" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_WFI</anchor>,
    <anchor link="SystemHintOp_SEV" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_SEV</anchor>,
    <anchor link="SystemHintOp_SEVL" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_SEVL</anchor>,
    <anchor link="SystemHintOp_DGH" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_DGH</anchor>,
    <anchor link="SystemHintOp_ESB" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_ESB</anchor>,
    <anchor link="SystemHintOp_PSB" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_PSB</anchor>,
    <anchor link="SystemHintOp_TSB" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_TSB</anchor>,
    <anchor link="SystemHintOp_BTI" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_BTI</anchor>,
    <anchor link="SystemHintOp_WFET" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_WFET</anchor>,
    <anchor link="SystemHintOp_WFIT" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_WFIT</anchor>,
    <anchor link="SystemHintOp_CLRBHB" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_CLRBHB</anchor>,
    <anchor link="SystemHintOp_GCSB" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_GCSB</anchor>,
    <anchor link="SystemHintOp_CHKFEAT" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_CHKFEAT</anchor>,
    <anchor link="SystemHintOp_CSDB" hover="enumeration SystemHintOp { SystemHintOp_NOP, SystemHintOp_YIELD, SystemHintOp_WFE, SystemHintOp_WFI, SystemHintOp_SEV, SystemHintOp_SEVL, SystemHintOp_DGH, SystemHintOp_ESB, SystemHintOp_PSB, SystemHintOp_TSB, SystemHintOp_BTI, SystemHintOp_WFET, SystemHintOp_WFIT, SystemHintOp_CLRBHB, SystemHintOp_GCSB, SystemHintOp_CHKFEAT, SystemHintOp_CSDB }">SystemHintOp_CSDB</anchor>
};</pstext>
    </ps>
    <ps name="aarch64/instrs/system/register/cpsr/pstatefield/PSTATEField" mylink="aarch64.instrs.system.register.cpsr.pstatefield.PSTATEField" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PSTATEField
// ===========
// MSR (immediate) instruction destinations.

enumeration <anchor link="PSTATEField" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField</anchor> {<anchor link="PSTATEField_DAIFSet" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_DAIFSet</anchor>, <anchor link="PSTATEField_DAIFClr" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_DAIFClr</anchor>,
                         <anchor link="PSTATEField_PAN" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_PAN</anchor>, // Armv8.1
                         <anchor link="PSTATEField_UAO" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_UAO</anchor>, // Armv8.2
                         <anchor link="PSTATEField_DIT" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_DIT</anchor>, // Armv8.4
                         <anchor link="PSTATEField_SSBS" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_SSBS</anchor>,
                         <anchor link="PSTATEField_TCO" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_TCO</anchor>, // Armv8.5
                         <anchor link="PSTATEField_SVCRSM" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_SVCRSM</anchor>,
                         <anchor link="PSTATEField_SVCRZA" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_SVCRZA</anchor>,
                         <anchor link="PSTATEField_SVCRSMZA" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_SVCRSMZA</anchor>,
                         <anchor link="PSTATEField_ALLINT" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_ALLINT</anchor>,
                         <anchor link="PSTATEField_PM" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_PM</anchor>,
                         <anchor link="PSTATEField_SP" hover="enumeration PSTATEField {PSTATEField_DAIFSet, PSTATEField_DAIFClr, PSTATEField_PAN, PSTATEField_UAO, PSTATEField_DIT, PSTATEField_SSBS, PSTATEField_TCO, PSTATEField_SVCRSM, PSTATEField_SVCRZA, PSTATEField_SVCRSMZA, PSTATEField_ALLINT, PSTATEField_PM, PSTATEField_SP }">PSTATEField_SP</anchor>
                         };</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/at/AArch64.AT" mylink="aarch64.instrs.system.sysops.at.AArch64.AT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AT()
// ============
// Perform address translation as per AT instructions.

<anchor link="AArch64.AT.4" hover="function: AArch64.AT(bits(64) address, TranslationStage stage_in, bits(2) el_in, ATAccess ataccess)">AArch64.AT</anchor>(bits(64) address, <a link="TranslationStage" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage</a> stage_in, bits(2) el_in, <a link="ATAccess" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess</a> ataccess)
    <a link="TranslationStage" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage</a> stage = stage_in;
    bits(2) el = el_in;
    bits(2) effective_nse_ns = <a link="impl-shared.EffectiveSCR_EL3_NSE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NSE()">EffectiveSCR_EL3_NSE</a>() : <a link="impl-shared.EffectiveSCR_EL3_NS.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</a>();
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; effective_nse_ns == '10' &amp;&amp; el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        UNDEFINED;
    // For stage 1 translation, when HCR_EL2.{E2H, TGE} is {1,1} and requested EL is EL1,
    // the EL2&amp;0 translation regime is used.
    if HCR_EL2.&lt;E2H, TGE&gt; == '11' &amp;&amp; el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; stage == <a link="TranslationStage_1" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_1</a> then
        el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; stage == <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a> &amp;&amp; !<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        stage = <a link="TranslationStage_1" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_1</a>;

    boolean write = ataccess IN {<a link="ATAccess_WritePAN" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_WritePAN</a>, <a link="ATAccess_Write" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_Write</a>};
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(el);
    boolean pan = ataccess IN {<a link="ATAccess_ReadPAN" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_ReadPAN</a>, <a link="ATAccess_WritePAN" file="shared_pseudocode.xml" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_WritePAN</a>};
    accdesc = <a link="impl-shared.CreateAccDescAT.4" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescAT(SecurityState ss, bits(2) el, boolean write, boolean pan)">CreateAccDescAT</a>(ss, el, write, pan);
    aligned = TRUE;

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime;
    if stage == <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a> then
        regime = <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
    else
        regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(el);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc;
    if (el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) || (el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el)) then
        if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> || TTBCR.EAE == '1' then
            (fault, addrdesc) = <a link="AArch32.S1TranslateLD.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S1TranslateLD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateLD</a>(fault, regime, address&lt;31:0&gt;, aligned,
                                                      accdesc);
        else
            (fault, addrdesc, -) = <a link="AArch32.S1TranslateSD.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor, SDFType) AArch32.S1TranslateSD(FaultRecord fault_in, Regime regime, bits(32) va, boolean aligned, AccessDescriptor accdesc)">AArch32.S1TranslateSD</a>(fault, regime, address&lt;31:0&gt;, aligned,
                                                         accdesc);
    else
        (fault, addrdesc) = <a link="AArch64.S1Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S1Translate(FaultRecord fault_in, Regime regime, bits(64) va, boolean aligned, AccessDescriptor accdesc)">AArch64.S1Translate</a>(fault, regime, address, aligned, accdesc);

    if stage == <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a> &amp;&amp; fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        boolean s1aarch64;
        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
            addrdesc.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(address, 64);
            (fault, addrdesc) = <a link="AArch32.S2Translate.4" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch32.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean aligned, AccessDescriptor accdesc)">AArch32.S2Translate</a>(fault, addrdesc, aligned, accdesc);
        elsif regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
            s1aarch64 = TRUE;
            (fault, addrdesc) = <a link="AArch64.S2Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</a>(fault, addrdesc, s1aarch64, aligned, accdesc);

    is_ATS1Ex = stage != <a link="TranslationStage_12" file="shared_pseudocode.xml" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</a>;
    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        addrdesc = <a link="impl-shared.CreateFaultyAddressDescriptor.2" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateFaultyAddressDescriptor(bits(64) va, FaultRecord fault)">CreateFaultyAddressDescriptor</a>(address, fault);
        // Take an exception on:
        // * A Synchronous External abort occurs on translation table walk
        // * A stage 2 fault occurs on a stage 1 walk
        // * A GPC Exception (FEAT_RME)
        // * A GPF from ATS1E{1,0}* when executed from EL1 and HCR_EL2.GPF == '1' (FEAT_RME)
        if (<a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault) ||
                (PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; fault.s2fs1walk) ||
                (<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> &amp;&amp; (
                    <a link="impl-shared.ReportAsGPCException.1" file="shared_pseudocode.xml" hover="function: boolean ReportAsGPCException(FaultRecord fault)">ReportAsGPCException</a>(fault) ||
                    (HCR_EL2.GPF == '1' &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; el IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>} &amp;&amp; is_ATS1Ex)
                ))) then
            PAR_EL1 = bits(128) UNKNOWN;
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(address, addrdesc.fault);

    <a link="AArch64.EncodePAR.3" file="shared_pseudocode.xml" hover="function: AArch64.EncodePAR(Regime regime, boolean is_ATS1Ex, AddressDescriptor addrdesc)">AArch64.EncodePAR</a>(regime, is_ATS1Ex, addrdesc);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/at/AArch64.EncodePAR" mylink="aarch64.instrs.system.sysops.at.AArch64.EncodePAR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.EncodePAR()
// ===================
// Encode PAR register with result of translation.

<anchor link="AArch64.EncodePAR.3" hover="function: AArch64.EncodePAR(Regime regime, boolean is_ATS1Ex, AddressDescriptor addrdesc)">AArch64.EncodePAR</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, boolean is_ATS1Ex, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc)
    PAR_EL1 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(128);
    paspace = addrdesc.paddress.paspace;

    if !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(addrdesc) then
        PAR_EL1.F = '0';
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
            if regime == <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a> then
                case paspace of
                    when <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>     PAR_EL1.&lt;NSE,NS&gt; = '00';
                    when <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>  PAR_EL1.&lt;NSE,NS&gt; = '01';
                    when <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>       PAR_EL1.&lt;NSE,NS&gt; = '10';
                    when <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>      PAR_EL1.&lt;NSE,NS&gt; = '11';

            elsif <a link="impl-shared.SecurityStateForRegime.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateForRegime(Regime regime)">SecurityStateForRegime</a>(regime) == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>  then
                PAR_EL1.NSE = bit UNKNOWN;
                PAR_EL1.NS = if paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then '0' else '1';

            elsif <a link="impl-shared.SecurityStateForRegime.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateForRegime(Regime regime)">SecurityStateForRegime</a>(regime) == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> then
                if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; is_ATS1Ex then
                    PAR_EL1.NSE = bit UNKNOWN;
                    PAR_EL1.NS  = bit UNKNOWN;
                else
                    PAR_EL1.NSE = bit UNKNOWN;
                    PAR_EL1.NS  = if paspace == <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then '0' else '1';

            else
                PAR_EL1.NSE = bit UNKNOWN;
                PAR_EL1.NS  = bit UNKNOWN;
        else
            PAR_EL1&lt;11&gt; = '1'; // RES1
            if <a link="impl-shared.SecurityStateForRegime.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateForRegime(Regime regime)">SecurityStateForRegime</a>(regime) == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
                PAR_EL1.NS = if paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then '0' else '1';
            else
                PAR_EL1.NS = bit UNKNOWN;
        PAR_EL1.SH   = <a link="impl-shared.ReportedPARShareability.1" file="shared_pseudocode.xml" hover="function: bits(2) ReportedPARShareability(bits(2) sh)">ReportedPARShareability</a>(<a link="impl-shared.PAREncodeShareability.1" file="shared_pseudocode.xml" hover="function: bits(2) PAREncodeShareability(MemoryAttributes memattrs)">PAREncodeShareability</a>(addrdesc.memattrs));
        if <a link="AArch64.IsVMSAv9_128.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.IsVMSAv9_128(Regime regime, boolean is_ATS1Ex)">AArch64.IsVMSAv9_128</a>(regime, is_ATS1Ex) then
            PAR_EL1.D128 = '1';
            PAR_EL1&lt;119:76&gt; = addrdesc.paddress.address&lt;55:12&gt;;
        else
            PAR_EL1.D128 = '0';
            PAR_EL1&lt;55:12&gt; = addrdesc.paddress.address&lt;55:12&gt;;
        PAR_EL1.ATTR = <a link="impl-shared.ReportedPARAttrs.1" file="shared_pseudocode.xml" hover="function: bits(8) ReportedPARAttrs(bits(8) parattrs)">ReportedPARAttrs</a>(<a link="impl-shared.EncodePARAttrs.1" file="shared_pseudocode.xml" hover="function: bits(8) EncodePARAttrs(MemoryAttributes memattrs)">EncodePARAttrs</a>(addrdesc.memattrs));
        PAR_EL1&lt;10&gt; = bit IMPLEMENTATION_DEFINED "Non-Faulting PAR";
    else
        PAR_EL1.F   = '1';
        PAR_EL1.DirtyBit    = if addrdesc.fault.dirtybit then '1' else '0';
        PAR_EL1.Overlay     = if addrdesc.fault.overlay then '1' else '0';
        PAR_EL1.TopLevel    = if addrdesc.fault.toplevel then '1' else '0';
        PAR_EL1.AssuredOnly = if addrdesc.fault.assuredonly then '1' else '0';
        PAR_EL1.FST = <a link="AArch64.PARFaultStatus.1" file="shared_pseudocode.xml" hover="function: bits(6) AArch64.PARFaultStatus(FaultRecord fault)">AArch64.PARFaultStatus</a>(addrdesc.fault);
        PAR_EL1.PTW = if addrdesc.fault.s2fs1walk then '1' else '0';
        PAR_EL1.S   = if addrdesc.fault.secondstage then '1' else '0';
        PAR_EL1&lt;11&gt; = '1'; // RES1
        PAR_EL1&lt;63:48&gt; = bits(16) IMPLEMENTATION_DEFINED "Faulting PAR";
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/at/AArch64.IsVMSAv9_128" mylink="aarch64.instrs.system.sysops.at.AArch64.IsVMSAv9_128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IsVMSAv9_128()
// ======================
// Check if the Translation Regime uses VMSAv9-128.

boolean <anchor link="AArch64.IsVMSAv9_128.2" hover="function: boolean AArch64.IsVMSAv9_128(Regime regime, boolean is_ATS1Ex)">AArch64.IsVMSAv9_128</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, boolean is_ATS1Ex)
    boolean is_VMSAv9_128;
    // Regime_EL2 does not support VMSAv9-128
    if regime == <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a> || !<a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() then
        is_VMSAv9_128 = FALSE;
    else
        is_VMSAv9_128 = FALSE;
        case regime of
            when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>
                is_VMSAv9_128 = TCR_EL3.D128 == '1';
            when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>
                is_VMSAv9_128 = TCR2_EL2.D128 == '1';
            when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>
                if (is_ATS1Ex || (HCR_EL2.&lt;VM,DC&gt; == '00')) then
                    is_VMSAv9_128 = TCR2_EL1.D128 == '1';
                else
                    is_VMSAv9_128 = VTCR_EL2.D128 == '1';

    return is_VMSAv9_128;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/at/AArch64.PARFaultStatus" mylink="aarch64.instrs.system.sysops.at.AArch64.PARFaultStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PARFaultStatus()
// ========================
// Fault status field decoding of 64-bit PAR.

bits(6) <anchor link="AArch64.PARFaultStatus.1" hover="function: bits(6) AArch64.PARFaultStatus(FaultRecord fault)">AArch64.PARFaultStatus</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    bits(6) fst;

    if fault.statuscode == <a link="Fault_Domain" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Domain</a> then
        // Report Domain fault
        assert fault.level IN {1,2};
        fst&lt;1:0&gt; = if fault.level == 1 then '01' else '10';
        fst&lt;5:2&gt; = '1111';
    else
        fst = <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level);
    return fst;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/at/GetPAR_EL1_D128" mylink="aarch64.instrs.system.sysops.at.GetPAR_EL1_D128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetPAR_EL1_D128()
// =================
// Query the PAR_EL1.D128 field

bit <anchor link="impl-aarch64.GetPAR_EL1_D128.0" hover="function: bit GetPAR_EL1_D128()">GetPAR_EL1_D128</anchor>()
    bit D128;

    D128 = PAR_EL1.D128;
    return D128;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/at/GetPAR_EL1_F" mylink="aarch64.instrs.system.sysops.at.GetPAR_EL1_F" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetPAR_EL1_F()
// ==============
// Query the PAR_EL1.F field.

bit <anchor link="impl-aarch64.GetPAR_EL1_F.0" hover="function: bit GetPAR_EL1_F()">GetPAR_EL1_F</anchor>()
    bit F;

    F = PAR_EL1.F;
    return F;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/dc/AArch64.DC" mylink="aarch64.instrs.system.sysops.dc.AArch64.DC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.DC()
// ============
// Perform Data Cache Operation.

<anchor link="AArch64.DC.4" hover="function: AArch64.DC(bits(64) regval, CacheType cachetype, CacheOp cacheop, CacheOpScope opscope_in)">AArch64.DC</anchor>(bits(64) regval, <a link="CacheType" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</a> cachetype, <a link="CacheOp" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp</a> cacheop, <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope_in)
    <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope = opscope_in;
    <a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache;

    cache.acctype   = <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>;
    cache.cachetype = cachetype;
    cache.cacheop   = cacheop;
    cache.opscope   = opscope;

    if opscope == <a link="CacheOpScope_SetWay" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_SetWay</a> then
        ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);
        cache.cpas = <a link="impl-shared.CPASAtSecurityState.1" file="shared_pseudocode.xml" hover="function: CachePASpace CPASAtSecurityState(SecurityState ss)">CPASAtSecurityState</a>(ss);
        cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        (cache.set, cache.way, cache.level) = <a link="impl-shared.DecodeSW.2" file="shared_pseudocode.xml" hover="function: (integer, integer, integer) DecodeSW(bits(64) regval, CacheType cachetype)">DecodeSW</a>(regval, cachetype);
        if (cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
          (HCR_EL2.SWIO == '1' || HCR_EL2.&lt;DC,VM&gt; != '00')) then
            cache.cacheop = <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a>;

        <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
        return;

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
        if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
            cache.is_vmid_valid = TRUE;
            cache.vmid          = <a link="impl-aarch64.VMID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) VMID[]">VMID</a>[];
        else
            cache.is_vmid_valid = FALSE;
    else
        cache.is_vmid_valid = FALSE;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        cache.is_asid_valid = TRUE;
        cache.asid          = <a link="impl-shared.ASID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) ASID[]">ASID</a>[];
    else
        cache.is_asid_valid = FALSE;

    if (opscope == <a link="CacheOpScope_PoDP" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoDP</a> &amp;&amp;
          boolean IMPLEMENTATION_DEFINED "Memory system does not supports PoDP") then
        opscope = <a link="CacheOpScope_PoP" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoP</a>;
    if (opscope == <a link="CacheOpScope_PoP" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoP</a> &amp;&amp;
          boolean IMPLEMENTATION_DEFINED "Memory system does not supports PoP") then
        opscope = <a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a>;
    vaddress = regval;

    size = 0;        // by default no watchpoint address
    if cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> then
        size = integer IMPLEMENTATION_DEFINED "Data Cache Invalidate Watchpoint Size";
        assert size &gt;= 4*(2^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(CTR_EL0.DminLine))) &amp;&amp; size &lt;= 2048;
        assert <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(size&lt;32:0&gt; AND (size-1)&lt;32:0&gt;) == 0; // size is power of 2
        vaddress = <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(regval, size);

    if <a link="impl-shared.DCInstNeedsTranslation.1" file="shared_pseudocode.xml" hover="function: boolean DCInstNeedsTranslation(CacheOpScope opscope)">DCInstNeedsTranslation</a>(opscope) then
        cache.vaddress  = vaddress;
        boolean aligned = TRUE;
        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescDC.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescDC(CacheRecord cache)">CreateAccDescDC</a>(cache);
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(vaddress, accdesc, aligned, size);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(regval, memaddrdesc.fault);

        cache.translated = TRUE;
        cache.paddress   = memaddrdesc.paddress;
        cache.cpas       = <a link="impl-shared.CPASAtPAS.1" file="shared_pseudocode.xml" hover="function: CachePASpace CPASAtPAS(PASpace pas)">CPASAtPAS</a>(memaddrdesc.paddress.paspace);
        if opscope IN {<a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a>, <a link="CacheOpScope_PoP" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoP</a>, <a link="CacheOpScope_PoDP" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoDP</a>} then
            cache.shareability = memaddrdesc.memattrs.shareability;
        else
            cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
    elsif opscope == <a link="CacheOpScope_PoE" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoE</a> then
        cache.vaddress         = bits(64) UNKNOWN;
        cache.translated       = TRUE;
        cache.shareability     = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        cache.paddress.address = regval&lt;55:0&gt;;
        cache.paddress.paspace = <a link="impl-shared.DecodePASpace.2" file="shared_pseudocode.xml" hover="function: PASpace DecodePASpace (bit nse, bit ns)">DecodePASpace</a>(regval&lt;62&gt;, regval&lt;63&gt;);
        cache.cpas             = <a link="impl-shared.CPASAtPAS.1" file="shared_pseudocode.xml" hover="function: CachePASpace CPASAtPAS(PASpace pas)">CPASAtPAS</a>(cache.paddress.paspace);

        // If a Reserved encoding is selected, the instruction is permitted to be treated as a NOP.
        if cache.paddress.paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
            <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();

        if boolean IMPLEMENTATION_DEFINED "Apply granule protection check on DC to PoE" then
            <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc;
            <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescDC.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescDC(CacheRecord cache)">CreateAccDescDC</a>(cache);
            memaddrdesc.paddress     = cache.paddress;
            memaddrdesc.fault.gpcf   = <a link="impl-shared.GranuleProtectionCheck.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GranuleProtectionCheck(AddressDescriptor addrdesc, AccessDescriptor accdesc)">GranuleProtectionCheck</a>(memaddrdesc, accdesc);

            if memaddrdesc.fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
                memaddrdesc.fault.statuscode = <a link="Fault_GPCFOnOutput" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnOutput</a>;
                memaddrdesc.fault.paddress   = memaddrdesc.paddress;
                <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(bits(64) UNKNOWN, memaddrdesc.fault);
    else
        cache.vaddress     = vaddress;
        cache.translated   = FALSE;
        cache.shareability = <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> UNKNOWN;
        cache.paddress     = <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> UNKNOWN;

    if (cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
            HCR_EL2.&lt;DC,VM&gt; != '00') then
        cache.cacheop = <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a>;

    <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/dc/AArch64.MemZero" mylink="aarch64.instrs.system.sysops.dc.AArch64.MemZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MemZero()
// =================

<anchor link="AArch64.MemZero.2" hover="function: AArch64.MemZero(bits(64) regval, CacheType cachetype)">AArch64.MemZero</anchor>(bits(64) regval, <a link="CacheType" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</a> cachetype)
    integer size = 4*(2^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(DCZID_EL0.BS)));
    assert size &lt;= <a link="MAX_ZERO_BLOCK_SIZE" file="shared_pseudocode.xml" hover="constant integer MAX_ZERO_BLOCK_SIZE = 2048">MAX_ZERO_BLOCK_SIZE</a>;
    if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then
        assert size &gt;= <a link="TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</a>;

    bits(64) vaddress = <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(regval, size);

    boolean tagaccess = cachetype IN {<a link="CacheType_Tag" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Tag</a>, <a link="CacheType_Data_Tag" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data_Tag</a>};
    boolean tagchecked = cachetype == <a link="CacheType_Data" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data</a>;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescDCZero.2" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescDCZero(boolean tagaccess, boolean tagchecked)">CreateAccDescDCZero</a>(tagaccess, tagchecked);

    if cachetype IN {<a link="CacheType_Tag" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Tag</a>, <a link="CacheType_Data_Tag" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data_Tag</a>} then
        <a link="AArch64.TagMemZero.4" file="shared_pseudocode.xml" hover="function: AArch64.TagMemZero(bits(64) regval, bits(64) vaddress, AccessDescriptor accdesc_in, integer size)">AArch64.TagMemZero</a>(regval, vaddress, accdesc, size);

    if cachetype IN {<a link="CacheType_Data" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data</a>, <a link="CacheType_Data_Tag" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data_Tag</a>} then
        <a link="AArch64.DataMemZero.4" file="shared_pseudocode.xml" hover="function: AArch64.DataMemZero(bits(64) regval, bits(64) vaddress, AccessDescriptor accdesc_in, integer size)">AArch64.DataMemZero</a>(regval, vaddress, accdesc, size);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/dc/MemZero" mylink="aarch64.instrs.system.sysops.dc.MemZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="MAX_ZERO_BLOCK_SIZE" hover="constant integer MAX_ZERO_BLOCK_SIZE = 2048">MAX_ZERO_BLOCK_SIZE</anchor> = 2048;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/ic/AArch64.IC" mylink="aarch64.instrs.system.sysops.ic.AArch64.IC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IC()
// ============
// Perform Instruction Cache Operation.

<anchor link="AArch64.IC.1" hover="function: AArch64.IC(CacheOpScope opscope)">AArch64.IC</anchor>(<a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    regval = bits(64) UNKNOWN;
    <a link="AArch64.IC.2" file="shared_pseudocode.xml" hover="function: AArch64.IC(bits(64) regval, CacheOpScope opscope)">AArch64.IC</a>(regval, opscope);

// AArch64.IC()
// ============
// Perform Instruction Cache Operation.

<anchor link="AArch64.IC.2" hover="function: AArch64.IC(bits(64) regval, CacheOpScope opscope)">AArch64.IC</anchor>(bits(64) regval, <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    <a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache;

    cache.acctype   = <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>;
    cache.cachetype = <a link="CacheType_Instruction" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Instruction</a>;
    cache.cacheop   = <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a>;
    cache.opscope   = opscope;

    if opscope IN {<a link="CacheOpScope_ALLU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLU</a>, <a link="CacheOpScope_ALLUIS" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLUIS</a>} then
        ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);
        cache.cpas = <a link="impl-shared.CPASAtSecurityState.1" file="shared_pseudocode.xml" hover="function: CachePASpace CPASAtSecurityState(SecurityState ss)">CPASAtSecurityState</a>(ss);
        if (opscope == <a link="CacheOpScope_ALLUIS" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLUIS</a> || (opscope == <a link="CacheOpScope_ALLU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLU</a> &amp;&amp; PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.FB == '1')) then
            cache.shareability = <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a>;
        else
            cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        cache.regval = regval;
        <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
    else
        assert opscope == <a link="CacheOpScope_PoU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoU</a>;

        if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} then
                cache.is_vmid_valid = TRUE;
                cache.vmid          = <a link="impl-aarch64.VMID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) VMID[]">VMID</a>[];
            else
                cache.is_vmid_valid = FALSE;
        else
            cache.is_vmid_valid = FALSE;

        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            cache.is_asid_valid = TRUE;
            cache.asid          = <a link="impl-shared.ASID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) ASID[]">ASID</a>[];
        else
            cache.is_asid_valid = FALSE;

        bits(64) vaddress = regval;
        boolean need_translate = <a link="impl-shared.ICInstNeedsTranslation.1" file="shared_pseudocode.xml" hover="function: boolean ICInstNeedsTranslation(CacheOpScope opscope)">ICInstNeedsTranslation</a>(opscope);

        cache.vaddress     = regval;
        cache.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        cache.translated   = need_translate;

        if !need_translate then
            cache.paddress = <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> UNKNOWN;
            <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
            return;

        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.CreateAccDescIC.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescIC(CacheRecord cache)">CreateAccDescIC</a>(cache);
        boolean aligned = TRUE;
        integer size = 0;
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(vaddress, accdesc, aligned, size);

        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memaddrdesc) then
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(regval, memaddrdesc.fault);

        cache.cpas     = <a link="impl-shared.CPASAtPAS.1" file="shared_pseudocode.xml" hover="function: CachePASpace CPASAtPAS(PASpace pas)">CPASAtPAS</a>(memaddrdesc.paddress.paspace);
        cache.paddress = memaddrdesc.paddress;
        <a link="impl-shared.CACHE_OP.1" file="shared_pseudocode.xml" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</a>(cache);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/predictionrestrict/AArch64.RestrictPrediction" mylink="aarch64.instrs.system.sysops.predictionrestrict.AArch64.RestrictPrediction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.RestrictPrediction()
// ============================
// Clear all predictions in the context.

<anchor link="AArch64.RestrictPrediction.2" hover="function: AArch64.RestrictPrediction(bits(64) val, RestrictType restriction)">AArch64.RestrictPrediction</anchor>(bits(64) val, <a link="RestrictType" file="shared_pseudocode.xml" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType</a> restriction)

    <a link="ExecutionCntxt" file="shared_pseudocode.xml" hover="type ExecutionCntxt is ( boolean is_vmid_valid, boolean all_vmid, bits(16) vmid, boolean is_asid_valid, boolean all_asid, bits(16) asid, bits(2) target_el, SecurityState security, RestrictType restriction )">ExecutionCntxt</a> c;
    target_el    = val&lt;25:24&gt;;

    // If the target EL is not implemented or the instruction is executed at an
    // EL lower than the specified level, the instruction is treated as a NOP.
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(target_el) || <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target_el) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();

    bit ns  = val&lt;26&gt;;
    bit nse = val&lt;27&gt;;
    ss = <a link="impl-shared.TargetSecurityState.2" file="shared_pseudocode.xml" hover="function: SecurityState TargetSecurityState(bit NS, bit NSE)">TargetSecurityState</a>(ns, nse);

    // If the combination of Security state and Exception level is not implemented,
    // the instruction is treated as a NOP.
    if ss == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a> &amp;&amp; target_el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; target_el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; ss != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();

    c.security  = ss;
    c.target_el = target_el;

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if (PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) || PSTATE.EL == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
            c.is_vmid_valid = TRUE;
            c.all_vmid      = FALSE;
            c.vmid          = <a link="impl-aarch64.VMID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) VMID[]">VMID</a>[];

        elsif (target_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(target_el)) || target_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
            c.is_vmid_valid = TRUE;
            c.all_vmid      = val&lt;48&gt; == '1';
            c.vmid          = val&lt;47:32&gt;;       // Only valid if  val&lt;48&gt; == '0';

        else
            c.is_vmid_valid = FALSE;
    else
        c.is_vmid_valid = FALSE;

    if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        c.is_asid_valid = TRUE;
        c.all_asid      = FALSE;
        c.asid          = <a link="impl-shared.ASID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) ASID[]">ASID</a>[];

    elsif target_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        c.is_asid_valid = TRUE;
        c.all_asid      = val&lt;16&gt; == '1';
        c.asid          = val&lt;15:0&gt;;            // Only valid if  val&lt;16&gt; == '0';

    else
        c.is_asid_valid = FALSE;

    c.restriction = restriction;
    <a link="impl-shared.RESTRICT_PREDICTIONS.1" file="shared_pseudocode.xml" hover="function: RESTRICT_PREDICTIONS(ExecutionCntxt c)">RESTRICT_PREDICTIONS</a>(c);</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/sysop/SysOp" mylink="aarch64.instrs.system.sysops.sysop.SysOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SysOp()
// =======

SystemOp <anchor link="impl-aarch64.SysOp.4" hover="function: SystemOp SysOp(bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2)">SysOp</anchor>(bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2)
    case op1:CRn:CRm:op2 of
        when '000 0111 1000 000' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E1R
        when '000 0111 1000 001' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E1W
        when '000 0111 1000 010' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E0R
        when '000 0111 1000 011' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E0W
        when '000 0111 1001 000' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E1RP
        when '000 0111 1001 001' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E1WP
        when '100 0111 1000 000' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E2R
        when '100 0111 1000 001' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E2W
        when '100 0111 1000 100' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S12E1R
        when '100 0111 1000 101' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S12E1W
        when '100 0111 1000 110' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S12E0R
        when '100 0111 1000 111' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S12E0W
        when '110 0111 1000 000' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E3R
        when '110 0111 1000 001' return <a link="Sys_AT" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</a>;    // S1E3W
        when '001 0111 0010 100' return <a link="Sys_BRB" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_BRB</a>;   // IALL
        when '001 0111 0010 101' return <a link="Sys_BRB" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_BRB</a>;   // INJ
        when '000 0111 0110 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // IVAC
        when '000 0111 0110 010' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // ISW
        when '000 0111 0110 011' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // IGVAC
        when '000 0111 0110 100' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // IGSW
        when '000 0111 0110 101' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // IGDVAC
        when '000 0111 0110 110' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // IGDSW
        when '000 0111 1010 010' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CSW
        when '000 0111 1010 100' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGSW
        when '000 0111 1010 110' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGDSW
        when '000 0111 1110 010' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CISW
        when '000 0111 1110 100' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIGSW
        when '000 0111 1110 110' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIGDSW
        when '011 0111 0100 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // ZVA
        when '011 0111 0100 011' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // GVA
        when '011 0111 0100 100' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // GZVA
        when '011 0111 1010 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CVAC
        when '011 0111 1010 011' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGVAC
        when '011 0111 1010 101' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGDVAC
        when '011 0111 1011 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CVAU
        when '011 0111 1100 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CVAP
        when '011 0111 1100 011' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGVAP
        when '011 0111 1100 101' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGDVAP
        when '011 0111 1101 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CVADP
        when '011 0111 1101 011' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGVADP
        when '011 0111 1101 101' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CGDVADP
        when '011 0111 1110 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIVAC
        when '011 0111 1110 011' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIGVAC
        when '011 0111 1110 101' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIGDVAC
        when '100 0111 1110 000' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIPAE
        when '100 0111 1110 111' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIGDPAE
        when '110 0111 1110 001' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIPAPA
        when '110 0111 1110 101' return <a link="Sys_DC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</a>;    // CIGDPAPA
        when '000 0111 0001 000' return <a link="Sys_IC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_IC</a>;    // IALLUIS
        when '000 0111 0101 000' return <a link="Sys_IC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_IC</a>;    // IALLU
        when '011 0111 0101 001' return <a link="Sys_IC" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_IC</a>;    // IVAU
        when '000 1000 0001 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLE1OS
        when '000 1000 0001 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE1OS
        when '000 1000 0001 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ASIDE1OS
        when '000 1000 0001 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAAE1OS
        when '000 1000 0001 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE1OS
        when '000 1000 0001 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAALE1OS
        when '000 1000 0010 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE1IS
        when '000 1000 0010 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAAE1IS
        when '000 1000 0010 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE1IS
        when '000 1000 0010 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAALE1IS
        when '000 1000 0011 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLE1IS
        when '000 1000 0011 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE1IS
        when '000 1000 0011 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ASIDE1IS
        when '000 1000 0011 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAAE1IS
        when '000 1000 0011 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE1IS
        when '000 1000 0011 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAALE1IS
        when '000 1000 0101 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE1OS
        when '000 1000 0101 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAAE1OS
        when '000 1000 0101 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE1OS
        when '000 1000 0101 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAALE1OS
        when '000 1000 0110 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE1
        when '000 1000 0110 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAAE1
        when '000 1000 0110 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE1
        when '000 1000 0110 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAALE1
        when '000 1000 0111 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLE1
        when '000 1000 0111 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE1
        when '000 1000 0111 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ASIDE1
        when '000 1000 0111 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAAE1
        when '000 1000 0111 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE1
        when '000 1000 0111 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAALE1
        when '000 1001 0001 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLE1OSNXS
        when '000 1001 0001 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE1OSNXS
        when '000 1001 0001 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ASIDE1OSNXS
        when '000 1001 0001 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAAE1OSNXS
        when '000 1001 0001 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE1OSNXS
        when '000 1001 0001 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAALE1OSNXS
        when '000 1001 0010 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE1ISNXS
        when '000 1001 0010 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAAE1ISNXS
        when '000 1001 0010 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE1ISNXS
        when '000 1001 0010 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAALE1ISNXS
        when '000 1001 0011 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLE1ISNXS
        when '000 1001 0011 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE1ISNXS
        when '000 1001 0011 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ASIDE1ISNXS
        when '000 1001 0011 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAAE1ISNXS
        when '000 1001 0011 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE1ISNXS
        when '000 1001 0011 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAALE1ISNXS
        when '000 1001 0101 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE1OSNXS
        when '000 1001 0101 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAAE1OSNXS
        when '000 1001 0101 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE1OSNXS
        when '000 1001 0101 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAALE1OSNXS
        when '000 1001 0110 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE1NXS
        when '000 1001 0110 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAAE1NXS
        when '000 1001 0110 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE1NXS
        when '000 1001 0110 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAALE1NXS
        when '000 1001 0111 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLE1NXS
        when '000 1001 0111 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE1NXS
        when '000 1001 0111 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ASIDE1NXS
        when '000 1001 0111 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAAE1NXS
        when '000 1001 0111 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE1NXS
        when '000 1001 0111 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAALE1NXS
        when '100 1000 0000 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2E1IS
        when '100 1000 0000 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2E1IS
        when '100 1000 0000 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2LE1IS
        when '100 1000 0000 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2LE1IS
        when '100 1000 0001 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE2OS
        when '100 1000 0001 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE2OS
        when '100 1000 0001 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE1OS
        when '100 1000 0001 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE2OS
        when '100 1000 0001 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLS12E1OS
        when '100 1000 0010 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE2IS
        when '100 1000 0010 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE2IS
        when '100 1000 0011 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE2IS
        when '100 1000 0011 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE2IS
        when '100 1000 0011 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE1IS
        when '100 1000 0011 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE2IS
        when '100 1000 0011 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLS12E1IS
        when '100 1000 0100 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2E1OS
        when '100 1000 0100 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2E1
        when '100 1000 0100 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2E1
        when '100 1000 0100 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2E1OS
        when '100 1000 0100 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2LE1OS
        when '100 1000 0100 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2LE1
        when '100 1000 0100 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2LE1
        when '100 1000 0100 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2LE1OS
        when '100 1000 0101 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE2OS
        when '100 1000 0101 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE2OS
        when '100 1000 0110 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE2
        when '100 1000 0110 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE2
        when '100 1000 0111 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE2
        when '100 1000 0111 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE2
        when '100 1000 0111 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE1
        when '100 1000 0111 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE2
        when '100 1000 0111 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLS12E1
        when '100 1001 0000 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2E1ISNXS
        when '100 1001 0000 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2E1ISNXS
        when '100 1001 0000 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2LE1ISNXS
        when '100 1001 0000 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2LE1ISNXS
        when '100 1001 0001 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE2OSNXS
        when '100 1001 0001 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE2OSNXS
        when '100 1001 0001 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE1OSNXS
        when '100 1001 0001 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE2OSNXS
        when '100 1001 0001 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLS12E1OSNXS
        when '100 1001 0010 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE2ISNXS
        when '100 1001 0010 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE2ISNXS
        when '100 1001 0011 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE2ISNXS
        when '100 1001 0011 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE2ISNXS
        when '100 1001 0011 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE1ISNXS
        when '100 1001 0011 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE2ISNXS
        when '100 1001 0011 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLS12E1ISNXS
        when '100 1001 0100 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2E1OSNXS
        when '100 1001 0100 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2E1NXS
        when '100 1001 0100 010' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2E1NXS
        when '100 1001 0100 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2E1OSNXS
        when '100 1001 0100 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2LE1OSNXS
        when '100 1001 0100 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // IPAS2LE1NXS
        when '100 1001 0100 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2LE1NXS
        when '100 1001 0100 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RIPAS2LE1OSNXS
        when '100 1001 0101 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE2OSNXS
        when '100 1001 0101 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE2OSNXS
        when '100 1001 0110 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE2NXS
        when '100 1001 0110 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE2NXS
        when '100 1001 0111 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE2NXS
        when '100 1001 0111 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE2NXS
        when '100 1001 0111 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE1NXS
        when '100 1001 0111 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE2NXS
        when '100 1001 0111 110' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VMALLS12E1NXS
        when '110 1000 0001 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE3OS
        when '110 1000 0001 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE3OS
        when '110 1000 0001 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // PAALLOS
        when '110 1000 0001 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE3OS
        when '110 1000 0010 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE3IS
        when '110 1000 0010 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE3IS
        when '110 1000 0011 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE3IS
        when '110 1000 0011 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE3IS
        when '110 1000 0011 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE3IS
        when '110 1000 0100 011' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RPAOS
        when '110 1000 0100 111' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RPALOS
        when '110 1000 0101 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE3OS
        when '110 1000 0101 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE3OS
        when '110 1000 0110 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE3
        when '110 1000 0110 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE3
        when '110 1000 0111 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE3
        when '110 1000 0111 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE3
        when '110 1000 0111 100' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // PAALL
        when '110 1000 0111 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE3
        when '110 1001 0001 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE3OSNXS
        when '110 1001 0001 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE3OSNXS
        when '110 1001 0001 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE3OSNXS
        when '110 1001 0010 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE3ISNXS
        when '110 1001 0010 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE3ISNXS
        when '110 1001 0011 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE3ISNXS
        when '110 1001 0011 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE3ISNXS
        when '110 1001 0011 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE3ISNXS
        when '110 1001 0101 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE3OSNXS
        when '110 1001 0101 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE3OSNXS
        when '110 1001 0110 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVAE3NXS
        when '110 1001 0110 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // RVALE3NXS
        when '110 1001 0111 000' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // ALLE3NXS
        when '110 1001 0111 001' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VAE3NXS
        when '110 1001 0111 101' return <a link="Sys_TLBI" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</a>;  // VALE3NXS
        otherwise                return <a link="Sys_SYS" file="shared_pseudocode.xml" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_SYS</a>;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/sysop/SystemOp" mylink="aarch64.instrs.system.sysops.sysop.SystemOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SystemOp
// ========
// System instruction types.

enumeration <anchor link="SystemOp" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">SystemOp</anchor> {<anchor link="Sys_AT" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_AT</anchor>, <anchor link="Sys_BRB" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_BRB</anchor>, <anchor link="Sys_DC" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_DC</anchor>, <anchor link="Sys_IC" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_IC</anchor>, <anchor link="Sys_TLBI" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_TLBI</anchor>, <anchor link="Sys_SYS" hover="enumeration SystemOp {Sys_AT, Sys_BRB, Sys_DC, Sys_IC, Sys_TLBI, Sys_SYS}">Sys_SYS</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBIP_IPAS2" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBIP_IPAS2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBIP_IPAS2()
// =====================
// Invalidate by IPA all stage 2 only TLB entries in the indicated shareability
// domain matching the indicated VMID in the indicated regime with the indicated security state.
// Note: stage 1 and stage 2 combined entries are not in the scope of this operation.
// IPA and related parameters of the are derived from Xt.

<anchor link="AArch64.TLBIP_IPAS2.7" hover="function: AArch64.TLBIP_IPAS2(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(128) Xt)">AArch64.TLBIP_IPAS2</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                    <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(128) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_IPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IPAS2</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl          = Xt&lt;47:44&gt;;
    r.address      = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(Xt&lt;107:64&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 64);
    r.d64          = r.ttl IN {'00xx'};
    r.d128         = TRUE;

    case security of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            r.ipaspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            r.ipaspace = if Xt&lt;63&gt; == '1' then <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> else <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            r.ipaspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
        otherwise
            // Root security state does not have stage 2 translation
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBIP_RIPAS2" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBIP_RIPAS2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBIP_RIPAS2()
// ======================
// Range invalidate by IPA all stage 2 only TLB entries in the indicated
// shareability domain matching the indicated VMID in the indicated regime with the indicated
// security state.
// Note: stage 1 and stage 2 combined entries are not in the scope of this operation.
// The range of IPA and related parameters of the are derived from Xt.

<anchor link="AArch64.TLBIP_RIPAS2.7" hover="function: AArch64.TLBIP_RIPAS2(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(128) Xt)">AArch64.TLBIP_RIPAS2</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                     <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(128) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_RIPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RIPAS2</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl&lt;1:0&gt;     = Xt&lt;38:37&gt;;
    r.d64          = r.ttl&lt;1:0&gt; == '00';
    r.d128         = TRUE;

    bits(2) tg        = Xt&lt;47:46&gt;;
    integer scale     = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;45:44&gt;);
    integer num       = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;43:39&gt;);
    integer baseaddr  = <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(Xt&lt;36:0&gt;);

    boolean valid;

    (valid, r.tg, r.address, r.end_address) = <a link="impl-aarch64.TLBIPRange.2" file="shared_pseudocode.xml" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIPRange(Regime regime, bits(128) Xt)">TLBIPRange</a>(regime, Xt);

    if !valid then return;

    case security of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            r.ipaspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            r.ipaspace = if Xt&lt;63&gt; == '1' then <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> else <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            r.ipaspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
        otherwise
            // Root security state does not have stage 2 translation
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBIP_RVA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBIP_RVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBIP_RVA()
// ===================
// Range invalidate by VA range all stage 1 TLB entries in the indicated
// shareability domain matching the indicated VMID and ASID (where regime
// supports VMID, ASID) in the indicated regime with the indicated security state.
// ASID, and range related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBIP_RVA.7" hover="function: AArch64.TLBIP_RVA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(128)  Xt)">AArch64.TLBIP_RVA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                  <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(128)  Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_RVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = Xt&lt;63:48&gt;;
    r.ttl&lt;1:0&gt;     = Xt&lt;38:37&gt;;
    r.d64          = r.ttl&lt;1:0&gt; == '00';
    r.d128         = TRUE;

    boolean valid;

    (valid, r.tg, r.address, r.end_address) = <a link="impl-aarch64.TLBIPRange.2" file="shared_pseudocode.xml" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIPRange(Regime regime, bits(128) Xt)">TLBIPRange</a>(regime, Xt);

    if !valid then return;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBIP_RVAA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBIP_RVAA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBIP_RVAA()
// ====================
// Range invalidate by VA range all stage 1 TLB entries in the indicated
// shareability domain matching the indicated VMID (where regimesupports VMID)
// and all ASID in the indicated regime with the indicated security state.
// VA range related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBIP_RVAA.7" hover="function: AArch64.TLBIP_RVAA(SecurityState security, Regime  regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(128) Xt)">AArch64.TLBIP_RVAA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a>  regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(128) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_RVAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVAA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl&lt;1:0&gt;     = Xt&lt;38:37&gt;;
    r.d64          = r.ttl&lt;1:0&gt; == '00';
    r.d128         = TRUE;

    bits(2) tg        = Xt&lt;47:46&gt;;
    integer scale     = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;45:44&gt;);
    integer num       = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;43:39&gt;);
    integer baseaddr  = <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(Xt&lt;36:0&gt;);

    boolean valid;

    (valid, r.tg, r.address, r.end_address) = <a link="impl-aarch64.TLBIPRange.2" file="shared_pseudocode.xml" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIPRange(Regime regime, bits(128) Xt)">TLBIPRange</a>(regime, Xt);

    if !valid then return;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBIP_VA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBIP_VA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBIP_VA()
// ==================
// Invalidate by VA all stage 1 TLB entries in the indicated shareability domain
// matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime
// with the indicated security state.
// ASID, VA and related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBIP_VA.7" hover="function: AArch64.TLBIP_VA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level,  TLBIMemAttr attr, bits(128) Xt)">AArch64.TLBIP_VA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                 <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level,  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(128) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = Xt&lt;63:48&gt;;
    r.ttl          = Xt&lt;47:44&gt;;
    r.address      = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(Xt&lt;107:64&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 64);
    r.d64          = r.ttl IN {'00xx'};
    r.d128         = TRUE;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBIP_VAA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBIP_VAA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBIP_VAA()
// ===================
// Invalidate by VA all stage 1 TLB entries in the indicated shareability domain
// matching the indicated VMID (where regime supports VMID) and all ASID in the indicated regime
// with the indicated security state.
// VA and related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBIP_VAA.7" hover="function: AArch64.TLBIP_VAA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr,  bits(128) Xt)">AArch64.TLBIP_VAA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                  <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr,  bits(128) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VAA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl          = Xt&lt;47:44&gt;;
    r.address      = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(Xt&lt;107:64&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 64);
    r.d64          = r.ttl IN {'00xx'};
    r.d128         = TRUE;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_ALL" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_ALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_ALL()
// ==================
// Invalidate all entries for the indicated translation regime with the
// the indicated security state for all TLBs within the indicated shareability domain.
// Invalidation applies to all applicable stage 1 and stage 2 entries.

<anchor link="AArch64.TLBI_ALL.4" hover="function: AArch64.TLBI_ALL(SecurityState security, Regime regime, Shareability shareability, TLBIMemAttr attr)">AArch64.TLBI_ALL</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_ALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ALL</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_ASID" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_ASID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_ASID()
// ===================
// Invalidate all stage 1 entries matching the indicated VMID (where regime supports)
// and ASID in the parameter Xt in the indicated translation regime with the
// indicated security state for all TLBs within the indicated shareability domain.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBI_ASID.6" hover="function: AArch64.TLBI_ASID(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr, bits(64) Xt)">AArch64.TLBI_ASID</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                  <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(64) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_ASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ASID</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr         = attr;
    r.asid         = Xt&lt;63:48&gt;;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_IPAS2" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_IPAS2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_IPAS2()
// ====================
// Invalidate by IPA all stage 2 only TLB entries in the indicated shareability
// domain matching the indicated VMID in the indicated regime with the indicated security state.
// Note: stage 1 and stage 2 combined entries are not in the scope of this operation.
// IPA and related parameters of the are derived from Xt.

<anchor link="AArch64.TLBI_IPAS2.7" hover="function: AArch64.TLBI_IPAS2(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(64) Xt)">AArch64.TLBI_IPAS2</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(64) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_IPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IPAS2</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl          = Xt&lt;47:44&gt;;
    r.address      = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(Xt&lt;39:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 64);
    r.d64          = TRUE;
    r.d128         = r.ttl IN {'00xx'};

    case security of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            r.ipaspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            r.ipaspace = if Xt&lt;63&gt; == '1' then <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> else <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            r.ipaspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
        otherwise
            // Root security state does not have stage 2 translation
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_PAALL" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_PAALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_PAALL()
// ====================
// TLB Invalidate ALL GPT Information.
// Invalidates cached copies of GPT entries from TLBs in the indicated
// Shareabilty domain.
// The invalidation applies to all TLB entries containing GPT information.

<anchor link="AArch64.TLBI_PAALL.1" hover="function: AArch64.TLBI_PAALL(Shareability shareability)">AArch64.TLBI_PAALL</anchor>(<a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability)
    assert <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;

    // r.security and r.regime do not apply for TLBI by PA operations
    r.op    = <a link="TLBIOp_PAALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_PAALL</a>;
    r.level = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.attr  = <a link="TLBI_AllAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBI_AllAttr</a>;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);

    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_RIPAS2" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_RIPAS2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_RIPAS2()
// =====================
// Range invalidate by IPA all stage 2 only TLB entries in the indicated
// shareability domain matching the indicated VMID in the indicated regime with the indicated
// security state.
// Note: stage 1 and stage 2 combined entries are not in the scope of this operation.
// The range of IPA and related parameters of the are derived from Xt.

<anchor link="AArch64.TLBI_RIPAS2.7" hover="function: AArch64.TLBI_RIPAS2(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(64) Xt)">AArch64.TLBI_RIPAS2</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                    <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(64) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_RIPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RIPAS2</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl&lt;1:0&gt;     = Xt&lt;38:37&gt;;
    r.d64          = TRUE;
    r.d128         = r.ttl&lt;1:0&gt; == '00';

    bits(2) tg        = Xt&lt;47:46&gt;;
    integer scale     = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;45:44&gt;);
    integer num       = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;43:39&gt;);
    integer baseaddr  = <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(Xt&lt;36:0&gt;);

    boolean valid;

    (valid, r.tg, r.address, r.end_address) = <a link="impl-aarch64.TLBIRange.2" file="shared_pseudocode.xml" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIRange(Regime regime, bits(64) Xt)">TLBIRange</a>(regime, Xt);

    if !valid then return;

    case security of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            r.ipaspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            r.ipaspace = if Xt&lt;63&gt; == '1' then <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> else <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            r.ipaspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
        otherwise
            // Root security state does not have stage 2 translation
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_RPA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_RPA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_RPA()
// ==================
// TLB Range Invalidate GPT Information by PA.
// Invalidates cached copies of GPT entries from TLBs in the indicated
// Shareabilty domain.
// The invalidation applies to TLB entries containing GPT information relating
// to the indicated physical address range.
// When the indicated level is
//     TLBILevel_Any  : this applies to TLB entries containing GPT information
//                      from all levels of the GPT walk
//     TLBILevel_Last : this applies to TLB entries containing GPT information
//                      from the last level of the GPT walk

<anchor link="AArch64.TLBI_RPA.3" hover="function: AArch64.TLBI_RPA(TLBILevel level, bits(64) Xt, Shareability shareability)">AArch64.TLBI_RPA</anchor>(<a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, bits(64) Xt, <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability)
    assert <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    integer range_bits;
    integer p;

    // r.security and r.regime do not apply for TLBI by PA operations
    r.op    = <a link="TLBIOp_RPA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RPA</a>;
    r.level = level;
    r.attr  = <a link="TLBI_AllAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBI_AllAttr</a>;

    // SIZE field
    case Xt&lt;47:44&gt; of
        when '0000' range_bits = 12; // 4KB
        when '0001' range_bits = 14; // 16KB
        when '0010' range_bits = 16; // 64KB
        when '0011' range_bits = 21; // 2MB
        when '0100' range_bits = 25; // 32MB
        when '0101' range_bits = 29; // 512MB
        when '0110' range_bits = 30; // 1GB
        when '0111' range_bits = 34; // 16GB
        when '1000' range_bits = 36; // 64GB
        when '1001' range_bits = 39; // 512GB
        otherwise   range_bits = 0;  // Reserved encoding

    // If SIZE selects a range smaller than PGS, then PGS is used instead
    case <a link="impl-shared.DecodePGS.1" file="shared_pseudocode.xml" hover="function: PGSe DecodePGS(bits(2) pgs)">DecodePGS</a>(GPCCR_EL3.PGS) of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  p = 12;
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> p = 14;
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> p = 16;

    if range_bits &lt; p then
        range_bits = p;

    bits(52) BaseADDR = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(52);
    case GPCCR_EL3.PGS of
        when '00' BaseADDR&lt;51:12&gt; = Xt&lt;39:0&gt;;   // 4KB
        when '10' BaseADDR&lt;51:14&gt; = Xt&lt;39:2&gt;;   // 16KB
        when '01' BaseADDR&lt;51:16&gt; = Xt&lt;39:4&gt;;   // 64KB

    // The calculation here automatically aligns BaseADDR to the size of
    // the region specififed in SIZE. However, the architecture does not
    // require this alignment and if BaseADDR is not aligned to the region
    // specified by SIZE then no entries are required to be invalidated.
    bits(52) start_addr = BaseADDR AND NOT <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(range_bits), 52);
    bits(52) end_addr   = start_addr + <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(range_bits), 52);

    // PASpace is not considered in TLBI by PA operations
    r.address     = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(start_addr, 64);
    r.end_address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(end_addr, 64);

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_RVA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_RVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_RVA()
// ==================
// Range invalidate by VA range all stage 1 TLB entries in the indicated
// shareability domain matching the indicated VMID and ASID (where regime
// supports VMID, ASID) in the indicated regime with the indicated security state.
// ASID, and range related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBI_RVA.7" hover="function: AArch64.TLBI_RVA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(64)  Xt)">AArch64.TLBI_RVA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                 <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(64)  Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_RVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = Xt&lt;63:48&gt;;
    r.ttl&lt;1:0&gt;     = Xt&lt;38:37&gt;;
    r.d64          = TRUE;
    r.d128         = r.ttl&lt;1:0&gt; == '00';

    boolean valid;

    (valid, r.tg, r.address, r.end_address) = <a link="impl-aarch64.TLBIRange.2" file="shared_pseudocode.xml" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIRange(Regime regime, bits(64) Xt)">TLBIRange</a>(regime, Xt);

    if !valid then return;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_RVAA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_RVAA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_RVAA()
// ===================
// Range invalidate by VA range all stage 1 TLB entries in the indicated
// shareability domain matching the indicated VMID (where regimesupports VMID)
// and all ASID in the indicated regime with the indicated security state.
// VA range related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBI_RVAA.7" hover="function: AArch64.TLBI_RVAA(SecurityState security, Regime  regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr, bits(64) Xt)">AArch64.TLBI_RVAA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a>  regime, bits(16) vmid,
                  <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(64) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_RVAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVAA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl&lt;1:0&gt;     = Xt&lt;38:37&gt;;
    r.d64          = TRUE;
    r.d128         = r.ttl&lt;1:0&gt; == '00';

    bits(2) tg        = Xt&lt;47:46&gt;;
    integer scale     = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;45:44&gt;);
    integer num       = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;43:39&gt;);
    integer baseaddr  = <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(Xt&lt;36:0&gt;);

    boolean valid;

    (valid, r.tg, r.address, r.end_address) = <a link="impl-aarch64.TLBIRange.2" file="shared_pseudocode.xml" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIRange(Regime regime, bits(64) Xt)">TLBIRange</a>(regime, Xt);

    if !valid then return;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_VA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_VA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_VA()
// =================
// Invalidate by VA all stage 1 TLB entries in the indicated shareability domain
// matching the indicated VMID and ASID (where regime supports VMID, ASID) in the indicated regime
// with the indicated security state.
// ASID, VA and related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBI_VA.7" hover="function: AArch64.TLBI_VA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level,  TLBIMemAttr attr, bits(64) Xt)">AArch64.TLBI_VA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level,  <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr, bits(64) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.asid         = Xt&lt;63:48&gt;;
    r.ttl          = Xt&lt;47:44&gt;;
    r.address      = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(Xt&lt;43:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 64);
    r.d64          = TRUE;
    r.d128         = r.ttl IN {'00xx'};

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_VAA" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_VAA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_VAA()
// ==================
// Invalidate by VA all stage 1 TLB entries in the indicated shareability domain
// matching the indicated VMID (where regime supports VMID) and all ASID in the indicated regime
// with the indicated security state.
// VA and related parameters are derived from Xt.
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.

<anchor link="AArch64.TLBI_VAA.7" hover="function: AArch64.TLBI_VAA(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBILevel level, TLBIMemAttr attr,  bits(64) Xt)">AArch64.TLBI_VAA</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                 <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a> level, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr,  bits(64) Xt)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VAA</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.vmid         = vmid;
    r.level        = level;
    r.attr         = attr;
    r.ttl          = Xt&lt;47:44&gt;;
    r.address      = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(Xt&lt;43:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 64);
    r.d64          = TRUE;
    r.d128         = r.ttl IN {'00xx'};

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_VMALL" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_VMALL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_VMALL()
// ====================
// Invalidate all stage 1 entries for the indicated translation regime with the
// the indicated security state for all TLBs within the indicated shareability
// domain that match the indicated VMID (where applicable).
// Note: stage 1 and stage 2 combined entries are in the scope of this operation.
// Note: stage 2 only entries are not in the scope of this operation.

<anchor link="AArch64.TLBI_VMALL.5" hover="function: AArch64.TLBI_VMALL(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr)">AArch64.TLBI_VMALL</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                   <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VMALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALL</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.vmid         = vmid;
    r.attr         = attr;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/AArch64.TLBI_VMALLS12" mylink="aarch64.instrs.system.sysops.tlbi.AArch64.TLBI_VMALLS12" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBI_VMALLS12()
// =======================
// Invalidate all stage 1 and stage 2 entries for the indicated translation
// regime with the indicated security state for all TLBs within the indicated
// shareability domain that match the indicated VMID.

<anchor link="AArch64.TLBI_VMALLS12.5" hover="function: AArch64.TLBI_VMALLS12(SecurityState security, Regime regime, bits(16) vmid, Shareability shareability, TLBIMemAttr attr)">AArch64.TLBI_VMALLS12</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(16) vmid,
                      <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a> attr)
    assert PSTATE.EL IN {<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>};

    <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r;
    r.op           = <a link="TLBIOp_VMALLS12" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALLS12</a>;
    r.from_aarch64 = TRUE;
    r.security     = security;
    r.regime       = regime;
    r.level        = <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a>;
    r.vmid         = vmid;
    r.attr         = attr;

    <a link="impl-aarch64.TLBI.1" file="shared_pseudocode.xml" hover="function: TLBI(TLBIRecord r)">TLBI</a>(r);
    if shareability != <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> then <a link="impl-aarch64.Broadcast.2" file="shared_pseudocode.xml" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</a>(shareability, r);
    return;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/ASID_NONE" mylink="aarch64.instrs.system.sysops.tlbi.ASID_NONE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(16) <anchor link="ASID_NONE" hover="constant bits(16) ASID_NONE = Zeros(16)">ASID_NONE</anchor> = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/Broadcast" mylink="aarch64.instrs.system.sysops.tlbi.Broadcast" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Broadcast()
// ===========
// IMPLEMENTATION DEFINED function to broadcast TLBI operation within the indicated shareability
// domain.

<anchor link="impl-aarch64.Broadcast.2" hover="function: Broadcast(Shareability shareability, TLBIRecord r)">Broadcast</anchor>(<a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, <a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r)
    IMPLEMENTATION_DEFINED;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/DecodeTLBITG" mylink="aarch64.instrs.system.sysops.tlbi.DecodeTLBITG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeTLBITG()
// ==============
// Decode translation granule size in TLBI range instructions

TGx <anchor link="impl-aarch64.DecodeTLBITG.1" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</anchor>(bits(2) tg)
    case tg of
        when '01'   return <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
        when '10'   return <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;
        when '11'   return <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/GPTTLBIMatch" mylink="aarch64.instrs.system.sysops.tlbi.GPTTLBIMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPTTLBIMatch()
// ==============
// Determine whether the GPT TLB entry lies within the scope of invalidation

boolean <anchor link="impl-aarch64.GPTTLBIMatch.2" hover="function: boolean GPTTLBIMatch(TLBIRecord tlbi, GPTEntry entry)">GPTTLBIMatch</anchor>(<a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> tlbi, <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> entry)
    assert tlbi.op IN {<a link="TLBIOp_RPA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RPA</a>, <a link="TLBIOp_PAALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_PAALL</a>};

    boolean match;
    bits(64) entry_size_mask    = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(entry.size), 64);
    bits(64) entry_end_address   = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(entry.pa&lt;55:0&gt; OR entry_size_mask&lt;55:0&gt;, 64);
    bits(64) entry_start_address = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(entry.pa&lt;55:0&gt; AND NOT entry_size_mask&lt;55:0&gt;, 64);

    case tlbi.op of
        when <a link="TLBIOp_RPA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RPA</a>
            match = (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.address&lt;55:0&gt;) &lt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_end_address&lt;55:0&gt;) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.end_address&lt;55:0&gt;) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_start_address&lt;55:0&gt;) &amp;&amp;
                     (tlbi.level == <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a> || entry.level == 1));
        when <a link="TLBIOp_PAALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_PAALL</a>
            match = TRUE;

    return match;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/HasLargeAddress" mylink="aarch64.instrs.system.sysops.tlbi.HasLargeAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HasLargeAddress()
// =================
// Returns TRUE if the regime is configured for 52 bit addresses, FALSE otherwise.

boolean <anchor link="impl-aarch64.HasLargeAddress.1" hover="function: boolean HasLargeAddress(Regime regime)">HasLargeAddress</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    if !<a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        return FALSE;
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>
            return TCR_EL3&lt;32&gt; == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>
            return TCR_EL2&lt;32&gt; == '1';
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>
            return TCR_EL2&lt;59&gt; == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>
            return TCR_EL1&lt;59&gt; == '1';
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/ResTLBIRTTL" mylink="aarch64.instrs.system.sysops.tlbi.ResTLBIRTTL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ResTLBIRTTL()
// =============
// Determine whether the TTL field in TLBI instructions that do apply
// to a range of addresses contains a reserved value

boolean <anchor link="impl-aarch64.ResTLBIRTTL.2" hover="function: boolean ResTLBIRTTL(bits(2) tg, bits(2) ttl)">ResTLBIRTTL</anchor>(bits(2) tg, bits(2) ttl)
    case ttl of
        when '00' return TRUE;
        when '01' return <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tg) == <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a> &amp;&amp; !<a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>();
        otherwise return FALSE;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/ResTLBITTL" mylink="aarch64.instrs.system.sysops.tlbi.ResTLBITTL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ResTLBITTL()
// ============
// Determine whether the TTL field in TLBI instructions that do not apply
// to a range of addresses contains a reserved value

boolean <anchor link="impl-aarch64.ResTLBITTL.1" hover="function: boolean ResTLBITTL(bits(4) ttl)">ResTLBITTL</anchor>(bits(4) ttl)
    case ttl of
        when '00xx' return TRUE;
        when '0100' return !<a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>();
        when '1000' return TRUE;
        when '1001' return !<a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>();
        when '1100' return TRUE;
        otherwise   return FALSE;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBI" mylink="aarch64.instrs.system.sysops.tlbi.TLBI" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBI()
// ======
// Invalidates TLB entries for which TLBIMatch() returns TRUE.

<anchor link="impl-aarch64.TLBI.1" hover="function: TLBI(TLBIRecord r)">TLBI</anchor>(<a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> r)
    IMPLEMENTATION_DEFINED;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBILevel" mylink="aarch64.instrs.system.sysops.tlbi.TLBILevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBILevel
// =========

enumeration <anchor link="TLBILevel" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</anchor> {
    <anchor link="TLBILevel_Any" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</anchor>,        // this applies to TLB entries at all levels
    <anchor link="TLBILevel_Last" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Last</anchor>        // this applies to TLB entries at last level only
};</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBIMatch" mylink="aarch64.instrs.system.sysops.tlbi.TLBIMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBIMatch()
// ===========
// Determine whether the TLB entry lies within the scope of invalidation

boolean <anchor link="impl-aarch64.TLBIMatch.2" hover="function: boolean TLBIMatch(TLBIRecord tlbi, TLBRecord entry)">TLBIMatch</anchor>(<a link="TLBIRecord" file="shared_pseudocode.xml" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</a> tlbi, <a link="TLBRecord" file="shared_pseudocode.xml" hover="type TLBRecord is ( TLBContext context, TTWState walkstate, integer blocksize, integer contigsize, bits(128) s1descriptor, bits(128) s2descriptor )">TLBRecord</a> entry)
    boolean match;
    bits(64) entry_block_mask    = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(entry.blocksize), 64);
    bits(64) entry_end_address   = entry.context.ia OR entry_block_mask;
    bits(64) entry_start_address = entry.context.ia AND NOT entry_block_mask;
    case tlbi.op of
        when <a link="TLBIOp_DALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DALL</a>, <a link="TLBIOp_IALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IALL</a>
            match = (tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime);
        when <a link="TLBIOp_DASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DASID</a>, <a link="TLBIOp_IASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IASID</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     (<a link="impl-shared.UseASID.1" file="shared_pseudocode.xml" hover="function: boolean UseASID(TLBContext access)">UseASID</a>(entry.context) &amp;&amp; entry.context.nG == '1' &amp;&amp;
                        tlbi.asid  == entry.context.asid));
        when <a link="TLBIOp_DVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DVA</a>, <a link="TLBIOp_IVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IVA</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     (!<a link="impl-shared.UseASID.1" file="shared_pseudocode.xml" hover="function: boolean UseASID(TLBContext access)">UseASID</a>(entry.context) || tlbi.asid == entry.context.asid ||
                        entry.context.nG == '0') &amp;&amp;
                     tlbi.address&lt;55:entry.blocksize&gt; == entry.context.ia&lt;55:entry.blocksize&gt; &amp;&amp;
                     (tlbi.level == <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a> || !entry.walkstate.istable));
        when <a link="TLBIOp_ALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ALL</a>
            relax_regime = (tlbi.from_aarch64 &amp;&amp;
                            tlbi.regime IN {<a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>, <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>} &amp;&amp;
                            entry.context.regime IN {<a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>, <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>});
            match = (tlbi.security == entry.context.ss &amp;&amp;
                     (tlbi.regime  == entry.context.regime || relax_regime));
        when <a link="TLBIOp_ASID" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ASID</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     (<a link="impl-shared.UseASID.1" file="shared_pseudocode.xml" hover="function: boolean UseASID(TLBContext access)">UseASID</a>(entry.context) &amp;&amp; entry.context.nG == '1' &amp;&amp;
                        tlbi.asid  == entry.context.asid));
        when <a link="TLBIOp_IPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IPAS2</a>, <a link="TLBIPOp_IPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_IPAS2</a>
            match = (!entry.context.includes_s1 &amp;&amp; entry.context.includes_s2 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     tlbi.ipaspace == entry.context.ipaspace &amp;&amp;
                     tlbi.address&lt;55:entry.blocksize&gt; == entry.context.ia&lt;55:entry.blocksize&gt; &amp;&amp;
                     (!tlbi.from_aarch64 || <a link="impl-aarch64.ResTLBITTL.1" file="shared_pseudocode.xml" hover="function: boolean ResTLBITTL(bits(4) ttl)">ResTLBITTL</a>(tlbi.ttl) || (
                         <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tlbi.ttl&lt;3:2&gt;) == entry.context.tg &amp;&amp;
                         <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.ttl&lt;1:0&gt;) == entry.walkstate.level)
                     ) &amp;&amp;
                     ((tlbi.d128  &amp;&amp; entry.context.isd128) ||
                      (tlbi.d64  &amp;&amp; !entry.context.isd128) ||
                      (tlbi.d64 &amp;&amp; tlbi.d128)) &amp;&amp;
                     (tlbi.level == <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a> || !entry.walkstate.istable));
        when <a link="TLBIOp_VAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VAA</a>, <a link="TLBIPOp_VAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_VAA</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     tlbi.address&lt;55:entry.blocksize&gt; == entry.context.ia&lt;55:entry.blocksize&gt; &amp;&amp;
                     (!tlbi.from_aarch64 || <a link="impl-aarch64.ResTLBITTL.1" file="shared_pseudocode.xml" hover="function: boolean ResTLBITTL(bits(4) ttl)">ResTLBITTL</a>(tlbi.ttl) || (
                         <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tlbi.ttl&lt;3:2&gt;) == entry.context.tg &amp;&amp;
                         <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.ttl&lt;1:0&gt;) == entry.walkstate.level)
                     ) &amp;&amp;
                     ((tlbi.d128  &amp;&amp; entry.context.isd128) ||
                      (tlbi.d64  &amp;&amp; !entry.context.isd128) ||
                      (tlbi.d64 &amp;&amp; tlbi.d128)) &amp;&amp;
                     (tlbi.level == <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a> || !entry.walkstate.istable));
        when <a link="TLBIOp_VA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VA</a>, <a link="TLBIPOp_VA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_VA</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     (!<a link="impl-shared.UseASID.1" file="shared_pseudocode.xml" hover="function: boolean UseASID(TLBContext access)">UseASID</a>(entry.context) || tlbi.asid == entry.context.asid ||
                        entry.context.nG == '0') &amp;&amp;
                     tlbi.address&lt;55:entry.blocksize&gt; == entry.context.ia&lt;55:entry.blocksize&gt; &amp;&amp;
                     (!tlbi.from_aarch64 || <a link="impl-aarch64.ResTLBITTL.1" file="shared_pseudocode.xml" hover="function: boolean ResTLBITTL(bits(4) ttl)">ResTLBITTL</a>(tlbi.ttl) || (
                         <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tlbi.ttl&lt;3:2&gt;) == entry.context.tg &amp;&amp;
                         <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.ttl&lt;1:0&gt;) == entry.walkstate.level)
                     ) &amp;&amp;
                     ((tlbi.d128  &amp;&amp; entry.context.isd128) ||
                      (tlbi.d64  &amp;&amp; !entry.context.isd128) ||
                      (tlbi.d64 &amp;&amp; tlbi.d128)) &amp;&amp;
                     (tlbi.level == <a link="TLBILevel_Any" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel_Any</a> || !entry.walkstate.istable));
        when <a link="TLBIOp_VMALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALL</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid));
        when <a link="TLBIOp_VMALLS12" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALLS12</a>
            match = (tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid));
        when <a link="TLBIOp_RIPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RIPAS2</a>, <a link="TLBIPOp_RIPAS2" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_RIPAS2</a>
            match = (!entry.context.includes_s1 &amp;&amp; entry.context.includes_s2 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     tlbi.ipaspace == entry.context.ipaspace &amp;&amp;
                     (tlbi.tg != '00' &amp;&amp; <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tlbi.tg) == entry.context.tg) &amp;&amp;
                     (!tlbi.from_aarch64 || <a link="impl-aarch64.ResTLBIRTTL.2" file="shared_pseudocode.xml" hover="function: boolean ResTLBIRTTL(bits(2) tg, bits(2) ttl)">ResTLBIRTTL</a>(tlbi.tg, tlbi.ttl&lt;1:0&gt;) ||
                        <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.ttl&lt;1:0&gt;) == entry.walkstate.level) &amp;&amp;
                     ((tlbi.d128  &amp;&amp; entry.context.isd128) ||
                      (tlbi.d64  &amp;&amp; !entry.context.isd128) ||
                      (tlbi.d64 &amp;&amp; tlbi.d128)) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.address&lt;55:0&gt;) &lt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_end_address&lt;55:0&gt;) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.end_address&lt;55:0&gt;) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_start_address&lt;55:0&gt;));
        when <a link="TLBIOp_RVAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVAA</a>, <a link="TLBIPOp_RVAA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_RVAA</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     (tlbi.tg != '00' &amp;&amp; <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tlbi.tg) == entry.context.tg) &amp;&amp;
                     (!tlbi.from_aarch64 || <a link="impl-aarch64.ResTLBIRTTL.2" file="shared_pseudocode.xml" hover="function: boolean ResTLBIRTTL(bits(2) tg, bits(2) ttl)">ResTLBIRTTL</a>(tlbi.tg, tlbi.ttl&lt;1:0&gt;) ||
                        <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.ttl&lt;1:0&gt;) == entry.walkstate.level) &amp;&amp;
                     ((tlbi.d128  &amp;&amp; entry.context.isd128) ||
                      (tlbi.d64  &amp;&amp; !entry.context.isd128) ||
                      (tlbi.d64 &amp;&amp; tlbi.d128)) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.address&lt;55:0&gt;) &lt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_end_address&lt;55:0&gt;) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.end_address&lt;55:0&gt;) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_start_address&lt;55:0&gt;));
        when <a link="TLBIOp_RVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVA</a>, <a link="TLBIPOp_RVA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_RVA</a>
            match = (entry.context.includes_s1 &amp;&amp;
                     tlbi.security == entry.context.ss &amp;&amp;
                     tlbi.regime   == entry.context.regime &amp;&amp;
                     (!<a link="impl-shared.UseVMID.1" file="shared_pseudocode.xml" hover="function: boolean UseVMID(TLBContext access)">UseVMID</a>(entry.context) || tlbi.vmid == entry.context.vmid) &amp;&amp;
                     (!<a link="impl-shared.UseASID.1" file="shared_pseudocode.xml" hover="function: boolean UseASID(TLBContext access)">UseASID</a>(entry.context) || tlbi.asid == entry.context.asid ||
                        entry.context.nG == '0') &amp;&amp;
                     (tlbi.tg != '00' &amp;&amp; <a link="impl-aarch64.DecodeTLBITG.1" file="shared_pseudocode.xml" hover="function: TGx DecodeTLBITG(bits(2) tg)">DecodeTLBITG</a>(tlbi.tg) == entry.context.tg) &amp;&amp;
                     (!tlbi.from_aarch64 || <a link="impl-aarch64.ResTLBIRTTL.2" file="shared_pseudocode.xml" hover="function: boolean ResTLBIRTTL(bits(2) tg, bits(2) ttl)">ResTLBIRTTL</a>(tlbi.tg, tlbi.ttl&lt;1:0&gt;) ||
                        <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.ttl&lt;1:0&gt;) == entry.walkstate.level) &amp;&amp;
                     ((tlbi.d128  &amp;&amp; entry.context.isd128) ||
                      (tlbi.d64  &amp;&amp; !entry.context.isd128) ||
                      (tlbi.d64 &amp;&amp; tlbi.d128)) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.address&lt;55:0&gt;) &lt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_end_address&lt;55:0&gt;) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.end_address&lt;55:0&gt;) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_start_address&lt;55:0&gt;));
        when <a link="TLBIOp_RPA" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RPA</a>
            entry_end_address&lt;55:0&gt; = (entry.walkstate.baseaddress.address&lt;55:0&gt; OR
                                               entry_block_mask&lt;55:0&gt;);
            entry_start_address&lt;55:0&gt; = (entry.walkstate.baseaddress.address&lt;55:0&gt; AND
                                                 NOT entry_block_mask&lt;55:0&gt;);
            match = (entry.context.includes_gpt &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.address&lt;55:0&gt;) &lt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_end_address&lt;55:0&gt;) &amp;&amp;
                     <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(tlbi.end_address&lt;55:0&gt;) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(entry_start_address&lt;55:0&gt;));
        when <a link="TLBIOp_PAALL" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_PAALL</a>
            match = entry.context.includes_gpt;

    if tlbi.attr == <a link="TLBI_ExcludeXS" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBI_ExcludeXS</a> &amp;&amp; entry.context.xs == '1' then
        match = FALSE;

    return match;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBIMemAttr" mylink="aarch64.instrs.system.sysops.tlbi.TLBIMemAttr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBIMemAttr
// ===========
// Defines the attributes of the memory operations that must be completed in
// order to deem the TLBI operation as completed.

enumeration <anchor link="TLBIMemAttr" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</anchor> {
    <anchor link="TLBI_AllAttr" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBI_AllAttr</anchor>,         // All TLB entries within the scope of the invalidation
    <anchor link="TLBI_ExcludeXS" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBI_ExcludeXS</anchor>        // Only TLB entries with XS=0 within the scope of the invalidation
};</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBIOp" mylink="aarch64.instrs.system.sysops.tlbi.TLBIOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBIOp
// ======

enumeration <anchor link="TLBIOp" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp</anchor> {
    <anchor link="TLBIOp_DALL" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DALL</anchor>,          // AArch32 Data TLBI operations - deprecated
    <anchor link="TLBIOp_DASID" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DASID</anchor>,
    <anchor link="TLBIOp_DVA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_DVA</anchor>,
    <anchor link="TLBIOp_IALL" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IALL</anchor>,          // AArch32 Instruction TLBI operations - deprecated
    <anchor link="TLBIOp_IASID" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IASID</anchor>,
    <anchor link="TLBIOp_IVA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IVA</anchor>,
    <anchor link="TLBIOp_ALL" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ALL</anchor>,
    <anchor link="TLBIOp_ASID" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_ASID</anchor>,
    <anchor link="TLBIOp_IPAS2" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_IPAS2</anchor>,
    <anchor link="TLBIPOp_IPAS2" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_IPAS2</anchor>,
    <anchor link="TLBIOp_VAA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VAA</anchor>,
    <anchor link="TLBIOp_VA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VA</anchor>,
    <anchor link="TLBIPOp_VAA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_VAA</anchor>,
    <anchor link="TLBIPOp_VA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_VA</anchor>,
    <anchor link="TLBIOp_VMALL" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALL</anchor>,
    <anchor link="TLBIOp_VMALLS12" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_VMALLS12</anchor>,
    <anchor link="TLBIOp_RIPAS2" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RIPAS2</anchor>,
    <anchor link="TLBIPOp_RIPAS2" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_RIPAS2</anchor>,
    <anchor link="TLBIOp_RVAA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVAA</anchor>,
    <anchor link="TLBIOp_RVA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RVA</anchor>,
    <anchor link="TLBIPOp_RVAA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_RVAA</anchor>,
    <anchor link="TLBIPOp_RVA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIPOp_RVA</anchor>,
    <anchor link="TLBIOp_RPA" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_RPA</anchor>,
    <anchor link="TLBIOp_PAALL" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp_PAALL</anchor>,
};</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBIPRange" mylink="aarch64.instrs.system.sysops.tlbi.TLBIPRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBIPRange()
// ============
// Extract the input address range information from encoded Xt.

(boolean, bits(2), bits(64), bits(64)) <anchor link="impl-aarch64.TLBIPRange.2" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIPRange(Regime regime, bits(128) Xt)">TLBIPRange</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(128) Xt)
    boolean  valid = TRUE;
    bits(64) start = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    bits(64) end   = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

    bits(2) tg        = Xt&lt;47:46&gt;;
    integer scale     = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;45:44&gt;);
    integer num       = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;43:39&gt;);
    integer tg_bits;

    if tg == '00' then
        return (FALSE, tg, start, end);

    case tg of
        when '01' // 4KB
            tg_bits = 12;
            start&lt;55:12&gt; = Xt&lt;107:64&gt;;
            start&lt;63:56&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;107&gt;, 8);
        when '10' // 16KB
            tg_bits = 14;
            start&lt;55:14&gt; = Xt&lt;107:66&gt;;
            start&lt;63:56&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;107&gt;, 8);
        when '11' // 64KB
            tg_bits = 16;
            start&lt;55:16&gt; = Xt&lt;107:68&gt;;
            start&lt;63:56&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;107&gt;, 8);
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    integer range = (num+1) &lt;&lt; (5*scale + 1 + tg_bits);
    end   = start + range&lt;63:0&gt;;

    if end&lt;55&gt; != start&lt;55&gt; then
        // overflow, saturate it
        end = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(start&lt;55&gt;, 64-55) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(55);

    return (valid, tg, start, end);</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBIRange" mylink="aarch64.instrs.system.sysops.tlbi.TLBIRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBIRange()
// ===========
// Extract the input address range information from encoded Xt.

(boolean, bits(2), bits(64), bits(64)) <anchor link="impl-aarch64.TLBIRange.2" hover="function: (boolean, bits(2), bits(64), bits(64)) TLBIRange(Regime regime, bits(64) Xt)">TLBIRange</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(64) Xt)
    boolean  valid = TRUE;
    bits(64) start = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    bits(64) end   = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

    bits(2) tg        = Xt&lt;47:46&gt;;
    integer scale     = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;45:44&gt;);
    integer num       = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Xt&lt;43:39&gt;);
    integer tg_bits;

    if tg == '00' then
        return (FALSE, tg, start, end);

    case tg of
        when '01' // 4KB
            tg_bits = 12;
            if <a link="impl-aarch64.HasLargeAddress.1" file="shared_pseudocode.xml" hover="function: boolean HasLargeAddress(Regime regime)">HasLargeAddress</a>(regime) then
                start&lt;52:16&gt; = Xt&lt;36:0&gt;;
                start&lt;63:53&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;36&gt;, 11);
            else
                start&lt;48:12&gt; = Xt&lt;36:0&gt;;
                start&lt;63:49&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;36&gt;, 15);
        when '10' // 16KB
            tg_bits = 14;
            if <a link="impl-aarch64.HasLargeAddress.1" file="shared_pseudocode.xml" hover="function: boolean HasLargeAddress(Regime regime)">HasLargeAddress</a>(regime) then
                start&lt;52:16&gt; = Xt&lt;36:0&gt;;
                start&lt;63:53&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;36&gt;, 11);
            else
                start&lt;50:14&gt; = Xt&lt;36:0&gt;;
                start&lt;63:51&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;36&gt;, 13);
        when '11' // 64KB
            tg_bits = 16;
            start&lt;52:16&gt; = Xt&lt;36:0&gt;;
            start&lt;63:53&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(Xt&lt;36&gt;, 11);
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    integer range = (num+1) &lt;&lt; (5*scale + 1 + tg_bits);
    end   = start + range&lt;63:0&gt;;

    if end&lt;52&gt; != start&lt;52&gt; then
        // overflow, saturate it
        end = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(start&lt;52&gt;, 64-52) : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(52);

    return (valid, tg, start, end);</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/TLBIRecord" mylink="aarch64.instrs.system.sysops.tlbi.TLBIRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBIRecord
// ==========
// Details related to a TLBI operation.

type <anchor link="TLBIRecord" hover="type TLBIRecord is ( TLBIOp op, boolean from_aarch64, SecurityState security, Regime regime, bits(16) vmid, bits(16) asid, TLBILevel level, TLBIMemAttr attr, PASpace ipaspace, bits(64) address, bits(64) end_address, boolean d64, boolean d128, bits(4) ttl, bits(2) tg )">TLBIRecord</anchor> is (
    <a link="TLBIOp" file="shared_pseudocode.xml" hover="enumeration TLBIOp { TLBIOp_DALL, TLBIOp_DASID, TLBIOp_DVA, TLBIOp_IALL, TLBIOp_IASID, TLBIOp_IVA, TLBIOp_ALL, TLBIOp_ASID, TLBIOp_IPAS2, TLBIPOp_IPAS2, TLBIOp_VAA, TLBIOp_VA, TLBIPOp_VAA, TLBIPOp_VA, TLBIOp_VMALL, TLBIOp_VMALLS12, TLBIOp_RIPAS2, TLBIPOp_RIPAS2, TLBIOp_RVAA, TLBIOp_RVA, TLBIPOp_RVAA, TLBIPOp_RVA, TLBIOp_RPA, TLBIOp_PAALL, }">TLBIOp</a>          op,
    boolean         from_aarch64, // originated as an AArch64 operation
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a>   security,
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a>          regime,
    bits(16)        vmid,
    bits(16)        asid,
    <a link="TLBILevel" file="shared_pseudocode.xml" hover="enumeration TLBILevel { TLBILevel_Any, TLBILevel_Last }">TLBILevel</a>       level,
    <a link="TLBIMemAttr" file="shared_pseudocode.xml" hover="enumeration TLBIMemAttr { TLBI_AllAttr, TLBI_ExcludeXS }">TLBIMemAttr</a>     attr,
    <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a>         ipaspace,     // For operations that take IPA as input address
    bits(64)        address,      // input address, for range operations, start address
    bits(64)        end_address,  // for range operations, end address
    boolean         d64,          // For operations that evict VMSAv8-64 based TLB entries
    boolean         d128,         // For operations that evict VMSAv9-128 based TLB entries
    bits(4)         ttl,          // translation table walk level holding the leaf entry
                                  // for the address being invalidated
                                  // For Non-Range Invalidations:
                                  //   When the ttl is
                                  //     '00xx'    : this applies to all TLB entries
                                  //     Otherwise : TLBIP instructions invalidates D128 TLB
                                  //                 entries only
                                  //                 TLBI instructions invalidates D64 TLB
                                  //                 entries only
                                  // For Range Invalidations:
                                  //   When the ttl is
                                  //     '00'      : this applies to all TLB entries
                                  //     Otherwise : TLBIP instructions invalidates D128 TLB
                                  //                 entries only
                                  //                 TLBI instructions invalidates D64 TLB
                                  //                 entries only
    bits(2)         tg            // for range operations, translation granule
)</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/VMID" mylink="aarch64.instrs.system.sysops.tlbi.VMID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VMID[]
// ======
// Effective VMID.

bits(16) <anchor link="impl-aarch64.VMID.read.0" hover="accessor: bits(16) VMID[]">VMID</anchor>[]
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            if <a link="impl-shared.Have16bitVMID.0" file="shared_pseudocode.xml" hover="function: boolean Have16bitVMID()">Have16bitVMID</a>() &amp;&amp; VTCR_EL2.VS == '1' then
                return VTTBR_EL2.VMID;
            else
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR_EL2.VMID&lt;7:0&gt;, 16);
        else
            return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR.VMID, 16);
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then
        return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    else
        return <a link="VMID_NONE" file="shared_pseudocode.xml" hover="constant bits(16) VMID_NONE = Zeros(16)">VMID_NONE</a>;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops/tlbi/VMID_NONE" mylink="aarch64.instrs.system.sysops.tlbi.VMID_NONE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(16) <anchor link="VMID_NONE" hover="constant bits(16) VMID_NONE = Zeros(16)">VMID_NONE</anchor> = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops_128/sysop_128/SysOp128" mylink="aarch64.instrs.system.sysops_128.sysop_128.SysOp128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SysOp128()
// ==========

SystemOp <anchor link="impl-aarch64.SysOp128.4" hover="function: SystemOp SysOp128(bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2)">SysOp128</anchor>(bits(3) op1, bits(4) CRn, bits(4) CRm, bits(3) op2)
    case op1:CRn:CRm:op2 of
        when '000 1000 0001 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE1OS
        when '000 1000 0001 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAAE1OS
        when '000 1000 0001 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE1OS
        when '000 1000 0001 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAALE1OS
        when '000 1000 0011 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE1IS
        when '000 1000 0011 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAAE1IS
        when '000 1000 0011 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE1IS
        when '000 1000 0011 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAALE1IS
        when '000 1000 0111 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE1
        when '000 1000 0111 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAAE1
        when '000 1000 0111 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE1
        when '000 1000 0111 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAALE1
        when '000 1001 0001 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE1OSNXS
        when '000 1001 0001 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAAE1OSNXS
        when '000 1001 0001 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE1OSNXS
        when '000 1001 0001 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAALE1OSNXS
        when '000 1001 0011 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE1ISNXS
        when '000 1001 0011 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAAE1ISNXS
        when '000 1001 0011 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE1ISNXS
        when '000 1001 0011 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAALE1ISNXS
        when '000 1001 0111 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE1NXS
        when '000 1001 0111 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAAE1NXS
        when '000 1001 0111 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE1NXS
        when '000 1001 0111 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAALE1NXS
        when '100 1000 0001 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE2OS
        when '100 1000 0001 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE2OS
        when '100 1000 0011 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE2IS
        when '100 1000 0011 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE2IS
        when '100 1000 0111 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE2
        when '100 1000 0111 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE2
        when '100 1001 0001 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE2OSNXS
        when '100 1001 0001 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE2OSNXS
        when '100 1001 0011 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE2ISNXS
        when '100 1001 0011 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE2ISNXS
        when '100 1001 0111 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE2NXS
        when '100 1001 0111 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE2NXS
        when '110 1000 0001 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE3OS
        when '110 1000 0001 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE3OS
        when '110 1000 0011 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE3IS
        when '110 1000 0011 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE3IS
        when '110 1000 0111 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE3
        when '110 1000 0111 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE3
        when '110 1001 0001 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE3OSNXS
        when '110 1001 0001 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE3OSNXS
        when '110 1001 0011 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE3ISNXS
        when '110 1001 0011 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE3ISNXS
        when '110 1001 0111 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VAE3NXS
        when '110 1001 0111 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // VALE3NXS
        when '100 1000 0000 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2E1IS
        when '100 1000 0000 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2LE1IS
        when '100 1000 0100 000' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2E1OS
        when '100 1000 0100 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2E1
        when '100 1000 0100 100' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2LE1OS
        when '100 1000 0100 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2LE1
        when '100 1001 0000 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2E1ISNXS
        when '100 1001 0000 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2LE1ISNXS
        when '100 1001 0100 000' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2E1OSNXS
        when '100 1001 0100 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2E1NXS
        when '100 1001 0100 100' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2LE1OSNXS
        when '100 1001 0100 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // IPAS2LE1NXS
        when '000 1000 0010 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE1IS
        when '000 1000 0010 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAAE1IS
        when '000 1000 0010 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE1IS
        when '000 1000 0010 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAALE1IS
        when '000 1000 0101 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE1OS
        when '000 1000 0101 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAAE1OS
        when '000 1000 0101 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE1OS
        when '000 1000 0101 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAALE1OS
        when '000 1000 0110 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE1
        when '000 1000 0110 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAAE1
        when '000 1000 0110 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE1
        when '000 1000 0110 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAALE1
        when '000 1001 0010 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE1ISNXS
        when '000 1001 0010 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAAE1ISNXS
        when '000 1001 0010 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE1ISNXS
        when '000 1001 0010 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAALE1ISNXS
        when '000 1001 0101 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE1OSNXS
        when '000 1001 0101 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAAE1OSNXS
        when '000 1001 0101 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE1OSNXS
        when '000 1001 0101 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAALE1OSNXS
        when '000 1001 0110 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE1NXS
        when '000 1001 0110 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAAE1NXS
        when '000 1001 0110 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE1NXS
        when '000 1001 0110 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAALE1NXS
        when '100 1000 0010 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE2IS
        when '100 1000 0010 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE2IS
        when '100 1000 0101 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE2OS
        when '100 1000 0101 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE2OS
        when '100 1000 0110 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE2
        when '100 1000 0110 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE2
        when '100 1001 0010 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE2ISNXS
        when '100 1001 0010 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE2ISNXS
        when '100 1001 0101 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE2OSNXS
        when '100 1001 0101 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE2OSNXS
        when '100 1001 0110 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE2NXS
        when '100 1001 0110 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE2NXS
        when '110 1000 0010 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE3IS
        when '110 1000 0010 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE3IS
        when '110 1000 0101 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE3OS
        when '110 1000 0101 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE3OS
        when '110 1000 0110 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE3
        when '110 1000 0110 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE3
        when '110 1001 0010 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE3ISNXS
        when '110 1001 0010 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE3ISNXS
        when '110 1001 0101 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE3OSNXS
        when '110 1001 0101 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE3OSNXS
        when '110 1001 0110 001' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVAE3NXS
        when '110 1001 0110 101' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RVALE3NXS
        when '100 1000 0000 010' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2E1IS
        when '100 1000 0000 110' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2LE1IS
        when '100 1000 0100 010' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2E1
        when '100 1000 0100 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2E1OS
        when '100 1000 0100 110' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2LE1
        when '100 1000 0100 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2LE1OS
        when '100 1001 0000 010' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2E1ISNXS
        when '100 1001 0000 110' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2LE1ISNXS
        when '100 1001 0100 010' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2E1NXS
        when '100 1001 0100 011' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2E1OSNXS
        when '100 1001 0100 110' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2LE1NXS
        when '100 1001 0100 111' return <a link="Sys_TLBIP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</a>;  // RIPAS2LE1OSNXS
        otherwise                return <a link="Sys_SYSP" file="shared_pseudocode.xml" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_SYSP</a>;</pstext>
    </ps>
    <ps name="aarch64/instrs/system/sysops_128/sysop_128/SystemOp128" mylink="aarch64.instrs.system.sysops_128.sysop_128.SystemOp128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SystemOp128()
// =============
// System instruction types.

enumeration <anchor link="SystemOp128" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">SystemOp128</anchor> {<anchor link="Sys_TLBIP" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_TLBIP</anchor>, <anchor link="Sys_SYSP" hover="enumeration SystemOp128 {Sys_TLBIP, Sys_SYSP}">Sys_SYSP</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/vector/arithmetic/binary/uniform/logical/bsl-eor/vbitop/VBitOp" mylink="aarch64.instrs.vector.arithmetic.binary.uniform.logical.bsl-eor.vbitop.VBitOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VBitOp
// ======
// Vector bit select instruction types.

enumeration <anchor link="VBitOp" hover="enumeration VBitOp      {VBitOp_VBIF, VBitOp_VBIT, VBitOp_VBSL, VBitOp_VEOR}">VBitOp</anchor>      {<anchor link="VBitOp_VBIF" hover="enumeration VBitOp      {VBitOp_VBIF, VBitOp_VBIT, VBitOp_VBSL, VBitOp_VEOR}">VBitOp_VBIF</anchor>, <anchor link="VBitOp_VBIT" hover="enumeration VBitOp      {VBitOp_VBIF, VBitOp_VBIT, VBitOp_VBSL, VBitOp_VEOR}">VBitOp_VBIT</anchor>, <anchor link="VBitOp_VBSL" hover="enumeration VBitOp      {VBitOp_VBIF, VBitOp_VBIT, VBitOp_VBSL, VBitOp_VEOR}">VBitOp_VBSL</anchor>, <anchor link="VBitOp_VEOR" hover="enumeration VBitOp      {VBitOp_VBIF, VBitOp_VBIT, VBitOp_VBSL, VBitOp_VEOR}">VBitOp_VEOR</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/vector/arithmetic/unary/cmp/compareop/CompareOp" mylink="aarch64.instrs.vector.arithmetic.unary.cmp.compareop.CompareOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CompareOp
// =========
// Vector compare instruction types.

enumeration <anchor link="CompareOp" hover="enumeration CompareOp   {CompareOp_GT, CompareOp_GE, CompareOp_EQ, CompareOp_LE, CompareOp_LT}">CompareOp</anchor>   {<anchor link="CompareOp_GT" hover="enumeration CompareOp   {CompareOp_GT, CompareOp_GE, CompareOp_EQ, CompareOp_LE, CompareOp_LT}">CompareOp_GT</anchor>, <anchor link="CompareOp_GE" hover="enumeration CompareOp   {CompareOp_GT, CompareOp_GE, CompareOp_EQ, CompareOp_LE, CompareOp_LT}">CompareOp_GE</anchor>, <anchor link="CompareOp_EQ" hover="enumeration CompareOp   {CompareOp_GT, CompareOp_GE, CompareOp_EQ, CompareOp_LE, CompareOp_LT}">CompareOp_EQ</anchor>,
                         <anchor link="CompareOp_LE" hover="enumeration CompareOp   {CompareOp_GT, CompareOp_GE, CompareOp_EQ, CompareOp_LE, CompareOp_LT}">CompareOp_LE</anchor>, <anchor link="CompareOp_LT" hover="enumeration CompareOp   {CompareOp_GT, CompareOp_GE, CompareOp_EQ, CompareOp_LE, CompareOp_LT}">CompareOp_LT</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/vector/logical/immediateop/ImmediateOp" mylink="aarch64.instrs.vector.logical.immediateop.ImmediateOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ImmediateOp
// ===========
// Vector logical immediate instruction types.

enumeration <anchor link="ImmediateOp" hover="enumeration ImmediateOp {ImmediateOp_MOVI, ImmediateOp_MVNI, ImmediateOp_ORR, ImmediateOp_BIC}">ImmediateOp</anchor> {<anchor link="ImmediateOp_MOVI" hover="enumeration ImmediateOp {ImmediateOp_MOVI, ImmediateOp_MVNI, ImmediateOp_ORR, ImmediateOp_BIC}">ImmediateOp_MOVI</anchor>, <anchor link="ImmediateOp_MVNI" hover="enumeration ImmediateOp {ImmediateOp_MOVI, ImmediateOp_MVNI, ImmediateOp_ORR, ImmediateOp_BIC}">ImmediateOp_MVNI</anchor>,
                         <anchor link="ImmediateOp_ORR" hover="enumeration ImmediateOp {ImmediateOp_MOVI, ImmediateOp_MVNI, ImmediateOp_ORR, ImmediateOp_BIC}">ImmediateOp_ORR</anchor>, <anchor link="ImmediateOp_BIC" hover="enumeration ImmediateOp {ImmediateOp_MOVI, ImmediateOp_MVNI, ImmediateOp_ORR, ImmediateOp_BIC}">ImmediateOp_BIC</anchor>};</pstext>
    </ps>
    <ps name="aarch64/instrs/vector/reduce/reduceop/Reduce" mylink="aarch64.instrs.vector.reduce.reduceop.Reduce" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Reduce()
// ========

bits(esize) <anchor link="impl-aarch64.Reduce.3" hover="function: bits(esize) Reduce(ReduceOp op, bits(N) input, integer esize)">Reduce</anchor>(<a link="ReduceOp" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp</a> op, bits(N) input, integer esize)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; FPCR.AH == '1';
    return <a link="impl-aarch64.Reduce.4" file="shared_pseudocode.xml" hover="function: bits(esize) Reduce(ReduceOp op, bits(N) input, integer esize, boolean altfp)">Reduce</a>(op, input, esize, altfp);

// Reduce()
// ========
// Perform the operation 'op' on pairs of elements from the input vector,
// reducing the vector to a scalar result. The 'altfp' argument controls
// alternative floating-point behavior.

bits(esize) <anchor link="impl-aarch64.Reduce.4" hover="function: bits(esize) Reduce(ReduceOp op, bits(N) input, integer esize, boolean altfp)">Reduce</anchor>(<a link="ReduceOp" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp</a> op, bits(N) input, integer esize, boolean altfp)
    integer half;
    bits(esize) hi;
    bits(esize) lo;
    bits(esize) result;

    if N == esize then
        return input&lt;esize-1:0&gt;;

    half = N DIV 2;
    hi = <a link="impl-aarch64.Reduce.4" file="shared_pseudocode.xml" hover="function: bits(esize) Reduce(ReduceOp op, bits(N) input, integer esize, boolean altfp)">Reduce</a>(op, input&lt;N-1:half&gt;, esize, altfp);
    lo = <a link="impl-aarch64.Reduce.4" file="shared_pseudocode.xml" hover="function: bits(esize) Reduce(ReduceOp op, bits(N) input, integer esize, boolean altfp)">Reduce</a>(op, input&lt;half-1:0&gt;, esize, altfp);

    case op of
        when <a link="ReduceOp_FMINNUM" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMINNUM</a>
            result = <a link="impl-shared.FPMinNum.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMinNum(bits(N) op1_in, bits(N) op2_in, FPCRType fpcr)">FPMinNum</a>(lo, hi, FPCR[]);
        when <a link="ReduceOp_FMAXNUM" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMAXNUM</a>
            result = <a link="impl-shared.FPMaxNum.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMaxNum(bits(N) op1_in, bits(N) op2_in, FPCRType fpcr)">FPMaxNum</a>(lo, hi, FPCR[]);
        when <a link="ReduceOp_FMIN" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMIN</a>
            result = <a link="impl-shared.FPMin.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMin(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMin</a>(lo, hi, FPCR[], altfp);
        when <a link="ReduceOp_FMAX" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMAX</a>
            result = <a link="impl-shared.FPMax.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMax(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMax</a>(lo, hi, FPCR[], altfp);
        when <a link="ReduceOp_FADD" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FADD</a>
            result = <a link="impl-shared.FPAdd.3" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPAdd</a>(lo, hi, FPCR[]);
        when <a link="ReduceOp_ADD" file="shared_pseudocode.xml" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_ADD</a>
            result = lo + hi;

    return result;</pstext>
    </ps>
    <ps name="aarch64/instrs/vector/reduce/reduceop/ReduceOp" mylink="aarch64.instrs.vector.reduce.reduceop.ReduceOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReduceOp
// ========
// Vector reduce instruction types.

enumeration <anchor link="ReduceOp" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp</anchor> {<anchor link="ReduceOp_FMINNUM" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMINNUM</anchor>, <anchor link="ReduceOp_FMAXNUM" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMAXNUM</anchor>,
                      <anchor link="ReduceOp_FMIN" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMIN</anchor>, <anchor link="ReduceOp_FMAX" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FMAX</anchor>,
                      <anchor link="ReduceOp_FADD" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_FADD</anchor>, <anchor link="ReduceOp_ADD" hover="enumeration ReduceOp {ReduceOp_FMINNUM, ReduceOp_FMAXNUM, ReduceOp_FMIN, ReduceOp_FMAX, ReduceOp_FADD, ReduceOp_ADD}">ReduceOp_ADD</anchor>};</pstext>
    </ps>
    <ps name="aarch64/translation/attrs/AArch64.MAIRAttr" mylink="aarch64.translation.attrs.AArch64.MAIRAttr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MAIRAttr()
// ==================
// Retrieve the memory attribute encoding indexed in the given MAIR

bits(8) AArch64.MAIRAttr(integer index, MAIRType mair2, MAIRType mair)
    bit_index = 8 * index;
    assert (index &lt; 8 || (<a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() &amp;&amp; (index &lt; 16)));
    if (index &gt; 7) then
        bit_index = bit_index - 64;                      // Read from LSB at MAIR2
        return mair2&lt;bit_index+7:bit_index&gt;;
    else
        return mair&lt;bit_index+7:bit_index&gt;;</pstext>
    </ps>
    <ps name="aarch64/translation/debug/AArch64.CheckBreakpoint" mylink="aarch64.translation.debug.AArch64.CheckBreakpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckBreakpoint()
// =========================
// Called before executing the instruction of length "size" bytes at "vaddress" in an AArch64
// translation regime, when either debug exceptions are enabled, or halting debug is enabled
// and halting is allowed.

FaultRecord <anchor link="AArch64.CheckBreakpoint.4" hover="function: FaultRecord AArch64.CheckBreakpoint(FaultRecord fault_in, bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckBreakpoint</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, bits(64) vaddress,
                                    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size)
    assert !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    assert (<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; size IN {2,4}) || size == 4;

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    for i = 0 to <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>() - 1
        if <a link="AArch64.BreakpointMatch.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.BreakpointMatch(integer n, bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.BreakpointMatch</a>(i, vaddress, accdesc, size) then
            fault.statuscode = <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;

    if fault.statuscode == <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a> &amp;&amp; <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() then
        reason = <a link="DebugHalt_Breakpoint" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Breakpoint = '000111'">DebugHalt_Breakpoint</a>;
        <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(reason);

    return fault;</pstext>
    </ps>
    <ps name="aarch64/translation/debug/AArch64.CheckDebug" mylink="aarch64.translation.debug.AArch64.CheckDebug" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckDebug()
// ====================
// Called on each access to check for a debug exception or entry to Debug state.

FaultRecord <anchor link="AArch64.CheckDebug.3" hover="function: FaultRecord AArch64.CheckDebug(bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckDebug</anchor>(bits(64) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size)

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
    boolean generate_exception;

    boolean d_side = (<a link="impl-shared.IsDataAccess.1" file="shared_pseudocode.xml" hover="function: boolean IsDataAccess(AccessType acctype)">IsDataAccess</a>(accdesc.acctype) || accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>);
    boolean i_side = (accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>);
    if accdesc.acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
        mask = '0';
        ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
        generate_exception = (<a link="AArch64.GenerateDebugExceptionsFrom.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state, bit mask)">AArch64.GenerateDebugExceptionsFrom</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, ss, mask) &amp;&amp;
                              MDSCR_EL1.MDE == '1');
    else
        generate_exception = <a link="AArch64.GenerateDebugExceptions.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptions()">AArch64.GenerateDebugExceptions</a>() &amp;&amp; MDSCR_EL1.MDE == '1';
    halt = <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>();

    if generate_exception || halt then
        if d_side then
            fault = <a link="AArch64.CheckWatchpoint.4" file="shared_pseudocode.xml" hover="function: FaultRecord AArch64.CheckWatchpoint(FaultRecord fault_in, bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckWatchpoint</a>(fault, vaddress, accdesc, size);
        elsif i_side then
            fault = <a link="AArch64.CheckBreakpoint.4" file="shared_pseudocode.xml" hover="function: FaultRecord AArch64.CheckBreakpoint(FaultRecord fault_in, bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckBreakpoint</a>(fault, vaddress, accdesc, size);

    return fault;</pstext>
    </ps>
    <ps name="aarch64/translation/debug/AArch64.CheckWatchpoint" mylink="aarch64.translation.debug.AArch64.CheckWatchpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckWatchpoint()
// =========================
// Called before accessing the memory location of "size" bytes at "address",
// when either debug exceptions are enabled for the access, or halting debug
// is enabled and halting is allowed.

FaultRecord <anchor link="AArch64.CheckWatchpoint.4" hover="function: FaultRecord AArch64.CheckWatchpoint(FaultRecord fault_in, bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckWatchpoint</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, bits(64) vaddress,
                                    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size)
    assert !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.S1TranslationRegime.0" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</a>());
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a> then
        if accdesc.cacheop != <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> then
            return fault;
    elsif !<a link="impl-shared.IsDataAccess.1" file="shared_pseudocode.xml" hover="function: boolean IsDataAccess(AccessType acctype)">IsDataAccess</a>(accdesc.acctype) then
        return fault;

    for i = 0 to <a link="impl-shared.NumWatchpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumWatchpointsImplemented()">NumWatchpointsImplemented</a>() - 1
        if <a link="AArch64.WatchpointMatch.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.WatchpointMatch(integer n, bits(64) vaddress, integer size, AccessDescriptor accdesc)">AArch64.WatchpointMatch</a>(i, vaddress, size, accdesc) then
            fault.statuscode = <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;
            if DBGWCR_EL1[i].LSC&lt;0&gt; == '1' &amp;&amp; accdesc.read then
                fault.write = FALSE;
            elsif DBGWCR_EL1[i].LSC&lt;1&gt; == '1' &amp;&amp; accdesc.write then
                fault.write = TRUE;

    if (fault.statuscode == <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a> &amp;&amp; <a link="impl-shared.HaltOnBreakpointOrWatchpoint.0" file="shared_pseudocode.xml" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</a>() &amp;&amp;
            !accdesc.nonfault &amp;&amp; !(accdesc.firstfault &amp;&amp; !accdesc.first)) then
        reason = <a link="DebugHalt_Watchpoint" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Watchpoint = '101011'">DebugHalt_Watchpoint</a>;
        EDWAR = vaddress;
        <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(reason);

    return fault;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.IASize" mylink="aarch64.translation.vmsa_addrcalc.AArch64.IASize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IASize()
// ================
// Retrieve the number of bits containing the input address

integer <anchor link="AArch64.IASize.1" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</anchor>(bits(6) txsz)
    return 64 - <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(txsz);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.LeafBase" mylink="aarch64.translation.vmsa_addrcalc.AArch64.LeafBase" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.LeafBase()
// ==================
// Extract the address embedded in a block and page descriptor pointing to the
// base of a memory block

bits(56) <anchor link="AArch64.LeafBase.5" hover="function: bits(56) AArch64.LeafBase(bits(N) descriptor, bit d128, bit ds, TGx tgx, integer level)">AArch64.LeafBase</anchor>(bits(N) descriptor, bit d128, bit ds,
                               <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer level)
    bits(56) leafbase = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(56);

    granulebits  = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(tgx);
    descsizelog2 = if d128 == '1' then 4 else 3;
    stride      = granulebits - descsizelog2;
    leafsize    = granulebits + stride * (<a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - level);

    leafbase&lt;47:0&gt; = descriptor&lt;47:leafsize&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(leafsize);

    if <a link="impl-shared.Have56BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitPAExt()">Have56BitPAExt</a>() &amp;&amp; d128 == '1' then
        leafbase&lt;55:48&gt; = descriptor&lt;55:48&gt;;
        return leafbase;
    if <a link="impl-shared.Have52BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</a>() &amp;&amp; tgx == <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> then
        leafbase&lt;51:48&gt; = descriptor&lt;15:12&gt;;
    elsif ds == '1' then
        leafbase&lt;51:48&gt; = descriptor&lt;9:8&gt;:descriptor&lt;49:48&gt;;

    return leafbase;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.NextTableBase" mylink="aarch64.translation.vmsa_addrcalc.AArch64.NextTableBase" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.NextTableBase()
// =======================
// Extract the address embedded in a table descriptor pointing to the base of
// the next level table of descriptors

bits(56) <anchor link="AArch64.NextTableBase.4" hover="function: bits(56) AArch64.NextTableBase(bits(N) descriptor, bit d128, bit ds, TGx tgx)">AArch64.NextTableBase</anchor>(bits(N) descriptor, bit d128, bit ds, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    bits(56) tablebase = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(56);

    case tgx of
        when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>  tablebase&lt;47:12&gt; = descriptor&lt;47:12&gt;;
        when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a> tablebase&lt;47:14&gt; = descriptor&lt;47:14&gt;;
        when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> tablebase&lt;47:16&gt; = descriptor&lt;47:16&gt;;

    if <a link="impl-shared.Have56BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitPAExt()">Have56BitPAExt</a>() &amp;&amp; d128 == '1' then
        tablebase&lt;55:48&gt; = descriptor&lt;55:48&gt;;
        return tablebase;
    if <a link="impl-shared.Have52BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</a>() &amp;&amp; tgx == <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> then
        tablebase&lt;51:48&gt; = descriptor&lt;15:12&gt;;
        return tablebase;
    if ds == '1' then
        tablebase&lt;51:48&gt; = descriptor&lt;9:8&gt;:descriptor&lt;49:48&gt;;
        return tablebase;
    return tablebase;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.PhysicalAddressSize" mylink="aarch64.translation.vmsa_addrcalc.AArch64.PhysicalAddressSize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PhysicalAddressSize()
// =============================
// Retrieve the number of bits bounding the physical address

integer <anchor link="AArch64.PhysicalAddressSize.3" hover="function: integer AArch64.PhysicalAddressSize(bit d128, bits(3) encoded_ps, TGx tgx)">AArch64.PhysicalAddressSize</anchor>(bit d128, bits(3) encoded_ps, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    integer ps;
    integer max_ps;

    case encoded_ps of
        when '000'  ps = 32;
        when '001'  ps = 36;
        when '010'  ps = 40;
        when '011'  ps = 42;
        when '100'  ps = 44;
        when '101'  ps = 48;
        when '110'  ps = 52;
        when '111'  ps = 56;
    if !<a link="impl-shared.Have56BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitPAExt()">Have56BitPAExt</a>() || d128 == '0' then
        if tgx != <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> &amp;&amp; !<a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
            max_ps = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(48, <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>());
        elsif !<a link="impl-shared.Have52BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</a>() then
            max_ps = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(48, <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>());
        else
            max_ps = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(52, <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>());
    else
        max_ps = <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>();

    return <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(ps, max_ps);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.S1SLTTEntryAddress" mylink="aarch64.translation.vmsa_addrcalc.AArch64.S1SLTTEntryAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1SLTTEntryAddress()
// ============================
// Compute the first stage 1 translation table descriptor address within the
// table pointed to by the base at the start level

<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> AArch64.S1SLTTEntryAddress(integer level, S1TTWParams walkparams,
                                       bits(64) ia, <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase)
    // Input Address size
    iasize       = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);
    granulebits  = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    descsizelog2 = if walkparams.d128 == '1' then 4 else 3;
    stride       = granulebits - descsizelog2;
    levels       = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - level;

    bits(56) index;
    lsb   = levels*stride + granulebits;
    msb   = iasize - 1;
    index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ia&lt;msb:lsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(descsizelog2), 56);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> descaddress;
    descaddress.address = tablebase.address OR index;
    descaddress.paspace = tablebase.paspace;

    return descaddress;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.S1StartLevel" mylink="aarch64.translation.vmsa_addrcalc.AArch64.S1StartLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1StartLevel()
// ======================
// Compute the initial lookup level when performing a stage 1 translation
// table walk

integer AArch64.S1StartLevel(S1TTWParams walkparams)
    // Input Address size
    iasize       = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);
    granulebits  = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    descsizelog2 = if walkparams.d128 == '1' then 4 else 3;
    stride       = granulebits - descsizelog2;
    s1startlevel = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - (((iasize-1) - granulebits) DIV stride);
    if walkparams.d128 == '1' then
        s1startlevel = s1startlevel + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.skl);
    return s1startlevel;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.S2SLTTEntryAddress" mylink="aarch64.translation.vmsa_addrcalc.AArch64.S2SLTTEntryAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2SLTTEntryAddress()
// ============================
// Compute the first stage 2 translation table descriptor address within the
// table pointed to by the base at the start level

<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> AArch64.S2SLTTEntryAddress(S2TTWParams walkparams, bits(56) ipa,
                                       <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase)
    startlevel   = AArch64.S2StartLevel(walkparams);
    iasize       = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);
    granulebits  = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    descsizelog2 = if walkparams.d128 == '1' then 4 else 3;
    stride       = granulebits - descsizelog2;
    levels       = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - startlevel;

    bits(56) index;
    integer lsb;
    integer msb;
    lsb   = levels*stride + granulebits;
    msb   = iasize - 1;
    index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa&lt;msb:lsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(descsizelog2), 56);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> descaddress;
    descaddress.address = tablebase.address OR index;
    descaddress.paspace = tablebase.paspace;

    return descaddress;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.S2StartLevel" mylink="aarch64.translation.vmsa_addrcalc.AArch64.S2StartLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2StartLevel()
// ======================
// Determine the initial lookup level when performing a stage 2 translation
// table walk

integer AArch64.S2StartLevel(S2TTWParams walkparams)
    if walkparams.d128 == '1' then
        iasize       = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);
        granulebits  = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
        descsizelog2 = 4;
        stride       = granulebits - descsizelog2;
        s2startlevel = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - (((iasize-1) - granulebits) DIV stride);
        s2startlevel = s2startlevel + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.skl);

        return s2startlevel;

    case walkparams.tgx of
        when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>
            case walkparams.sl2:walkparams.sl0 of
                when '000' return 2;
                when '001' return 1;
                when '010' return 0;
                when '011' return 3;
                when '100' return -1;
        when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>
            case walkparams.sl0 of
                when '00' return 3;
                when '01' return 2;
                when '10' return 1;
                when '11' return 0;
        when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>
            case walkparams.sl0 of
                when '00' return 3;
                when '01' return 2;
                when '10' return 1;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.TTBaseAddress" mylink="aarch64.translation.vmsa_addrcalc.AArch64.TTBaseAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TTBaseAddress()
// =======================
// Retrieve the PA/IPA pointing to the base of the initial translation table

bits(56) <anchor link="AArch64.TTBaseAddress.7" hover="function: bits(56) AArch64.TTBaseAddress(bits(64) ttb, bits(6) txsz, bits(3) ps, bit d128, bit ds, TGx tgx, integer startlevel)">AArch64.TTBaseAddress</anchor>(bits(64) ttb, bits(6) txsz, bits(3) ps,
                                   bit d128, bit ds, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer startlevel)
    bits(56) tablebase = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(56);

    // Input Address size
    iasize      = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(txsz);
    granulebits = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(tgx);
    descsizelog2 = if d128 == '1' then 4 else 3;
    stride      = granulebits - descsizelog2;
    levels      = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - startlevel;

    // Base address is aligned to size of the initial translation table in bytes
    tsize = (iasize - (levels*stride + granulebits)) + descsizelog2;

    if <a link="impl-shared.Have56BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitPAExt()">Have56BitPAExt</a>() &amp;&amp;  d128 == '1' then
        tsize = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>(tsize, 5);
        tablebase&lt;55:5&gt; = ttb&lt;50:0&gt;;
    elsif (<a link="impl-shared.Have52BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</a>() &amp;&amp; tgx == <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> &amp;&amp; ps == '110') || (ds == '1') then
        tsize = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>(tsize, 6);
        tablebase&lt;51:6&gt; = ttb&lt;4:1&gt;:ttb&lt;46:5&gt;;
    else
        tablebase&lt;47:1&gt; = ttb&lt;46:0&gt;;
    tablebase = <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(tablebase, 1 &lt;&lt; tsize);
    return tablebase;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_addrcalc/AArch64.TTEntryAddress" mylink="aarch64.translation.vmsa_addrcalc.AArch64.TTEntryAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TTEntryAddress()
// ========================
// Compute translation table descriptor address within the table pointed to by
// the table base

FullAddress <anchor link="AArch64.TTEntryAddress.7" hover="function: FullAddress AArch64.TTEntryAddress(integer level, bit d128, bits(2) skl, TGx tgx, bits(6) txsz, bits(64) ia, FullAddress tablebase)">AArch64.TTEntryAddress</anchor>(integer level, bit d128, bits(2) skl, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, bits(6) txsz,
                                   bits(64) ia, <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase)
    // Input Address size
    iasize      = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(txsz);
    granulebits = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(tgx);
    descsizelog2 = if d128 == '1' then 4 else 3;
    stride      = granulebits - descsizelog2;
    levels      = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - level;

    bits(56) index;
    integer lsb;
    integer msb;

    lsb   = levels*stride + granulebits;
    if d128 == '1' then
        msb   = (lsb + stride*(1 + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(skl))) - 1;
    else
        msb   = (lsb + stride) - 1;
    index = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ia&lt;msb:lsb&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(descsizelog2), 56);

    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> descaddress;
    descaddress.address = tablebase.address OR index;
    descaddress.paspace = tablebase.paspace;

    return descaddress;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.AddrTop" mylink="aarch64.translation.vmsa_faults.AArch64.AddrTop" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.AddrTop()
// =================
// Get the top bit position of the virtual address.
// Bits above are not accounted as part of the translation process.

integer <anchor link="AArch64.AddrTop.3" hover="function: integer AArch64.AddrTop(bit tbid, AccessType acctype, bit tbi)">AArch64.AddrTop</anchor>(bit tbid, <a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype, bit tbi)
    if tbid == '1' &amp;&amp; acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        return 63;

    if tbi == '1' then
        return 55;
    else
        return 63;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.ContiguousBitFaults" mylink="aarch64.translation.vmsa_faults.AArch64.ContiguousBitFaults" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ContiguousBitFaults()
// =============================
// If contiguous bit is set, returns whether the translation size exceeds the
// input address size and if the implementation generates a fault

boolean <anchor link="AArch64.ContiguousBitFaults.4" hover="function: boolean AArch64.ContiguousBitFaults(bit d128, bits(6) txsz, TGx tgx, integer level)">AArch64.ContiguousBitFaults</anchor>(bit d128, bits(6) txsz, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer level)
    // Input Address size
    iasize = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(txsz);
    // Translation size
    tsize  = <a link="impl-shared.TranslationSize.3" file="shared_pseudocode.xml" hover="function: integer TranslationSize(bit d128, TGx tgx, integer level)">TranslationSize</a>(d128, tgx, level) + <a link="impl-shared.ContiguousSize.3" file="shared_pseudocode.xml" hover="function: integer ContiguousSize(bit d128, TGx tgx, integer level)">ContiguousSize</a>(d128, tgx, level);

    return (tsize &gt; iasize &amp;&amp;
            boolean IMPLEMENTATION_DEFINED "Translation fault on misprogrammed contiguous bit");</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.IPAIsOutOfRange" mylink="aarch64.translation.vmsa_faults.AArch64.IPAIsOutOfRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.IPAIsOutOfRange()
// =========================
// Check bits not resolved by translation are ZERO

boolean AArch64.IPAIsOutOfRange(bits(56) ipa, S2TTWParams walkparams)
    //Input Address size
    iasize = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);

    if iasize &lt; 56 then
        return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(ipa&lt;55:iasize&gt;);
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.OAOutOfRange" mylink="aarch64.translation.vmsa_faults.AArch64.OAOutOfRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.OAOutOfRange()
// ======================
// Returns whether output address is expressed in the configured size number of bits

boolean <anchor link="AArch64.OAOutOfRange.5" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</anchor>(<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate, bit d128, bits(3) ps,
                             <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, bits(64) ia)
    // Output Address size
    oasize  = <a link="AArch64.PhysicalAddressSize.3" file="shared_pseudocode.xml" hover="function: integer AArch64.PhysicalAddressSize(bit d128, bits(3) encoded_ps, TGx tgx)">AArch64.PhysicalAddressSize</a>(d128, ps, tgx);

    if oasize &lt; 56 then
        if walkstate.istable then
            baseaddress = walkstate.baseaddress.address;
            return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(baseaddress&lt;55:oasize&gt;);
        else
            // Output address
            oa = <a link="impl-shared.StageOA.4" file="shared_pseudocode.xml" hover="function: FullAddress StageOA(bits(64) ia, bit d128, TGx tgx, TTWState walkstate)">StageOA</a>(ia, d128, tgx, walkstate);
            return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(oa.address&lt;55:oasize&gt;);
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1CheckPermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S1CheckPermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1CheckPermissions()
// ============================
// Checks whether stage 1 access violates permissions of target memory
// and returns a fault record

<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> AArch64.S1CheckPermissions(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate,
                                       S1TTWParams walkparams, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = walkstate.permissions;
    <a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> s1perms;

    s1perms = AArch64.S1ComputePermissions(regime, walkstate, walkparams, accdesc);

    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        if s1perms.overlay &amp;&amp; s1perms.ox == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif (walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;
                <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_INSTRDEVICE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_INSTRDEVICE</a>) == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>) then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif s1perms.x == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
    elsif accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a> then
        if accdesc.cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> then
            if s1perms.overlay &amp;&amp; s1perms.ow == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
                fault.overlay    = TRUE;
            elsif s1perms.w == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        // DC from privileged context which clean cannot generate a Permission fault
        elsif accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            if s1perms.overlay &amp;&amp; s1perms.or == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
                fault.overlay    = TRUE;
            elsif (walkparams.cmow == '1' &amp;&amp;
                    accdesc.opscope == <a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a> &amp;&amp;
                    accdesc.cacheop == <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a> &amp;&amp;
                    s1perms.overlay &amp;&amp; s1perms.ow == '0') then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
                fault.overlay    = TRUE;
            elsif s1perms.r == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            elsif (walkparams.cmow == '1' &amp;&amp;
                    accdesc.opscope == <a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a> &amp;&amp;
                    accdesc.cacheop == <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a> &amp;&amp;
                    s1perms.w == '0') then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
    elsif accdesc.acctype == <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a> then
        // IC from privileged context cannot generate Permission fault
        if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            if (s1perms.overlay &amp;&amp; s1perms.or == '0' &amp;&amp;
                  boolean IMPLEMENTATION_DEFINED "Permission fault on <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> IC_IVAU execution") then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
                fault.overlay    = TRUE;
            elsif walkparams.cmow == '1' &amp;&amp; s1perms.overlay &amp;&amp; s1perms.ow == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
                fault.overlay    = TRUE;
            elsif (s1perms.r == '0' &amp;&amp;
                  boolean IMPLEMENTATION_DEFINED "Permission fault on <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> IC_IVAU execution") then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            elsif walkparams.cmow == '1' &amp;&amp; s1perms.w == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
    elsif <a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() &amp;&amp; accdesc.acctype == <a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a> then
        if s1perms.gcs == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif accdesc.write &amp;&amp; walkparams.&lt;ha,hd&gt; != '11' &amp;&amp; permissions.ndirty == '1' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.dirtybit   = TRUE;
            fault.write      = TRUE;
    elsif accdesc.read &amp;&amp; s1perms.overlay &amp;&amp; s1perms.or == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.overlay    = TRUE;
        fault.write      = FALSE;
    elsif accdesc.write &amp;&amp; s1perms.overlay &amp;&amp; s1perms.ow == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.overlay    = TRUE;
        fault.write      = TRUE;
    elsif accdesc.read &amp;&amp; s1perms.r == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.write      = FALSE;
    elsif accdesc.write &amp;&amp; s1perms.w == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.write      = TRUE;
    elsif (accdesc.write &amp;&amp; accdesc.tagaccess &amp;&amp;
            walkstate.memattrs.tags == <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a>) then
        fault.statuscode   = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.write        = TRUE;
        fault.s1tagnotdata = TRUE;
    elsif (accdesc.write &amp;&amp; !(walkparams.&lt;ha,hd&gt; == '11') &amp;&amp; walkparams.pie == '1' &amp;&amp;
            permissions.ndirty == '1') then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.dirtybit   = TRUE;
        fault.write      = TRUE;

    return fault;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1ComputePermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S1ComputePermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1ComputePermissions()
// ==============================
// Computes the overall stage 1 permissions

<a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> AArch64.S1ComputePermissions(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate,
                                              S1TTWParams walkparams, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = walkstate.permissions;
    <a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> s1perms;

    if walkparams.pie == '1' then
        s1perms = AArch64.S1IndirectBasePermissions(regime, walkstate, walkparams, accdesc);
    else
        s1perms = AArch64.S1DirectBasePermissions(regime, walkstate, walkparams, accdesc);

    if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="AArch64.S1E0POEnabled.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1E0POEnabled(Regime regime, bit nv1)">AArch64.S1E0POEnabled</a>(regime, walkparams.nv1) then
        s1perms.overlay = FALSE;
    elsif accdesc.el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="AArch64.S1POEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1POEnabled(Regime regime)">AArch64.S1POEnabled</a>(regime) then
        s1perms.overlay = FALSE;

    if s1perms.overlay then
        s1overlay_perms = <a link="AArch64.S1OverlayPermissions.3" file="shared_pseudocode.xml" hover="function: S1AccessControls AArch64.S1OverlayPermissions(Regime regime, TTWState walkstate, AccessDescriptor accdesc)">AArch64.S1OverlayPermissions</a>(regime, walkstate, accdesc);
        s1perms.or = s1overlay_perms.or;
        s1perms.ow = s1overlay_perms.ow;
        s1perms.ox = s1overlay_perms.ox;

    // If wxn is set, overlay execute permissions is set to 0
    if s1perms.overlay &amp;&amp; s1perms.wxn == '1' &amp;&amp; s1perms.ox == '1' then
        s1perms.ow = '0';
    elsif s1perms.wxn == '1' then
        s1perms.x = '0';

    return s1perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1DirectBasePermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S1DirectBasePermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1DirectBasePermissions()
// =================================
// Computes the stage 1 direct base permissions

<a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> AArch64.S1DirectBasePermissions(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate,
                                                 S1TTWParams walkparams, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bit  r,  w,  x;
    bit pr, pw, px;
    bit ur, uw, ux;
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = walkstate.permissions;
    <a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> s1perms;

    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        // Apply leaf permissions
        case permissions.ap&lt;2:1&gt; of
            when '00' (pr,pw,ur,uw) = ('1','1','0','0'); // Privileged access
            when '01' (pr,pw,ur,uw) = ('1','1','1','1'); // No effect
            when '10' (pr,pw,ur,uw) = ('1','0','0','0'); // Read-only, privileged access
            when '11' (pr,pw,ur,uw) = ('1','0','1','0'); // Read-only

        // Apply hierarchical permissions
        case permissions.ap_table of
            when '00' (pr,pw,ur,uw) = ( pr, pw, ur, uw); // No effect
            when '01' (pr,pw,ur,uw) = ( pr, pw,'0','0'); // Privileged access
            when '10' (pr,pw,ur,uw) = ( pr,'0', ur,'0'); // Read-only
            when '11' (pr,pw,ur,uw) = ( pr,'0','0','0'); // Read-only, privileged access

        // Locations writable by unprivileged cannot be executed by privileged
        px = NOT(permissions.pxn OR permissions.pxn_table OR uw);
        ux = NOT(permissions.uxn OR permissions.uxn_table);

        if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; accdesc.pan &amp;&amp; !(regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; walkparams.nv1 == '1') then
            bit pan;
            if (boolean IMPLEMENTATION_DEFINED "SCR_EL3.SIF affects EPAN" &amp;&amp;
                    accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp;
                    walkstate.baseaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> &amp;&amp;
                    walkparams.sif == '1') then
                ux = '0';

            if (boolean IMPLEMENTATION_DEFINED "Realm <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>&amp;0 regime affects EPAN" &amp;&amp;
                    accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; regime == <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> &amp;&amp;
                    walkstate.baseaddress.paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>) then
                ux = '0';

            pan = PSTATE.PAN AND (ur OR uw OR (walkparams.epan AND ux));
            pr = pr AND NOT(pan);
            pw = pw AND NOT(pan);

    else
        // Apply leaf permissions
        case permissions.ap&lt;2&gt; of
            when '0' (pr,pw) = ('1','1'); // No effect
            when '1' (pr,pw) = ('1','0'); // Read-only

        // Apply hierarchical permissions
        case permissions.ap_table&lt;1&gt; of
            when '0' (pr,pw) = ( pr, pw); // No effect
            when '1' (pr,pw) = ( pr,'0'); // Read-only

        px = NOT(permissions.xn OR permissions.xn_table);

    (r,w,x) = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then (ur,uw,ux) else (pr,pw,px);

    // Compute WXN value
    wxn = walkparams.wxn AND w AND x;

    // Prevent execution from Non-secure space by PE in secure state if SIF is set
    if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; walkstate.baseaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
        x = x AND NOT(walkparams.sif);
    // Prevent execution from non-Root space by Root
    if accdesc.ss == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a> &amp;&amp; walkstate.baseaddress.paspace != <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a> then
        x = '0';
    // Prevent execution from non-Realm space by Realm EL2 and Realm EL2&amp;0
    if (accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; regime IN {<a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>, <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>} &amp;&amp;
            walkstate.baseaddress.paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>) then
        x = '0';

    s1perms.r   = r;
    s1perms.w   = w;
    s1perms.x   = x;
    s1perms.gcs = '0';
    s1perms.wxn = wxn;
    s1perms.overlay = TRUE;

    return s1perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1HasAlignmentFault" mylink="aarch64.translation.vmsa_faults.AArch64.S1HasAlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1HasAlignmentFault()
// =============================
// Returns whether stage 1 output fails alignment requirement on data accesses
// to Device memory

boolean <anchor link="AArch64.S1HasAlignmentFault.4" hover="function: boolean AArch64.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch64.S1HasAlignmentFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned,
                                    bit ntlsmd, <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        return FALSE;
    elsif <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() &amp;&amp; accdesc.tagaccess &amp;&amp; accdesc.write then
        return (memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;
                <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVICETAGSTORE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVICETAGSTORE</a>) == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>);
    elsif accdesc.a32lsmd &amp;&amp; ntlsmd == '0' then
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;  memattrs.device != <a link="DeviceType_GRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_GRE</a>;
    elsif accdesc.acctype == <a link="AccessType_DCZero" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DCZero</a> then
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
    else
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp; !aligned;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1IndirectBasePermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S1IndirectBasePermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1IndirectBasePermissions()
// ===================================
// Computes the stage 1 indirect base permissions

<a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> AArch64.S1IndirectBasePermissions(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate,
                                                   S1TTWParams walkparams,
                                                   <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    bit  r,  w,  x,  gcs,  wxn,   overlay;
    bit pr, pw, px, pgcs, pwxn, p_overlay;
    bit ur, uw, ux, ugcs, uwxn, u_overlay;
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = walkstate.permissions;
    <a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> s1perms;

    // Apply privileged indirect permissions
    case permissions.ppi of
        when '0000' (pr,pw,px,pgcs) = ('0','0','0','0'); // No access
        when '0001' (pr,pw,px,pgcs) = ('1','0','0','0'); // Privileged read
        when '0010' (pr,pw,px,pgcs) = ('0','0','1','0'); // Privileged execute
        when '0011' (pr,pw,px,pgcs) = ('1','0','1','0'); // Privileged read and execute
        when '0100' (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved
        when '0101' (pr,pw,px,pgcs) = ('1','1','0','0'); // Privileged read and write
        when '0110' (pr,pw,px,pgcs) = ('1','1','1','0'); // Privileged read, write and execute
        when '0111' (pr,pw,px,pgcs) = ('1','1','1','0'); // Privileged read, write and execute
        when '1000' (pr,pw,px,pgcs) = ('1','0','0','0'); // Privileged read
        when '1001' (pr,pw,px,pgcs) = ('1','0','0','1'); // Privileged read and gcs
        when '1010' (pr,pw,px,pgcs) = ('1','0','1','0'); // Privileged read and execute
        when '1011' (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved
        when '1100' (pr,pw,px,pgcs) = ('1','1','0','0'); // Privileged read and write
        when '1101' (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved
        when '1110' (pr,pw,px,pgcs) = ('1','1','1','0'); // Privileged read, write and execute
        when '1111' (pr,pw,px,pgcs) = ('0','0','0','0'); // Reserved

    p_overlay = NOT(permissions.ppi[3]);
    pwxn = if permissions.ppi == '0110' then '1' else '0';

    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        // Apply unprivileged indirect permissions
        case permissions.upi of
            when '0000' (ur,uw,ux,ugcs) = ('0','0','0','0'); // No access
            when '0001' (ur,uw,ux,ugcs) = ('1','0','0','0'); // Unprivileged read
            when '0010' (ur,uw,ux,ugcs) = ('0','0','1','0'); // Unprivileged execute
            when '0011' (ur,uw,ux,ugcs) = ('1','0','1','0'); // Unprivileged read and execute
            when '0100' (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved
            when '0101' (ur,uw,ux,ugcs) = ('1','1','0','0'); // Unprivileged read and write
            when '0110' (ur,uw,ux,ugcs) = ('1','1','1','0'); // Unprivileged read, write and execute
            when '0111' (ur,uw,ux,ugcs) = ('1','1','1','0'); // Unprivileged read, write and execute
            when '1000' (ur,uw,ux,ugcs) = ('1','0','0','0'); // Unprivileged read
            when '1001' (ur,uw,ux,ugcs) = ('1','0','0','1'); // Unprivileged read and gcs
            when '1010' (ur,uw,ux,ugcs) = ('1','0','1','0'); // Unprivileged read and execute
            when '1011' (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved
            when '1100' (ur,uw,ux,ugcs) = ('1','1','0','0'); // Unprivileged read and write
            when '1101' (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved
            when '1110' (ur,uw,ux,ugcs) = ('1','1','1','0'); // Unprivileged read,write and execute
            when '1111' (ur,uw,ux,ugcs) = ('0','0','0','0'); // Reserved

        u_overlay = NOT(permissions.upi[3]);
        uwxn = if permissions.upi == '0110' then '1' else '0';

        // If the decoded permissions has either px or pgcs along with either uw or ugcs,
        // then all effective Stage 1 Base Permissions are set to 0
        if ((px == '1' || pgcs == '1') &amp;&amp; (uw == '1' || ugcs == '1')) then
            (pr,pw,px,pgcs) = ('0','0','0','0');
            (ur,uw,ux,ugcs) = ('0','0','0','0');

        if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; accdesc.pan &amp;&amp; !(regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; walkparams.nv1 == '1') then
            if PSTATE.PAN == '1' &amp;&amp; (permissions.upi != '0000') then
                (pr,pw) = ('0','0');

    if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        (r,w,x,gcs,wxn,overlay) = (ur,uw,ux,ugcs,uwxn,u_overlay);
    else
        (r,w,x,gcs,wxn,overlay) = (pr,pw,px,pgcs,pwxn,p_overlay);

    // Prevent execution from Non-secure space by PE in secure state if SIF is set
    if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; walkstate.baseaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
        x = x AND NOT(walkparams.sif);
        gcs = '0';
    // Prevent execution from non-Root space by Root
    if accdesc.ss == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a> &amp;&amp; walkstate.baseaddress.paspace != <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a> then
        x = '0';
        gcs = '0';
    // Prevent execution from non-Realm space by Realm EL2 and Realm EL2&amp;0
    if (accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; regime IN {<a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>, <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>} &amp;&amp;
        walkstate.baseaddress.paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>) then
        x = '0';
        gcs = '0';

    s1perms.r       = r;
    s1perms.w       = w;
    s1perms.x       = x;
    s1perms.gcs     = gcs;
    s1perms.wxn     = wxn;
    s1perms.overlay = overlay == '1';

    return s1perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1OverlayPermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S1OverlayPermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1OverlayPermissions()
// ==============================
// Computes the stage 1 overlay permissions

S1AccessControls <anchor link="AArch64.S1OverlayPermissions.3" hover="function: S1AccessControls AArch64.S1OverlayPermissions(Regime regime, TTWState walkstate, AccessDescriptor accdesc)">AArch64.S1OverlayPermissions</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate,
                                              <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    bit  r,  w,  x;
    bit pr, pw, px;
    bit ur, uw, ux;
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = walkstate.permissions;
    <a link="S1AccessControls" file="shared_pseudocode.xml" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</a> s1overlay_perms;

    S1PORType por = AArch64.S1POR(regime);
    integer bit_index = 4 * <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(permissions.po_index);
    bits(4) ppo = por&lt;bit_index+3:bit_index&gt;;

    // Apply privileged overlay permissions
    case ppo of
        when '0000' (pr,pw,px) = ('0','0','0'); // No access
        when '0001' (pr,pw,px) = ('1','0','0'); // Privileged read
        when '0010' (pr,pw,px) = ('0','0','1'); // Privileged execute
        when '0011' (pr,pw,px) = ('1','0','1'); // Privileged read and execute
        when '0100' (pr,pw,px) = ('0','1','0'); // Privileged write
        when '0101' (pr,pw,px) = ('1','1','0'); // Privileged read and write
        when '0110' (pr,pw,px) = ('0','1','1'); // Privileged write and execute
        when '0111' (pr,pw,px) = ('1','1','1'); // Privileged read, write and execute
        when '1xxx' (pr,pw,px) = ('0','0','0'); // Reserved

    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        bits(4) upo = POR_EL0&lt;bit_index+3:bit_index&gt;;

        // Apply unprivileged overlay permissions
        case upo of
            when '0000' (ur,uw,ux) = ('0','0','0'); // No access
            when '0001' (ur,uw,ux) = ('1','0','0'); // Unprivileged read
            when '0010' (ur,uw,ux) = ('0','0','1'); // Unprivileged execute
            when '0011' (ur,uw,ux) = ('1','0','1'); // Unprivileged read and execute
            when '0100' (ur,uw,ux) = ('0','1','0'); // Unprivileged write
            when '0101' (ur,uw,ux) = ('1','1','0'); // Unprivileged read and write
            when '0110' (ur,uw,ux) = ('0','1','1'); // Unprivileged write and execute
            when '0111' (ur,uw,ux) = ('1','1','1'); // Unprivileged read, write and execute
            when '1xxx' (ur,uw,ux) = ('0','0','0'); // Reserved

    (r,w,x) = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then (ur,uw,ux) else (pr,pw,px);

    s1overlay_perms.or = r;
    s1overlay_perms.ow = w;
    s1overlay_perms.ox = x;

    return s1overlay_perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S1TxSZFaults" mylink="aarch64.translation.vmsa_faults.AArch64.S1TxSZFaults" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1TxSZFaults()
// ======================
// Detect whether configuration of stage 1 TxSZ field generates a fault

boolean AArch64.S1TxSZFaults(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams)
    mintxsz = <a link="AArch64.S1MinTxSZ.4" file="shared_pseudocode.xml" hover="function: integer AArch64.S1MinTxSZ(Regime regime, bit d128, bit ds, TGx tgx)">AArch64.S1MinTxSZ</a>(regime, walkparams.d128, walkparams.ds, walkparams.tgx);
    maxtxsz = <a link="AArch64.MaxTxSZ.1" file="shared_pseudocode.xml" hover="function: integer AArch64.MaxTxSZ(TGx tgx)">AArch64.MaxTxSZ</a>(walkparams.tgx);

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &lt; mintxsz then
        return (<a link="impl-shared.Have52BitVAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitVAExt()">Have52BitVAExt</a>() ||
                boolean IMPLEMENTATION_DEFINED "<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> on TxSZ value below minimum");
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &gt; maxtxsz then
        return boolean IMPLEMENTATION_DEFINED "<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> on TxSZ value above maximum";

    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2CheckPermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S2CheckPermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2CheckPermissions()
// ============================
// Verifies memory access with available permissions.

(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a>, boolean) AArch64.S2CheckPermissions(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate,
                                                  S2TTWParams walkparams, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa,
                                                  <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="MemType" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType</a> memtype = walkstate.memattrs.memtype;
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = walkstate.permissions;
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    <a link="S2AccessControls" file="shared_pseudocode.xml" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</a> s2perms = AArch64.S2ComputePermissions(permissions, walkparams, accdesc);

    bit  r,  w;
    bit or, ow;

    if accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> then
        r = s2perms.r_mmu;
        w = s2perms.w_mmu;
        or = s2perms.or_mmu;
        ow = s2perms.ow_mmu;
    elsif accdesc.rcw then
        r = s2perms.r_rcw;
        w = s2perms.w_rcw;
        or = s2perms.or_rcw;
        ow = s2perms.ow_rcw;
    else
        r = s2perms.r;
        w = s2perms.w;
        or = s2perms.or;
        ow = s2perms.ow;

    if accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> then
        if (accdesc.toplevel &amp;&amp; accdesc.varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> &amp;&amp;
               ((walkparams.tl0 == '1' &amp;&amp; s2perms.toplevel0 == '0') ||
               (walkparams.tl1 == '1' &amp;&amp; s2perms.&lt;toplevel1,toplevel0&gt; == '10'))) then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.toplevel   = TRUE;
        elsif (accdesc.toplevel &amp;&amp; accdesc.varange == <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a> &amp;&amp;
               ((walkparams.tl1 == '1' &amp;&amp; s2perms.toplevel1 == '0') ||
               (walkparams.tl0 == '1' &amp;&amp; s2perms.&lt;toplevel1,toplevel0&gt; == '01'))) then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.toplevel   = TRUE;
        elsif walkparams.ptw == '1' &amp;&amp; memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif s2perms.overlay &amp;&amp; or == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif accdesc.write &amp;&amp; s2perms.overlay &amp;&amp; ow == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        // Prevent translation table walks in Non-secure space by Realm state
        elsif accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; walkstate.baseaddress.paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif r == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif accdesc.write &amp;&amp; w == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif (accdesc.write &amp;&amp; !(walkparams.&lt;ha,hd&gt; == '11') &amp;&amp; walkparams.s2pie == '1' &amp;&amp;
                permissions.s2dirty == '0') then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.dirtybit   = TRUE;
            fault.write      = TRUE;
    // Stage 2 Permission fault due to AssuredOnly check
    elsif ((walkstate.s2assuredonly == '1' &amp;&amp; !ipa.s1assured) ||
           (walkstate.s2assuredonly != '1' &amp;&amp; <a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() &amp;&amp; VTCR_EL2.GCSH == '1' &amp;&amp;
            accdesc.acctype == <a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a> &amp;&amp; accdesc.el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>)) then
        fault.statuscode  = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.assuredonly = TRUE;
    elsif accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        if s2perms.overlay &amp;&amp; s2perms.ox == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif (memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;
                <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_INSTRDEVICE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_INSTRDEVICE</a>) == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>) then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;

        // Prevent execution from Non-secure space by Realm state
        elsif accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; walkstate.baseaddress.paspace != <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif s2perms.x == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;

    elsif accdesc.acctype == <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a> then
        if accdesc.cacheop == <a link="CacheOp_Invalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</a> then
            if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; s2perms.overlay &amp;&amp; ow == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
                fault.overlay    = TRUE;
            if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; w == '0' then
                fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; s2perms.overlay &amp;&amp; or == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif (walkparams.cmow == '1' &amp;&amp;
                accdesc.opscope == <a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a> &amp;&amp;
                accdesc.cacheop == <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a> &amp;&amp;
                s2perms.overlay &amp;&amp; ow == '0') then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; r == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif (walkparams.cmow == '1' &amp;&amp;
                accdesc.opscope == <a link="CacheOpScope_PoC" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</a> &amp;&amp;
                accdesc.cacheop == <a link="CacheOp_CleanInvalidate" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</a> &amp;&amp;
                w == '0') then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;

    elsif accdesc.acctype == <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a> then
        if (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; s2perms.overlay &amp;&amp; or == '0' &amp;&amp;
                boolean IMPLEMENTATION_DEFINED "Permission fault on <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> IC_IVAU execution") then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif walkparams.cmow == '1' &amp;&amp; s2perms.overlay &amp;&amp; ow == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
            fault.overlay    = TRUE;
        elsif (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) &amp;&amp; accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp;  r == '0' &amp;&amp;
                boolean IMPLEMENTATION_DEFINED "Permission fault on <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> IC_IVAU execution") then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        elsif walkparams.cmow == '1' &amp;&amp; w == '0' then
            fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;

    elsif accdesc.read &amp;&amp; s2perms.overlay &amp;&amp; or == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.overlay    = TRUE;
        fault.write      = FALSE;
    elsif accdesc.write &amp;&amp; s2perms.overlay &amp;&amp; ow == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.overlay    = TRUE;
        fault.write      = TRUE;
    elsif accdesc.read &amp;&amp; r == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.write      = FALSE;
    elsif accdesc.write &amp;&amp; w == '0' then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.write      = TRUE;
    elsif ((accdesc.tagaccess || accdesc.tagchecked) &amp;&amp;
            ipa.memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> &amp;&amp;
            permissions.s2tag_na == '1') then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.tagaccess  = TRUE;
        fault.write      = accdesc.tagaccess &amp;&amp; accdesc.write;
    elsif (accdesc.write &amp;&amp; !(walkparams.&lt;ha,hd&gt; == '11') &amp;&amp; walkparams.s2pie == '1' &amp;&amp;
            permissions.s2dirty == '0') then
        fault.statuscode = <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>;
        fault.dirtybit   = TRUE;
        fault.write      = TRUE;

    // MRO* allows only RCW and MMU writes
    boolean mro;
    if s2perms.overlay then
        mro = (s2perms.&lt;w,w_rcw,w_mmu&gt; AND s2perms.&lt;ow,ow_rcw,ow_mmu&gt;) == '011';
    else
        mro = s2perms.&lt;w,w_rcw,w_mmu&gt; == '011';

    return (fault, mro);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2ComputePermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S2ComputePermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2ComputePermissions()
// ==============================
// Compute the overall stage 2 permissions.

<a link="S2AccessControls" file="shared_pseudocode.xml" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</a> AArch64.S2ComputePermissions(<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions, S2TTWParams walkparams,
                                              <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    <a link="S2AccessControls" file="shared_pseudocode.xml" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</a> s2perms;

    if walkparams.s2pie == '1' then
        s2perms = <a link="AArch64.S2IndirectBasePermissions.2" file="shared_pseudocode.xml" hover="function: S2AccessControls AArch64.S2IndirectBasePermissions(Permissions permissions, AccessDescriptor accdesc)">AArch64.S2IndirectBasePermissions</a>(permissions, accdesc);
        s2perms.overlay = <a link="impl-shared.HaveS2POExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS2POExt()">HaveS2POExt</a>() &amp;&amp; VTCR_EL2.S2POE == '1';
        if s2perms.overlay then
            s2overlay_perms = <a link="AArch64.S2OverlayPermissions.2" file="shared_pseudocode.xml" hover="function: S2AccessControls AArch64.S2OverlayPermissions(Permissions permissions, AccessDescriptor accdesc)">AArch64.S2OverlayPermissions</a>(permissions, accdesc);
            s2perms.or          = s2overlay_perms.or;
            s2perms.ow          = s2overlay_perms.ow;
            s2perms.ox          = s2overlay_perms.ox;
            s2perms.or_rcw      = s2overlay_perms.or_rcw;
            s2perms.ow_rcw      = s2overlay_perms.ow_rcw;
            s2perms.or_mmu      = s2overlay_perms.or_mmu;
            s2perms.ow_mmu      = s2overlay_perms.ow_mmu;

            s2perms.toplevel0   = s2perms.toplevel0 OR s2overlay_perms.toplevel0;
            s2perms.toplevel1   = s2perms.toplevel1 OR s2overlay_perms.toplevel1;
    else
        s2perms = <a link="AArch64.S2DirectBasePermissions.2" file="shared_pseudocode.xml" hover="function: S2AccessControls AArch64.S2DirectBasePermissions(Permissions permissions, AccessDescriptor accdesc)">AArch64.S2DirectBasePermissions</a>(permissions, accdesc);

    return s2perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2DirectBasePermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S2DirectBasePermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2DirectBasePermissions()
// =================================
// Computes the stage 2 direct base permissions.

S2AccessControls <anchor link="AArch64.S2DirectBasePermissions.2" hover="function: S2AccessControls AArch64.S2DirectBasePermissions(Permissions permissions, AccessDescriptor accdesc)">AArch64.S2DirectBasePermissions</anchor>(<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions,
                                                 <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="S2AccessControls" file="shared_pseudocode.xml" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</a> s2perms;
    r = permissions.s2ap&lt;0&gt;;
    w = permissions.s2ap&lt;1&gt;;
    bit px, ux;
    case (permissions.s2xn:permissions.s2xnx) of
        when '00' (px,ux) = ('1','1');
        when '01' (px,ux) = ('0','1');
        when '10' (px,ux) = ('0','0');
        when '11' (px,ux) = ('1','0');

    x = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then ux else px;
    s2perms.r = r;
    s2perms.w = w;
    s2perms.x = x;
    s2perms.r_rcw = r;
    s2perms.w_rcw = w;
    s2perms.r_mmu = r;
    s2perms.w_mmu = w;

    return s2perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2HasAlignmentFault" mylink="aarch64.translation.vmsa_faults.AArch64.S2HasAlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2HasAlignmentFault()
// =============================
// Returns whether stage 2 output fails alignment requirement on data accesses
// to Device memory

boolean <anchor link="AArch64.S2HasAlignmentFault.3" hover="function: boolean AArch64.S2HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, MemoryAttributes memattrs)">AArch64.S2HasAlignmentFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned,
                                    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        return FALSE;
    elsif <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() &amp;&amp; accdesc.tagaccess &amp;&amp; accdesc.write then
        return (memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp;
                <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_DEVICETAGSTORE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVICETAGSTORE</a>) == <a link="Constraint_FAULT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</a>);
    elsif accdesc.acctype == <a link="AccessType_DCZero" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DCZero</a> then
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
    else
        return memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp; !aligned;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2InconsistentSL" mylink="aarch64.translation.vmsa_faults.AArch64.S2InconsistentSL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2InconsistentSL()
// ==========================
// Detect inconsistent configuration of stage 2 TxSZ and SL fields

boolean AArch64.S2InconsistentSL(S2TTWParams walkparams)
    startlevel   = AArch64.S2StartLevel(walkparams);
    levels       = <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - startlevel;
    granulebits  = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(walkparams.tgx);
    descsizelog2 = 3;
    stride       = granulebits - descsizelog2;

    // Input address size must at least be large enough to be resolved from the start level
    sl_min_iasize = (
        levels * stride // Bits resolved by table walk, except initial level
        + granulebits   // Bits directly mapped to output address
        + 1);           // At least 1 more bit to be decoded by initial level

    // Can accomodate 1 more stride in the level + concatenation of up to 2^4 tables
    sl_max_iasize = sl_min_iasize + (stride-1) + 4;
    // Configured Input Address size
    iasize        = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);

    return iasize &lt; sl_min_iasize || iasize &gt; sl_max_iasize;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2IndirectBasePermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S2IndirectBasePermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2IndirectBasePermissions()
// ===================================
// Computes the stage 2 indirect base permissions.

S2AccessControls <anchor link="AArch64.S2IndirectBasePermissions.2" hover="function: S2AccessControls AArch64.S2IndirectBasePermissions(Permissions permissions, AccessDescriptor accdesc)">AArch64.S2IndirectBasePermissions</anchor>(<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions,
                                                   <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bit r, w;
    bit r_rcw, w_rcw;
    bit r_mmu, w_mmu;
    bit px, ux;
    bit toplevel0, toplevel1;
    <a link="S2AccessControls" file="shared_pseudocode.xml" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</a> s2perms;

    bits(4) s2pi = permissions.s2pi;
    case s2pi of
        when '0000' (r,w,px,ux,w_rcw,w_mmu) = ('0','0','0','0','0','0');  // No Access
        when '0001' (r,w,px,ux,w_rcw,w_mmu) = ('0','0','0','0','0','0');  // Reserved
        when '0010' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO
        when '0011' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO-TL1
        when '0100' (r,w,px,ux,w_rcw,w_mmu) = ('0','1','0','0','0','0');  // Write Only
        when '0101' (r,w,px,ux,w_rcw,w_mmu) = ('0','0','0','0','0','0');  // Reserved
        when '0110' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO-TL0
        when '0111' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO-TL01
        when '1000' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','0','0');  // Read Only
        when '1001' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','1','0','0');  // Read, Unpriv Execute
        when '1010' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','1','0','0','0');  // Read, Priv Execute
        when '1011' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','1','1','0','0');  // Read, All Execute
        when '1100' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','0','0','1','1');  // RW
        when '1101' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','0','1','1','1');  // RW, Unpriv Execute
        when '1110' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','1','0','1','1');  // RW, Priv Execute
        when '1111' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','1','1','1','1');  // RW, All Execute

    x = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then ux else px;

    // RCW and MMU read permissions.
    (r_rcw, r_mmu) = (r, r);

    // Stage 2 Top Level Permission Attributes.
    case s2pi of
        when '0110' (toplevel0,toplevel1) = ('1','0');
        when '0011' (toplevel0,toplevel1) = ('0','1');
        when '0111' (toplevel0,toplevel1) = ('1','1');
        otherwise   (toplevel0,toplevel1) = ('0','0');

    s2perms.r = r;
    s2perms.w = w;
    s2perms.x = x;
    s2perms.r_rcw = r_rcw;
    s2perms.r_mmu = r_mmu;
    s2perms.w_rcw = w_rcw;
    s2perms.w_mmu = w_mmu;
    s2perms.toplevel0 = toplevel0;
    s2perms.toplevel1 = toplevel1;

    return s2perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2InvalidSL" mylink="aarch64.translation.vmsa_faults.AArch64.S2InvalidSL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2InvalidSL()
// =====================
// Detect invalid configuration of SL field

boolean AArch64.S2InvalidSL(S2TTWParams walkparams)
    case walkparams.tgx of
        when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>
            case walkparams.sl2:walkparams.sl0 of
                when '1x1' return TRUE;
                when '11x' return TRUE;
                when '010' return <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>() &lt; 44;
                when '011' return !<a link="impl-shared.HaveSmallTranslationTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSmallTranslationTableExt()">HaveSmallTranslationTableExt</a>();
                otherwise  return FALSE;
        when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>
            case walkparams.sl0 of
                when '11' return walkparams.ds == '0';
                when '10' return <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>() &lt; 42;
                otherwise  return FALSE;
        when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>
            case walkparams.sl0 of
                when '11'  return TRUE;
                when '10'  return <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>() &lt; 44;
                otherwise  return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2OverlayPermissions" mylink="aarch64.translation.vmsa_faults.AArch64.S2OverlayPermissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2OverlayPermissions()
// ==============================
// Computes the stage 2 overlay permissions.

S2AccessControls <anchor link="AArch64.S2OverlayPermissions.2" hover="function: S2AccessControls AArch64.S2OverlayPermissions(Permissions permissions, AccessDescriptor accdesc)">AArch64.S2OverlayPermissions</anchor>(<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    bit r, w;
    bit r_rcw, w_rcw;
    bit r_mmu, w_mmu;
    bit px, ux;
    bit toplevel0, toplevel1;
    <a link="S2AccessControls" file="shared_pseudocode.xml" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</a> s2overlay_perms;

    integer index = 4 * <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(permissions.s2po_index);
    bits(4) s2po = S2POR_EL1[index+3 : index];
    case s2po of
        when '0000' (r,w,px,ux,w_rcw,w_mmu) = ('0','0','0','0','0','0');  // No Access
        when '0001' (r,w,px,ux,w_rcw,w_mmu) = ('0','0','0','0','0','0');  // Reserved
        when '0010' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO
        when '0011' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO-TL1
        when '0100' (r,w,px,ux,w_rcw,w_mmu) = ('0','1','0','0','0','0');  // Write Only
        when '0101' (r,w,px,ux,w_rcw,w_mmu) = ('0','0','0','0','0','0');  // Reserved
        when '0110' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO-TL0
        when '0111' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','1','1');  // MRO-TL01
        when '1000' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','0','0','0');  // Read Only
        when '1001' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','0','1','0','0');  // Read, Unpriv Execute
        when '1010' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','1','0','0','0');  // Read, Priv Execute
        when '1011' (r,w,px,ux,w_rcw,w_mmu) = ('1','0','1','1','0','0');  // Read, All Execute
        when '1100' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','0','0','1','1');  // RW
        when '1101' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','0','1','1','1');  // RW, Unpriv Execute
        when '1110' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','1','0','1','1');  // RW, Priv Execute
        when '1111' (r,w,px,ux,w_rcw,w_mmu) = ('1','1','1','1','1','1');  // RW, All Execute

    x = if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then ux else px;

    // RCW and MMU read permissions.
    (r_rcw, r_mmu) = (r, r);

    // Stage 2 Top Level Permission Attributes.
    case s2po of
        when '0110' (toplevel0,toplevel1) = ('1','0');
        when '0011' (toplevel0,toplevel1) = ('0','1');
        when '0111' (toplevel0,toplevel1) = ('1','1');
        otherwise   (toplevel0,toplevel1) = ('0','0');

    s2overlay_perms.or = r;
    s2overlay_perms.ow = w;
    s2overlay_perms.ox = x;
    s2overlay_perms.or_rcw = r_rcw;
    s2overlay_perms.ow_rcw = w_rcw;
    s2overlay_perms.or_mmu = r_mmu;
    s2overlay_perms.ow_mmu = w_mmu;
    s2overlay_perms.toplevel0 = toplevel0;
    s2overlay_perms.toplevel1 = toplevel1;

    return s2overlay_perms;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.S2TxSZFaults" mylink="aarch64.translation.vmsa_faults.AArch64.S2TxSZFaults" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2TxSZFaults()
// ======================
// Detect whether configuration of stage 2 TxSZ field generates a fault

boolean AArch64.S2TxSZFaults(S2TTWParams walkparams, boolean s1aarch64)
    mintxsz = <a link="AArch64.S2MinTxSZ.4" file="shared_pseudocode.xml" hover="function: integer AArch64.S2MinTxSZ(bit d128, bit ds, TGx tgx, boolean s1aarch64)">AArch64.S2MinTxSZ</a>(walkparams.d128, walkparams.ds, walkparams.tgx, s1aarch64);
    maxtxsz = <a link="AArch64.MaxTxSZ.1" file="shared_pseudocode.xml" hover="function: integer AArch64.MaxTxSZ(TGx tgx)">AArch64.MaxTxSZ</a>(walkparams.tgx);

    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &lt; mintxsz then
        return (<a link="impl-shared.Have52BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</a>() ||
                boolean IMPLEMENTATION_DEFINED "<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> on TxSZ value below minimum");
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &gt; maxtxsz then
        return boolean IMPLEMENTATION_DEFINED "<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> on TxSZ value above maximum";

    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_faults/AArch64.VAIsOutOfRange" mylink="aarch64.translation.vmsa_faults.AArch64.VAIsOutOfRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.VAIsOutOfRange()
// ========================
// Check bits not resolved by translation are identical and of accepted value

boolean AArch64.VAIsOutOfRange(bits(64) va_in, <a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype,
                               <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams)
    bits(64) va = va_in;

    addrtop = <a link="AArch64.AddrTop.3" file="shared_pseudocode.xml" hover="function: integer AArch64.AddrTop(bit tbid, AccessType acctype, bit tbi)">AArch64.AddrTop</a>(walkparams.tbid, acctype, walkparams.tbi);

    // If the VA has a Logical Address Tag then the bits holding the Logical Address Tag are
    // ignored when checking if the address is out of range.
    if walkparams.mtx == '1' then
        va&lt;59:56&gt; = if <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va) == <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a> then '1111' else '0000';

    // Input Address size
    iasize  = <a link="AArch64.IASize.1" file="shared_pseudocode.xml" hover="function: integer AArch64.IASize(bits(6) txsz)">AArch64.IASize</a>(walkparams.txsz);

    // The min value of TxSZ can be 8, with LVA3 implemented.
    // If TxSZ is set to 8 iasize becomes 64 - 8 = 56
    // If tbi is also set, addrtop becomes 55
    // Then the return statements check va&lt;56:55&gt;
    // The check here is to guard against this corner case.
    if addrtop &lt; iasize then
        return FALSE;

    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        if <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va) == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
            return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;addrtop:iasize&gt;);
        else
            return !<a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(va&lt;addrtop:iasize&gt;);
    else
        return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;addrtop:iasize&gt;);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_memattr/AArch64.S2ApplyFWBMemAttrs" mylink="aarch64.translation.vmsa_memattr.AArch64.S2ApplyFWBMemAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2ApplyFWBMemAttrs()
// ============================
// Apply stage 2 forced Write-Back on stage 1 memory attributes.

<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> AArch64.S2ApplyFWBMemAttrs(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> s1_memattrs, S2TTWParams walkparams,
                                            bits(N) descriptor)
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    s2_attr = descriptor&lt;5:2&gt;;
    s2_sh   = if walkparams.ds == '1' then walkparams.sh else descriptor&lt;9:8&gt;;
    s2_fnxs = descriptor&lt;11&gt;;

    if s2_attr&lt;2&gt; == '0' then          // S2 Device, S1 any
        s2_device = <a link="impl-shared.DecodeDevice.1" file="shared_pseudocode.xml" hover="function: DeviceType DecodeDevice(bits(2) device)">DecodeDevice</a>(s2_attr&lt;1:0&gt;);
        memattrs.memtype = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
        if s1_memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
            memattrs.device = <a link="impl-shared.S2CombineS1Device.2" file="shared_pseudocode.xml" hover="function: DeviceType S2CombineS1Device(DeviceType s1_device, DeviceType s2_device)">S2CombineS1Device</a>(s1_memattrs.device, s2_device);
        else
            memattrs.device = s2_device;

        memattrs.xs = s1_memattrs.xs;

    elsif s2_attr&lt;1:0&gt; == '11' then    // S2 attr = S1 attr
        memattrs = s1_memattrs;

    elsif s2_attr&lt;1:0&gt; == '10' then    // Force writeback
        memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
        memattrs.inner.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
        memattrs.outer.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;

        if (s1_memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp;
                s1_memattrs.inner.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>) then
            memattrs.inner.hints     = s1_memattrs.inner.hints;
            memattrs.inner.transient = s1_memattrs.inner.transient;
        else
            memattrs.inner.hints     = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
            memattrs.inner.transient = FALSE;

        if (s1_memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp;
                s1_memattrs.outer.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>) then
            memattrs.outer.hints     = s1_memattrs.outer.hints;
            memattrs.outer.transient = s1_memattrs.outer.transient;
        else
            memattrs.outer.hints     = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
            memattrs.outer.transient = FALSE;

        memattrs.xs = '0';

    else                               // Non-cacheable unless S1 is device
        if s1_memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
            memattrs = s1_memattrs;
        else
            <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> cacheability_attr;
            cacheability_attr.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;

            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.inner   = cacheability_attr;
            memattrs.outer   = cacheability_attr;

            memattrs.xs = s1_memattrs.xs;

    s2_shareability = <a link="impl-shared.DecodeShareability.1" file="shared_pseudocode.xml" hover="function: Shareability DecodeShareability(bits(2) sh)">DecodeShareability</a>(s2_sh);
    memattrs.shareability = <a link="impl-shared.S2CombineS1Shareability.2" file="shared_pseudocode.xml" hover="function: Shareability S2CombineS1Shareability(Shareability s1_shareability, Shareability s2_shareability)">S2CombineS1Shareability</a>(s1_memattrs.shareability, s2_shareability);
    memattrs.tags         = <a link="impl-shared.S2MemTagType.2" file="shared_pseudocode.xml" hover="function: MemTagType S2MemTagType(MemoryAttributes s2_memattrs, MemTagType s1_tagtype)">S2MemTagType</a>(memattrs, s1_memattrs.tags);
    memattrs.notagaccess  = (s2_attr&lt;3:1&gt; == '111' &amp;&amp; memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>);

    if s2_fnxs == '1' then
        memattrs.xs = '0';

    memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(memattrs);
    return memattrs;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_tlbcontext/AArch64.GetS1TLBContext" mylink="aarch64.translation.vmsa_tlbcontext.AArch64.GetS1TLBContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GetS1TLBContext()
// =========================
// Gather translation context for accesses with VA to match against TLB entries

TLBContext <anchor link="AArch64.GetS1TLBContext.4" hover="function: TLBContext AArch64.GetS1TLBContext(Regime regime, SecurityState ss, bits(64) va, TGx tg)">AArch64.GetS1TLBContext</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(64) va, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tg)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  tlbcontext = <a link="AArch64.TLBContextEL3.3" file="shared_pseudocode.xml" hover="function: TLBContext AArch64.TLBContextEL3(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL3</a>(ss, va, tg);
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  tlbcontext = <a link="AArch64.TLBContextEL2.3" file="shared_pseudocode.xml" hover="function: TLBContext AArch64.TLBContextEL2(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL2</a>(ss, va, tg);
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> tlbcontext = <a link="AArch64.TLBContextEL20.3" file="shared_pseudocode.xml" hover="function: TLBContext AArch64.TLBContextEL20(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL20</a>(ss, va, tg);
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> tlbcontext = <a link="AArch64.TLBContextEL10.3" file="shared_pseudocode.xml" hover="function: TLBContext AArch64.TLBContextEL10(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL10</a>(ss, va, tg);

    tlbcontext.includes_s1  = TRUE;
    // The following may be amended for EL1&amp;0 Regime if caching of stage 2 is successful
    tlbcontext.includes_s2  = FALSE;
    // The following may be amended if Granule Protection Check passes
    tlbcontext.includes_gpt = FALSE;
    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_tlbcontext/AArch64.GetS2TLBContext" mylink="aarch64.translation.vmsa_tlbcontext.AArch64.GetS2TLBContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GetS2TLBContext()
// =========================
// Gather translation context for accesses with IPA to match against TLB entries

TLBContext <anchor link="AArch64.GetS2TLBContext.3" hover="function: TLBContext AArch64.GetS2TLBContext(SecurityState ss, FullAddress ipa, TGx tg)">AArch64.GetS2TLBContext</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> ipa, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tg)
    assert <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss       = ss;
    tlbcontext.regime   = <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
    tlbcontext.ipaspace = ipa.paspace;
    tlbcontext.vmid     = <a link="impl-aarch64.VMID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) VMID[]">VMID</a>[];
    tlbcontext.tg       = tg;
    tlbcontext.ia       = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.address, 64);
    if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then
        tlbcontext.cnp = if ipa.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then VSTTBR_EL2.CnP else VTTBR_EL2.CnP;
    else
        tlbcontext.cnp = '0';

    tlbcontext.includes_s1  = FALSE;
    tlbcontext.includes_s2  = TRUE;
    // This amy be amended if Granule Protection Check passes
    tlbcontext.includes_gpt = FALSE;
    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_tlbcontext/AArch64.TLBContextEL10" mylink="aarch64.translation.vmsa_tlbcontext.AArch64.TLBContextEL10" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBContextEL10()
// ========================
// Gather translation context for accesses under EL10 regime to match against TLB entries

TLBContext <anchor link="AArch64.TLBContextEL10.3" hover="function: TLBContext AArch64.TLBContextEL10(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL10</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(64) va, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tg)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss     = ss;
    tlbcontext.regime = <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
    tlbcontext.vmid   = <a link="impl-aarch64.VMID.read.0" file="shared_pseudocode.xml" hover="accessor: bits(16) VMID[]">VMID</a>[];
    tlbcontext.asid   = if TCR_EL1.A1 == '0' then TTBR0_EL1.ASID else TTBR1_EL1.ASID;
    if TCR_EL1.AS == '0' then
        tlbcontext.asid&lt;15:8&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
    tlbcontext.tg     = tg;
    tlbcontext.ia     = va;

    if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then
        if <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va) == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
            tlbcontext.cnp = TTBR0_EL1.CnP;
        else
            tlbcontext.cnp = TTBR1_EL1.CnP;
    else
        tlbcontext.cnp = '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_tlbcontext/AArch64.TLBContextEL2" mylink="aarch64.translation.vmsa_tlbcontext.AArch64.TLBContextEL2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBContextEL2()
// =======================
// Gather translation context for accesses under EL2 regime to match against TLB entries

TLBContext <anchor link="AArch64.TLBContextEL2.3" hover="function: TLBContext AArch64.TLBContextEL2(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL2</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(64) va, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tg)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss     = ss;
    tlbcontext.regime = <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>;
    tlbcontext.tg     = tg;
    tlbcontext.ia     = va;
    tlbcontext.cnp    = if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then TTBR0_EL2.CnP else '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_tlbcontext/AArch64.TLBContextEL20" mylink="aarch64.translation.vmsa_tlbcontext.AArch64.TLBContextEL20" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBContextEL20()
// ========================
// Gather translation context for accesses under EL20 regime to match against TLB entries

TLBContext <anchor link="AArch64.TLBContextEL20.3" hover="function: TLBContext AArch64.TLBContextEL20(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL20</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(64) va, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tg)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss     = ss;
    tlbcontext.regime = <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>;
    tlbcontext.asid   = if TCR_EL2.A1 == '0' then TTBR0_EL2.ASID else TTBR1_EL2.ASID;
    if TCR_EL2.AS == '0' then
        tlbcontext.asid&lt;15:8&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
    tlbcontext.tg     = tg;
    tlbcontext.ia     = va;

    if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then
        if <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va) == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
            tlbcontext.cnp = TTBR0_EL2.CnP;
        else
            tlbcontext.cnp = TTBR1_EL2.CnP;
    else
        tlbcontext.cnp = '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_tlbcontext/AArch64.TLBContextEL3" mylink="aarch64.translation.vmsa_tlbcontext.AArch64.TLBContextEL3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TLBContextEL3()
// =======================
// Gather translation context for accesses under EL3 regime to match against TLB entries

TLBContext <anchor link="AArch64.TLBContextEL3.3" hover="function: TLBContext AArch64.TLBContextEL3(SecurityState ss, bits(64) va, TGx tg)">AArch64.TLBContextEL3</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(64) va, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tg)
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> tlbcontext;

    tlbcontext.ss     = ss;
    tlbcontext.regime = <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>;
    tlbcontext.tg     = tg;
    tlbcontext.ia     = va;
    tlbcontext.cnp    = if <a link="impl-shared.HaveCommonNotPrivateTransExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</a>() then TTBR0_EL3.CnP else '0';

    return tlbcontext;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.FullTranslate" mylink="aarch64.translation.vmsa_translation.AArch64.FullTranslate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.FullTranslate()
// =======================
// Address translation as specified by VMSA
// Alignment check NOT due to memory type is expected to be done before translation

AddressDescriptor <anchor link="AArch64.FullTranslate.3" hover="function: AddressDescriptor AArch64.FullTranslate(bits(64) va, AccessDescriptor accdesc, boolean aligned)">AArch64.FullTranslate</anchor>(bits(64) va, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, boolean aligned)
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(accdesc.el);
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa;
    (fault, ipa) = <a link="AArch64.S1Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S1Translate(FaultRecord fault_in, Regime regime, bits(64) va, boolean aligned, AccessDescriptor accdesc)">AArch64.S1Translate</a>(fault, regime, va, aligned, accdesc);

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return <a link="impl-shared.CreateFaultyAddressDescriptor.2" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateFaultyAddressDescriptor(bits(64) va, FaultRecord fault)">CreateFaultyAddressDescriptor</a>(va, fault);

    assert (accdesc.ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>) IMPLIES <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        s1aarch64 = TRUE;
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> pa;
        (fault, pa) = <a link="AArch64.S2Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</a>(fault, ipa, s1aarch64, aligned, accdesc);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return <a link="impl-shared.CreateFaultyAddressDescriptor.2" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateFaultyAddressDescriptor(bits(64) va, FaultRecord fault)">CreateFaultyAddressDescriptor</a>(va, fault);
        else
            return pa;
    else
        return ipa;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.MemSwapTableDesc" mylink="aarch64.translation.vmsa_translation.AArch64.MemSwapTableDesc" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MemSwapTableDesc()
// ==========================
// Perform HW update of table descriptor as an atomic operation

(FaultRecord, bits(N)) <anchor link="AArch64.MemSwapTableDesc.6" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, bits(N) prev_desc,
                                                bits(N) new_desc, bit ee,
                                                <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a>  descaccess,
                                                <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> descpaddr)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    boolean iswrite;

    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        fault.gpcf = <a link="impl-shared.GranuleProtectionCheck.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GranuleProtectionCheck(AddressDescriptor addrdesc, AccessDescriptor accdesc)">GranuleProtectionCheck</a>(descpaddr, descaccess);
        if fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
            fault.statuscode = <a link="Fault_GPCFOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</a>;
            fault.paddress   = descpaddr.paddress;
            fault.gpcfs2walk = fault.secondstage;
            return (fault, bits(N) UNKNOWN);

    // All observers in the shareability domain observe the
    // following memory read and write accesses atomically.
    bits(N) mem_desc;
    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, mem_desc) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(descpaddr, N DIV 8, descaccess);

    if ee == '1' then
        mem_desc = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(mem_desc);

    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        iswrite = FALSE;
        fault = <a link="impl-shared.HandleExternalTTWAbort.6" file="shared_pseudocode.xml" hover="function: FaultRecord HandleExternalTTWAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, AccessDescriptor accdesc, integer size, FaultRecord input_fault)">HandleExternalTTWAbort</a>(memstatus, iswrite, descpaddr, descaccess, N DIV 8, fault);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(fault.statuscode) then
            return (fault, bits(N) UNKNOWN);

    if mem_desc == prev_desc  then
        ordered_new_desc = if ee == '1' then <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(new_desc) else new_desc;
        memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(descpaddr, N DIV 8, descaccess, ordered_new_desc);

        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
            iswrite = TRUE;
            fault = <a link="impl-shared.HandleExternalTTWAbort.6" file="shared_pseudocode.xml" hover="function: FaultRecord HandleExternalTTWAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, AccessDescriptor accdesc, integer size, FaultRecord input_fault)">HandleExternalTTWAbort</a>(memstatus, iswrite, descpaddr, descaccess, N DIV 8,
                                           fault);

            if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(fault.statuscode) then
                return (fault, bits(N) UNKNOWN);

        // Reflect what is now in memory (in little endian format)
        mem_desc = new_desc;

    return (fault, mem_desc);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.S1DisabledOutput" mylink="aarch64.translation.vmsa_translation.AArch64.S1DisabledOutput" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1DisabledOutput()
// ==========================
// Map the VA to IPA/PA and assign default memory attributes

(FaultRecord, AddressDescriptor) <anchor link="AArch64.S1DisabledOutput.5" hover="function: (FaultRecord, AddressDescriptor) AArch64.S1DisabledOutput(FaultRecord fault_in, Regime regime, bits(64) va_in, AccessDescriptor accdesc, boolean aligned)">AArch64.S1DisabledOutput</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                                          bits(64) va_in, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                                          boolean aligned)

    bits(64) va = va_in;
    walkparams = AArch64.GetS1TTWParams(regime, accdesc.ss, va);
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    // No memory page is guarded when stage 1 address translation is disabled
    <a link="impl-aarch64.SetInGuardedPage.1" file="shared_pseudocode.xml" hover="function: SetInGuardedPage(boolean guardedpage)">SetInGuardedPage</a>(FALSE);

    // Output Address
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> oa;
    oa.address = va&lt;55:0&gt;;
    case accdesc.ss of
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    oa.paspace = <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> oa.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      oa.paspace = <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     oa.paspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; walkparams.dc == '1' then
        <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> default_cacheability;
        default_cacheability.attrs     = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
        default_cacheability.hints     = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
        default_cacheability.transient = FALSE;

        memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
        memattrs.outer        = default_cacheability;
        memattrs.inner        = default_cacheability;
        memattrs.shareability = <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        if walkparams.dct == '1' then
            memattrs.tags     = <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>;
        elsif walkparams.mtx == '1' then
            memattrs.tags     = <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a>;
            if walkparams.tbi == '0' then
                // For the purpose of the checks in this function, the MTE tag bits are ignored.
                va&lt;59:56&gt;     = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(va&lt;55&gt;, 4);
        else
            memattrs.tags     = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
        memattrs.xs           = '0';
    elsif accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> i_cache_attr;
        if <a link="AArch64.S1ICacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1ICacheEnabled(Regime regime)">AArch64.S1ICacheEnabled</a>(regime) then
            i_cache_attr.attrs     = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            i_cache_attr.hints     = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            i_cache_attr.transient = FALSE;
        else
            i_cache_attr.attrs     = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;

        memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
        memattrs.outer        = i_cache_attr;
        memattrs.inner        = i_cache_attr;
        memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        if walkparams.mtx == '1' then
            memattrs.tags     = <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a>;
        else
            memattrs.tags     = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
        memattrs.xs           = '1';
    else
        memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
        memattrs.device       = <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a>;
        memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        if walkparams.mtx == '1' then
            memattrs.tags = <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a>;
            if walkparams.tbi == '0' then
                // For the purpose of the checks in this function, the MTE tag bits are ignored.
                if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
                    va&lt;59:56&gt; = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(va&lt;55&gt;, 4);
                else
                    va&lt;59:56&gt; = '0000';
        else
            memattrs.tags = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
        memattrs.xs           = '1';
    memattrs.notagaccess = FALSE;

    fault.level = 0;
    addrtop     = <a link="AArch64.AddrTop.3" file="shared_pseudocode.xml" hover="function: integer AArch64.AddrTop(bit tbid, AccessType acctype, bit tbi)">AArch64.AddrTop</a>(walkparams.tbid, accdesc.acctype, walkparams.tbi);

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(va&lt;addrtop:<a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>()&gt;) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
    elsif <a link="AArch64.S1HasAlignmentFault.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch64.S1HasAlignmentFault</a>(accdesc, aligned, walkparams.ntlsmd, memattrs) then
        fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);
    else
        ipa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(va_in, oa, memattrs);
        ipa.mecid = AArch64.S1DisabledOutputMECID(walkparams, regime, ipa.paddress.paspace);
        return (fault, ipa);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.S1Translate" mylink="aarch64.translation.vmsa_translation.AArch64.S1Translate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1Translate()
// =====================
// Translate VA to IPA/PA depending on the regime

(FaultRecord, AddressDescriptor) <anchor link="AArch64.S1Translate.5" hover="function: (FaultRecord, AddressDescriptor) AArch64.S1Translate(FaultRecord fault_in, Regime regime, bits(64) va, boolean aligned, AccessDescriptor accdesc)">AArch64.S1Translate</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                                     bits(64) va, boolean aligned,
                                                     <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    // Prepare fault fields in case a fault is detected
    fault.secondstage = FALSE;
    fault.s2fs1walk   = FALSE;

    if !<a link="AArch64.S1Enabled.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1Enabled(Regime regime, AccessType acctype)">AArch64.S1Enabled</a>(regime, accdesc.acctype) then
        return <a link="AArch64.S1DisabledOutput.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S1DisabledOutput(FaultRecord fault_in, Regime regime, bits(64) va_in, AccessDescriptor accdesc, boolean aligned)">AArch64.S1DisabledOutput</a>(fault, regime, va, accdesc, aligned);

    walkparams = AArch64.GetS1TTWParams(regime, accdesc.ss, va);

    constant integer s1mintxsz = <a link="AArch64.S1MinTxSZ.4" file="shared_pseudocode.xml" hover="function: integer AArch64.S1MinTxSZ(Regime regime, bit d128, bit ds, TGx tgx)">AArch64.S1MinTxSZ</a>(regime, walkparams.d128,
                                                   walkparams.ds, walkparams.tgx);
    constant integer s1maxtxsz = <a link="AArch64.MaxTxSZ.1" file="shared_pseudocode.xml" hover="function: integer AArch64.MaxTxSZ(TGx tgx)">AArch64.MaxTxSZ</a>(walkparams.tgx);
    if AArch64.S1TxSZFaults(regime, walkparams) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);
    elsif <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &lt; s1mintxsz then
        walkparams.txsz = s1mintxsz&lt;5:0&gt;;
    elsif <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &gt; s1maxtxsz then
        walkparams.txsz = s1maxtxsz&lt;5:0&gt;;

    if AArch64.VAIsOutOfRange(va, accdesc.acctype, regime, walkparams) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    if accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; walkparams.e0pd == '1' then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; walkparams.nfd == '1' &amp;&amp; accdesc.transactional then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    if <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() &amp;&amp; accdesc.el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; walkparams.nfd == '1' &amp;&amp; (
            (accdesc.nonfault &amp;&amp; accdesc.contiguous) ||
            (accdesc.firstfault &amp;&amp; !accdesc.first &amp;&amp; !accdesc.contiguous)) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> descipaddr;
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    bits(128) descriptor;
    bits(128) new_desc;
    bits(128) mem_desc;
    repeat
        if walkparams.d128 == '1' then
            (fault, descipaddr, walkstate, descriptor) = AArch64.S1Walk(fault, walkparams, va,
                                                                        regime, accdesc, 128);
        else
            (fault, descipaddr, walkstate, descriptor&lt;63:0&gt;) = AArch64.S1Walk(fault, walkparams,
                                                                              va, regime, accdesc,
                                                                              64);
            descriptor&lt;127:64&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

        if accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
            // Flag the fetched instruction is from a guarded page
            <a link="impl-aarch64.SetInGuardedPage.1" file="shared_pseudocode.xml" hover="function: SetInGuardedPage(boolean guardedpage)">SetInGuardedPage</a>(walkstate.guardedpage == '1');

        if <a link="AArch64.S1HasAlignmentFault.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, bit ntlsmd, MemoryAttributes memattrs)">AArch64.S1HasAlignmentFault</a>(accdesc, aligned, walkparams.ntlsmd,
                                       walkstate.memattrs) then
            fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;

        if fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            fault = AArch64.S1CheckPermissions(fault, regime, walkstate, walkparams, accdesc);

        new_desc = descriptor;
        if walkparams.ha == '1' &amp;&amp; <a link="AArch64.SettingAccessFlagPermitted.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.SettingAccessFlagPermitted(FaultRecord fault)">AArch64.SettingAccessFlagPermitted</a>(fault) then
            // Set descriptor AF bit
            new_desc&lt;10&gt; = '1';

        // If HW update of dirty bit is enabled, the walk state permissions
        // will already reflect a configuration permitting writes.
        // The update of the descriptor occurs only if the descriptor bits in
        // memory do not reflect that and the access instigates a write.

        if (<a link="AArch64.SettingDirtyStatePermitted.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.SettingDirtyStatePermitted(FaultRecord fault)">AArch64.SettingDirtyStatePermitted</a>(fault) &amp;&amp;
                walkparams.ha  == '1' &amp;&amp;
                walkparams.hd  == '1' &amp;&amp;
                (walkparams.pie == '1' || descriptor&lt;51&gt; == '1') &amp;&amp;
                accdesc.write &amp;&amp;
                !(accdesc.acctype IN {<a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>})) then
            // Clear descriptor AP[2]/nDirty bit permitting stage 1 writes
            new_desc&lt;7&gt; = '0';

        // Either the access flag was clear or AP[2]/nDirty is set
        if new_desc != descriptor then
            <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> descpaddr;
            descaccess = <a link="impl-shared.CreateAccDescTTEUpdate.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescTTEUpdate(AccessDescriptor accdesc_in)">CreateAccDescTTEUpdate</a>(accdesc);
            if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
                <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> s2fault;
                s1aarch64 = TRUE;
                s2aligned = TRUE;
                (s2fault, descpaddr) = <a link="AArch64.S2Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</a>(fault, descipaddr, s1aarch64, s2aligned,
                                                           descaccess);

                if s2fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
                    return (s2fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

            else
                descpaddr = descipaddr;
            if walkparams.d128 == '1' then
                (fault, mem_desc) = <a link="AArch64.MemSwapTableDesc.6" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</a>(fault, descriptor, new_desc,
                                                             walkparams.ee, descaccess, descpaddr);
            else
                (fault, mem_desc&lt;63:0&gt;) = <a link="AArch64.MemSwapTableDesc.6" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</a>(fault, descriptor&lt;63:0&gt;,
                                                                   new_desc&lt;63:0&gt;, walkparams.ee,
                                                                   descaccess, descpaddr);
                mem_desc&lt;127:64&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

    until new_desc == descriptor || mem_desc == new_desc;

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    // Output Address
    oa = <a link="impl-shared.StageOA.4" file="shared_pseudocode.xml" hover="function: FullAddress StageOA(bits(64) ia, bit d128, TGx tgx, TTWState walkstate)">StageOA</a>(va, walkparams.d128, walkparams.tgx, walkstate);
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    if (accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
        (walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> || !<a link="AArch64.S1ICacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1ICacheEnabled(Regime regime)">AArch64.S1ICacheEnabled</a>(regime))) then
        // Treat memory attributes as Normal Non-Cacheable
        memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        memattrs.xs = walkstate.memattrs.xs;
    elsif (accdesc.acctype != <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp; !<a link="AArch64.S1DCacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1DCacheEnabled(Regime regime)">AArch64.S1DCacheEnabled</a>(regime) &amp;&amp;
             walkstate.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>) then
        // Treat memory attributes as Normal Non-Cacheable
        memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        memattrs.xs = walkstate.memattrs.xs;

        // The effect of SCTLR_ELx.C when '0' is Constrained UNPREDICTABLE
        // on the Tagged attribute
        if (<a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() &amp;&amp; walkstate.memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> &amp;&amp;
            !<a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_S1CTAGGED" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_S1CTAGGED</a>)) then
            memattrs.tags = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
    else
        memattrs = walkstate.memattrs;

    // Shareability value of stage 1 translation subject to stage 2 is IMPLEMENTATION DEFINED
    // to be either effective value or descriptor value
    if (regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.VM == '1' &amp;&amp;
            !(boolean IMPLEMENTATION_DEFINED "Apply effective shareability at stage 1")) then
        memattrs.shareability = walkstate.memattrs.shareability;
    else
        memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(memattrs);

    if accdesc.ls64 &amp;&amp; memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> then
        if memattrs.inner.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> || memattrs.outer.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
            fault.statuscode = <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>;
            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    ipa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(va, oa, memattrs);
    ipa.s1assured = walkstate.s1assured;
    varange   = <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va);
    ipa.mecid = AArch64.S1OutputMECID(walkparams, regime, varange, ipa.paddress.paspace,
                                      descriptor);
    return (fault, ipa);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.S2Translate" mylink="aarch64.translation.vmsa_translation.AArch64.S2Translate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2Translate()
// =====================
// Translate stage 1 IPA to PA and combine memory attributes

(FaultRecord, AddressDescriptor) <anchor link="AArch64.S2Translate.5" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa,
                                                     boolean s1aarch64, boolean aligned,
                                                     <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    walkparams = AArch64.GetS2TTWParams(accdesc.ss, ipa.paddress.paspace, s1aarch64);
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    boolean s2fs1mro;

    // Prepare fault fields in case a fault is detected
    fault.statuscode  = <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>; // Ignore any faults from stage 1
    fault.secondstage = TRUE;
    fault.s2fs1walk   = accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>;
    fault.ipaddress   = ipa.paddress;

    if walkparams.vm != '1' then
        // Stage 2 translation is disabled
        return (fault, ipa);

    constant integer s2mintxsz = <a link="AArch64.S2MinTxSZ.4" file="shared_pseudocode.xml" hover="function: integer AArch64.S2MinTxSZ(bit d128, bit ds, TGx tgx, boolean s1aarch64)">AArch64.S2MinTxSZ</a>(walkparams.d128, walkparams.ds,
                                                   walkparams.tgx, s1aarch64);
    constant integer s2maxtxsz = <a link="AArch64.MaxTxSZ.1" file="shared_pseudocode.xml" hover="function: integer AArch64.MaxTxSZ(TGx tgx)">AArch64.MaxTxSZ</a>(walkparams.tgx);
    if AArch64.S2TxSZFaults(walkparams, s1aarch64) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);
    elsif <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &lt; s2mintxsz then
        walkparams.txsz = s2mintxsz&lt;5:0&gt;;
    elsif <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(walkparams.txsz) &gt; s2maxtxsz then
        walkparams.txsz = s2maxtxsz&lt;5:0&gt;;

    if (walkparams.d128 == '0' &amp;&amp;
        (AArch64.S2InvalidSL(walkparams) || AArch64.S2InconsistentSL(walkparams))) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    if AArch64.IPAIsOutOfRange(ipa.paddress.address, walkparams) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> descpaddr;
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    bits(128) descriptor;
    bits(128) new_desc;
    bits(128) mem_desc;
    repeat
        if walkparams.d128 == '1' then
            (fault, descpaddr, walkstate, descriptor) = AArch64.S2Walk(fault, ipa, walkparams,
                                                                       accdesc, 128);
        else
            (fault, descpaddr, walkstate, descriptor&lt;63:0&gt;) = AArch64.S2Walk(fault, ipa,
                                                                             walkparams, accdesc,
                                                                             64);
            descriptor&lt;127:64&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

        if <a link="AArch64.S2HasAlignmentFault.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.S2HasAlignmentFault(AccessDescriptor accdesc, boolean aligned, MemoryAttributes memattrs)">AArch64.S2HasAlignmentFault</a>(accdesc, aligned, walkstate.memattrs) then
            fault.statuscode = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;

        if fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            (fault, s2fs1mro) = AArch64.S2CheckPermissions(fault, walkstate, walkparams, ipa,
                                                           accdesc);

        new_desc = descriptor;
        if walkparams.ha == '1' &amp;&amp; <a link="AArch64.SettingAccessFlagPermitted.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.SettingAccessFlagPermitted(FaultRecord fault)">AArch64.SettingAccessFlagPermitted</a>(fault) then
            // Set descriptor AF bit
            new_desc&lt;10&gt; = '1';

        // If HW update of dirty bit is enabled, the walk state permissions
        // will already reflect a configuration permitting writes.
        // The update of the descriptor occurs only if the descriptor bits in
        // memory do not reflect that and the access instigates a write.

        if (<a link="AArch64.SettingDirtyStatePermitted.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.SettingDirtyStatePermitted(FaultRecord fault)">AArch64.SettingDirtyStatePermitted</a>(fault) &amp;&amp;
                walkparams.ha  == '1' &amp;&amp;
                walkparams.hd  == '1' &amp;&amp;
                (walkparams.s2pie == '1' || descriptor&lt;51&gt; == '1') &amp;&amp;
                accdesc.write &amp;&amp;
                !(accdesc.acctype IN {<a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>, <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>})) then
            // Set descriptor S2AP[1]/Dirty bit permitting stage 2 writes
            new_desc&lt;7&gt; = '1';

        // Either the access flag was clear or S2AP[1]/Dirty is clear
        if new_desc != descriptor then
            <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> descaccess = <a link="impl-shared.CreateAccDescTTEUpdate.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescTTEUpdate(AccessDescriptor accdesc_in)">CreateAccDescTTEUpdate</a>(accdesc);
            if walkparams.d128 == '1' then
                (fault, mem_desc) = <a link="AArch64.MemSwapTableDesc.6" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</a>(fault, descriptor, new_desc,
                                                             walkparams.ee, descaccess,
                                                             descpaddr);
            else
                (fault, mem_desc&lt;63:0&gt;) = <a link="AArch64.MemSwapTableDesc.6" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</a>(fault, descriptor&lt;63:0&gt;,
                                                                   new_desc&lt;63:0&gt;, walkparams.ee,
                                                                   descaccess, descpaddr);
                mem_desc&lt;127:64&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);

    until new_desc == descriptor || mem_desc == new_desc;

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    ipa_64 = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.paddress.address, 64);
    // Output Address
    oa = <a link="impl-shared.StageOA.4" file="shared_pseudocode.xml" hover="function: FullAddress StageOA(bits(64) ia, bit d128, TGx tgx, TTWState walkstate)">StageOA</a>(ipa_64, walkparams.d128, walkparams.tgx, walkstate);
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> s2_memattrs;
    if ((accdesc.acctype == <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a> &amp;&amp;
            walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp; walkparams.ptw == '0') ||
        (accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
            (walkstate.memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> || HCR_EL2.ID == '1')) ||
        (accdesc.acctype != <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> &amp;&amp;
             walkstate.memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp; HCR_EL2.CD == '1')) then
        // Treat memory attributes as Normal Non-Cacheable
        s2_memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        s2_memattrs.xs = walkstate.memattrs.xs;
    else
        s2_memattrs = walkstate.memattrs;

    if accdesc.ls64 &amp;&amp; s2_memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> then
        if s2_memattrs.inner.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> || s2_memattrs.outer.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
            fault.statuscode = <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>;
            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN);

    s2aarch64 = TRUE;
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    if walkparams.fwb == '0' then
        memattrs = <a link="impl-shared.S2CombineS1MemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes S2CombineS1MemAttrs(MemoryAttributes s1_memattrs, MemoryAttributes s2_memattrs, boolean s2aarch64)">S2CombineS1MemAttrs</a>(ipa.memattrs, s2_memattrs, s2aarch64);
    else
        memattrs = s2_memattrs;

    pa = <a link="impl-shared.CreateAddressDescriptor.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</a>(ipa.vaddress, oa, memattrs);
    pa.s2fs1mro = s2fs1mro;
    pa.mecid = AArch64.S2OutputMECID(walkparams, pa.paddress.paspace, descriptor);
    return (fault, pa);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.SettingAccessFlagPermitted" mylink="aarch64.translation.vmsa_translation.AArch64.SettingAccessFlagPermitted" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SettingAccessFlagPermitted()
// ====================================
// Determine whether the access flag could be set by HW given the fault status

boolean <anchor link="AArch64.SettingAccessFlagPermitted.1" hover="function: boolean AArch64.SettingAccessFlagPermitted(FaultRecord fault)">AArch64.SettingAccessFlagPermitted</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    if fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return TRUE;
    elsif fault.statuscode IN {<a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>, <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>} then
        return <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_AFUPDATE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_AFUPDATE</a>);
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.SettingDirtyStatePermitted" mylink="aarch64.translation.vmsa_translation.AArch64.SettingDirtyStatePermitted" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SettingDirtyStatePermitted()
// ====================================
// Determine whether the dirty state could be set by HW given the fault status

boolean <anchor link="AArch64.SettingDirtyStatePermitted.1" hover="function: boolean AArch64.SettingDirtyStatePermitted(FaultRecord fault)">AArch64.SettingDirtyStatePermitted</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    if fault.statuscode == <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return TRUE;
    elsif fault.statuscode == <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a> then
        return <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_DBUPDATE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DBUPDATE</a>);
    else
        return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_translation/AArch64.TranslateAddress" mylink="aarch64.translation.vmsa_translation.AArch64.TranslateAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.TranslateAddress()
// ==========================
// Main entry point for translating an address

AddressDescriptor <anchor link="AArch64.TranslateAddress.4" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</anchor>(bits(64) va, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                           boolean aligned, integer size)
    if (SPESampleInFlight &amp;&amp; !(accdesc.acctype IN {<a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>,
                                                   <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>})) then
        <a link="impl-aarch64.SPEStartCounter.1" file="shared_pseudocode.xml" hover="function: SPEStartCounter(integer counter_index)">SPEStartCounter</a>(<a link="SPECounterPosTranslationLatency" file="shared_pseudocode.xml" hover="constant integer SPECounterPosTranslationLatency = 2">SPECounterPosTranslationLatency</a>);

    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> result = <a link="AArch64.FullTranslate.3" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.FullTranslate(bits(64) va, AccessDescriptor accdesc, boolean aligned)">AArch64.FullTranslate</a>(va, accdesc, aligned);

    if !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(result) &amp;&amp; accdesc.acctype != <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        result.fault = <a link="AArch64.CheckDebug.3" file="shared_pseudocode.xml" hover="function: FaultRecord AArch64.CheckDebug(bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckDebug</a>(va, accdesc, size);

    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(result) &amp;&amp; (
            accdesc.acctype != <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a> ||
            boolean IMPLEMENTATION_DEFINED "GPC <a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> on DC operations") then
        result.fault.gpcf = <a link="impl-shared.GranuleProtectionCheck.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GranuleProtectionCheck(AddressDescriptor addrdesc, AccessDescriptor accdesc)">GranuleProtectionCheck</a>(result, accdesc);

        if result.fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
            result.fault.statuscode = <a link="Fault_GPCFOnOutput" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnOutput</a>;
            result.fault.paddress   = result.paddress;

    if !<a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(result) &amp;&amp; accdesc.acctype == <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a> then
        result.fault = <a link="AArch64.CheckDebug.3" file="shared_pseudocode.xml" hover="function: FaultRecord AArch64.CheckDebug(bits(64) vaddress, AccessDescriptor accdesc, integer size)">AArch64.CheckDebug</a>(va, accdesc, size);

    if (SPESampleInFlight &amp;&amp; !(accdesc.acctype IN {<a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>,
                                                   <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>})) then
        <a link="impl-aarch64.SPEStopCounter.1" file="shared_pseudocode.xml" hover="function: SPEStopCounter(integer counter_index)">SPEStopCounter</a>(<a link="SPECounterPosTranslationLatency" file="shared_pseudocode.xml" hover="constant integer SPECounterPosTranslationLatency = 2">SPECounterPosTranslationLatency</a>);

    // Update virtual address for abort functions
    result.vaddress = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(va, 64);

    return result;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.BlockDescSupported" mylink="aarch64.translation.vmsa_ttentry.AArch64.BlockDescSupported" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BlockDescSupported()
// ============================
// Determine whether a block descriptor is valid for the given granule size
// and level

boolean <anchor link="AArch64.BlockDescSupported.4" hover="function: boolean AArch64.BlockDescSupported(bit d128, bit ds, TGx tgx, integer level)">AArch64.BlockDescSupported</anchor>(bit d128, bit ds, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer level)
    case tgx of
        when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>  return ((level == 0 &amp;&amp; (ds == '1' || d128 == '1')) ||
                               level == 1 ||
                               level == 2);
        when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a> return ((level == 1 &amp;&amp; (ds == '1' || d128 == '1')) ||
                               level == 2);
        when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> return ((level == 1 &amp;&amp; (d128 == '1' || <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>() &gt;= 52)) ||
                               level == 2);
    return FALSE;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.BlocknTFaults" mylink="aarch64.translation.vmsa_ttentry.AArch64.BlocknTFaults" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BlocknTFaults()
// =======================
// Identify whether the nT bit in a block descriptor is effectively set
// causing a translation fault

boolean <anchor link="AArch64.BlocknTFaults.2" hover="function: boolean AArch64.BlocknTFaults(bit d128, bits(N) descriptor)">AArch64.BlocknTFaults</anchor>(bit d128, bits(N) descriptor)
    bit nT;
    if !<a link="impl-shared.HaveBlockBBM.0" file="shared_pseudocode.xml" hover="function: boolean HaveBlockBBM()">HaveBlockBBM</a>() then
        return FALSE;
    nT = if d128 == '1' then descriptor&lt;6&gt; else descriptor&lt;16&gt;;
    bbm_level = <a link="AArch64.BlockBBMSupportLevel.0" file="shared_pseudocode.xml" hover="function: integer AArch64.BlockBBMSupportLevel()">AArch64.BlockBBMSupportLevel</a>();
    nT_faults = (boolean IMPLEMENTATION_DEFINED
                 "BBM level 1 or 2 support nT bit causes Translation <a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a>");

    return bbm_level IN {1, 2} &amp;&amp; nT == '1' &amp;&amp; nT_faults;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.ContiguousBit" mylink="aarch64.translation.vmsa_ttentry.AArch64.ContiguousBit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ContiguousBit()
// =======================
// Get the value of the contiguous bit

bit <anchor link="AArch64.ContiguousBit.4" hover="function: bit AArch64.ContiguousBit(TGx tgx, bit d128, integer level, bits(N) descriptor)">AArch64.ContiguousBit</anchor>(<a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, bit d128, integer level, bits(N) descriptor)
    if d128 == '1' then
        return descriptor&lt;111&gt;;
    // When using TGx 64KB and FEAT_LPA is implememted,
    // the Contiguous bit is RES0 for Block descriptors at level 1

    if tgx == <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> &amp;&amp; level == 1 then
        return '0'; // RES0

    // When the effective value of TCR_ELx.DS is '1',
    // the Contiguous bit is RES0 for all the following:
    //      * For TGx 4KB, Block descriptors at level 0
    //      * For TGx 16KB, Block descriptors at level 1

    if tgx == <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a> &amp;&amp; level == 1 then
        return '0'; // RES0

    if tgx == <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>  &amp;&amp; level == 0 then
        return '0'; // RES0

    return descriptor&lt;52&gt;;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.DecodeDescriptorType" mylink="aarch64.translation.vmsa_ttentry.AArch64.DecodeDescriptorType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.DecodeDescriptorType()
// ==============================
// Determine whether the descriptor is a page, block or table

DescriptorType <anchor link="AArch64.DecodeDescriptorType.5" hover="function: DescriptorType AArch64.DecodeDescriptorType(bits(N) descriptor, bit d128, bit ds, TGx tgx, integer level)">AArch64.DecodeDescriptorType</anchor>(bits(N) descriptor, bit d128, bit ds,
                                            <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer level)
    if descriptor&lt;0&gt; == '0' then
        return <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>;
    elsif d128 == '1' then
        bits(2) skl = descriptor&lt;110:109&gt;;
        if tgx IN {<a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>, <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>} &amp;&amp; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(skl) == 3 then
            return <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>;

        integer effective_level = level + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(skl);
        if effective_level &gt; <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> then
            return <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>;
        elsif effective_level == <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> then
            return <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;
        else
            return <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>;
    else
        if descriptor&lt;1&gt; == '1' then
            if level == <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> then
                return <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;
            else
                return <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>;
        elsif descriptor&lt;1&gt; == '0' then
            if <a link="AArch64.BlockDescSupported.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.BlockDescSupported(bit d128, bit ds, TGx tgx, integer level)">AArch64.BlockDescSupported</a>(d128, ds, tgx, level) then
                return <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;
            else
                return <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.S1ApplyOutputPerms" mylink="aarch64.translation.vmsa_ttentry.AArch64.S1ApplyOutputPerms" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1ApplyOutputPerms()
// ============================
// Apply output permissions encoded in stage 1 page/block descriptors

<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> AArch64.S1ApplyOutputPerms(<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions_in, bits(N) descriptor,
                                       <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams)
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = permissions_in;

    bits (4) pi_index;
    if walkparams.pie == '1' then
        if walkparams.d128 == '1' then
            pi_index = descriptor&lt;118:115&gt;;
        else
            pi_index = descriptor&lt;54:53&gt;:descriptor&lt;51&gt;:descriptor&lt;6&gt;;
        bit_index          = 4 * <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pi_index);
        permissions.ppi    = walkparams.pir&lt;bit_index+3:bit_index&gt;;
        permissions.upi    = walkparams.pire0&lt;bit_index+3:bit_index&gt;;
        permissions.ndirty = descriptor&lt;7&gt;;
    else
        if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; walkparams.nv1 == '1' then
            permissions.ap&lt;2:1&gt; = descriptor&lt;7&gt;:'0';
            permissions.pxn     = descriptor&lt;54&gt;;
        elsif <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
            permissions.ap&lt;2:1&gt; = descriptor&lt;7:6&gt;;
            permissions.uxn     = descriptor&lt;54&gt;;
            permissions.pxn     = descriptor&lt;53&gt;;
        else
            permissions.ap&lt;2:1&gt; = descriptor&lt;7&gt;:'1';
            permissions.xn      = descriptor&lt;54&gt;;
        // Descriptors marked with DBM set have the effective value of AP[2] cleared.
        // This implies no Permission faults caused by lack of write permissions are
        // reported, and the Dirty bit can be set.
        if walkparams.ha == '1' &amp;&amp; walkparams.hd == '1' &amp;&amp; descriptor&lt;51&gt; == '1' then
            permissions.ap&lt;2&gt; = '0';

    boolean poe   = <a link="AArch64.S1POEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1POEnabled(Regime regime)">AArch64.S1POEnabled</a>(regime);
    boolean e0poe = <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) &amp;&amp; <a link="AArch64.S1E0POEnabled.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1E0POEnabled(Regime regime, bit nv1)">AArch64.S1E0POEnabled</a>(regime, walkparams.nv1);

    if poe || e0poe then
        if walkparams.d128 == '1' then
            permissions.po_index = descriptor&lt;124:121&gt;;
        else
            permissions.po_index = '0':descriptor&lt;62:60&gt;;

    return permissions;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.S1ApplyTablePerms" mylink="aarch64.translation.vmsa_ttentry.AArch64.S1ApplyTablePerms" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1ApplyTablePerms()
// ===========================
// Apply hierarchical permissions encoded in stage 1 table descriptors

<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> AArch64.S1ApplyTablePerms(<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions_in, bits(N) descriptor,
                                      <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, S1TTWParams walkparams)
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions = permissions_in;
    bits(2) ap_table;
    bit pxn_table;
    bit uxn_table;
    bit xn_table;
    if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; walkparams.nv1 == '1' then
        if walkparams.d128 == '1' then
            ap_table  = descriptor&lt;126&gt;:'0';
            pxn_table = descriptor&lt;124&gt;;
        else
            ap_table  = descriptor&lt;62&gt;:'0';
            pxn_table = descriptor&lt;60&gt;;
        permissions.ap_table  = permissions.ap_table  OR ap_table;
        permissions.pxn_table = permissions.pxn_table OR pxn_table;

    elsif <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        if walkparams.d128 == '1' then
            ap_table  = descriptor&lt;126:125&gt;;
            uxn_table = descriptor&lt;124&gt;;
            pxn_table = descriptor&lt;123&gt;;
        else
            ap_table  = descriptor&lt;62:61&gt;;
            uxn_table = descriptor&lt;60&gt;;
            pxn_table = descriptor&lt;59&gt;;
        permissions.ap_table  = permissions.ap_table  OR ap_table;
        permissions.uxn_table = permissions.uxn_table OR uxn_table;
        permissions.pxn_table = permissions.pxn_table OR pxn_table;
    else
        if walkparams.d128 == '1' then
            ap_table = descriptor&lt;126&gt;:'0';
            xn_table = descriptor&lt;124&gt;;
        else
            ap_table = descriptor&lt;62&gt;:'0';
            xn_table = descriptor&lt;60&gt;;
        permissions.ap_table = permissions.ap_table OR ap_table;
        permissions.xn_table = permissions.xn_table OR xn_table;

    return permissions;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_ttentry/AArch64.S2ApplyOutputPerms" mylink="aarch64.translation.vmsa_ttentry.AArch64.S2ApplyOutputPerms" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2ApplyOutputPerms()
// ============================
// Apply output permissions encoded in stage 2 page/block descriptors

<a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> AArch64.S2ApplyOutputPerms(bits(N) descriptor, S2TTWParams walkparams)
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions;
    bits(4) s2pi_index;
    if walkparams.s2pie == '1' then
        if walkparams.d128 == '1' then
            s2pi_index = descriptor&lt;118:115&gt;;
        else
            s2pi_index = descriptor&lt;54:53,51,6&gt;;
        bit_index = 4 * <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(s2pi_index);
        permissions.s2pi = walkparams.s2pir&lt;bit_index+3 : bit_index&gt;;
        permissions.s2dirty = descriptor&lt;7&gt;;
    else
        permissions.s2ap = descriptor&lt;7:6&gt;;
        if walkparams.d128 == '1' then
            permissions.s2xn = descriptor&lt;118&gt;;
        else
            permissions.s2xn = descriptor&lt;54&gt;;

        if <a link="impl-shared.HaveExtendedExecuteNeverExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveExtendedExecuteNeverExt()">HaveExtendedExecuteNeverExt</a>() then
            if walkparams.d128 == '1' then
                permissions.s2xnx = descriptor&lt;117&gt;;
            else
                permissions.s2xnx = descriptor&lt;53&gt;;
        else
            permissions.s2xnx = '0';

        // Descriptors marked with DBM set have the effective value of S2AP[1] set.
        // This implies no Permission faults caused by lack of write permissions are
        // reported, and the Dirty bit can be set.
        bit desc_dbm;
        if walkparams.d128 == '1' then
            desc_dbm = descriptor&lt;115&gt;;
        else
            desc_dbm = descriptor&lt;51&gt;;
        if walkparams.ha == '1' &amp;&amp; walkparams.hd == '1' &amp;&amp; desc_dbm == '1' then
            permissions.s2ap&lt;1&gt; = '1';
    if walkparams.s2pie == '1' &amp;&amp; <a link="impl-shared.HaveS2POExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS2POExt()">HaveS2POExt</a>() &amp;&amp; VTCR_EL2.S2POE == '1' then
        if walkparams.d128 == '1' then
            permissions.s2po_index = descriptor&lt;124:121&gt;;
        else
            permissions.s2po_index = descriptor&lt;62:59&gt;;
    return permissions;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S1InitialTTWState" mylink="aarch64.translation.vmsa_walk.AArch64.S1InitialTTWState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1InitialTTWState()
// ===========================
// Set properties of first access to translation tables in stage 1

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.S1InitialTTWState(S1TTWParams walkparams, bits(64) va, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                   <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    walkstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase;
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a> permissions;
    bits(64)    ttb;

    startlevel  = AArch64.S1StartLevel(walkparams);
    ttb         = <a link="AArch64.S1TTB.2" file="shared_pseudocode.xml" hover="function: bits(64) AArch64.S1TTB(Regime regime, bits(64) va)">AArch64.S1TTB</a>(regime, va);
    case ss of
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    tablebase.paspace = <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> tablebase.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      tablebase.paspace = <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     tablebase.paspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;

    tablebase.address = <a link="AArch64.TTBaseAddress.7" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.TTBaseAddress(bits(64) ttb, bits(6) txsz, bits(3) ps, bit d128, bit ds, TGx tgx, integer startlevel)">AArch64.TTBaseAddress</a>(ttb, walkparams.txsz,
                                              walkparams.ps, walkparams.d128,
                                              walkparams.ds,
                                              walkparams.tgx, startlevel);

    permissions.ap_table = '00';
    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        permissions.uxn_table = '0';
        permissions.pxn_table = '0';
    else
        permissions.xn_table  = '0';

    walkstate.baseaddress = tablebase;
    walkstate.level       = startlevel;
    walkstate.istable     = TRUE;
    // In regimes that support global and non-global translations, translation
    // table entries from lookup levels other than the final level of lookup
    // are treated as being non-global
    walkstate.nG          = if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then '1' else '0';
    walkstate.memattrs    = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(walkparams.sh, walkparams.irgn, walkparams.orgn);
    walkstate.permissions = permissions;
    if (walkparams.d128 == '1' || walkparams.pnch == '1') then
        walkstate.s1assured = TRUE;
    else
        walkstate.s1assured = FALSE;
    walkstate.disch = walkparams.disch;

    return walkstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S1NextWalkStateLeaf" mylink="aarch64.translation.vmsa_walk.AArch64.S1NextWalkStateLeaf" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1NextWalkStateLeaf()
// =============================
// Decode stage 1 page or block descriptor as output to this stage of translation

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.S1NextWalkStateLeaf(<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> currentstate, boolean s2fs1mro, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                     <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, S1TTWParams walkparams, bits(N) descriptor)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    nextstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> baseaddress;
    baseaddress.address = <a link="AArch64.LeafBase.5" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.LeafBase(bits(N) descriptor, bit d128, bit ds, TGx tgx, integer level)">AArch64.LeafBase</a>(descriptor, walkparams.d128,
                                               walkparams.ds,
                                               walkparams.tgx, currentstate.level);

    if currentstate.baseaddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
        // Determine PA space of the block from NS bit
        bit ns;
        ns = if walkparams.d128 == '1' then descriptor&lt;127&gt; else descriptor&lt;5&gt;;
        baseaddress.paspace = if ns == '0' then <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> else <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    elsif currentstate.baseaddress.paspace == <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a> then
        // Determine PA space of the block from NSE and NS bits
        bit nse;
        bit ns;
        &lt;nse,ns&gt; = if walkparams.d128 == '1' then descriptor&lt;11,127&gt; else descriptor&lt;11,5&gt;;
        baseaddress.paspace = <a link="impl-shared.DecodePASpace.2" file="shared_pseudocode.xml" hover="function: PASpace DecodePASpace (bit nse, bit ns)">DecodePASpace</a>(nse, ns);

        // If Secure state is not implemented, but RME is,
        // force Secure space accesses to Non-secure space
        if baseaddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> &amp;&amp; !<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then
            baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    elsif (currentstate.baseaddress.paspace == <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> &amp;&amp;
            regime IN {<a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>, <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>}) then
        // Realm EL2 and EL2&amp;0 regimes have a stage 1 NS bit
        bit ns;
        ns = if walkparams.d128 == '1' then descriptor&lt;127&gt; else descriptor&lt;5&gt;;
        baseaddress.paspace = if ns == '0' then <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> else <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    elsif currentstate.baseaddress.paspace == <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a> then
        // Realm EL1&amp;0 regime does not have a stage 1 NS bit
        baseaddress.paspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
    else
        baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    nextstate.istable     = FALSE;
    nextstate.level       = currentstate.level;
    nextstate.baseaddress = baseaddress;

    bits(4) attrindx;
    if walkparams.aie == '1' then
        if walkparams.d128 == '1' then
            attrindx = descriptor&lt;5:2&gt;;
        else
            attrindx = descriptor&lt;59,4:2&gt;;
    else
        attrindx = '0':descriptor&lt;4:2&gt;;

    bits(2) sh;
    if walkparams.d128 == '1' then
        sh = descriptor&lt;9:8&gt;;
    elsif walkparams.ds == '1' then
        sh = walkparams.sh;
    else
        sh = descriptor&lt;9:8&gt;;
    attr = AArch64.MAIRAttr(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(attrindx), walkparams.mair2, walkparams.mair);
    s1aarch64 = TRUE;

    nextstate.memattrs    = S1DecodeMemAttrs(attr, sh, s1aarch64, walkparams);
    nextstate.permissions = AArch64.S1ApplyOutputPerms(currentstate.permissions,
                                                       descriptor, regime, walkparams);
    bit protected;
    if walkparams.d128 == '1' then
        protected = descriptor&lt;114&gt;;
    else
        protected = if walkparams.pnch == '1' then descriptor&lt;52&gt; else '0';
    if (currentstate.s1assured &amp;&amp; s2fs1mro &amp;&amp; protected == '1') then
        nextstate.s1assured = TRUE;
    else
        nextstate.s1assured = FALSE;

    if walkparams.pnch == '1' || currentstate.disch == '1' then
        nextstate.contiguous = '0';
    else
        nextstate.contiguous = <a link="AArch64.ContiguousBit.4" file="shared_pseudocode.xml" hover="function: bit AArch64.ContiguousBit(TGx tgx, bit d128, integer level, bits(N) descriptor)">AArch64.ContiguousBit</a>(walkparams.tgx, walkparams.d128,
                                                     currentstate.level, descriptor);
    if !<a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
        nextstate.nG = '0';
    elsif ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; currentstate.baseaddress.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
        // In Secure state, a translation must be treated as non-global,
        // regardless of the value of the nG bit,
        // if NSTable is set to 1 at any level of the translation table walk
        nextstate.nG = '1';
    else
        nextstate.nG = descriptor&lt;11&gt;;

    if walkparams.d128 == '1' then
        nextstate.guardedpage = descriptor&lt;113&gt;;
    else
        nextstate.guardedpage = descriptor&lt;50&gt;;

    return nextstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S1NextWalkStateTable" mylink="aarch64.translation.vmsa_walk.AArch64.S1NextWalkStateTable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1NextWalkStateTable()
// ==============================
// Decode stage 1 table descriptor to transition to the next level

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.S1NextWalkStateTable(<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> currentstate, boolean s2fs1mro, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                      S1TTWParams walkparams, bits(N) descriptor)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    nextstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase;

    tablebase.address = <a link="AArch64.NextTableBase.4" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.NextTableBase(bits(N) descriptor, bit d128, bit ds, TGx tgx)">AArch64.NextTableBase</a>(descriptor, walkparams.d128,
                                              walkparams.ds,
                                              walkparams.tgx);
    if currentstate.baseaddress.paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
        // Determine PA space of the next table from NSTable bit
        bit nstable;
        nstable = if walkparams.d128 == '1' then descriptor&lt;127&gt; else descriptor&lt;63&gt;;
        tablebase.paspace = if nstable == '0' then <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> else <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    else
        // Otherwise bit 63 is RES0 and there is no NSTable bit
        tablebase.paspace = currentstate.baseaddress.paspace;

    nextstate.istable     = TRUE;
    nextstate.nG          = currentstate.nG;
    if walkparams.d128 == '1' then
        skl = descriptor&lt;110:109&gt;;
        nextstate.level   = currentstate.level + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(skl) + 1;
    else
        nextstate.level   = currentstate.level + 1;
    nextstate.baseaddress = tablebase;
    nextstate.memattrs    = currentstate.memattrs;
    if walkparams.hpd == '0' &amp;&amp; walkparams.pie == '0' then
        nextstate.permissions = AArch64.S1ApplyTablePerms(currentstate.permissions, descriptor,
                                                          regime, walkparams);
    else
        nextstate.permissions = currentstate.permissions;
    bit protected;
    if walkparams.d128 == '1' then
        protected = descriptor&lt;114&gt;;
    else
        protected = if walkparams.pnch == '1' then descriptor&lt;52&gt; else '0';
    if (currentstate.s1assured &amp;&amp; s2fs1mro &amp;&amp; protected == '1') then
        nextstate.s1assured = TRUE;
    else
        nextstate.s1assured = FALSE;
    nextstate.disch = if walkparams.d128 == '1' then descriptor&lt;112&gt; else '0';

    return nextstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S1Walk" mylink="aarch64.translation.vmsa_walk.AArch64.S1Walk" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1Walk()
// ================
// Traverse stage 1 translation tables obtaining the final descriptor
// as well as the address leading to that descriptor

(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a>, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a>, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>, bits(N)) AArch64.S1Walk(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in,
                                                                   S1TTWParams walkparams,
                                                                   bits(64) va, <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime,
                                                                   <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                                                   integer N)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) &amp;&amp; <a link="AArch64.S1EPD.2" file="shared_pseudocode.xml" hover="function: bit AArch64.S1EPD(Regime regime, bits(64) va)">AArch64.S1EPD</a>(regime, va) == '1' then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                bits(N) UNKNOWN);

    walkstate = AArch64.S1InitialTTWState(walkparams, va, regime, accdesc.ss);
    constant integer startlevel = walkstate.level;

    // Detect Address Size Fault by TTB
    if <a link="AArch64.OAOutOfRange.5" file="shared_pseudocode.xml" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</a>(walkstate, walkparams.d128,
                            walkparams.ps, walkparams.tgx, va) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                bits(N) UNKNOWN);

    bits(N) descriptor;
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> walkaddress;
    bits(2) skl = '00';
    walkaddress.vaddress = va;
    walkaddress.mecid = <a link="AArch64.TTWalkMECID.3" file="shared_pseudocode.xml" hover="function: bits(16) AArch64.TTWalkMECID(bit emec, Regime regime, SecurityState ss)">AArch64.TTWalkMECID</a>(walkparams.emec, regime, accdesc.ss);

    if !<a link="AArch64.S1DCacheEnabled.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.S1DCacheEnabled(Regime regime)">AArch64.S1DCacheEnabled</a>(regime) then
        walkaddress.memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        walkaddress.memattrs.xs = walkstate.memattrs.xs;
    else
        walkaddress.memattrs = walkstate.memattrs;

    // Shareability value of stage 1 translation subject to stage 2 is IMPLEMENTATION DEFINED
    // to be either effective value or descriptor value
    if (regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.VM == '1' &amp;&amp;
            !(boolean IMPLEMENTATION_DEFINED "Apply effective shareability at stage 1")) then
        walkaddress.memattrs.shareability = walkstate.memattrs.shareability;
    else
        walkaddress.memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(walkaddress.memattrs);

    boolean s2fs1mro = FALSE;

    <a link="DescriptorType" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType</a> desctype;
    repeat
        fault.level = walkstate.level;
        <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> descaddress;
        if walkstate.level == startlevel then
            descaddress = AArch64.S1SLTTEntryAddress(walkstate.level, walkparams, va,
                                                     walkstate.baseaddress);
        else
            skl = if walkparams.d128 == '1' then descriptor&lt;110:109&gt; else '00';
            descaddress = <a link="AArch64.TTEntryAddress.7" file="shared_pseudocode.xml" hover="function: FullAddress AArch64.TTEntryAddress(integer level, bit d128, bits(2) skl, TGx tgx, bits(6) txsz, bits(64) ia, FullAddress tablebase)">AArch64.TTEntryAddress</a>(walkstate.level, walkparams.d128, skl,
                                                 walkparams.tgx, walkparams.txsz, va,
                                                 walkstate.baseaddress);
        walkaddress.paddress = descaddress;

        boolean toplevel = walkstate.level == startlevel;
        <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange  = <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va);
        <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> walkaccess = <a link="impl-shared.CreateAccDescS1TTW.3" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescS1TTW(boolean toplevel, VARange varange, AccessDescriptor accdesc_in)">CreateAccDescS1TTW</a>(toplevel, varange, accdesc);
        <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> s2fault;
        <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> s2walkaddress;
        if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
            s1aarch64 = TRUE;
            aligned   = TRUE;
            (s2fault, s2walkaddress) = <a link="AArch64.S2Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</a>(fault, walkaddress, s1aarch64, aligned,
                                                           walkaccess);

            if s2fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
                return (s2fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                        bits(N) UNKNOWN);

            s2fs1mro = s2walkaddress.s2fs1mro;
            (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(walkparams.ee, s2walkaddress, walkaccess,
                                                  fault, N);
        else
            (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(walkparams.ee, walkaddress, walkaccess,
                                                  fault, N);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                    bits(N) UNKNOWN);

        bits(N) new_descriptor;
        repeat
            new_descriptor = descriptor;
            desctype = <a link="AArch64.DecodeDescriptorType.5" file="shared_pseudocode.xml" hover="function: DescriptorType AArch64.DecodeDescriptorType(bits(N) descriptor, bit d128, bit ds, TGx tgx, integer level)">AArch64.DecodeDescriptorType</a>(descriptor, walkparams.d128, walkparams.ds,
                                                    walkparams.tgx, walkstate.level);
            case desctype of
                when <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>
                    walkstate = AArch64.S1NextWalkStateTable(walkstate, s2fs1mro,
                                                             regime, walkparams, descriptor);
                    // Detect Address Size Fault by table descriptor

                    if <a link="AArch64.OAOutOfRange.5" file="shared_pseudocode.xml" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</a>(walkstate, walkparams.d128,
                                            walkparams.ps, walkparams.tgx, va) then
                        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
                        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                                bits(N) UNKNOWN);

                    if walkparams.haft == '1' then
                        new_descriptor&lt;10&gt; = '1';

                    if walkparams.d128 == '1' then
                        skl = descriptor&lt;110:109&gt;;
                        if skl != '00' &amp;&amp; <a link="AArch64.BlocknTFaults.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.BlocknTFaults(bit d128, bits(N) descriptor)">AArch64.BlocknTFaults</a>(walkparams.d128, descriptor) then
                            fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                                    bits(N) UNKNOWN);
                when <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>
                    walkstate = AArch64.S1NextWalkStateLeaf(walkstate, s2fs1mro,
                                                            regime, accdesc.ss, walkparams,
                                                            descriptor);
                when <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>
                    fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                    return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                            bits(N) UNKNOWN);
                otherwise
                    <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

            if new_descriptor != descriptor then
                <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> descpaddr;
                <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> descaccess = <a link="impl-shared.CreateAccDescTTEUpdate.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescTTEUpdate(AccessDescriptor accdesc_in)">CreateAccDescTTEUpdate</a>(accdesc);
                if regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
                    s1aarch64 = TRUE;
                    aligned   = TRUE;
                    (s2fault, descpaddr) = <a link="AArch64.S2Translate.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, AddressDescriptor) AArch64.S2Translate(FaultRecord fault_in, AddressDescriptor ipa, boolean s1aarch64, boolean aligned, AccessDescriptor accdesc)">AArch64.S2Translate</a>(fault, walkaddress,
                                                               s1aarch64, aligned,
                                                               descaccess);
                else
                    descpaddr = walkaddress;

                (fault, descriptor) = <a link="AArch64.MemSwapTableDesc.6" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</a>(fault, descriptor, new_descriptor,
                                                               walkparams.ee, descaccess,
                                                               descpaddr);
                if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
                    return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN,
                            <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);
        until new_descriptor == descriptor;
    until desctype == <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;

    if (walkstate.contiguous == '1' &amp;&amp;
        <a link="AArch64.ContiguousBitFaults.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.ContiguousBitFaults(bit d128, bits(6) txsz, TGx tgx, integer level)">AArch64.ContiguousBitFaults</a>(walkparams.d128, walkparams.txsz, walkparams.tgx,
                                    walkstate.level)) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
    elsif (desctype == <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a> &amp;&amp; walkstate.level &lt; <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> &amp;&amp;
          <a link="AArch64.BlocknTFaults.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.BlocknTFaults(bit d128, bits(N) descriptor)">AArch64.BlocknTFaults</a>(walkparams.d128, descriptor)) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
    elsif AArch64.S1AMECFault(walkparams, walkstate.baseaddress.paspace, regime, descriptor) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
    // Detect Address Size Fault by final output
    elsif <a link="AArch64.OAOutOfRange.5" file="shared_pseudocode.xml" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</a>(walkstate, walkparams.d128,
                               walkparams.ps, walkparams.tgx, va) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
    // Check descriptor AF bit
    elsif (descriptor&lt;10&gt; == '0' &amp;&amp; walkparams.ha == '0' &amp;&amp;
            !(accdesc.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>} &amp;&amp;
            !boolean IMPLEMENTATION_DEFINED "Generate access flag fault on IC/DC operations")) then
        fault.statuscode = <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>;

    if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);

    return (fault, walkaddress, walkstate, descriptor);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S2InitialTTWState" mylink="aarch64.translation.vmsa_walk.AArch64.S2InitialTTWState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2InitialTTWState()
// ===========================
// Set properties of first access to translation tables in stage 2

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.S2InitialTTWState(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, S2TTWParams walkparams)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    walkstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase;
    bits(64)    ttb;

    ttb               = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR_EL2.BADDR, 64);
    startlevel        = AArch64.S2StartLevel(walkparams);
    case ss of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> tablebase.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     tablebase.paspace = <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
    tablebase.address = <a link="AArch64.TTBaseAddress.7" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.TTBaseAddress(bits(64) ttb, bits(6) txsz, bits(3) ps, bit d128, bit ds, TGx tgx, integer startlevel)">AArch64.TTBaseAddress</a>(ttb, walkparams.txsz,
                                              walkparams.ps, walkparams.d128,
                                              walkparams.ds,
                                              walkparams.tgx, startlevel);

    walkstate.baseaddress = tablebase;
    walkstate.level       = startlevel;
    walkstate.istable     = TRUE;
    walkstate.memattrs    = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(walkparams.sh, walkparams.irgn, walkparams.orgn);

    return walkstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S2NextWalkStateLeaf" mylink="aarch64.translation.vmsa_walk.AArch64.S2NextWalkStateLeaf" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2NextWalkStateLeaf()
// =============================
// Decode stage 2 page or block descriptor as output to this stage of translation

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.S2NextWalkStateLeaf(<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> currentstate, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss,
                                     S2TTWParams walkparams, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa,
                                     bits(N) descriptor)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    nextstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> baseaddress;

    if ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        baseaddress.paspace = AArch64.SS2OutputPASpace(walkparams, ipa.paddress.paspace);
    elsif ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> then
        bit ns;
        ns = if walkparams.d128 == '1' then descriptor&lt;127&gt; else descriptor&lt;55&gt;;
        baseaddress.paspace = if ns == '1' then <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> else <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
    else
        baseaddress.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    baseaddress.address   = <a link="AArch64.LeafBase.5" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.LeafBase(bits(N) descriptor, bit d128, bit ds, TGx tgx, integer level)">AArch64.LeafBase</a>(descriptor, walkparams.d128, walkparams.ds,
                                             walkparams.tgx, currentstate.level);

    nextstate.istable     = FALSE;
    nextstate.level       = currentstate.level;
    nextstate.baseaddress = baseaddress;
    nextstate.permissions = AArch64.S2ApplyOutputPerms(descriptor, walkparams);

    s2_attr = descriptor&lt;5:2&gt;;
    s2_sh   = if walkparams.ds == '1' then walkparams.sh else descriptor&lt;9:8&gt;;
    s2_fnxs = descriptor&lt;11&gt;;
    if walkparams.fwb == '1' then
        nextstate.memattrs = AArch64.S2ApplyFWBMemAttrs(ipa.memattrs, walkparams, descriptor);
        if s2_attr&lt;3:1&gt; == '111' then
            nextstate.permissions.s2tag_na = '1';
        else
            nextstate.permissions.s2tag_na = '0';
    else
        s2aarch64 = TRUE;
        nextstate.memattrs = <a link="impl-shared.S2DecodeMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes S2DecodeMemAttrs(bits(4) attr, bits(2) sh, boolean s2aarch64)">S2DecodeMemAttrs</a>(s2_attr, s2_sh, s2aarch64);
        // FnXS is used later to mask the XS value from stage 1
        nextstate.memattrs.xs = NOT s2_fnxs;
        if s2_attr == '0100' then
            nextstate.permissions.s2tag_na = '1';
        else
            nextstate.permissions.s2tag_na = '0';
    nextstate.contiguous = <a link="AArch64.ContiguousBit.4" file="shared_pseudocode.xml" hover="function: bit AArch64.ContiguousBit(TGx tgx, bit d128, integer level, bits(N) descriptor)">AArch64.ContiguousBit</a>(walkparams.tgx, walkparams.d128,
                                                 currentstate.level, descriptor);
    if walkparams.d128 == '1' then
        nextstate.s2assuredonly = descriptor&lt;114&gt;;
    else
        nextstate.s2assuredonly = if walkparams.assuredonly == '1' then descriptor&lt;58&gt; else '0';

    return nextstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S2NextWalkStateTable" mylink="aarch64.translation.vmsa_walk.AArch64.S2NextWalkStateTable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2NextWalkStateTable()
// ==============================
// Decode stage 2 table descriptor to transition to the next level

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.S2NextWalkStateTable(<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> currentstate, S2TTWParams walkparams,
                                      bits(N) descriptor)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    nextstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase;

    tablebase.address = <a link="AArch64.NextTableBase.4" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.NextTableBase(bits(N) descriptor, bit d128, bit ds, TGx tgx)">AArch64.NextTableBase</a>(descriptor, walkparams.d128,
                                              walkparams.ds,
                                              walkparams.tgx);
    tablebase.paspace = currentstate.baseaddress.paspace;

    nextstate.istable     = TRUE;
    if walkparams.d128 == '1' then
        skl = descriptor&lt;110:109&gt;;
        nextstate.level   = currentstate.level + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(skl) + 1;
    else
        nextstate.level   = currentstate.level + 1;
    nextstate.baseaddress = tablebase;
    nextstate.memattrs    = currentstate.memattrs;

    return nextstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.S2Walk" mylink="aarch64.translation.vmsa_walk.AArch64.S2Walk" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2Walk()
// ================
// Traverse stage 2 translation tables obtaining the final descriptor
// as well as the address leading to that descriptor

(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a>, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a>, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>, bits(N)) AArch64.S2Walk(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in,
                                                                   <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> ipa,
                                                                   S2TTWParams walkparams,
                                                                   <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                                                   integer N)

    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;
    ipa_64 = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.paddress.address, 64);

    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate;
    if accdesc.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        walkstate = AArch64.SS2InitialTTWState(walkparams, ipa.paddress.paspace);
    else
        walkstate = AArch64.S2InitialTTWState(accdesc.ss, walkparams);

    constant integer startlevel = walkstate.level;

    // Detect Address Size Fault by TTB
    if <a link="AArch64.OAOutOfRange.5" file="shared_pseudocode.xml" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</a>(walkstate, walkparams.d128, walkparams.ps, walkparams.tgx,
                            ipa_64) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
        fault.level      = 0;
        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);

    bits(N) descriptor;
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> walkaccess = <a link="impl-shared.CreateAccDescS2TTW.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescS2TTW(AccessDescriptor accdesc_in)">CreateAccDescS2TTW</a>(accdesc);
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> walkaddress;
    bits(2) skl = '00';

    walkaddress.vaddress = ipa.vaddress;
    walkaddress.mecid = <a link="AArch64.TTWalkMECID.3" file="shared_pseudocode.xml" hover="function: bits(16) AArch64.TTWalkMECID(bit emec, Regime regime, SecurityState ss)">AArch64.TTWalkMECID</a>(walkparams.emec, <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>, accdesc.ss);

    if HCR_EL2.CD == '1' then
        walkaddress.memattrs = <a link="impl-shared.NormalNCMemAttr.0" file="shared_pseudocode.xml" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</a>();
        walkaddress.memattrs.xs = walkstate.memattrs.xs;
    else
        walkaddress.memattrs = walkstate.memattrs;

    walkaddress.memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(walkaddress.memattrs);

    <a link="DescriptorType" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType</a> desctype;
    repeat
        fault.level = walkstate.level;

        <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> descaddress;
        if walkstate.level == startlevel then
            // Initial lookup might index into concatenated tables
            descaddress = AArch64.S2SLTTEntryAddress(walkparams, ipa.paddress.address,
                                                     walkstate.baseaddress);
        else
            skl = if walkparams.d128 == '1' then descriptor&lt;110:109&gt; else '00';
            ipa_64 = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(ipa.paddress.address, 64);
            descaddress = <a link="AArch64.TTEntryAddress.7" file="shared_pseudocode.xml" hover="function: FullAddress AArch64.TTEntryAddress(integer level, bit d128, bits(2) skl, TGx tgx, bits(6) txsz, bits(64) ia, FullAddress tablebase)">AArch64.TTEntryAddress</a>(walkstate.level, walkparams.d128, skl,
                                                 walkparams.tgx, walkparams.txsz, ipa_64,
                                                 walkstate.baseaddress);

        walkaddress.paddress = descaddress;
        (fault, descriptor) = <a link="impl-shared.FetchDescriptor.5" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</a>(walkparams.ee, walkaddress, walkaccess, fault, N);

        if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);

        bits(N) new_descriptor;
        repeat
            new_descriptor = descriptor;
            desctype = <a link="AArch64.DecodeDescriptorType.5" file="shared_pseudocode.xml" hover="function: DescriptorType AArch64.DecodeDescriptorType(bits(N) descriptor, bit d128, bit ds, TGx tgx, integer level)">AArch64.DecodeDescriptorType</a>(descriptor, walkparams.d128, walkparams.ds,
                                                    walkparams.tgx, walkstate.level);
            case desctype of
                when <a link="DescriptorType_Table" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</a>
                    walkstate = AArch64.S2NextWalkStateTable(walkstate, walkparams, descriptor);

                    // Detect Address Size Fault by table descriptor
                    if <a link="AArch64.OAOutOfRange.5" file="shared_pseudocode.xml" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</a>(walkstate, walkparams.d128,
                                            walkparams.ps, walkparams.tgx, ipa_64) then
                        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
                        return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN,
                                <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);

                    if walkparams.haft == '1' then
                        new_descriptor&lt;10&gt; = '1';

                    if walkparams.d128 == '1' then
                        skl = descriptor&lt;110:109&gt;;
                        if skl != '00' &amp;&amp; <a link="AArch64.BlocknTFaults.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.BlocknTFaults(bit d128, bits(N) descriptor)">AArch64.BlocknTFaults</a>(walkparams.d128, descriptor) then
                            fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                            return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN,
                                    bits(N) UNKNOWN);

                when <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>
                    walkstate = AArch64.S2NextWalkStateLeaf(walkstate, accdesc.ss, walkparams, ipa,
                                                            descriptor);
                when <a link="DescriptorType_Invalid" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</a>
                    fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
                    return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);

                otherwise
                    <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

            if new_descriptor != descriptor then
                <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> descaccess = <a link="impl-shared.CreateAccDescTTEUpdate.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescTTEUpdate(AccessDescriptor accdesc_in)">CreateAccDescTTEUpdate</a>(accdesc);
                (fault, descriptor) = <a link="AArch64.MemSwapTableDesc.6" file="shared_pseudocode.xml" hover="function: (FaultRecord, bits(N)) AArch64.MemSwapTableDesc(FaultRecord fault_in, bits(N) prev_desc, bits(N) new_desc, bit ee, AccessDescriptor  descaccess, AddressDescriptor descpaddr)">AArch64.MemSwapTableDesc</a>(fault, descriptor, new_descriptor,
                                                               walkparams.ee, descaccess,
                                                               walkaddress);
                if fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a> then
                    return (fault, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> UNKNOWN, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> UNKNOWN, bits(N) UNKNOWN);
        until new_descriptor == descriptor;
    until desctype == <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a>;

    if (walkstate.contiguous == '1' &amp;&amp;
        <a link="AArch64.ContiguousBitFaults.4" file="shared_pseudocode.xml" hover="function: boolean AArch64.ContiguousBitFaults(bit d128, bits(6) txsz, TGx tgx, integer level)">AArch64.ContiguousBitFaults</a>(walkparams.d128, walkparams.txsz, walkparams.tgx,
                                    walkstate.level)) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
    elsif (desctype == <a link="DescriptorType_Leaf" file="shared_pseudocode.xml" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</a> &amp;&amp; walkstate.level &lt; <a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> &amp;&amp;
          <a link="AArch64.BlocknTFaults.2" file="shared_pseudocode.xml" hover="function: boolean AArch64.BlocknTFaults(bit d128, bits(N) descriptor)">AArch64.BlocknTFaults</a>(walkparams.d128, descriptor)) then
        fault.statuscode = <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>;
    // Detect Address Size Fault by final output
    elsif <a link="AArch64.OAOutOfRange.5" file="shared_pseudocode.xml" hover="function: boolean AArch64.OAOutOfRange(TTWState walkstate, bit d128, bits(3) ps, TGx tgx, bits(64) ia)">AArch64.OAOutOfRange</a>(walkstate, walkparams.d128, walkparams.ps, walkparams.tgx,
                               ipa_64) then
        fault.statuscode = <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>;
    // Check descriptor AF bit
    elsif (descriptor&lt;10&gt; == '0' &amp;&amp; walkparams.ha == '0' &amp;&amp;
            !(accdesc.acctype IN {<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>} &amp;&amp;
            !boolean IMPLEMENTATION_DEFINED "Generate access flag fault on IC/DC operations")) then
        fault.statuscode = <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>;

    return (fault, walkaddress, walkstate, descriptor);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.SS2InitialTTWState" mylink="aarch64.translation.vmsa_walk.AArch64.SS2InitialTTWState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SS2InitialTTWState()
// ============================
// Set properties of first access to translation tables in Secure stage 2

<a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> AArch64.SS2InitialTTWState(S2TTWParams walkparams, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> ipaspace)
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    walkstate;
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> tablebase;
    bits(64)    ttb;

    if ipaspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
        ttb = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VSTTBR_EL2.BADDR, 64);
    else
        ttb = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR_EL2.BADDR, 64);

    if ipaspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
        if walkparams.sw == '0' then
            tablebase.paspace = <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        else
            tablebase.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    else
        if walkparams.nsw == '0' then
            tablebase.paspace = <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        else
            tablebase.paspace = <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;

    startlevel        = AArch64.S2StartLevel(walkparams);
    tablebase.address = <a link="AArch64.TTBaseAddress.7" file="shared_pseudocode.xml" hover="function: bits(56) AArch64.TTBaseAddress(bits(64) ttb, bits(6) txsz, bits(3) ps, bit d128, bit ds, TGx tgx, integer startlevel)">AArch64.TTBaseAddress</a>(ttb, walkparams.txsz,
                                              walkparams.ps, walkparams.d128,
                                              walkparams.ds,
                                              walkparams.tgx, startlevel);

    walkstate.baseaddress = tablebase;
    walkstate.level       = startlevel;
    walkstate.istable     = TRUE;
    walkstate.memattrs    = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(walkparams.sh, walkparams.irgn, walkparams.orgn);

    return walkstate;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walk/AArch64.SS2OutputPASpace" mylink="aarch64.translation.vmsa_walk.AArch64.SS2OutputPASpace" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SS2OutputPASpace()
// ==========================
// Assign PA Space to output of Secure stage 2 translation

<a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> AArch64.SS2OutputPASpace(S2TTWParams walkparams, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> ipaspace)
    if ipaspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
        if walkparams.&lt;sw,sa&gt; == '00' then
            return <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        else
            return <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
    else
        if walkparams.&lt;sw,sa,nsw,nsa&gt; == '0000' then
            return <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        else
            return <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.BBMSupportLevel" mylink="aarch64.translation.vmsa_walkparams.AArch64.BBMSupportLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BBMSupportLevel()
// =========================
// Returns the level of FEAT_BBM supported

integer <anchor link="AArch64.BlockBBMSupportLevel.0" hover="function: integer AArch64.BlockBBMSupportLevel()">AArch64.BlockBBMSupportLevel</anchor>()
    if !<a link="impl-shared.HaveBlockBBM.0" file="shared_pseudocode.xml" hover="function: boolean HaveBlockBBM()">HaveBlockBBM</a>() then
        return integer UNKNOWN;
    else
        return integer IMPLEMENTATION_DEFINED "Block BBM support level";</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.GetS1TTWParams" mylink="aarch64.translation.vmsa_walkparams.AArch64.GetS1TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GetS1TTWParams()
// ========================
// Returns stage 1 translation table walk parameters from respective controlling
// System registers.

S1TTWParams AArch64.GetS1TTWParams(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(64) va)
    S1TTWParams walkparams;

    varange = <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va);

    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  walkparams = AArch64.S1TTWParamsEL3();
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  walkparams = AArch64.S1TTWParamsEL2(ss);
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> walkparams = AArch64.S1TTWParamsEL20(ss, varange);
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> walkparams = AArch64.S1TTWParamsEL10(varange);

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.GetS2TTWParams" mylink="aarch64.translation.vmsa_walkparams.AArch64.GetS2TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GetS2TTWParams()
// ========================
// Gather walk parameters for stage 2 translation

S2TTWParams AArch64.GetS2TTWParams(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> ipaspace, boolean s1aarch64)
    S2TTWParams walkparams;

    if ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
        walkparams = AArch64.NSS2TTWParams(s1aarch64);
    elsif <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        walkparams = AArch64.SS2TTWParams(ipaspace, s1aarch64);
    elsif ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> then
        walkparams = AArch64.RLS2TTWParams(s1aarch64);
    else
        <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.GetVARange" mylink="aarch64.translation.vmsa_walkparams.AArch64.GetVARange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.GetVARange()
// ====================
// Determines if the VA that is to be translated lies in LOWER or UPPER address range.

VARange <anchor link="AArch64.GetVARange.1" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</anchor>(bits(64) va)
    if va&lt;55&gt; == '0' then
        return <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a>;
    else
        return <a link="VARange_UPPER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</a>;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.HaveS1TG" mylink="aarch64.translation.vmsa_walkparams.AArch64.HaveS1TG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.HaveS1TG()
// ==================
// Determine whether the given translation granule is supported for stage 1

boolean <anchor link="AArch64.HaveS1TG.1" hover="function: boolean AArch64.HaveS1TG(TGx tgx)">AArch64.HaveS1TG</anchor>(<a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    case tgx of
        when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>  return boolean IMPLEMENTATION_DEFINED "Has 4K Translation Granule";
        when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a> return boolean IMPLEMENTATION_DEFINED "Has 16K Translation Granule";
        when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> return boolean IMPLEMENTATION_DEFINED "Has 64K Translation Granule";</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.HaveS2TG" mylink="aarch64.translation.vmsa_walkparams.AArch64.HaveS2TG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.HaveS2TG()
// ==================
// Determine whether the given translation granule is supported for stage 2

boolean <anchor link="AArch64.HaveS2TG.1" hover="function: boolean AArch64.HaveS2TG(TGx tgx)">AArch64.HaveS2TG</anchor>(<a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);

    if <a link="impl-shared.HaveGTGExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveGTGExt()">HaveGTGExt</a>() then
        case tgx of
            when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>
                return boolean IMPLEMENTATION_DEFINED "Has Stage 2 4K Translation Granule";
            when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>
                return boolean IMPLEMENTATION_DEFINED "Has Stage 2 16K Translation Granule";
            when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>
                return boolean IMPLEMENTATION_DEFINED "Has Stage 2 64K Translation Granule";
    else
        return <a link="AArch64.HaveS1TG.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveS1TG(TGx tgx)">AArch64.HaveS1TG</a>(tgx);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.MaxTxSZ" mylink="aarch64.translation.vmsa_walkparams.AArch64.MaxTxSZ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.MaxTxSZ()
// =================
// Retrieve the maximum value of TxSZ indicating minimum input address size for both
// stages of translation

integer <anchor link="AArch64.MaxTxSZ.1" hover="function: integer AArch64.MaxTxSZ(TGx tgx)">AArch64.MaxTxSZ</anchor>(<a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    if <a link="impl-shared.HaveSmallTranslationTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSmallTranslationTableExt()">HaveSmallTranslationTableExt</a>() then
        case tgx of
            when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>   return 48;
            when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>  return 48;
            when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>  return 47;

    return 39;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.NSS2TTWParams" mylink="aarch64.translation.vmsa_walkparams.AArch64.NSS2TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.NSS2TTWParams()
// =======================
// Gather walk parameters specific for Non-secure stage 2 translation

S2TTWParams AArch64.NSS2TTWParams(boolean s1aarch64)
    S2TTWParams walkparams;

    walkparams.vm   = HCR_EL2.VM OR HCR_EL2.DC;
    walkparams.tgx  = <a link="AArch64.S2DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S2DecodeTG0(bits(2) tg0_in)">AArch64.S2DecodeTG0</a>(VTCR_EL2.TG0);
    walkparams.txsz = VTCR_EL2.T0SZ;
    walkparams.ps   = VTCR_EL2.PS;
    walkparams.irgn = VTCR_EL2.IRGN0;
    walkparams.orgn = VTCR_EL2.ORGN0;
    walkparams.sh   = VTCR_EL2.SH0;
    walkparams.ee   = SCTLR_EL2.EE;
    walkparams.d128 = if <a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() then VTCR_EL2.D128 else '0';
    if walkparams.d128 == '1' then
        walkparams.skl = VTTBR_EL2.SKL;
    else
        walkparams.sl0 = VTCR_EL2.SL0;

    walkparams.ptw = if HCR_EL2.TGE == '0'         then HCR_EL2.PTW else '0';
    walkparams.fwb = if <a link="impl-shared.HaveStage2MemAttrControl.0" file="shared_pseudocode.xml" hover="function: boolean HaveStage2MemAttrControl()">HaveStage2MemAttrControl</a>() then HCR_EL2.FWB else '0';
    walkparams.ha  = if <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>()  then VTCR_EL2.HA else '0';
    walkparams.hd  = if <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>()  then VTCR_EL2.HD else '0';
    if walkparams.tgx IN {<a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>, <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>} &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.ds = VTCR_EL2.DS;
    else
        walkparams.ds = '0';
    if walkparams.tgx == <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a> &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.sl2 = VTCR_EL2.SL2 AND VTCR_EL2.DS;
    else
        walkparams.sl2 = '0';
    walkparams.cmow = if <a link="impl-shared.HaveFeatCMOW.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatCMOW()">HaveFeatCMOW</a>() &amp;&amp; <a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() then HCRX_EL2.CMOW else '0';
    if walkparams.d128 == '1' then
        walkparams.s2pie = '1';
    else
        walkparams.s2pie = if <a link="impl-shared.HaveS2PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS2PIExt()">HaveS2PIExt</a>() then VTCR_EL2.S2PIE else '0';
    walkparams.s2pir = if <a link="impl-shared.HaveS2PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS2PIExt()">HaveS2PIExt</a>() then S2PIR_EL2 else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() &amp;&amp; walkparams.d128 != '1' then
        walkparams.assuredonly = VTCR_EL2.AssuredOnly;
    else
        walkparams.assuredonly = '0';
    walkparams.tl0   = if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() then VTCR_EL2.TL0 else '0';
    walkparams.tl1   = if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() then VTCR_EL2.TL1 else '0';
    if <a link="impl-shared.HaveAccessFlagUpdateForTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</a>() &amp;&amp; walkparams.ha == '1' then
        walkparams.haft = VTCR_EL2.HAFT;
    else
        walkparams.haft = '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.PAMax" mylink="aarch64.translation.vmsa_walkparams.AArch64.PAMax" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PAMax()
// ===============
// Returns the IMPLEMENTATION DEFINED maximum number of bits capable of representing
// physical address for this processor

integer <anchor link="AArch64.PAMax.0" hover="function: integer AArch64.PAMax()">AArch64.PAMax</anchor>()
    return integer IMPLEMENTATION_DEFINED "Maximum Physical Address Size";</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.RLS2TTWParams" mylink="aarch64.translation.vmsa_walkparams.AArch64.RLS2TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.RLS2TTWParams()
// =======================
// Gather walk parameters specific for Realm stage 2 translation

S2TTWParams AArch64.RLS2TTWParams(boolean s1aarch64)
    // Realm stage 2 walk parameters are similar to Non-secure
    S2TTWParams walkparams = AArch64.NSS2TTWParams(s1aarch64);
    walkparams.emec = if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() &amp;&amp; <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then SCTLR2_EL2.EMEC else '0';
    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1DCacheEnabled" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1DCacheEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1DCacheEnabled()
// =========================
// Determine cacheability of stage 1 data accesses

boolean <anchor link="AArch64.S1DCacheEnabled.1" hover="function: boolean AArch64.S1DCacheEnabled(Regime regime)">AArch64.S1DCacheEnabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return SCTLR_EL3.C == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return SCTLR_EL2.C == '1';
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return SCTLR_EL2.C == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return SCTLR_EL1.C == '1';</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1DecodeTG0" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1DecodeTG0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1DecodeTG0()
// =====================
// Decode stage 1 granule size configuration bits TG0

TGx <anchor link="AArch64.S1DecodeTG0.1" hover="function: TGx AArch64.S1DecodeTG0(bits(2) tg0_in)">AArch64.S1DecodeTG0</anchor>(bits(2) tg0_in)
    bits(2) tg0 = tg0_in;
    <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx;

    if tg0 == '11' then
        tg0 = bits(2) IMPLEMENTATION_DEFINED "TG0 encoded granule size";

    case tg0 of
        when '00'   tgx = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
        when '01'   tgx = <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;
        when '10'   tgx = <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;

    if !<a link="AArch64.HaveS1TG.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveS1TG(TGx tgx)">AArch64.HaveS1TG</a>(tgx) then
        case bits(2) IMPLEMENTATION_DEFINED "TG0 encoded granule size" of
            when '00'   tgx = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
            when '01'   tgx = <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;
            when '10'   tgx = <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;

    return tgx;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1DecodeTG1" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1DecodeTG1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1DecodeTG1()
// =====================
// Decode stage 1 granule size configuration bits TG1

TGx <anchor link="AArch64.S1DecodeTG1.1" hover="function: TGx AArch64.S1DecodeTG1(bits(2) tg1_in)">AArch64.S1DecodeTG1</anchor>(bits(2) tg1_in)
    bits(2) tg1 = tg1_in;
    <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx;

    if tg1 == '00' then
        tg1 = bits(2) IMPLEMENTATION_DEFINED "TG1 encoded granule size";

    case tg1 of
        when '10'   tgx = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
        when '11'   tgx = <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;
        when '01'   tgx = <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;

    if !<a link="AArch64.HaveS1TG.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveS1TG(TGx tgx)">AArch64.HaveS1TG</a>(tgx) then
        case bits(2) IMPLEMENTATION_DEFINED "TG1 encoded granule size" of
            when '10'   tgx = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
            when '11'   tgx = <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;
            when '01'   tgx = <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;

    return tgx;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1E0POEnabled" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1E0POEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1E0POEnabled()
// =======================
// Determine whether stage 1 unprivileged permission overlay is enabled

boolean <anchor link="AArch64.S1E0POEnabled.2" hover="function: boolean AArch64.S1E0POEnabled(Regime regime, bit nv1)">AArch64.S1E0POEnabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bit nv1)
    assert <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime);

    if !<a link="impl-shared.HaveS1POExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1POExt()">HaveS1POExt</a>() then
        return FALSE;

    case regime of
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() &amp;&amp; TCR2_EL2.E0POE == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() &amp;&amp; nv1 == '0' &amp;&amp; TCR2_EL1.E0POE == '1';</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1EPD" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1EPD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1EPD()
// ===============
// Determine whether stage 1 translation table walk is allowed for the VA range

bit <anchor link="AArch64.S1EPD.2" hover="function: bit AArch64.S1EPD(Regime regime, bits(64) va)">AArch64.S1EPD</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(64) va)
    assert <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime);
    varange = <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va);

    case regime of
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then TCR_EL2.EPD0 else TCR_EL2.EPD1;
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then TCR_EL1.EPD0 else TCR_EL1.EPD1;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1Enabled" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1Enabled()
// ===================
// Determine if stage 1 is enabled for the access type for this translation regime

boolean <anchor link="AArch64.S1Enabled.2" hover="function: boolean AArch64.S1Enabled(Regime regime, AccessType acctype)">AArch64.S1Enabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, <a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype)
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return SCTLR_EL3.M == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return SCTLR_EL2.M == '1';
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return SCTLR_EL2.M == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return (!<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() || HCR_EL2.&lt;DC,TGE&gt; == '00') &amp;&amp; SCTLR_EL1.M == '1';</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1ICacheEnabled" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1ICacheEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1ICacheEnabled()
// =========================
// Determine cacheability of stage 1 instruction fetches

boolean <anchor link="AArch64.S1ICacheEnabled.1" hover="function: boolean AArch64.S1ICacheEnabled(Regime regime)">AArch64.S1ICacheEnabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return SCTLR_EL3.I == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return SCTLR_EL2.I == '1';
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return SCTLR_EL2.I == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return SCTLR_EL1.I == '1';</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1MinTxSZ" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1MinTxSZ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1MinTxSZ()
// ===================
// Retrieve the minimum value of TxSZ indicating maximum input address size for stage 1

integer <anchor link="AArch64.S1MinTxSZ.4" hover="function: integer AArch64.S1MinTxSZ(Regime regime, bit d128, bit ds, TGx tgx)">AArch64.S1MinTxSZ</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bit d128, bit ds, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    if <a link="impl-shared.Have56BitVAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitVAExt()">Have56BitVAExt</a>() &amp;&amp; d128 == '1' then
        if <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(regime) then
            return 9;
        else
            return 8;
    if (<a link="impl-shared.Have52BitVAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitVAExt()">Have52BitVAExt</a>() &amp;&amp; tgx == <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>) || ds == '1' then
        return 12;

    return 16;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1POEnabled" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1POEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1POEnabled()
// =====================
// Determine whether stage 1 privileged permission overlay is enabled

boolean <anchor link="AArch64.S1POEnabled.1" hover="function: boolean AArch64.S1POEnabled(Regime regime)">AArch64.S1POEnabled</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    if !<a link="impl-shared.HaveS1POExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1POExt()">HaveS1POExt</a>() then
        return FALSE;

    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return TCR_EL3.POE == '1';
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() &amp;&amp; TCR2_EL2.POE == '1';
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() &amp;&amp; TCR2_EL2.POE == '1';
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() &amp;&amp; TCR2_EL1.POE == '1';</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1POR" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1POR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1POR()
// ===============
// Identify stage 1 permissions overlay register for the acting translation regime

S1PORType AArch64.S1POR(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return POR_EL3;
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return POR_EL2;
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return POR_EL2;
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return POR_EL1;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1TTB" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1TTB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1TTB()
// ===============
// Identify stage 1 table base register's BADDR for the acting translation regime

bits(64) <anchor link="AArch64.S1TTB.2" hover="function: bits(64) AArch64.S1TTB(Regime regime, bits(64) va)">AArch64.S1TTB</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime, bits(64) va)
    varange = <a link="AArch64.GetVARange.1" file="shared_pseudocode.xml" hover="function: VARange AArch64.GetVARange(bits(64) va)">AArch64.GetVARange</a>(va);

    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR0_EL3.BADDR, 64);
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR0_EL2.BADDR, 64);
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>
            if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR0_EL2.BADDR, 64);
            else
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR1_EL2.BADDR, 64);
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>
            if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR0_EL1.BADDR, 64);
            else
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR1_EL1.BADDR, 64);</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1TTWParamsEL10" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1TTWParamsEL10" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1TTWParamsEL10()
// =========================
// Gather stage 1 translation table walk parameters for EL1&amp;0 regime
// (with EL2 enabled or disabled)

S1TTWParams AArch64.S1TTWParamsEL10(<a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange)
    S1TTWParams walkparams;

    if <a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() then
        walkparams.d128 = TCR2_EL1.D128;
    else
        walkparams.d128 = '0';
    if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
        walkparams.tgx   = <a link="AArch64.S1DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S1DecodeTG0(bits(2) tg0_in)">AArch64.S1DecodeTG0</a>(TCR_EL1.TG0);
        walkparams.txsz  = TCR_EL1.T0SZ;
        walkparams.irgn  = TCR_EL1.IRGN0;
        walkparams.orgn  = TCR_EL1.ORGN0;
        walkparams.sh    = TCR_EL1.SH0;
        walkparams.tbi   = TCR_EL1.TBI0;

        walkparams.nfd   = if <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() || <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then TCR_EL1.NFD0  else '0';
        walkparams.tbid  = if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>()           then TCR_EL1.TBID0 else '0';
        walkparams.e0pd  = if <a link="impl-shared.HaveE0PDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveE0PDExt()">HaveE0PDExt</a>()          then TCR_EL1.E0PD0 else '0';
        walkparams.hpd   = if <a link="AArch64.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</a>()   then TCR_EL1.HPD0  else '0';
        walkparams.mtx   = if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>() then TCR_EL1.MTX0 else '0';
        walkparams.skl   = if walkparams.d128 == '1' then TTBR0_EL1.SKL else '00';
        walkparams.disch = if walkparams.d128 == '1' then TCR2_EL1.DisCH0 else '0';
    else
        walkparams.tgx   = <a link="AArch64.S1DecodeTG1.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S1DecodeTG1(bits(2) tg1_in)">AArch64.S1DecodeTG1</a>(TCR_EL1.TG1);
        walkparams.txsz  = TCR_EL1.T1SZ;
        walkparams.irgn  = TCR_EL1.IRGN1;
        walkparams.orgn  = TCR_EL1.ORGN1;
        walkparams.sh    = TCR_EL1.SH1;
        walkparams.tbi   = TCR_EL1.TBI1;

        walkparams.nfd   = if <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() || <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then TCR_EL1.NFD1  else '0';
        walkparams.tbid  = if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>()           then TCR_EL1.TBID1 else '0';
        walkparams.e0pd  = if <a link="impl-shared.HaveE0PDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveE0PDExt()">HaveE0PDExt</a>()          then TCR_EL1.E0PD1 else '0';
        walkparams.hpd   = if <a link="AArch64.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</a>()   then TCR_EL1.HPD1  else '0';
        walkparams.mtx   = if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>()          then TCR_EL1.MTX1 else '0';
        walkparams.skl   = if walkparams.d128 == '1' then TTBR1_EL1.SKL else '00';
        walkparams.disch = if walkparams.d128 == '1' then TCR2_EL1.DisCH1 else '0';

    walkparams.mair = MAIR_EL1;
    if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() then
        walkparams.mair2 = MAIR2_EL1;
    walkparams.aie  = if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() then TCR2_EL1.AIE else '0';
    walkparams.wxn  = SCTLR_EL1.WXN;
    walkparams.ps   = TCR_EL1.IPS;
    walkparams.ee   = SCTLR_EL1.EE;
    if (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; (!<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() || <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>())) then
        walkparams.sif = SCR_EL3.SIF;
    else
        walkparams.sif = '0';

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        walkparams.dc  = HCR_EL2.DC;
        walkparams.dct = if <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then HCR_EL2.DCT else '0';

    if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then
        walkparams.ntlsmd = SCTLR_EL1.nTLSMD;
    else
        walkparams.ntlsmd = '1';

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        if HCR_EL2.&lt;NV,NV1&gt; == '01' then
            case <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_NVNV1" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_NVNV1</a>) of
                when <a link="Constraint_NVNV1_00" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NVNV1_00</a> walkparams.nv1 = '0';
                when <a link="Constraint_NVNV1_01" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NVNV1_01</a> walkparams.nv1 = '1';
                when <a link="Constraint_NVNV1_11" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NVNV1_11</a> walkparams.nv1 = '1';
        else
            walkparams.nv1 = HCR_EL2.NV1;
    else
        walkparams.nv1 = '0';

    walkparams.cmow = if <a link="impl-shared.HaveFeatCMOW.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatCMOW()">HaveFeatCMOW</a>()            then SCTLR_EL1.CMOW else '0';
    walkparams.ha   = if <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>() then TCR_EL1.HA else '0';
    walkparams.hd   = if <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>() then TCR_EL1.HD else '0';
    if walkparams.tgx IN {<a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>, <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>} &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.ds = TCR_EL1.DS;
    else
        walkparams.ds = '0';
    if walkparams.d128 == '1' then
        walkparams.pie = '1';
    else
        walkparams.pie = if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() then TCR2_EL1.PIE else '0';
    if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() then
        walkparams.pir = PIR_EL1;
        if walkparams.nv1 != '1'then
            walkparams.pire0 = PIRE0_EL1;
    if <a link="impl-shared.HavePAN3Ext.0" file="shared_pseudocode.xml" hover="function: boolean HavePAN3Ext()">HavePAN3Ext</a>() then
        walkparams.epan = if walkparams.pie == '0' then SCTLR_EL1.EPAN else '1';
    else
        walkparams.epan = '0';
    if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() &amp;&amp; walkparams.d128 == '0' &amp;&amp; <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() then
        walkparams.pnch = TCR2_EL1.PnCH;
    else
        walkparams.pnch = '0';
    if <a link="impl-shared.HaveAccessFlagUpdateForTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</a>() &amp;&amp; walkparams.ha == '1' &amp;&amp; <a link="impl-aarch64.IsTCR2EL1Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL1Enabled()">IsTCR2EL1Enabled</a>() then
        walkparams.haft = TCR2_EL1.HAFT;
    else
        walkparams.haft = '0';
    walkparams.emec = if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() &amp;&amp; <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then SCTLR2_EL2.EMEC else '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1TTWParamsEL2" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1TTWParamsEL2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1TTWParamsEL2()
// ========================
// Gather stage 1 translation table walk parameters for EL2 regime

S1TTWParams AArch64.S1TTWParamsEL2(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    S1TTWParams walkparams;

    walkparams.tgx  = <a link="AArch64.S1DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S1DecodeTG0(bits(2) tg0_in)">AArch64.S1DecodeTG0</a>(TCR_EL2.TG0);
    walkparams.txsz = TCR_EL2.T0SZ;
    walkparams.ps   = TCR_EL2.PS;
    walkparams.irgn = TCR_EL2.IRGN0;
    walkparams.orgn = TCR_EL2.ORGN0;
    walkparams.sh   = TCR_EL2.SH0;
    walkparams.tbi  = TCR_EL2.TBI;
    walkparams.mair = MAIR_EL2;
    if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() then
        walkparams.mair2 = MAIR2_EL2;
    walkparams.aie  = if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then TCR2_EL2.AIE else '0';
    walkparams.wxn  = SCTLR_EL2.WXN;
    walkparams.ee   = SCTLR_EL2.EE;
    if (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; (!<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() || <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>())) then
        walkparams.sif = SCR_EL3.SIF;
    else
        walkparams.sif = '0';

    walkparams.tbid = if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>()              then TCR_EL2.TBID else '0';
    walkparams.hpd  = if <a link="AArch64.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</a>()      then TCR_EL2.HPD  else '0';
    walkparams.ha   = if <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>() then TCR_EL2.HA   else '0';
    walkparams.hd   = if <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>() then TCR_EL2.HD   else '0';
    if walkparams.tgx IN {<a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>, <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>} &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.ds = TCR_EL2.DS;
    else
        walkparams.ds = '0';
    walkparams.pie = if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then TCR2_EL2.PIE else '0';
    if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() then
        walkparams.pir = PIR_EL2;
    walkparams.mtx  = if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>()             then TCR_EL2.MTX else '0';
    walkparams.pnch = if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then TCR2_EL2.PnCH else '0';
    if <a link="impl-shared.HaveAccessFlagUpdateForTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</a>() &amp;&amp; walkparams.ha == '1' &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then
        walkparams.haft = TCR2_EL2.HAFT;
    else
        walkparams.haft = '0';
    walkparams.emec = if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() &amp;&amp; <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then SCTLR2_EL2.EMEC else '0';
    if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() &amp;&amp; ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then
        walkparams.amec = TCR2_EL2.AMEC0;
    else
        walkparams.amec = '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1TTWParamsEL20" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1TTWParamsEL20" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1TTWParamsEL20()
// =========================
// Gather stage 1 translation table walk parameters for EL2&amp;0 regime

S1TTWParams AArch64.S1TTWParamsEL20(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange)
    S1TTWParams walkparams;

    if <a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then
        walkparams.d128 = TCR2_EL2.D128;
    else
        walkparams.d128 = '0';
    if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then
        walkparams.tgx   = <a link="AArch64.S1DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S1DecodeTG0(bits(2) tg0_in)">AArch64.S1DecodeTG0</a>(TCR_EL2.TG0);
        walkparams.txsz  = TCR_EL2.T0SZ;
        walkparams.irgn  = TCR_EL2.IRGN0;
        walkparams.orgn  = TCR_EL2.ORGN0;
        walkparams.sh    = TCR_EL2.SH0;
        walkparams.tbi   = TCR_EL2.TBI0;

        walkparams.nfd   = if <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() || <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then TCR_EL2.NFD0  else '0';
        walkparams.tbid  = if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>()           then TCR_EL2.TBID0 else '0';
        walkparams.e0pd  = if <a link="impl-shared.HaveE0PDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveE0PDExt()">HaveE0PDExt</a>()          then TCR_EL2.E0PD0 else '0';
        walkparams.hpd   = if <a link="AArch64.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</a>()   then TCR_EL2.HPD0  else '0';
        walkparams.mtx   = if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>()          then TCR_EL2.MTX0 else '0';
        walkparams.skl   = if walkparams.d128 == '1' then TTBR0_EL2.SKL else '00';
        walkparams.disch = if walkparams.d128 == '1' then TCR2_EL2.DisCH0 else '0';
    else
        walkparams.tgx   = <a link="AArch64.S1DecodeTG1.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S1DecodeTG1(bits(2) tg1_in)">AArch64.S1DecodeTG1</a>(TCR_EL2.TG1);
        walkparams.txsz  = TCR_EL2.T1SZ;
        walkparams.irgn  = TCR_EL2.IRGN1;
        walkparams.orgn  = TCR_EL2.ORGN1;
        walkparams.sh    = TCR_EL2.SH1;
        walkparams.tbi   = TCR_EL2.TBI1;

        walkparams.nfd   = if <a link="impl-aarch64.HaveSVE.0" file="shared_pseudocode.xml" hover="function: boolean HaveSVE()">HaveSVE</a>() || <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() then TCR_EL2.NFD1  else '0';
        walkparams.tbid  = if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>()           then TCR_EL2.TBID1 else '0';
        walkparams.e0pd  = if <a link="impl-shared.HaveE0PDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveE0PDExt()">HaveE0PDExt</a>()          then TCR_EL2.E0PD1 else '0';
        walkparams.hpd   = if <a link="AArch64.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</a>()   then TCR_EL2.HPD1  else '0';
        walkparams.mtx   = if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>()          then TCR_EL2.MTX1 else '0';
        walkparams.skl   = if walkparams.d128 == '1' then TTBR1_EL2.SKL else '00';
        walkparams.disch = if walkparams.d128 == '1' then TCR2_EL2.DisCH1 else '0';
    walkparams.mair = MAIR_EL2;
    if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() then
        walkparams.mair2 = MAIR2_EL2;
    walkparams.aie  = if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then TCR2_EL2.AIE else '0';
    walkparams.wxn  = SCTLR_EL2.WXN;
    walkparams.ps   = TCR_EL2.IPS;
    walkparams.ee   = SCTLR_EL2.EE;
    if (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; (!<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() || <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>())) then
        walkparams.sif = SCR_EL3.SIF;
    else
        walkparams.sif = '0';

    if <a link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</a>() then
        walkparams.ntlsmd = SCTLR_EL2.nTLSMD;
    else
        walkparams.ntlsmd = '1';

    walkparams.cmow = if <a link="impl-shared.HaveFeatCMOW.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatCMOW()">HaveFeatCMOW</a>()            then SCTLR_EL2.CMOW else '0';
    walkparams.ha   = if <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>() then TCR_EL2.HA else '0';
    walkparams.hd   = if <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>() then TCR_EL2.HD else '0';
    if walkparams.tgx IN {<a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>, <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>} &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.ds = TCR_EL2.DS;
    else
        walkparams.ds = '0';
    if walkparams.d128 == '1' then
        walkparams.pie = '1';
    else
        walkparams.pie = if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then TCR2_EL2.PIE else '0';
    if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() then
        walkparams.pir   = PIR_EL2;
        walkparams.pire0 = PIRE0_EL2;
    if <a link="impl-shared.HavePAN3Ext.0" file="shared_pseudocode.xml" hover="function: boolean HavePAN3Ext()">HavePAN3Ext</a>() then
        walkparams.epan = if walkparams.pie == '0' then SCTLR_EL2.EPAN else '1';
    else
        walkparams.epan = '0';
    if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() &amp;&amp; walkparams.d128 == '0' &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then
        walkparams.pnch = TCR2_EL2.PnCH;
    else
        walkparams.pnch = '0';
    if <a link="impl-shared.HaveAccessFlagUpdateForTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</a>() &amp;&amp; walkparams.ha == '1' &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then
        walkparams.haft = TCR2_EL2.HAFT;
    else
        walkparams.haft = '0';
    walkparams.emec = if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() &amp;&amp; <a link="impl-aarch64.IsSCTLR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSCTLR2EL2Enabled()">IsSCTLR2EL2Enabled</a>() then SCTLR2_EL2.EMEC else '0';
    if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() &amp;&amp; ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> &amp;&amp; <a link="impl-aarch64.IsTCR2EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsTCR2EL2Enabled()">IsTCR2EL2Enabled</a>() then
        walkparams.amec = if varange == <a link="VARange_LOWER" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</a> then TCR2_EL2.AMEC0 else TCR2_EL2.AMEC1;
    else
        walkparams.amec = '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S1TTWParamsEL3" mylink="aarch64.translation.vmsa_walkparams.AArch64.S1TTWParamsEL3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S1TTWParamsEL3()
// ========================
// Gather stage 1 translation table walk parameters for EL3 regime

S1TTWParams AArch64.S1TTWParamsEL3()
    S1TTWParams walkparams;

    walkparams.tgx  = <a link="AArch64.S1DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S1DecodeTG0(bits(2) tg0_in)">AArch64.S1DecodeTG0</a>(TCR_EL3.TG0);
    walkparams.txsz = TCR_EL3.T0SZ;
    walkparams.ps   = TCR_EL3.PS;
    walkparams.irgn = TCR_EL3.IRGN0;
    walkparams.orgn = TCR_EL3.ORGN0;
    walkparams.sh   = TCR_EL3.SH0;
    walkparams.tbi  = TCR_EL3.TBI;
    walkparams.mair = MAIR_EL3;
    if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() then
        walkparams.mair2 = MAIR2_EL3;
    walkparams.aie  = if <a link="impl-shared.HaveAIEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAIEExt()">HaveAIEExt</a>() then TCR_EL3.AIE else '0';
    walkparams.wxn  = SCTLR_EL3.WXN;
    walkparams.ee   = SCTLR_EL3.EE;
    walkparams.sif = if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() || <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then SCR_EL3.SIF else '0';

    walkparams.tbid = if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>()              then TCR_EL3.TBID else '0';
    walkparams.hpd  = if <a link="AArch64.HaveHPDExt.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</a>()      then TCR_EL3.HPD  else '0';
    walkparams.ha   = if <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>() then TCR_EL3.HA   else '0';
    walkparams.hd   = if <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>() then TCR_EL3.HD   else '0';
    if walkparams.tgx IN {<a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>, <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>} &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.ds = TCR_EL3.DS;
    else
        walkparams.ds = '0';
    walkparams.d128  = if <a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() then TCR_EL3.D128 else '0';
    walkparams.skl   = if walkparams.d128 == '1' then TTBR0_EL3.SKL else '00';
    walkparams.disch = if walkparams.d128 == '1' then TCR_EL3.DisCH0 else '0';
    if walkparams.d128 == '1' then
        walkparams.pie = '1';
    else
        walkparams.pie = if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() then TCR_EL3.PIE else '0';
    if <a link="impl-shared.HaveS1PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</a>() then
        walkparams.pir = PIR_EL3;
    walkparams.mtx  = if <a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>()             then TCR_EL3.MTX else '0';
    if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() &amp;&amp; walkparams.d128 == '0' then
        walkparams.pnch = TCR_EL3.PnCH;
    else
        walkparams.pnch = '0';
    if <a link="impl-shared.HaveAccessFlagUpdateForTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</a>() &amp;&amp; walkparams.ha == '1' then
        walkparams.haft = TCR_EL3.HAFT;
    else
        walkparams.haft = '0';
    walkparams.emec = if <a link="impl-shared.HaveFeatMEC.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</a>() then SCTLR2_EL3.EMEC else '0';

    return walkparams;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S2DecodeTG0" mylink="aarch64.translation.vmsa_walkparams.AArch64.S2DecodeTG0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2DecodeTG0()
// =====================
// Decode stage 2 granule size configuration bits TG0

TGx <anchor link="AArch64.S2DecodeTG0.1" hover="function: TGx AArch64.S2DecodeTG0(bits(2) tg0_in)">AArch64.S2DecodeTG0</anchor>(bits(2) tg0_in)
    bits(2) tg0 = tg0_in;
    <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx;

    if tg0 == '11' then
        tg0 = bits(2) IMPLEMENTATION_DEFINED "TG0 encoded granule size";

    case tg0 of
        when '00'   tgx = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
        when '01'   tgx = <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;
        when '10'   tgx = <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;

    if !<a link="AArch64.HaveS2TG.1" file="shared_pseudocode.xml" hover="function: boolean AArch64.HaveS2TG(TGx tgx)">AArch64.HaveS2TG</a>(tgx) then
        case bits(2) IMPLEMENTATION_DEFINED "TG0 encoded granule size" of
            when '00'   tgx = <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>;
            when '01'   tgx = <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>;
            when '10'   tgx = <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>;

    return tgx;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.S2MinTxSZ" mylink="aarch64.translation.vmsa_walkparams.AArch64.S2MinTxSZ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.S2MinTxSZ()
// ===================
// Retrieve the minimum value of TxSZ indicating maximum input address size for stage 2

integer <anchor link="AArch64.S2MinTxSZ.4" hover="function: integer AArch64.S2MinTxSZ(bit d128, bit ds, TGx tgx, boolean s1aarch64)">AArch64.S2MinTxSZ</anchor>(bit d128, bit ds, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, boolean s1aarch64)
    ips = <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>();

    if d128 == '0' then
        if <a link="impl-shared.Have52BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</a>() &amp;&amp; tgx != <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> &amp;&amp; ds == '0' then
            ips = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(48, <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>());
        else
            ips = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(52, <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>());
    min_txsz = 64 - ips;
    if !s1aarch64 then
        // EL1 is AArch32
        min_txsz = <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(min_txsz, 24);

    return min_txsz;</pstext>
    </ps>
    <ps name="aarch64/translation/vmsa_walkparams/AArch64.SS2TTWParams" mylink="aarch64.translation.vmsa_walkparams.AArch64.SS2TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.SS2TTWParams()
// ======================
// Gather walk parameters specific for secure stage 2 translation

S2TTWParams AArch64.SS2TTWParams(<a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> ipaspace, boolean s1aarch64)
    S2TTWParams walkparams;

    walkparams.d128 = if <a link="impl-shared.Have128BitDescriptorExt.0" file="shared_pseudocode.xml" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</a>() then VTCR_EL2.D128 else '0';
    if ipaspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a> then
        walkparams.tgx  = <a link="AArch64.S2DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S2DecodeTG0(bits(2) tg0_in)">AArch64.S2DecodeTG0</a>(VSTCR_EL2.TG0);
        walkparams.txsz = VSTCR_EL2.T0SZ;
        if walkparams.d128 == '1' then
            walkparams.skl = VSTTBR_EL2.SKL;
        else
            walkparams.sl0 = VSTCR_EL2.SL0;
        if walkparams.tgx == <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a> &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
            walkparams.sl2 = VSTCR_EL2.SL2 AND VTCR_EL2.DS;
        else
            walkparams.sl2 = '0';
    elsif ipaspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
        walkparams.tgx  = <a link="AArch64.S2DecodeTG0.1" file="shared_pseudocode.xml" hover="function: TGx AArch64.S2DecodeTG0(bits(2) tg0_in)">AArch64.S2DecodeTG0</a>(VTCR_EL2.TG0);
        walkparams.txsz = VTCR_EL2.T0SZ;
        if walkparams.d128 == '1' then
            walkparams.skl = VTTBR_EL2.SKL;
        else
            walkparams.sl0 = VTCR_EL2.SL0;
        if walkparams.tgx == <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a> &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
            walkparams.sl2 = VTCR_EL2.SL2 AND VTCR_EL2.DS;
        else
            walkparams.sl2 = '0';
    else
        <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    walkparams.sw   = VSTCR_EL2.SW;
    walkparams.nsw  = VTCR_EL2.NSW;
    walkparams.sa   = VSTCR_EL2.SA;
    walkparams.nsa  = VTCR_EL2.NSA;
    walkparams.vm   = HCR_EL2.VM OR HCR_EL2.DC;
    walkparams.ps   = VTCR_EL2.PS;
    walkparams.irgn = VTCR_EL2.IRGN0;
    walkparams.orgn = VTCR_EL2.ORGN0;
    walkparams.sh   = VTCR_EL2.SH0;
    walkparams.ee   = SCTLR_EL2.EE;

    walkparams.ptw = if HCR_EL2.TGE == '0'         then HCR_EL2.PTW else '0';
    walkparams.fwb = if <a link="impl-shared.HaveStage2MemAttrControl.0" file="shared_pseudocode.xml" hover="function: boolean HaveStage2MemAttrControl()">HaveStage2MemAttrControl</a>() then HCR_EL2.FWB else '0';
    walkparams.ha  = if <a link="impl-shared.HaveAccessFlagUpdateExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</a>()  then VTCR_EL2.HA else '0';
    walkparams.hd  = if <a link="impl-shared.HaveDirtyBitModifierExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</a>()  then VTCR_EL2.HD else '0';
    if walkparams.tgx IN {<a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>, <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>} &amp;&amp; <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>() then
        walkparams.ds = VTCR_EL2.DS;
    else
        walkparams.ds = '0';
    walkparams.cmow = if <a link="impl-shared.HaveFeatCMOW.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatCMOW()">HaveFeatCMOW</a>() &amp;&amp; <a link="impl-aarch64.IsHCRXEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsHCRXEL2Enabled()">IsHCRXEL2Enabled</a>() then HCRX_EL2.CMOW else '0';
    if walkparams.d128 == '1' then
        walkparams.s2pie = '1';
    else
        walkparams.s2pie = if <a link="impl-shared.HaveS2PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS2PIExt()">HaveS2PIExt</a>() then VTCR_EL2.S2PIE else '0';
    walkparams.s2pir = if <a link="impl-shared.HaveS2PIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveS2PIExt()">HaveS2PIExt</a>() then S2PIR_EL2 else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() &amp;&amp; walkparams.d128 != '1' then
        walkparams.assuredonly = VTCR_EL2.AssuredOnly;
    else
        walkparams.assuredonly = '0';
    walkparams.tl0   = if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() then VTCR_EL2.TL0 else '0';
    walkparams.tl1   = if <a link="impl-shared.HaveTHExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTHExt()">HaveTHExt</a>() then VTCR_EL2.TL1 else '0';
    if <a link="impl-shared.HaveAccessFlagUpdateForTableExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</a>() &amp;&amp; walkparams.ha == '1' then
        walkparams.haft = VTCR_EL2.HAFT;
    else
        walkparams.haft = '0';
    walkparams.emec = '0';

    return walkparams;</pstext>
    </ps>
    <ps name="shared/debug/ClearStickyErrors/ClearStickyErrors" mylink="shared.debug.ClearStickyErrors.ClearStickyErrors" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearStickyErrors()
// ===================

<anchor link="impl-shared.ClearStickyErrors.0" hover="function: ClearStickyErrors()">ClearStickyErrors</anchor>()
    EDSCR.TXU = '0';            // Clear TX underrun flag
    EDSCR.RXO = '0';            // Clear RX overrun flag

    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then            // in Debug state
        EDSCR.ITO = '0';        // Clear ITR overrun flag

    // If halted and the ITR is not empty then it is UNPREDICTABLE whether the EDSCR.ERR is cleared.
    // The UNPREDICTABLE behavior also affects the instructions in flight, but this is not described
    // in the pseudocode.
    if (<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.ITE == '0' &amp;&amp;
          <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_CLEARERRITEZERO" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_CLEARERRITEZERO</a>)) then
        return;
    EDSCR.ERR = '0';            // Clear cumulative error flag

    return;</pstext>
    </ps>
    <ps name="shared/debug/DebugTarget/DebugTarget" mylink="shared.debug.DebugTarget.DebugTarget" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugTarget()
// =============
// Returns the debug exception target Exception level

bits(2) <anchor link="impl-shared.DebugTarget.0" hover="function: bits(2) DebugTarget()">DebugTarget</anchor>()
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    return <a link="impl-shared.DebugTargetFrom.1" file="shared_pseudocode.xml" hover="function: bits(2) DebugTargetFrom(SecurityState from_state)">DebugTargetFrom</a>(ss);</pstext>
    </ps>
    <ps name="shared/debug/DebugTarget/DebugTargetFrom" mylink="shared.debug.DebugTarget.DebugTargetFrom" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugTargetFrom()
// =================

bits(2) <anchor link="impl-shared.DebugTargetFrom.1" hover="function: bits(2) DebugTargetFrom(SecurityState from_state)">DebugTargetFrom</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> from_state)
    boolean route_to_el2;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (from_state != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> ||
        (<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || SCR_EL3.EEL2 == '1'))) then
        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            route_to_el2 = (HDCR.TDE == '1' || HCR.TGE == '1');
        else
            route_to_el2 = (MDCR_EL2.TDE == '1' || HCR_EL2.TGE == '1');
    else
        route_to_el2 = FALSE;

    bits(2) target;
    if route_to_el2 then
        target = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; from_state == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        target = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    else
        target = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

    return target;</pstext>
    </ps>
    <ps name="shared/debug/DoubleLockStatus/DoubleLockStatus" mylink="shared.debug.DoubleLockStatus.DoubleLockStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DoubleLockStatus()
// ==================
// Returns the state of the OS Double Lock.
//    FALSE if OSDLR_EL1.DLK == 0 or DBGPRCR_EL1.CORENPDRQ == 1 or the PE is in Debug state.
//    TRUE if OSDLR_EL1.DLK == 1 and DBGPRCR_EL1.CORENPDRQ == 0 and the PE is in Non-debug state.

boolean <anchor link="impl-shared.DoubleLockStatus.0" hover="function: boolean DoubleLockStatus()">DoubleLockStatus</anchor>()
    if !<a link="impl-shared.HaveDoubleLock.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleLock()">HaveDoubleLock</a>() then
        return FALSE;
    elsif <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        return DBGOSDLR.DLK == '1' &amp;&amp; DBGPRCR.CORENPDRQ == '0' &amp;&amp; !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();
    else
        return OSDLR_EL1.DLK == '1' &amp;&amp; DBGPRCR_EL1.CORENPDRQ == '0' &amp;&amp; !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();</pstext>
    </ps>
    <ps name="shared/debug/OSLockStatus/OSLockStatus" mylink="shared.debug.OSLockStatus.OSLockStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// OSLockStatus()
// ==============
// Returns the state of the OS Lock.

boolean <anchor link="impl-shared.OSLockStatus.0" hover="function: boolean OSLockStatus()">OSLockStatus</anchor>()
    return (if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then DBGOSLSR.OSLK else OSLSR_EL1.OSLK) == '1';</pstext>
    </ps>
    <ps name="shared/debug/SoftwareLockStatus/Component" mylink="shared.debug.SoftwareLockStatus.Component" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Component
// =========
// Component Types.

enumeration <anchor link="Component" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component</anchor> {
        <anchor link="Component_PMU" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_PMU</anchor>,
        <anchor link="Component_Debug" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_Debug</anchor>,
        <anchor link="Component_CTI" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_CTI</anchor>
};</pstext>
    </ps>
    <ps name="shared/debug/SoftwareLockStatus/GetAccessComponent" mylink="shared.debug.SoftwareLockStatus.GetAccessComponent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetAccessComponent()
// ====================
// Returns the accessed component.

Component <anchor link="impl-shared.GetAccessComponent.0" hover="function: Component GetAccessComponent()">GetAccessComponent</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/SoftwareLockStatus/SoftwareLockStatus" mylink="shared.debug.SoftwareLockStatus.SoftwareLockStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SoftwareLockStatus()
// ====================
// Returns the state of the Software Lock.

boolean <anchor link="impl-shared.SoftwareLockStatus.0" hover="function: boolean SoftwareLockStatus()">SoftwareLockStatus</anchor>()
    <a link="Component" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component</a> component = <a link="impl-shared.GetAccessComponent.0" file="shared_pseudocode.xml" hover="function: Component GetAccessComponent()">GetAccessComponent</a>();
    if !<a link="impl-shared.HaveSoftwareLock.1" file="shared_pseudocode.xml" hover="function: boolean HaveSoftwareLock(Component component)">HaveSoftwareLock</a>(component) then
        return FALSE;
    case component of
        when <a link="Component_Debug" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_Debug</a>
            return EDLSR.SLK == '1';
        when <a link="Component_PMU" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_PMU</a>
            return PMLSR.SLK == '1';
        when <a link="Component_CTI" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_CTI</a>
            return CTILSR.SLK == '1';
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/AccessState" mylink="shared.debug.authentication.AccessState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AccessState()
// =============
// Returns the Security state of the access.

SecurityState <anchor link="impl-shared.AccessState.0" hover="function: SecurityState AccessState()">AccessState</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/AllowExternalDebugAccess" mylink="shared.debug.authentication.AllowExternalDebugAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AllowExternalDebugAccess()
// ==========================
// Returns TRUE if an external debug interface access to the External debug registers
// is allowed, FALSE otherwise.

boolean <anchor link="impl-shared.AllowExternalDebugAccess.0" hover="function: boolean AllowExternalDebugAccess()">AllowExternalDebugAccess</anchor>()
    // The access may also be subject to OS Lock, power-down, etc.
    return <a link="impl-shared.AllowExternalDebugAccess.1" file="shared_pseudocode.xml" hover="function: boolean AllowExternalDebugAccess(SecurityState access_state)">AllowExternalDebugAccess</a>(<a link="impl-shared.AccessState.0" file="shared_pseudocode.xml" hover="function: SecurityState AccessState()">AccessState</a>());

// AllowExternalDebugAccess()
// ==========================
// Returns TRUE if an external debug interface access to the External debug registers
// is allowed for the given Security state, FALSE otherwise.

boolean <anchor link="impl-shared.AllowExternalDebugAccess.1" hover="function: boolean AllowExternalDebugAccess(SecurityState access_state)">AllowExternalDebugAccess</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> access_state)
    // The access may also be subject to OS Lock, power-down, etc.
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        case MDCR_EL3.&lt;EDADE,EDAD&gt; of
            when '00' return TRUE;
            when '01' return access_state IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>};
            when '10' return access_state IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>};
            when '11' return access_state == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>;

    if <a link="impl-shared.HaveSecureExtDebugView.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureExtDebugView()">HaveSecureExtDebugView</a>() then
        if access_state == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then return TRUE;
    else
        if !<a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>() then return FALSE;
        if <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>() then return TRUE;

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        EDAD_bit = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SDCR.EDAD else MDCR_EL3.EDAD;
        return EDAD_bit == '0';
    else
        return <a link="impl-shared.NonSecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean NonSecureOnlyImplementation()">NonSecureOnlyImplementation</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/AllowExternalPMUAccess" mylink="shared.debug.authentication.AllowExternalPMUAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AllowExternalPMUAccess()
// ========================
// Returns TRUE if an external debug interface access to the PMU registers is
// allowed, FALSE otherwise.

boolean <anchor link="impl-shared.AllowExternalPMUAccess.0" hover="function: boolean AllowExternalPMUAccess()">AllowExternalPMUAccess</anchor>()
    // The access may also be subject to OS Lock, power-down, etc.
    return <a link="impl-shared.AllowExternalPMUAccess.1" file="shared_pseudocode.xml" hover="function: boolean AllowExternalPMUAccess(SecurityState access_state)">AllowExternalPMUAccess</a>(<a link="impl-shared.AccessState.0" file="shared_pseudocode.xml" hover="function: SecurityState AccessState()">AccessState</a>());

// AllowExternalPMUAccess()
// ========================
// Returns TRUE if an external debug interface access to the PMU registers is
// allowed for the given Security state, FALSE otherwise.

boolean <anchor link="impl-shared.AllowExternalPMUAccess.1" hover="function: boolean AllowExternalPMUAccess(SecurityState access_state)">AllowExternalPMUAccess</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> access_state)
    // The access may also be subject to OS Lock, power-down, etc.
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        case MDCR_EL3.&lt;EPMADE,EPMAD&gt; of
            when '00' return TRUE;
            when '01' return access_state IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>};
            when '10' return access_state IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>};
            when '11' return access_state == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>;

    if <a link="impl-shared.HaveSecureExtDebugView.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureExtDebugView()">HaveSecureExtDebugView</a>() then
        if access_state == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then return TRUE;
    else
        if !<a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>() then return FALSE;
        if <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>() then return TRUE;

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        EPMAD_bit = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SDCR.EPMAD else MDCR_EL3.EPMAD;
        return EPMAD_bit == '0';
    else
        return <a link="impl-shared.NonSecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean NonSecureOnlyImplementation()">NonSecureOnlyImplementation</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/AllowExternalTraceAccess" mylink="shared.debug.authentication.AllowExternalTraceAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AllowExternalTraceAccess()
// ==========================
// Returns TRUE if an external Trace access to the Trace registers is allowed, FALSE otherwise.

boolean <anchor link="impl-shared.AllowExternalTraceAccess.0" hover="function: boolean AllowExternalTraceAccess()">AllowExternalTraceAccess</anchor>()
    if !<a link="impl-shared.HaveTraceBufferExtension.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceBufferExtension()">HaveTraceBufferExtension</a>() then
        return TRUE;
    else
        return <a link="impl-shared.AllowExternalTraceAccess.1" file="shared_pseudocode.xml" hover="function: boolean AllowExternalTraceAccess(SecurityState access_state)">AllowExternalTraceAccess</a>(<a link="impl-shared.AccessState.0" file="shared_pseudocode.xml" hover="function: SecurityState AccessState()">AccessState</a>());

// AllowExternalTraceAccess()
// ==========================
// Returns TRUE if an external Trace access to the Trace registers is allowed for the
// given Security state, FALSE otherwise.

boolean <anchor link="impl-shared.AllowExternalTraceAccess.1" hover="function: boolean AllowExternalTraceAccess(SecurityState access_state)">AllowExternalTraceAccess</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> access_state)
    // The access may also be subject to OS lock, power-down, etc.
    if !<a link="impl-shared.HaveTraceBufferExtension.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceBufferExtension()">HaveTraceBufferExtension</a>() then return TRUE;
    assert <a link="impl-shared.HaveSecureExtDebugView.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureExtDebugView()">HaveSecureExtDebugView</a>();
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        case MDCR_EL3.&lt;ETADE,ETAD&gt; of
            when '00' return TRUE;
            when '01' return access_state IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>};
            when '10' return access_state IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>};
            when '11' return access_state == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>;

    if access_state == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then return TRUE;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        // External Trace access is not supported for EL3 using AArch32
        assert !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        return MDCR_EL3.ETAD == '0';
    else
        return <a link="impl-shared.NonSecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean NonSecureOnlyImplementation()">NonSecureOnlyImplementation</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/Debug_authentication" mylink="shared.debug.authentication.Debug_authentication" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">signal DBGEN;
signal NIDEN;
signal SPIDEN;
signal SPNIDEN;
signal RLPIDEN;
signal RTPIDEN;</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalInvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalInvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalInvasiveDebugEnabled()
// ==============================
// The definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the DBGEN signal.

boolean <anchor link="impl-shared.ExternalInvasiveDebugEnabled.0" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</anchor>()
    return DBGEN == HIGH;</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalNoninvasiveDebugAllowed" mylink="shared.debug.authentication.ExternalNoninvasiveDebugAllowed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalNoninvasiveDebugAllowed()
// =================================
// Returns TRUE if Trace and PC Sample-based Profiling are allowed

boolean <anchor link="impl-shared.ExternalNoninvasiveDebugAllowed.0" hover="function: boolean ExternalNoninvasiveDebugAllowed()">ExternalNoninvasiveDebugAllowed</anchor>()
    return <a link="impl-shared.ExternalNoninvasiveDebugAllowed.1" file="shared_pseudocode.xml" hover="function: boolean ExternalNoninvasiveDebugAllowed(bits(2) el)">ExternalNoninvasiveDebugAllowed</a>(PSTATE.EL);

// ExternalNoninvasiveDebugAllowed()
// =================================

boolean <anchor link="impl-shared.ExternalNoninvasiveDebugAllowed.1" hover="function: boolean ExternalNoninvasiveDebugAllowed(bits(2) el)">ExternalNoninvasiveDebugAllowed</anchor>(bits(2) el)
    if !<a link="impl-shared.ExternalNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalNoninvasiveDebugEnabled()">ExternalNoninvasiveDebugEnabled</a>() then return FALSE;
    ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(el);

    if ((<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) &amp;&amp; el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp;
        ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; SDER.SUNIDEN == '1') then
        return TRUE;

    case ss of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> return TRUE;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    return <a link="impl-shared.ExternalSecureNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureNoninvasiveDebugEnabled()">ExternalSecureNoninvasiveDebugEnabled</a>();
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     return <a link="impl-shared.ExternalRealmNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRealmNoninvasiveDebugEnabled()">ExternalRealmNoninvasiveDebugEnabled</a>();
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      return <a link="impl-shared.ExternalRootNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRootNoninvasiveDebugEnabled()">ExternalRootNoninvasiveDebugEnabled</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalNoninvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalNoninvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalNoninvasiveDebugEnabled()
// =================================
// This function returns TRUE if the FEAT_Debugv8p4 is implemented.
// Otherwise, this function is IMPLEMENTATION DEFINED, and, in the
// recommended interface, ExternalNoninvasiveDebugEnabled returns
// the state of the (DBGEN OR NIDEN) signal.

boolean <anchor link="impl-shared.ExternalNoninvasiveDebugEnabled.0" hover="function: boolean ExternalNoninvasiveDebugEnabled()">ExternalNoninvasiveDebugEnabled</anchor>()
    return !<a link="impl-shared.HaveNoninvasiveDebugAuth.0" file="shared_pseudocode.xml" hover="function: boolean HaveNoninvasiveDebugAuth()">HaveNoninvasiveDebugAuth</a>() || <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>() || NIDEN == HIGH;</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalRealmInvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalRealmInvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalRealmInvasiveDebugEnabled()
// ===================================
// The definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the
// (DBGEN AND RLPIDEN) signal.

boolean <anchor link="impl-shared.ExternalRealmInvasiveDebugEnabled.0" hover="function: boolean ExternalRealmInvasiveDebugEnabled()">ExternalRealmInvasiveDebugEnabled</anchor>()
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then return FALSE;
    return <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>() &amp;&amp; RLPIDEN == HIGH;</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalRealmNoninvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalRealmNoninvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalRealmNoninvasiveDebugEnabled()
// ======================================
// The definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the
// (DBGEN AND RLPIDEN) signal.

boolean <anchor link="impl-shared.ExternalRealmNoninvasiveDebugEnabled.0" hover="function: boolean ExternalRealmNoninvasiveDebugEnabled()">ExternalRealmNoninvasiveDebugEnabled</anchor>()
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then return FALSE;
    return <a link="impl-shared.ExternalRealmInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRealmInvasiveDebugEnabled()">ExternalRealmInvasiveDebugEnabled</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalRootInvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalRootInvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalRootInvasiveDebugEnabled()
// ==================================
// The definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the
// (DBGEN AND RLPIDEN AND RTPIDEN AND SPIDEN) signal when FEAT_SEL2 is implemented
// and the (DBGEN AND RLPIDEN AND RTPIDEN) signal when FEAT_SEL2 is not implemented.

boolean <anchor link="impl-shared.ExternalRootInvasiveDebugEnabled.0" hover="function: boolean ExternalRootInvasiveDebugEnabled()">ExternalRootInvasiveDebugEnabled</anchor>()
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then return FALSE;
    return (<a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>() &amp;&amp;
            (!<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() || <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>()) &amp;&amp;
            <a link="impl-shared.ExternalRealmInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRealmInvasiveDebugEnabled()">ExternalRealmInvasiveDebugEnabled</a>() &amp;&amp;
            RTPIDEN == HIGH);</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalRootNoninvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalRootNoninvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalRootNoninvasiveDebugEnabled()
// =====================================
// The definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the
// (DBGEN AND RLPIDEN AND SPIDEN AND RTPIDEN) signal.

boolean <anchor link="impl-shared.ExternalRootNoninvasiveDebugEnabled.0" hover="function: boolean ExternalRootNoninvasiveDebugEnabled()">ExternalRootNoninvasiveDebugEnabled</anchor>()
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then return FALSE;
    return <a link="impl-shared.ExternalRootInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRootInvasiveDebugEnabled()">ExternalRootInvasiveDebugEnabled</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalSecureInvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalSecureInvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalSecureInvasiveDebugEnabled()
// ====================================
// The definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the (DBGEN AND SPIDEN) signal.
// CoreSight allows asserting SPIDEN without also asserting DBGEN, but this is not recommended.

boolean <anchor link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</anchor>()
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>() then return FALSE;
    return <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>() &amp;&amp; SPIDEN == HIGH;</pstext>
    </ps>
    <ps name="shared/debug/authentication/ExternalSecureNoninvasiveDebugEnabled" mylink="shared.debug.authentication.ExternalSecureNoninvasiveDebugEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalSecureNoninvasiveDebugEnabled()
// =======================================
// This function returns the value of ExternalSecureInvasiveDebugEnabled() when FEAT_Debugv8p4
// is implemented. Otherwise, the definition of this function is IMPLEMENTATION DEFINED.
// In the recommended interface, this function returns the state of the (DBGEN OR NIDEN) AND
// (SPIDEN OR SPNIDEN) signal.

boolean <anchor link="impl-shared.ExternalSecureNoninvasiveDebugEnabled.0" hover="function: boolean ExternalSecureNoninvasiveDebugEnabled()">ExternalSecureNoninvasiveDebugEnabled</anchor>()
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>() then return FALSE;
    if <a link="impl-shared.HaveNoninvasiveDebugAuth.0" file="shared_pseudocode.xml" hover="function: boolean HaveNoninvasiveDebugAuth()">HaveNoninvasiveDebugAuth</a>() then
        return <a link="impl-shared.ExternalNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalNoninvasiveDebugEnabled()">ExternalNoninvasiveDebugEnabled</a>() &amp;&amp; (SPIDEN == HIGH || SPNIDEN == HIGH);
    else
        return <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/IsAccessSecure" mylink="shared.debug.authentication.IsAccessSecure" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsAccessSecure()
// ================
// Returns TRUE when an access is Secure

boolean <anchor link="impl-shared.IsAccessSecure.0" hover="function: boolean IsAccessSecure()">IsAccessSecure</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/authentication/IsCorePowered" mylink="shared.debug.authentication.IsCorePowered" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsCorePowered()
// ===============
// Returns TRUE if the Core power domain is powered on, FALSE otherwise.

boolean <anchor link="impl-shared.IsCorePowered.0" hover="function: boolean IsCorePowered()">IsCorePowered</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/breakpoint/CheckValidStateMatch" mylink="shared.debug.breakpoint.CheckValidStateMatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckValidStateMatch()
// ======================
// Checks for an invalid state match that will generate Constrained
// Unpredictable behavior, otherwise returns Constraint_NONE.

(Constraint, bits(2), bit, bit, bits(2)) <anchor link="impl-shared.CheckValidStateMatch.5" hover="function: (Constraint, bits(2), bit, bit, bits(2)) CheckValidStateMatch(bits(2) ssc_in, bit ssce_in, bit hmc_in, bits(2) pxc_in, boolean isbreakpnt)">CheckValidStateMatch</anchor>(bits(2) ssc_in, bit ssce_in,
                                                              bit hmc_in, bits(2) pxc_in,
                                                              boolean isbreakpnt)
    if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then assert ssce_in == '0';
    boolean reserved = FALSE;
    bits(2) ssc = ssc_in;
    bit ssce    = ssce_in;
    bit hmc     = hmc_in;
    bits(2) pxc = pxc_in;

    // Values that are not allocated in any architecture version
    case hmc:ssce:ssc:pxc of
        when '0 0 11 10' reserved = TRUE;
        when '0 0 1x xx' reserved = !<a link="impl-shared.HaveSecureState.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureState()">HaveSecureState</a>();
        when '1 0 00 x0' reserved = TRUE;
        when '1 0 01 10' reserved = TRUE;
        when '1 0 1x 10' reserved = TRUE;
        when 'x 1 xx xx' reserved = ssc != '01' || (hmc:pxc) IN {'000','110'};
        otherwise        reserved = FALSE;

    // Match 'Usr/Sys/Svc' valid only for AArch32 breakpoints
    if (!isbreakpnt || !<a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) &amp;&amp; hmc:pxc == '000' &amp;&amp; ssc != '11' then
        reserved = TRUE;

    // Both EL3 and EL2 are not implemented
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (hmc != '0' || ssc != '00') then
        reserved = TRUE;

    // EL3 is not implemented
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; ssc IN {'01','10'} &amp;&amp; hmc:ssc:pxc != '10100' then
        reserved = TRUE;

    // EL3 using AArch64 only
    if (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>()) &amp;&amp; hmc:ssc:pxc == '11000' then
        reserved = TRUE;

    // EL2 is not implemented
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; hmc:ssc:pxc == '11100' then
        reserved = TRUE;

    // Secure EL2 is not implemented
    if !<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; (hmc:ssc:pxc)  IN {'01100','10100','x11x1'} then
        reserved = TRUE;

    if reserved then
        // If parameters are set to a reserved type, behaves as either disabled or a defined type
        <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
        (c, &lt;hmc,ssc,ssce,pxc&gt;) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESBPWPCTRL" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESBPWPCTRL</a>, 6);
        assert c IN {<a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a>, <a link="Constraint_UNKNOWN" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</a>};
        if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then
            return (c, bits(2) UNKNOWN, bit UNKNOWN, bit UNKNOWN, bits(2) UNKNOWN);
        // Otherwise the value returned by ConstrainUnpredictableBits must be a not-reserved value

    return (<a link="Constraint_NONE" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</a>, ssc, ssce, hmc, pxc);</pstext>
    </ps>
    <ps name="shared/debug/breakpoint/ContextMatchingBreakpointRange" mylink="shared.debug.breakpoint.ContextMatchingBreakpointRange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ContextMatchingBreakpointRange()
// ================================
// Returns two numbers indicating the index of the first and last context-aware breakpoint.

(integer, integer) <anchor link="impl-shared.ContextMatchingBreakpointRange.0" hover="function: (integer, integer) ContextMatchingBreakpointRange()">ContextMatchingBreakpointRange</anchor>()
    integer b = <a link="impl-shared.NumBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</a>();
    integer c = <a link="impl-shared.NumContextAwareBreakpointsImplemented.0" file="shared_pseudocode.xml" hover="function: integer NumContextAwareBreakpointsImplemented()">NumContextAwareBreakpointsImplemented</a>();

    if b &lt;= 16 then
        return (b - c, b - 1);
    elsif c &lt;= 16 then
        return (16 - c, 15);
    else
        return (0, c - 1);</pstext>
    </ps>
    <ps name="shared/debug/breakpoint/IsContextMatchingBreakpoint" mylink="shared.debug.breakpoint.IsContextMatchingBreakpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsContextMatchingBreakpoint()
// =============================
// Returns TRUE if DBGBCR_EL1[n] is a context-aware breakpoint.

boolean <anchor link="impl-shared.IsContextMatchingBreakpoint.1" hover="function: boolean IsContextMatchingBreakpoint(integer n)">IsContextMatchingBreakpoint</anchor>(integer n)
    (lower, upper) = <a link="impl-shared.ContextMatchingBreakpointRange.0" file="shared_pseudocode.xml" hover="function: (integer, integer) ContextMatchingBreakpointRange()">ContextMatchingBreakpointRange</a>();
    return n &gt;= lower &amp;&amp; n &lt;= upper;</pstext>
    </ps>
    <ps name="shared/debug/breakpoint/NumBreakpointsImplemented" mylink="shared.debug.breakpoint.NumBreakpointsImplemented" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NumBreakpointsImplemented()
// ===========================
// Returns the number of breakpoints implemented. This is indicated to software by
// DBGDIDR.BRPs in AArch32 state, and ID_AA64DFR0_EL1.BRPs in AArch64 state.

integer <anchor link="impl-shared.NumBreakpointsImplemented.0" hover="function: integer NumBreakpointsImplemented()">NumBreakpointsImplemented</anchor>()
    return integer IMPLEMENTATION_DEFINED "Number of breakpoints";</pstext>
    </ps>
    <ps name="shared/debug/breakpoint/NumContextAwareBreakpointsImplemented" mylink="shared.debug.breakpoint.NumContextAwareBreakpointsImplemented" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NumContextAwareBreakpointsImplemented()
// =======================================
// Returns the number of context-aware breakpoints implemented. This is indicated to software by
// DBGDIDR.CTX_CMPs in AArch32 state, and ID_AA64DFR0_EL1.CTX_CMPs in AArch64 state.

integer <anchor link="impl-shared.NumContextAwareBreakpointsImplemented.0" hover="function: integer NumContextAwareBreakpointsImplemented()">NumContextAwareBreakpointsImplemented</anchor>()
    return integer IMPLEMENTATION_DEFINED "Number of context-aware breakpoints";</pstext>
    </ps>
    <ps name="shared/debug/breakpoint/NumWatchpointsImplemented" mylink="shared.debug.breakpoint.NumWatchpointsImplemented" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NumWatchpointsImplemented()
// ===========================
// Returns the number of watchpoints implemented. This is indicated to software by
// DBGDIDR.WRPs in AArch32 state, and ID_AA64DFR0_EL1.WRPs in AArch64 state.

integer <anchor link="impl-shared.NumWatchpointsImplemented.0" hover="function: integer NumWatchpointsImplemented()">NumWatchpointsImplemented</anchor>()
    return integer IMPLEMENTATION_DEFINED "Number of watchpoints";</pstext>
    </ps>
    <ps name="shared/debug/cti/CTI_SetEventLevel" mylink="shared.debug.cti.CTI_SetEventLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CTI_SetEventLevel()
// ===================
// Set a Cross Trigger multi-cycle input event trigger to the specified level.

CTI_SetEventLevel(<a link="CrossTriggerIn" file="shared_pseudocode.xml" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn</a> id, signal level);</pstext>
    </ps>
    <ps name="shared/debug/cti/CTI_SignalEvent" mylink="shared.debug.cti.CTI_SignalEvent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CTI_SignalEvent()
// =================
// Signal a discrete event on a Cross Trigger input event trigger.

<anchor link="impl-shared.CTI_SignalEvent.1" hover="function: CTI_SignalEvent(CrossTriggerIn id)">CTI_SignalEvent</anchor>(<a link="CrossTriggerIn" file="shared_pseudocode.xml" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn</a> id);</pstext>
    </ps>
    <ps name="shared/debug/cti/CrossTrigger" mylink="shared.debug.cti.CrossTrigger" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CrossTrigger
// ============

enumeration <anchor link="CrossTriggerOut" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut</anchor> {<anchor link="CrossTriggerOut_DebugRequest" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_DebugRequest</anchor>, <anchor link="CrossTriggerOut_RestartRequest" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_RestartRequest</anchor>,
                             <anchor link="CrossTriggerOut_IRQ" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_IRQ</anchor>,          <anchor link="CrossTriggerOut_RSVD3" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_RSVD3</anchor>,
                             <anchor link="CrossTriggerOut_TraceExtIn0" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_TraceExtIn0</anchor>,  <anchor link="CrossTriggerOut_TraceExtIn1" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_TraceExtIn1</anchor>,
                             <anchor link="CrossTriggerOut_TraceExtIn2" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_TraceExtIn2</anchor>,  <anchor link="CrossTriggerOut_TraceExtIn3" hover="enumeration CrossTriggerOut {CrossTriggerOut_DebugRequest, CrossTriggerOut_RestartRequest, CrossTriggerOut_IRQ,          CrossTriggerOut_RSVD3, CrossTriggerOut_TraceExtIn0,  CrossTriggerOut_TraceExtIn1, CrossTriggerOut_TraceExtIn2,  CrossTriggerOut_TraceExtIn3}">CrossTriggerOut_TraceExtIn3</anchor>};

enumeration <anchor link="CrossTriggerIn" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn</anchor>  {<anchor link="CrossTriggerIn_CrossHalt" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_CrossHalt</anchor>,     <anchor link="CrossTriggerIn_PMUOverflow" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_PMUOverflow</anchor>,
                             <anchor link="CrossTriggerIn_RSVD2" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_RSVD2</anchor>,         <anchor link="CrossTriggerIn_RSVD3" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_RSVD3</anchor>,
                             <anchor link="CrossTriggerIn_TraceExtOut0" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_TraceExtOut0</anchor>,  <anchor link="CrossTriggerIn_TraceExtOut1" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_TraceExtOut1</anchor>,
                             <anchor link="CrossTriggerIn_TraceExtOut2" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_TraceExtOut2</anchor>,  <anchor link="CrossTriggerIn_TraceExtOut3" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_TraceExtOut3</anchor>};</pstext>
    </ps>
    <ps name="shared/debug/dccanditr/CheckForDCCInterrupts" mylink="shared.debug.dccanditr.CheckForDCCInterrupts" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckForDCCInterrupts()
// =======================

<anchor link="impl-shared.CheckForDCCInterrupts.0" hover="function: CheckForDCCInterrupts()">CheckForDCCInterrupts</anchor>()
    commrx = (EDSCR.RXfull == '1');
    commtx = (EDSCR.TXfull == '0');

    // COMMRX and COMMTX support is optional and not recommended for new designs.
    // SetInterruptRequestLevel(InterruptID_COMMRX, if commrx then HIGH else LOW);
    // SetInterruptRequestLevel(InterruptID_COMMTX, if commtx then HIGH else LOW);

    // The value to be driven onto the common COMMIRQ signal.
    boolean commirq;
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        commirq = ((commrx &amp;&amp; DBGDCCINT.RX == '1') ||
                   (commtx &amp;&amp; DBGDCCINT.TX == '1'));
    else
        commirq = ((commrx &amp;&amp; MDCCINT_EL1.RX == '1') ||
                   (commtx &amp;&amp; MDCCINT_EL1.TX == '1'));
    SetInterruptRequestLevel(<a link="InterruptID_COMMIRQ" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_COMMIRQ</a>, if commirq then HIGH else LOW);

    return;</pstext>
    </ps>
    <ps name="shared/debug/dccanditr/DBGDTRRX_EL0" mylink="shared.debug.dccanditr.DBGDTRRX_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DBGDTRRX_EL0[] (external write)
// ===============================
// Called on writes to debug register 0x08C.

<anchor link="impl-shared.DBGDTRRX_EL0.write.1" hover="accessor: DBGDTRRX_EL0[boolean memory_mapped] = bits(32) value">DBGDTRRX_EL0</anchor>[boolean memory_mapped] = bits(32) value

    if EDPRSR&lt;6:5,0&gt; != '001' then                      // Check DLK, OSLK and PU bits
        IMPLEMENTATION_DEFINED "generate error response";
        return;

    if EDSCR.ERR == '1' then return;                    // Error flag set: ignore write

    // The Software lock is OPTIONAL.
    if memory_mapped &amp;&amp; EDLSR.SLK == '1' then return;   // Software lock locked: ignore write

    if EDSCR.RXfull == '1' || (<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.MA == '1' &amp;&amp; EDSCR.ITE == '0') then
        EDSCR.RXO = '1';  EDSCR.ERR = '1';              // Overrun condition: ignore write
        return;

    EDSCR.RXfull = '1';
    DTRRX = value;

    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.MA == '1' then
        EDSCR.ITE = '0';                            // See comments in EDITR[] (external write)
        if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
            <a link="impl-shared.ExecuteA64.1" file="shared_pseudocode.xml" hover="function: ExecuteA64(bits(32) instr)">ExecuteA64</a>(0xD5330501&lt;31:0&gt;);               // A64 "MRS X1,DBGDTRRX_EL0"
            <a link="impl-shared.ExecuteA64.1" file="shared_pseudocode.xml" hover="function: ExecuteA64(bits(32) instr)">ExecuteA64</a>(0xB8004401&lt;31:0&gt;);               // A64 "STR W1,[X0],#4"
            <a link="impl-aarch64.X.write.2" file="shared_pseudocode.xml" hover="accessor: X[integer n, integer width] = bits(width) value">X</a>[1, 64] = bits(64) UNKNOWN;
        else
            <a link="impl-shared.ExecuteT32.2" file="shared_pseudocode.xml" hover="function: ExecuteT32(bits(16) hw1, bits(16) hw2)">ExecuteT32</a>(0xEE10&lt;15:0&gt; /*hw1*/, 0x1E15&lt;15:0&gt; /*hw2*/);  // T32 "MRS R1,DBGDTRRXint"
            <a link="impl-shared.ExecuteT32.2" file="shared_pseudocode.xml" hover="function: ExecuteT32(bits(16) hw1, bits(16) hw2)">ExecuteT32</a>(0xF840&lt;15:0&gt; /*hw1*/, 0x1B04&lt;15:0&gt; /*hw2*/);  // T32 "STR R1,[R0],#4"
            <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[1] = bits(32) UNKNOWN;
        // If the store aborts, the Data Abort exception is taken and EDSCR.ERR is set to 1
        if EDSCR.ERR == '1' then
            EDSCR.RXfull = bit UNKNOWN;
            DBGDTRRX_EL0 = bits(64) UNKNOWN;
        else
            // "MRS X1,DBGDTRRX_EL0" calls DBGDTR_EL0[] (read) which clears RXfull.
            assert EDSCR.RXfull == '0';

        EDSCR.ITE = '1';                                // See comments in EDITR[] (external write)
    return;

// DBGDTRRX_EL0[] (external read)
// ==============================

bits(32) <anchor link="impl-shared.DBGDTRRX_EL0.read.1" hover="accessor: bits(32) DBGDTRRX_EL0[boolean memory_mapped]">DBGDTRRX_EL0</anchor>[boolean memory_mapped]
    return DTRRX;</pstext>
    </ps>
    <ps name="shared/debug/dccanditr/DBGDTRTX_EL0" mylink="shared.debug.dccanditr.DBGDTRTX_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DBGDTRTX_EL0[] (external read)
// ==============================
// Called on reads of debug register 0x080.

bits(32) <anchor link="impl-shared.DBGDTRTX_EL0.read.1" hover="accessor: bits(32) DBGDTRTX_EL0[boolean memory_mapped]">DBGDTRTX_EL0</anchor>[boolean memory_mapped]

    if EDPRSR&lt;6:5,0&gt; != '001' then                      // Check DLK, OSLK and PU bits
        IMPLEMENTATION_DEFINED "generate error response";
        return bits(32) UNKNOWN;

    underrun = EDSCR.TXfull == '0' || (<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.MA == '1' &amp;&amp; EDSCR.ITE == '0');
    value = if underrun then bits(32) UNKNOWN else DTRTX;

    if EDSCR.ERR == '1' then return value;              // Error flag set: no side-effects

    // The Software lock is OPTIONAL.
    if memory_mapped &amp;&amp; EDLSR.SLK == '1' then           // Software lock locked: no side-effects
        return value;

    if underrun then
        EDSCR.TXU = '1';  EDSCR.ERR = '1';              // Underrun condition: block side-effects
        return value;                                   // Return UNKNOWN

    EDSCR.TXfull = '0';
    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.MA == '1' then
        EDSCR.ITE = '0';                                // See comments in EDITR[] (external write)

        if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
            <a link="impl-shared.ExecuteA64.1" file="shared_pseudocode.xml" hover="function: ExecuteA64(bits(32) instr)">ExecuteA64</a>(0xB8404401&lt;31:0&gt;);               // A64 "LDR W1,[X0],#4"
        else
            <a link="impl-shared.ExecuteT32.2" file="shared_pseudocode.xml" hover="function: ExecuteT32(bits(16) hw1, bits(16) hw2)">ExecuteT32</a>(0xF850&lt;15:0&gt; /*hw1*/, 0x1B04&lt;15:0&gt; /*hw2*/);      // T32 "LDR R1,[R0],#4"
        // If the load aborts, the Data Abort exception is taken and EDSCR.ERR is set to 1
        if EDSCR.ERR == '1' then
            EDSCR.TXfull = bit UNKNOWN;
            DBGDTRTX_EL0 = bits(64) UNKNOWN;
        else
            if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
                <a link="impl-shared.ExecuteA64.1" file="shared_pseudocode.xml" hover="function: ExecuteA64(bits(32) instr)">ExecuteA64</a>(0xD5130501&lt;31:0&gt;);           // A64 "MSR DBGDTRTX_EL0,X1"
            else
                <a link="impl-shared.ExecuteT32.2" file="shared_pseudocode.xml" hover="function: ExecuteT32(bits(16) hw1, bits(16) hw2)">ExecuteT32</a>(0xEE00&lt;15:0&gt; /*hw1*/, 0x1E15&lt;15:0&gt; /*hw2*/);  // T32 "MSR DBGDTRTXint,R1"
            // "MSR DBGDTRTX_EL0,X1" calls DBGDTR_EL0[] (write) which sets TXfull.
            assert EDSCR.TXfull == '1';
        if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
            <a link="impl-aarch64.X.write.2" file="shared_pseudocode.xml" hover="accessor: X[integer n, integer width] = bits(width) value">X</a>[1, 64] = bits(64) UNKNOWN;
        else
            <a link="impl-aarch32.R.write.1" file="shared_pseudocode.xml" hover="accessor: R[integer n] = bits(32) value">R</a>[1] = bits(32) UNKNOWN;
        EDSCR.ITE = '1';                                // See comments in EDITR[] (external write)

    return value;

// DBGDTRTX_EL0[] (external write)
// ===============================

<anchor link="impl-shared.DBGDTRTX_EL0.write.1" hover="accessor: DBGDTRTX_EL0[boolean memory_mapped] = bits(32) value">DBGDTRTX_EL0</anchor>[boolean memory_mapped] = bits(32) value
    // The Software lock is OPTIONAL.
    if memory_mapped &amp;&amp; EDLSR.SLK == '1' then return;   // Software lock locked: ignore write
    DTRTX = value;
    return;</pstext>
    </ps>
    <ps name="shared/debug/dccanditr/DBGDTR_EL0" mylink="shared.debug.dccanditr.DBGDTR_EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DBGDTR_EL0[] (write)
// ====================
// System register writes to DBGDTR_EL0, DBGDTRTX_EL0 (AArch64) and DBGDTRTXint (AArch32)

DBGDTR_EL0[] = bits(N) value_in
    bits(N) value = value_in;
    // For MSR DBGDTRTX_EL0,&lt;Rt&gt;  N=32, value=X[t]&lt;31:0&gt;, X[t]&lt;63:32&gt; is ignored
    // For MSR DBGDTR_EL0,&lt;Xt&gt;    N=64, value=X[t]&lt;63:0&gt;
    assert N IN {32,64};
    if EDSCR.TXfull == '1' then
        value = bits(N) UNKNOWN;
    // On a 64-bit write, implement a half-duplex channel
    if N == 64 then DTRRX = value&lt;63:32&gt;;
    DTRTX = value&lt;31:0&gt;;        // 32-bit or 64-bit write
    EDSCR.TXfull = '1';
    return;

// DBGDTR_EL0[] (read)
// ===================
// System register reads of DBGDTR_EL0, DBGDTRRX_EL0 (AArch64) and DBGDTRRXint (AArch32)

bits(N) <anchor link="impl-shared.DBGDTR_EL0.read.0" hover="accessor: bits(N) DBGDTR_EL0[]">DBGDTR_EL0</anchor>[]
    // For MRS &lt;Rt&gt;,DBGDTRTX_EL0  N=32, X[t]=Zeros(32):result
    // For MRS &lt;Xt&gt;,DBGDTR_EL0    N=64, X[t]=result
    assert N IN {32,64};
    bits(N) result;
    if EDSCR.RXfull == '0' then
        result = bits(N) UNKNOWN;
    else
        // On a 64-bit read, implement a half-duplex channel
        // NOTE: the word order is reversed on reads with regards to writes
        if N == 64 then result&lt;63:32&gt; = DTRTX;
        result&lt;31:0&gt; = DTRRX;
    EDSCR.RXfull = '0';
    return result;</pstext>
    </ps>
    <ps name="shared/debug/dccanditr/DTR" mylink="shared.debug.dccanditr.DTR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(32) DTRRX;
bits(32) DTRTX;</pstext>
    </ps>
    <ps name="shared/debug/dccanditr/EDITR" mylink="shared.debug.dccanditr.EDITR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EDITR[] (external write)
// ========================
// Called on writes to debug register 0x084.

<anchor link="impl-shared.EDITR.write.1" hover="accessor: EDITR[boolean memory_mapped] = bits(32) value">EDITR</anchor>[boolean memory_mapped] = bits(32) value
    if EDPRSR&lt;6:5,0&gt; != '001' then                      // Check DLK, OSLK and PU bits
        IMPLEMENTATION_DEFINED "generate error response";
        return;

    if EDSCR.ERR == '1' then return;                    // Error flag set: ignore write

    // The Software lock is OPTIONAL.
    if memory_mapped &amp;&amp; EDLSR.SLK == '1' then return;   // Software lock locked: ignore write

    if !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then return;                           // Non-debug state: ignore write

    if EDSCR.ITE == '0' || EDSCR.MA == '1' then
        EDSCR.ITO = '1';  EDSCR.ERR = '1';              // Overrun condition: block write
        return;

    // ITE indicates whether the processor is ready to accept another instruction; the processor
    // may support multiple outstanding instructions. Unlike the "InstrCompl" flag in [v7A] there
    // is no indication that the pipeline is empty (all instructions have completed). In this
    // pseudocode, the assumption is that only one instruction can be executed at a time,
    // meaning ITE acts like "InstrCompl".
    EDSCR.ITE = '0';

    if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        <a link="impl-shared.ExecuteA64.1" file="shared_pseudocode.xml" hover="function: ExecuteA64(bits(32) instr)">ExecuteA64</a>(value);
    else
        <a link="impl-shared.ExecuteT32.2" file="shared_pseudocode.xml" hover="function: ExecuteT32(bits(16) hw1, bits(16) hw2)">ExecuteT32</a>(value&lt;15:0&gt;/*hw1*/, value&lt;31:16&gt; /*hw2*/);

    EDSCR.ITE = '1';

    return;</pstext>
    </ps>
    <ps name="shared/debug/halting/DCPSInstruction" mylink="shared.debug.halting.DCPSInstruction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DCPSInstruction()
// =================
// Operation of the DCPS instruction in Debug state

<anchor link="impl-shared.DCPSInstruction.1" hover="function: DCPSInstruction(bits(2) target_el)">DCPSInstruction</anchor>(bits(2) target_el)

    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();

    bits(2) handle_el;
    case target_el of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || (PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>()) then
                handle_el = PSTATE.EL;
            elsif <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.TGE == '1' then
                UNDEFINED;
            else
                handle_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
                UNDEFINED;
            elsif PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
                handle_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
            elsif !<a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>() &amp;&amp; <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
                UNDEFINED;
            else
                handle_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            if EDSCR.SDD == '1' || !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
                UNDEFINED;
            else
                handle_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    from_secure = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(handle_el) then
        if PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then SCR.NS = '0';
        assert <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();                  // Cannot move from AArch64 to AArch32
        case handle_el of
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>);
                if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; SCTLR.SPAN == '0' then
                    PSTATE.PAN = '1';
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>);
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
                <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(<a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>);
                if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() then
                    if !from_secure then
                        PSTATE.PAN = '0';
                    elsif SCTLR.SPAN == '0' then
                        PSTATE.PAN = '1';
        if handle_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            ELR_hyp = bits(32) UNKNOWN;  HSR = bits(32) UNKNOWN;
        else
            <a link="impl-aarch32.LR.write.none" file="shared_pseudocode.xml" hover="accessor: LR = bits(32) value">LR</a> = bits(32) UNKNOWN;
        <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = bits(32) UNKNOWN;
        PSTATE.E = <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].EE;
        DLR = bits(32) UNKNOWN;  DSPSR = bits(32) UNKNOWN;

    else                                        // Targeting AArch64
        from_32 = <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
        if from_32 then <a link="AArch64.MaybeZeroRegisterUppers.0" file="shared_pseudocode.xml" hover="function: AArch64.MaybeZeroRegisterUppers()">AArch64.MaybeZeroRegisterUppers</a>();
        if from_32 &amp;&amp; <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' then
            <a link="impl-aarch64.ResetSVEState.0" file="shared_pseudocode.xml" hover="function: ResetSVEState()">ResetSVEState</a>();
        else
            <a link="impl-aarch64.MaybeZeroSVEUppers.1" file="shared_pseudocode.xml" hover="function: MaybeZeroSVEUppers(bits(2) target_el)">MaybeZeroSVEUppers</a>(target_el);
        PSTATE.nRW = '0';  PSTATE.SP = '1';  PSTATE.EL = handle_el;
        if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() &amp;&amp; ((handle_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; SCTLR_EL1.SPAN == '0') ||
                            (handle_el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; HCR_EL2.E2H == '1' &amp;&amp;
                             HCR_EL2.TGE == '1' &amp;&amp; SCTLR_EL2.SPAN == '0')) then
            PSTATE.PAN = '1';
        <a link="impl-aarch64.ELR.write.0" file="shared_pseudocode.xml" hover="accessor: ELR[] = bits(64) value">ELR</a>[] = bits(64) UNKNOWN;  <a link="impl-shared.SPSR.write.0" file="shared_pseudocode.xml" hover="accessor: SPSR[] = bits(N) value">SPSR</a>[] = bits(64) UNKNOWN;  <a link="impl-aarch64.ESR.write.0" file="shared_pseudocode.xml" hover="accessor: ESR[] = ESRType value">ESR</a>[] = bits(64) UNKNOWN;
        DLR_EL0 = bits(64) UNKNOWN;  DSPSR_EL0 = bits(64) UNKNOWN;
        if <a link="impl-shared.HaveUAOExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveUAOExt()">HaveUAOExt</a>() then PSTATE.UAO = '0';
        if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() then PSTATE.TCO = '1';
        if <a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() then PSTATE.EXLOCK = '0';

    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                        // Update EDSCR PE state flags
    sync_errors = <a link="impl-shared.HaveIESB.0" file="shared_pseudocode.xml" hover="function: boolean HaveIESB()">HaveIESB</a>() &amp;&amp; <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].IESB == '1';
    if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        sync_errors = (sync_errors ||
                       (<a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1' &amp;&amp; SCR_EL3.NMEA == '1' &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>));
    // SCTLR[].IESB might be ignored in Debug state.
    if !<a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_IESBinDebug" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_IESBinDebug</a>) then
        sync_errors = FALSE;
    if sync_errors then
        <a link="impl-shared.SynchronizeErrors.0" file="shared_pseudocode.xml" hover="function: SynchronizeErrors()">SynchronizeErrors</a>();
    return;</pstext>
    </ps>
    <ps name="shared/debug/halting/DRPSInstruction" mylink="shared.debug.halting.DRPSInstruction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DRPSInstruction()
// =================
// Operation of the A64 DRPS and T32 ERET instructions in Debug state

<anchor link="impl-shared.DRPSInstruction.0" hover="function: DRPSInstruction()">DRPSInstruction</anchor>()

    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();

    sync_errors = <a link="impl-shared.HaveIESB.0" file="shared_pseudocode.xml" hover="function: boolean HaveIESB()">HaveIESB</a>() &amp;&amp; <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].IESB == '1';
    if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        sync_errors = (sync_errors ||
                       (<a link="impl-shared.EffectiveEA.0" file="shared_pseudocode.xml" hover="function: bit EffectiveEA()">EffectiveEA</a>() == '1' &amp;&amp; SCR_EL3.NMEA == '1' &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>));
    // SCTLR[].IESB might be ignored in Debug state.
    if !<a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_IESBinDebug" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_IESBinDebug</a>) then
        sync_errors = FALSE;
    if sync_errors then
        <a link="impl-shared.SynchronizeErrors.0" file="shared_pseudocode.xml" hover="function: SynchronizeErrors()">SynchronizeErrors</a>();

    <a link="impl-shared.DebugRestorePSR.0" file="shared_pseudocode.xml" hover="function: DebugRestorePSR()">DebugRestorePSR</a>();

    return;</pstext>
    </ps>
    <ps name="shared/debug/halting/DebugHalt" mylink="shared.debug.halting.DebugHalt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(6) <anchor link="DebugHalt_Breakpoint" hover="constant bits(6) DebugHalt_Breakpoint = '000111'">DebugHalt_Breakpoint</anchor>      = '000111';
constant bits(6) <anchor link="DebugHalt_EDBGRQ" hover="constant bits(6) DebugHalt_EDBGRQ = '010011'">DebugHalt_EDBGRQ</anchor>          = '010011';
constant bits(6) <anchor link="DebugHalt_Step_Normal" hover="constant bits(6) DebugHalt_Step_Normal = '011011'">DebugHalt_Step_Normal</anchor>     = '011011';
constant bits(6) <anchor link="DebugHalt_Step_Exclusive" hover="constant bits(6) DebugHalt_Step_Exclusive = '011111'">DebugHalt_Step_Exclusive</anchor>  = '011111';
constant bits(6) <anchor link="DebugHalt_OSUnlockCatch" hover="constant bits(6) DebugHalt_OSUnlockCatch = '100011'">DebugHalt_OSUnlockCatch</anchor>   = '100011';
constant bits(6) <anchor link="DebugHalt_ResetCatch" hover="constant bits(6) DebugHalt_ResetCatch = '100111'">DebugHalt_ResetCatch</anchor>      = '100111';
constant bits(6) <anchor link="DebugHalt_Watchpoint" hover="constant bits(6) DebugHalt_Watchpoint = '101011'">DebugHalt_Watchpoint</anchor>      = '101011';
constant bits(6) <anchor link="DebugHalt_HaltInstruction" hover="constant bits(6) DebugHalt_HaltInstruction = '101111'">DebugHalt_HaltInstruction</anchor> = '101111';
constant bits(6) <anchor link="DebugHalt_SoftwareAccess" hover="constant bits(6) DebugHalt_SoftwareAccess = '110011'">DebugHalt_SoftwareAccess</anchor>  = '110011';
constant bits(6) <anchor link="DebugHalt_ExceptionCatch" hover="constant bits(6) DebugHalt_ExceptionCatch = '110111'">DebugHalt_ExceptionCatch</anchor>  = '110111';
constant bits(6) <anchor link="DebugHalt_Step_NoSyndrome" hover="constant bits(6) DebugHalt_Step_NoSyndrome = '111011'">DebugHalt_Step_NoSyndrome</anchor> = '111011';</pstext>
    </ps>
    <ps name="shared/debug/halting/DebugRestorePSR" mylink="shared.debug.halting.DebugRestorePSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugRestorePSR()
// =================

<anchor link="impl-shared.DebugRestorePSR.0" hover="function: DebugRestorePSR()">DebugRestorePSR</anchor>()
    // PSTATE.{N,Z,C,V,Q,GE,SS,D,A,I,F} are not observable and ignored in Debug state, so
    // behave as if UNKNOWN.
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        bits(32) spsr = <a link="impl-shared.SPSR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(N) SPSR[]">SPSR</a>[];
        <a link="impl-shared.SetPSTATEFromPSR.1" file="shared_pseudocode.xml" hover="function: SetPSTATEFromPSR(bits(N) spsr)">SetPSTATEFromPSR</a>(spsr);
        PSTATE.&lt;N,Z,C,V,Q,GE,SS,A,I,F&gt; = bits(13) UNKNOWN;
        //  In AArch32, all instructions are T32 and unconditional.
        PSTATE.IT = '00000000';  PSTATE.T = '1';        // PSTATE.J is RES0
        DLR = bits(32) UNKNOWN;  DSPSR = bits(32) UNKNOWN;
    else
        bits(64) spsr = <a link="impl-shared.SPSR.read.0" file="shared_pseudocode.xml" hover="accessor: bits(N) SPSR[]">SPSR</a>[];
        <a link="impl-shared.SetPSTATEFromPSR.1" file="shared_pseudocode.xml" hover="function: SetPSTATEFromPSR(bits(N) spsr)">SetPSTATEFromPSR</a>(spsr);
        PSTATE.&lt;N,Z,C,V,SS,D,A,I,F&gt; = bits(9) UNKNOWN;
        DLR_EL0 = bits(64) UNKNOWN;  DSPSR_EL0 = bits(64) UNKNOWN;
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                                // Update EDSCR PE state flags</pstext>
    </ps>
    <ps name="shared/debug/halting/DisableITRAndResumeInstructionPrefetch" mylink="shared.debug.halting.DisableITRAndResumeInstructionPrefetch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DisableITRAndResumeInstructionPrefetch()
// ========================================

<anchor link="impl-shared.DisableITRAndResumeInstructionPrefetch.0" hover="function: DisableITRAndResumeInstructionPrefetch()">DisableITRAndResumeInstructionPrefetch</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/halting/ExecuteA64" mylink="shared.debug.halting.ExecuteA64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExecuteA64()
// ============
// Execute an A64 instruction in Debug state.

<anchor link="impl-shared.ExecuteA64.1" hover="function: ExecuteA64(bits(32) instr)">ExecuteA64</anchor>(bits(32) instr);</pstext>
    </ps>
    <ps name="shared/debug/halting/ExecuteT32" mylink="shared.debug.halting.ExecuteT32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExecuteT32()
// ============
// Execute a T32 instruction in Debug state.

<anchor link="impl-shared.ExecuteT32.2" hover="function: ExecuteT32(bits(16) hw1, bits(16) hw2)">ExecuteT32</anchor>(bits(16) hw1, bits(16) hw2);</pstext>
    </ps>
    <ps name="shared/debug/halting/ExitDebugState" mylink="shared.debug.halting.ExitDebugState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExitDebugState()
// ================

<anchor link="impl-shared.ExitDebugState.0" hover="function: ExitDebugState()">ExitDebugState</anchor>()
    assert <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();
    <a link="impl-shared.SynchronizeContext.0" file="shared_pseudocode.xml" hover="function: SynchronizeContext()">SynchronizeContext</a>();

    // Although EDSCR.STATUS signals that the PE is restarting, debuggers must use EDPRSR.SDR to
    // detect that the PE has restarted.
    EDSCR.STATUS = '000001';                           // Signal restarting
    // Clear any pending Halting debug events
    if <a link="impl-shared.Havev8p8Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p8Debug()">Havev8p8Debug</a>() then
        EDESR&lt;3:0&gt; = '0000';
    else
        EDESR&lt;2:0&gt; = '000';

    bits(64) new_pc;
    bits(64) spsr;

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        new_pc = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(DLR, 64);
        if <a link="impl-shared.Havev8p9Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p9Debug()">Havev8p9Debug</a>() then
            spsr = DSPSR2 : DSPSR;
        else
            spsr = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(DSPSR, 64);
    else
        new_pc = DLR_EL0;
        spsr = DSPSR_EL0;

    boolean illegal_psr_state = <a link="impl-shared.IllegalExceptionReturn.1" file="shared_pseudocode.xml" hover="function: boolean IllegalExceptionReturn(bits(N) spsr)">IllegalExceptionReturn</a>(spsr);
    // If this is an illegal return, SetPSTATEFromPSR() will set PSTATE.IL.
    <a link="impl-shared.SetPSTATEFromPSR.1" file="shared_pseudocode.xml" hover="function: SetPSTATEFromPSR(bits(N) spsr)">SetPSTATEFromPSR</a>(spsr);                            // Can update privileged bits, even at EL0

    boolean branch_conditional = FALSE;
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_RESTARTALIGNPC" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTARTALIGNPC</a>) then new_pc&lt;0&gt; = '0';
        // AArch32 branch
        <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(new_pc&lt;31:0&gt;, <a link="BranchType_DBGEXIT" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DBGEXIT</a>, branch_conditional);
    else
        // If targeting AArch32 then PC[63:32,1:0] might be set to UNKNOWN.
        if illegal_psr_state &amp;&amp; spsr&lt;4&gt; == '1' then
            new_pc&lt;63:32&gt; = bits(32) UNKNOWN;
            new_pc&lt;1:0&gt; = bits(2) UNKNOWN;
        if <a link="impl-shared.HaveBRBExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBExt()">HaveBRBExt</a>() then
            <a link="impl-aarch64.BRBEDebugStateExit.1" file="shared_pseudocode.xml" hover="function: BRBEDebugStateExit(bits(64) target_address)">BRBEDebugStateExit</a>(new_pc);
        // A type of branch that is never predicted
        <a link="impl-shared.BranchTo.3" file="shared_pseudocode.xml" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</a>(new_pc, <a link="BranchType_DBGEXIT" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DBGEXIT</a>, branch_conditional);

    (EDSCR.STATUS,EDPRSR.SDR) = ('000010','1');        // Atomically signal restarted
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                               // Stop signalling PE state
    <a link="impl-shared.DisableITRAndResumeInstructionPrefetch.0" file="shared_pseudocode.xml" hover="function: DisableITRAndResumeInstructionPrefetch()">DisableITRAndResumeInstructionPrefetch</a>();

    return;</pstext>
    </ps>
    <ps name="shared/debug/halting/Halt" mylink="shared.debug.halting.Halt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Halt()
// ======

<anchor link="impl-shared.Halt.1" hover="function: Halt(bits(6) reason)">Halt</anchor>(bits(6) reason)
    boolean is_async = FALSE;
    <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(reason, is_async);

// Halt()
// ======

<anchor link="impl-shared.Halt.2" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</anchor>(bits(6) reason, boolean is_async)

    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then
        <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_DBG" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_DBG</a>, FALSE);

    <a link="impl-shared.CTI_SignalEvent.1" file="shared_pseudocode.xml" hover="function: CTI_SignalEvent(CrossTriggerIn id)">CTI_SignalEvent</a>(<a link="CrossTriggerIn_CrossHalt" file="shared_pseudocode.xml" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_CrossHalt</a>);  // Trigger other cores to halt

    bits(64) preferred_restart_address = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    bits(64) spsr = <a link="impl-shared.GetPSRFromPSTATE.2" file="shared_pseudocode.xml" hover="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N)">GetPSRFromPSTATE</a>(<a link="DebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">DebugState</a>, 64);

    if (<a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() &amp;&amp; !is_async &amp;&amp; !(reason IN {<a link="DebugHalt_Step_Normal" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Step_Normal = '011011'">DebugHalt_Step_Normal</a>, <a link="DebugHalt_Step_Exclusive" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Step_Exclusive = '011111'">DebugHalt_Step_Exclusive</a>,
        <a link="DebugHalt_Step_NoSyndrome" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Step_NoSyndrome = '111011'">DebugHalt_Step_NoSyndrome</a>, <a link="DebugHalt_Breakpoint" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Breakpoint = '000111'">DebugHalt_Breakpoint</a>, <a link="DebugHalt_HaltInstruction" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_HaltInstruction = '101111'">DebugHalt_HaltInstruction</a>}) &amp;&amp;
        <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ZEROBTYPE" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ZEROBTYPE</a>)) then
        spsr&lt;11:10&gt; = '00';

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        DLR = preferred_restart_address&lt;31:0&gt;;
        DSPSR = spsr&lt;31:0&gt;;
        if <a link="impl-shared.Havev8p9Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p9Debug()">Havev8p9Debug</a>() then
            DSPSR2 = spsr&lt;63:32&gt;;
    else
        DLR_EL0 = preferred_restart_address;
        DSPSR_EL0 = spsr;

    EDSCR.ITE = '1';
    EDSCR.ITO = '0';
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        EDSCR.SDD = if <a link="impl-shared.ExternalRootInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRootInvasiveDebugEnabled()">ExternalRootInvasiveDebugEnabled</a>() then '0' else '1';
    elsif <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        EDSCR.SDD = '0';                        // If entered in Secure state, allow debug
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        EDSCR.SDD = if <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>() then '0' else '1';
    else
        EDSCR.SDD = '1';                        // Otherwise EDSCR.SDD is RES1
    EDSCR.MA = '0';

    // In Debug state:
    // * PSTATE.{SS,SSBS,D,A,I,F} are not observable and ignored so behave-as-if UNKNOWN.
    // * PSTATE.{N,Z,C,V,Q,GE,E,M,nRW,EL,SP,DIT} are also not observable, but since these
    //     are not changed on exception entry, this function also leaves them unchanged.
    // * PSTATE.{IT,T} are ignored.
    // * PSTATE.IL is ignored and behave-as-if 0.
    // * PSTATE.BTYPE is ignored and behave-as-if 0.
    // * PSTATE.TCO is set 1.
    // * PSTATE.{UAO,PAN} are observable and not changed on entry into Debug state.

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        PSTATE.&lt;IT,SS,SSBS,A,I,F,T&gt; = bits(14) UNKNOWN;
    else
        PSTATE.&lt;SS,SSBS,D,A,I,F&gt;    = bits(6)  UNKNOWN;

        PSTATE.TCO = '1';
        PSTATE.BTYPE = '00';
    PSTATE.IL = '0';
    <a link="impl-shared.StopInstructionPrefetchAndEnableITR.0" file="shared_pseudocode.xml" hover="function: StopInstructionPrefetchAndEnableITR()">StopInstructionPrefetchAndEnableITR</a>();
    EDSCR.STATUS = reason;                      // Signal entered Debug state
    <a link="impl-shared.UpdateEDSCRFields.0" file="shared_pseudocode.xml" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</a>();                        // Update EDSCR PE state flags.
    return;</pstext>
    </ps>
    <ps name="shared/debug/halting/HaltOnBreakpointOrWatchpoint" mylink="shared.debug.halting.HaltOnBreakpointOrWatchpoint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaltOnBreakpointOrWatchpoint()
// ==============================
// Returns TRUE if the Breakpoint and Watchpoint debug events should be considered for Debug
// state entry, FALSE if they should be considered for a debug exception.

boolean <anchor link="impl-shared.HaltOnBreakpointOrWatchpoint.0" hover="function: boolean HaltOnBreakpointOrWatchpoint()">HaltOnBreakpointOrWatchpoint</anchor>()
    return <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDSCR.HDE == '1' &amp;&amp; OSLSR_EL1.OSLK == '0';</pstext>
    </ps>
    <ps name="shared/debug/halting/Halted" mylink="shared.debug.halting.Halted" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Halted()
// ========

boolean <anchor link="impl-shared.Halted.0" hover="function: boolean Halted()">Halted</anchor>()
    return !(EDSCR.STATUS IN {'000001', '000010'});                     // Halted</pstext>
    </ps>
    <ps name="shared/debug/halting/HaltingAllowed" mylink="shared.debug.halting.HaltingAllowed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaltingAllowed()
// ================
// Returns TRUE if halting is currently allowed, FALSE if halting is prohibited.

boolean <anchor link="impl-shared.HaltingAllowed.0" hover="function: boolean HaltingAllowed()">HaltingAllowed</anchor>()
    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() || <a link="impl-shared.DoubleLockStatus.0" file="shared_pseudocode.xml" hover="function: boolean DoubleLockStatus()">DoubleLockStatus</a>() then
        return FALSE;
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    case ss of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> return <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>();
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    return <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>();
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      return <a link="impl-shared.ExternalRootInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRootInvasiveDebugEnabled()">ExternalRootInvasiveDebugEnabled</a>();
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     return <a link="impl-shared.ExternalRealmInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRealmInvasiveDebugEnabled()">ExternalRealmInvasiveDebugEnabled</a>();</pstext>
    </ps>
    <ps name="shared/debug/halting/Restarting" mylink="shared.debug.halting.Restarting" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Restarting()
// ============

boolean <anchor link="impl-shared.Restarting.0" hover="function: boolean Restarting()">Restarting</anchor>()
    return EDSCR.STATUS == '000001';                                    // Restarting</pstext>
    </ps>
    <ps name="shared/debug/halting/StopInstructionPrefetchAndEnableITR" mylink="shared.debug.halting.StopInstructionPrefetchAndEnableITR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StopInstructionPrefetchAndEnableITR()
// =====================================

<anchor link="impl-shared.StopInstructionPrefetchAndEnableITR.0" hover="function: StopInstructionPrefetchAndEnableITR()">StopInstructionPrefetchAndEnableITR</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/halting/UpdateEDSCRFields" mylink="shared.debug.halting.UpdateEDSCRFields" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UpdateEDSCRFields()
// ===================
// Update EDSCR PE state fields

<anchor link="impl-shared.UpdateEDSCRFields.0" hover="function: UpdateEDSCRFields()">UpdateEDSCRFields</anchor>()

    if !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        EDSCR.EL = '00';
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
            EDSCR.&lt;NSE,NS&gt; = bits(2) UNKNOWN;
        else
            EDSCR.NS = bit UNKNOWN;

        EDSCR.RW = '1111';
    else
        EDSCR.EL = PSTATE.EL;
        ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
            case ss of
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    EDSCR.&lt;NSE,NS&gt; = '00';
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> EDSCR.&lt;NSE,NS&gt; = '01';
                when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      EDSCR.&lt;NSE,NS&gt; = '10';
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     EDSCR.&lt;NSE,NS&gt; = '11';
        else
            EDSCR.NS = if ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then '0' else '1';

        bits(4) RW;
        RW&lt;1&gt; = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then '0' else '1';
        if PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            RW&lt;0&gt; = RW&lt;1&gt;;
        else
            RW&lt;0&gt; = if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then '0' else '1';
        if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) || (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].NS == '0' &amp;&amp; !<a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>()) then
            RW&lt;2&gt; = RW&lt;1&gt;;
        else
            RW&lt;2&gt; = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then '0' else '1';
        if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            RW&lt;3&gt; = RW&lt;2&gt;;
        else
            RW&lt;3&gt; = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then '0' else '1';

        // The least-significant bits of EDSCR.RW are UNKNOWN if any higher EL is using AArch32.
        if RW&lt;3&gt; == '0' then RW&lt;2:0&gt; = bits(3) UNKNOWN;
        elsif RW&lt;2&gt; == '0' then RW&lt;1:0&gt; = bits(2) UNKNOWN;
        elsif RW&lt;1&gt; == '0' then RW&lt;0&gt; = bit UNKNOWN;
        EDSCR.RW = RW;
    return;</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckExceptionCatch" mylink="shared.debug.haltingevents.CheckExceptionCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckExceptionCatch()
// =====================
// Check whether an Exception Catch debug event is set on the current Exception level

<anchor link="impl-shared.CheckExceptionCatch.1" hover="function: CheckExceptionCatch(boolean exception_entry)">CheckExceptionCatch</anchor>(boolean exception_entry)
    // Called after an exception entry or exit, that is, such that the Security state
    // and PSTATE.EL are correct for the exception target. When FEAT_Debugv8p2
    // is not implemented, this function might also be called at any time.
    ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);
    integer base;

    case ss of
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    base = 0;
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> base = 4;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     base = 16;
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      base = 0;
    if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() then
        boolean halt;
        if <a link="impl-shared.HaveExtendedECDebugEvents.0" file="shared_pseudocode.xml" hover="function: boolean HaveExtendedECDebugEvents()">HaveExtendedECDebugEvents</a>() then
            exception_exit = !exception_entry;
            increment = if ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> then 4 else 8;
            ctrl = EDECCR&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) + base + increment&gt;:EDECCR&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) + base&gt;;
            case ctrl of
                when '00'  halt = FALSE;
                when '01'  halt = TRUE;
                when '10'  halt = (exception_exit == TRUE);
                when '11'  halt = (exception_entry == TRUE);
        else
            halt = (EDECCR&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) + base&gt; == '1');

        if halt then
            if <a link="impl-shared.Havev8p8Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p8Debug()">Havev8p8Debug</a>() &amp;&amp; exception_entry then
                EDESR.EC = '1';
            else
                <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(<a link="DebugHalt_ExceptionCatch" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_ExceptionCatch = '110111'">DebugHalt_ExceptionCatch</a>);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckHaltingStep" mylink="shared.debug.haltingevents.CheckHaltingStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckHaltingStep()
// ==================
// Check whether EDESR.SS has been set by Halting Step

<anchor link="impl-shared.CheckHaltingStep.1" hover="function: CheckHaltingStep(boolean is_async)">CheckHaltingStep</anchor>(boolean is_async)
    if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDESR.SS == '1' then
        // The STATUS code depends on how we arrived at the state where EDESR.SS == 1.
        if <a link="impl-shared.HaltingStep_DidNotStep.0" file="shared_pseudocode.xml" hover="function: boolean HaltingStep_DidNotStep()">HaltingStep_DidNotStep</a>() then
            <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_Step_NoSyndrome" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Step_NoSyndrome = '111011'">DebugHalt_Step_NoSyndrome</a>, is_async);
        elsif <a link="impl-shared.HaltingStep_SteppedEX.0" file="shared_pseudocode.xml" hover="function: boolean HaltingStep_SteppedEX()">HaltingStep_SteppedEX</a>() then
            <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_Step_Exclusive" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Step_Exclusive = '011111'">DebugHalt_Step_Exclusive</a>, is_async);
        else
            <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_Step_Normal" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_Step_Normal = '011011'">DebugHalt_Step_Normal</a>, is_async);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckOSUnlockCatch" mylink="shared.debug.haltingevents.CheckOSUnlockCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckOSUnlockCatch()
// ====================
// Called on unlocking the OS Lock to pend an OS Unlock Catch debug event

<anchor link="impl-shared.CheckOSUnlockCatch.0" hover="function: CheckOSUnlockCatch()">CheckOSUnlockCatch</anchor>()
    if ((<a link="impl-shared.HaveDoPD.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoPD()">HaveDoPD</a>() &amp;&amp; CTIDEVCTL.OSUCE == '1') ||
        (!<a link="impl-shared.HaveDoPD.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoPD()">HaveDoPD</a>() &amp;&amp; EDECR.OSUCE == '1')) then
        if !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then EDESR.OSUC = '1';</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckPendingExceptionCatch" mylink="shared.debug.haltingevents.CheckPendingExceptionCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckPendingExceptionCatch()
// ============================
// Check whether EDESR.EC has been set by an Exception Catch debug event.

<anchor link="impl-shared.CheckPendingExceptionCatch.1" hover="function: CheckPendingExceptionCatch(boolean is_async)">CheckPendingExceptionCatch</anchor>(boolean is_async)
    if <a link="impl-shared.Havev8p8Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p8Debug()">Havev8p8Debug</a>() &amp;&amp; <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDESR.EC == '1' then
        <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_ExceptionCatch" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_ExceptionCatch = '110111'">DebugHalt_ExceptionCatch</a>, is_async);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckPendingOSUnlockCatch" mylink="shared.debug.haltingevents.CheckPendingOSUnlockCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckPendingOSUnlockCatch()
// ===========================
// Check whether EDESR.OSUC has been set by an OS Unlock Catch debug event

<anchor link="impl-shared.CheckPendingOSUnlockCatch.0" hover="function: CheckPendingOSUnlockCatch()">CheckPendingOSUnlockCatch</anchor>()
    if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDESR.OSUC == '1' then
        boolean is_async = TRUE;
        <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_OSUnlockCatch" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_OSUnlockCatch = '100011'">DebugHalt_OSUnlockCatch</a>, is_async);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckPendingResetCatch" mylink="shared.debug.haltingevents.CheckPendingResetCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckPendingResetCatch()
// ========================
// Check whether EDESR.RC has been set by a Reset Catch debug event

<anchor link="impl-shared.CheckPendingResetCatch.0" hover="function: CheckPendingResetCatch()">CheckPendingResetCatch</anchor>()
    if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDESR.RC == '1' then
        boolean is_async = TRUE;
        <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_ResetCatch" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_ResetCatch = '100111'">DebugHalt_ResetCatch</a>, is_async);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckResetCatch" mylink="shared.debug.haltingevents.CheckResetCatch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckResetCatch()
// =================
// Called after reset

<anchor link="impl-shared.CheckResetCatch.0" hover="function: CheckResetCatch()">CheckResetCatch</anchor>()
    if (<a link="impl-shared.HaveDoPD.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoPD()">HaveDoPD</a>() &amp;&amp; CTIDEVCTL.RCE == '1') || (!<a link="impl-shared.HaveDoPD.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoPD()">HaveDoPD</a>() &amp;&amp; EDECR.RCE == '1') then
        EDESR.RC = '1';
        // If halting is allowed then halt immediately
        if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() then <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(<a link="DebugHalt_ResetCatch" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_ResetCatch = '100111'">DebugHalt_ResetCatch</a>);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckSoftwareAccessToDebugRegisters" mylink="shared.debug.haltingevents.CheckSoftwareAccessToDebugRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSoftwareAccessToDebugRegisters()
// =====================================
// Check for access to Breakpoint and Watchpoint registers.

<anchor link="impl-shared.CheckSoftwareAccessToDebugRegisters.0" hover="function: CheckSoftwareAccessToDebugRegisters()">CheckSoftwareAccessToDebugRegisters</anchor>()
    os_lock = (if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then DBGOSLSR.OSLK else OSLSR_EL1.OSLK);
    if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDSCR.TDA == '1' &amp;&amp; os_lock == '0' then
        <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(<a link="DebugHalt_SoftwareAccess" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_SoftwareAccess = '110011'">DebugHalt_SoftwareAccess</a>);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/CheckTRBEHalt" mylink="shared.debug.haltingevents.CheckTRBEHalt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckTRBEHalt()
// ===============

<anchor link="impl-shared.CheckTRBEHalt.0" hover="function: CheckTRBEHalt()">CheckTRBEHalt</anchor>()
    if !<a link="impl-shared.Havev8p9Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p9Debug()">Havev8p9Debug</a>() || !<a link="impl-shared.HaveFeatTRBEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatTRBEExt()">HaveFeatTRBEExt</a>() then
        return;

    if (<a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; <a link="impl-shared.TraceBufferEnabled.0" file="shared_pseudocode.xml" hover="function: boolean TraceBufferEnabled()">TraceBufferEnabled</a>() &amp;&amp;
        TRBSR_EL1.IRQ == '1' &amp;&amp; EDECR.TRBE == '1') then
        <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(<a link="DebugHalt_EDBGRQ" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_EDBGRQ = '010011'">DebugHalt_EDBGRQ</a>);</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/ExternalDebugRequest" mylink="shared.debug.haltingevents.ExternalDebugRequest" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalDebugRequest()
// ======================

<anchor link="impl-shared.ExternalDebugRequest.0" hover="function: ExternalDebugRequest()">ExternalDebugRequest</anchor>()
    if <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() then
        boolean is_async = TRUE;
        <a link="impl-shared.Halt.2" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason, boolean is_async)">Halt</a>(<a link="DebugHalt_EDBGRQ" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_EDBGRQ = '010011'">DebugHalt_EDBGRQ</a>, is_async);
    // Otherwise the CTI continues to assert the debug request until it is taken.</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/HaltingStep_DidNotStep" mylink="shared.debug.haltingevents.HaltingStep_DidNotStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaltingStep_DidNotStep()
// ========================
// Returns TRUE if the previously executed instruction was executed in the inactive state, that is,
// if it was not itself stepped.

boolean <anchor link="impl-shared.HaltingStep_DidNotStep.0" hover="function: boolean HaltingStep_DidNotStep()">HaltingStep_DidNotStep</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/HaltingStep_SteppedEX" mylink="shared.debug.haltingevents.HaltingStep_SteppedEX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaltingStep_SteppedEX()
// =======================
// Returns TRUE if the previously executed instruction was a Load-Exclusive class instruction
// executed in the active-not-pending state.

boolean <anchor link="impl-shared.HaltingStep_SteppedEX.0" hover="function: boolean HaltingStep_SteppedEX()">HaltingStep_SteppedEX</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/haltingevents/RunHaltingStep" mylink="shared.debug.haltingevents.RunHaltingStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RunHaltingStep()
// ================

<anchor link="impl-shared.RunHaltingStep.4" hover="function: RunHaltingStep(boolean exception_generated, bits(2) exception_target, boolean syscall, boolean reset)">RunHaltingStep</anchor>(boolean exception_generated, bits(2) exception_target, boolean syscall,
               boolean reset)
    // "exception_generated" is TRUE if the previous instruction generated a synchronous exception
    // or was cancelled by an asynchronous exception.
    //
    // if "exception_generated" is TRUE then "exception_target" is the target of the exception, and
    // "syscall" is TRUE if the exception is a synchronous exception where the preferred return
    // address is the instruction following that which generated the exception.
    //
    // "reset" is TRUE if exiting reset state into the highest EL.

    if reset then assert !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();             // Cannot come out of reset halted
    active = EDECR.SS == '1' &amp;&amp; !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();

    if active &amp;&amp; reset then                     // Coming out of reset with EDECR.SS set
        EDESR.SS = '1';
    elsif active &amp;&amp; <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() then
        boolean advance;
        if exception_generated &amp;&amp; exception_target == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            advance = syscall || <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>();
        else
            advance = TRUE;
        if advance then EDESR.SS = '1';

    return;</pstext>
    </ps>
    <ps name="shared/debug/interrupts/ExternalDebugInterruptsDisabled" mylink="shared.debug.interrupts.ExternalDebugInterruptsDisabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExternalDebugInterruptsDisabled()
// =================================
// Determine whether EDSCR disables interrupts routed to 'target'.

boolean <anchor link="impl-shared.ExternalDebugInterruptsDisabled.1" hover="function: boolean ExternalDebugInterruptsDisabled(bits(2) target)">ExternalDebugInterruptsDisabled</anchor>(bits(2) target)
    boolean int_dis;
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(target);
    if <a link="impl-shared.Havev8p4Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p4Debug()">Havev8p4Debug</a>() then
        if EDSCR.INTdis[0] == '1' then
            case ss of
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> int_dis = <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>();
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    int_dis = <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>();
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     int_dis = <a link="impl-shared.ExternalRealmInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRealmInvasiveDebugEnabled()">ExternalRealmInvasiveDebugEnabled</a>();
                when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>      int_dis = <a link="impl-shared.ExternalRootInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRootInvasiveDebugEnabled()">ExternalRootInvasiveDebugEnabled</a>();
        else
            int_dis = FALSE;
    else
        case target of
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
                int_dis = (EDSCR.INTdis == '11' &amp;&amp; <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>());
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
                int_dis = (EDSCR.INTdis IN {'1x'} &amp;&amp; <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>());
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                if ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
                    int_dis = (EDSCR.INTdis IN {'1x'} &amp;&amp; <a link="impl-shared.ExternalSecureInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureInvasiveDebugEnabled()">ExternalSecureInvasiveDebugEnabled</a>());
                else
                    int_dis = (EDSCR.INTdis != '00' &amp;&amp; <a link="impl-shared.ExternalInvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalInvasiveDebugEnabled()">ExternalInvasiveDebugEnabled</a>());
    return int_dis;</pstext>
    </ps>
    <ps name="shared/debug/pmu" mylink="shared.debug.pmu" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">array integer PMUEventAccumulator[0..30];  // Accumulates PMU events for a cycle

array boolean PMULastThresholdValue[0..30];// A record of the threshold result for each</pstext>
    </ps>
    <ps name="shared/debug/pmu/CYCLE_COUNTER_ID" mylink="shared.debug.pmu.CYCLE_COUNTER_ID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="CYCLE_COUNTER_ID" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</anchor> = 31;</pstext>
    </ps>
    <ps name="shared/debug/pmu/CheckForPMUOverflow" mylink="shared.debug.pmu.CheckForPMUOverflow" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckForPMUOverflow()
// =====================
// Signal Performance Monitors overflow IRQ and CTI overflow events.
// Called before each instruction is executed.

<anchor link="impl-shared.CheckForPMUOverflow.0" hover="function: CheckForPMUOverflow()">CheckForPMUOverflow</anchor>()
    boolean check_cnten  = FALSE;
    boolean check_e      = TRUE;
    boolean check_inten  = TRUE;
    boolean include_lo   = TRUE;
    boolean include_hi   = TRUE;
    boolean exclude_cyc  = FALSE;
    boolean exclude_sync = FALSE;

    boolean pmuirq = <a link="impl-shared.PMUOverflowCondition.7" file="shared_pseudocode.xml" hover="function: boolean PMUOverflowCondition(boolean check_e, boolean check_cnten, boolean check_inten, boolean include_hi, boolean include_lo, boolean exclude_cyc, boolean exclude_sync)">PMUOverflowCondition</a>(check_e, check_cnten, check_inten,
                                          include_hi, include_lo,
                                          exclude_cyc, exclude_sync);

    SetInterruptRequestLevel(<a link="InterruptID_PMUIRQ" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_PMUIRQ</a>,  if pmuirq then HIGH else LOW);
    CTI_SetEventLevel(<a link="CrossTriggerIn_PMUOverflow" file="shared_pseudocode.xml" hover="enumeration CrossTriggerIn  {CrossTriggerIn_CrossHalt,     CrossTriggerIn_PMUOverflow, CrossTriggerIn_RSVD2,         CrossTriggerIn_RSVD3, CrossTriggerIn_TraceExtOut0,  CrossTriggerIn_TraceExtOut1, CrossTriggerIn_TraceExtOut2,  CrossTriggerIn_TraceExtOut3}">CrossTriggerIn_PMUOverflow</a>, if pmuirq then HIGH else LOW);

    // The request remains set until the condition is cleared.
    // For example, an interrupt handler or cross-triggered event handler clears
    // the overflow status flag by writing to PMOVSCLR_EL0.

    if <a link="impl-shared.HavePMUv3p9.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p9()">HavePMUv3p9</a>() &amp;&amp; <a link="impl-shared.Havev8p9Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p9Debug()">Havev8p9Debug</a>() then
        if pmuirq &amp;&amp; <a link="impl-shared.HaltingAllowed.0" file="shared_pseudocode.xml" hover="function: boolean HaltingAllowed()">HaltingAllowed</a>() &amp;&amp; EDECR.PME == '1' then
            <a link="impl-shared.Halt.1" file="shared_pseudocode.xml" hover="function: Halt(bits(6) reason)">Halt</a>(<a link="DebugHalt_EDBGRQ" file="shared_pseudocode.xml" hover="constant bits(6) DebugHalt_EDBGRQ = '010011'">DebugHalt_EDBGRQ</a>);

    if <a link="impl-aarch64.ShouldBRBEFreeze.0" file="shared_pseudocode.xml" hover="function: boolean ShouldBRBEFreeze()">ShouldBRBEFreeze</a>() then
        <a link="impl-aarch64.BRBEFreeze.0" file="shared_pseudocode.xml" hover="function: BRBEFreeze()">BRBEFreeze</a>();

    return;</pstext>
    </ps>
    <ps name="shared/debug/pmu/CountPMUEvents" mylink="shared.debug.pmu.CountPMUEvents" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CountPMUEvents()
// ================
// Return TRUE if counter "idx" should count its event.
// For the cycle counter, idx == CYCLE_COUNTER_ID (32).
// For the instruction counter, idx == INSTRUCTION_COUNTER_ID (33).

boolean <anchor link="impl-shared.CountPMUEvents.1" hover="function: boolean CountPMUEvents(integer idx)">CountPMUEvents</anchor>(integer idx)
    constant integer num_counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();
    assert (idx == <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a> || idx &lt; num_counters ||
            (idx == <a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a> &amp;&amp; <a link="impl-shared.HavePMUv3ICNTR.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3ICNTR()">HavePMUv3ICNTR</a>()));

    boolean debug;
    boolean enabled;
    boolean prohibited;
    boolean filtered;
    boolean frozen;
    boolean resvd_for_el2;
    bit E;
    bit spme;
    bits(32) ovflws;

    // Event counting is disabled in Debug state
    debug = <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();

    // Software can reserve some counters for EL2
    resvd_for_el2 = <a link="impl-shared.PMUCounterIsHyp.1" file="shared_pseudocode.xml" hover="function: boolean PMUCounterIsHyp(integer n)">PMUCounterIsHyp</a>(idx);
    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();

    // Main enable controls
    case idx of
        when <a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>
            assert <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>();
            enabled = PMCR_EL0.E == '1' &amp;&amp; PMCNTENSET_EL0.F0 == '1';
        when <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>
            if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
                enabled = PMCR_EL0.E == '1' &amp;&amp; PMCNTENSET_EL0.C == '1';
            else
                enabled = PMCR.E == '1' &amp;&amp; PMCNTENSET.C == '1';
        otherwise
            if resvd_for_el2 then
                E = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then MDCR_EL2.HPME else HDCR.HPME;
            else
                E = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMCR_EL0.E else PMCR.E;

            if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
                enabled = E == '1' &amp;&amp; PMCNTENSET_EL0&lt;idx&gt; == '1';
            else
                enabled = E == '1' &amp;&amp; PMCNTENSET&lt;idx&gt; == '1';

    // Event counting is allowed unless it is prohibited by any rule below
    prohibited = FALSE;

    // Event counting in Secure state is prohibited if all of:
    // * EL3 is implemented
    // * One of the following is true:
    //   - EL3 is using AArch64, MDCR_EL3.SPME == 0, and either:
    //     - FEAT_PMUv3p7 is not implemented
    //     - MDCR_EL3.MPMX == 0
    //   - EL3 is using AArch32 and SDCR.SPME == 0
    // * Executing at EL0 using AArch32 and one of the following is true:
    //     - EL3 is using AArch32 and SDER.SUNIDEN == 0
    //     - EL3 is using AArch64, EL1 is using AArch32, and SDER32_EL3.SUNIDEN == 0
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            prohibited = MDCR_EL3.SPME == '0' &amp;&amp; <a link="impl-shared.HavePMUv3p7.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p7()">HavePMUv3p7</a>() &amp;&amp; MDCR_EL3.MPMX == '0';
        else
            prohibited = SDCR.SPME == '0';

        if prohibited &amp;&amp; PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
                prohibited = SDER.SUNIDEN == '0';
            elsif <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
                prohibited = SDER32_EL3.SUNIDEN == '0';

    // Event counting at EL3 is prohibited if all of:
    // * FEAT_PMUv3p7 is implemented
    // * EL3 is using AArch64
    // * One of the following is true:
    //   - MDCR_EL3.SPME == 0
    //   - PMNx is not reserved for EL2
    // * MDCR_EL3.MPMX == 1
    if !prohibited &amp;&amp; <a link="impl-shared.HavePMUv3p7.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p7()">HavePMUv3p7</a>() &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        prohibited = MDCR_EL3.MPMX == '1' &amp;&amp; (MDCR_EL3.SPME == '0' || !resvd_for_el2);

    // Event counting at EL2 is prohibited if all of:
    // * The HPMD Extension is implemented
    // * PMNx is not reserved for EL2
    // * EL2 is using AArch64 and MDCR_EL2.HPMD == 1 or EL2 is using AArch32 and HDCR.HPMD == 1
    if !prohibited &amp;&amp; PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; <a link="impl-shared.HaveHPMDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveHPMDExt()">HaveHPMDExt</a>() &amp;&amp; !resvd_for_el2 then
        hpmd = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then MDCR_EL2.HPMD else HDCR.HPMD;
        prohibited = hpmd == '1';

    // The IMPLEMENTATION DEFINED authentication interface might override software
    if prohibited &amp;&amp; !<a link="impl-shared.HaveNoSecurePMUDisableOverride.0" file="shared_pseudocode.xml" hover="function: boolean HaveNoSecurePMUDisableOverride()">HaveNoSecurePMUDisableOverride</a>() then
        prohibited = !<a link="impl-shared.ExternalSecureNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureNoninvasiveDebugEnabled()">ExternalSecureNoninvasiveDebugEnabled</a>();

    // Event counting might be frozen
    frozen = FALSE;

    // If FEAT_PMUv3p7 is implemented, event counting can be frozen
    if <a link="impl-shared.HavePMUv3p7.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p7()">HavePMUv3p7</a>() then
        bit FZ;
        if resvd_for_el2 then
            FZ = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then MDCR_EL2.HPMFZO else HDCR.HPMFZO;
        else
            FZ = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMCR_EL0.FZO else PMCR.FZO;

        frozen = (FZ == '1') &amp;&amp; <a link="impl-shared.HiLoPMUOverflow.1" file="shared_pseudocode.xml" hover="function: boolean HiLoPMUOverflow(boolean resvd_for_el2)">HiLoPMUOverflow</a>(resvd_for_el2);

    // PMCR_EL0.DP or PMCR.DP disables the cycle counter when event counting is prohibited
    if (prohibited || frozen) &amp;&amp; idx == <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a> then
        dp = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMCR_EL0.DP else PMCR.DP;
        enabled = enabled &amp;&amp; dp == '0';
        // Otherwise whether event counting is prohibited does not affect the cycle counter
        prohibited = FALSE;
        frozen = FALSE;

    // Freeze-on-SPE event is not implemented.

    // If FEAT_PMUv3p5 is implemented, cycle counting can be prohibited.
    // This is not overridden by PMCR_EL0.DP.
    if <a link="impl-shared.HavePMUv3p5.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p5()">HavePMUv3p5</a>() &amp;&amp; idx == <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a> then
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
            sccd = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then MDCR_EL3.SCCD else SDCR.SCCD;
            if sccd == '1' then
                prohibited = TRUE;

        if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
            hccd = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then MDCR_EL2.HCCD else HDCR.HCCD;
            if hccd == '1' then
                prohibited = TRUE;

    // If FEAT_PMUv3p7 is implemented, cycle counting an be prohibited at EL3.
    // This is not overriden by PMCR_EL0.DP.
    if <a link="impl-shared.HavePMUv3p7.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3p7()">HavePMUv3p7</a>() &amp;&amp; idx == <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a> then
        if PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; MDCR_EL3.MCCD == '1' then
            prohibited = TRUE;

    // Event counting can be filtered by the {P, U, NSK, NSU, NSH, M, SH, RLK, RLU, RLH} bits
    bits(32) filter;
    case idx of
        when <a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>
            filter = PMICFILTR_EL0&lt;31:0&gt;;
        when <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>
            filter = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMCCFILTR_EL0&lt;31:0&gt; else PMCCFILTR;
        otherwise
            filter = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMEVTYPER_EL0[idx]&lt;31:0&gt; else PMEVTYPER[idx];

    P   = filter&lt;31&gt;;
    U   = filter&lt;30&gt;;
    NSK = if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then filter&lt;29&gt; else '0';
    NSU = if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then filter&lt;28&gt; else '0';
    NSH = if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then filter&lt;27&gt; else '0';
    M   = if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then filter&lt;26&gt; else '0';
    SH  = if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then filter&lt;24&gt; else '0';
    RLK = if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then filter&lt;22&gt; else '0';
    RLU = if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then filter&lt;21&gt; else '0';
    RLH = if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then filter&lt;20&gt; else '0';

    ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    case PSTATE.EL of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            case ss of
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> filtered = U != NSU;
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    filtered = U == '1';
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     filtered = U != RLU;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            case ss of
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> filtered = P != NSK;
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    filtered = P == '1';
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     filtered = P != RLK;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            case ss of
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> filtered = NSH == '0';
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    filtered = NSH == SH;
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     filtered = NSH == RLH;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
                filtered = M != P;
            else
                filtered = P == '1';

    return !debug &amp;&amp; enabled &amp;&amp; !prohibited &amp;&amp; !filtered &amp;&amp; !frozen;</pstext>
    </ps>
    <ps name="shared/debug/pmu/GetNumEventCounters" mylink="shared.debug.pmu.GetNumEventCounters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetNumEventCounters()
// =====================
// Returns the number of event counters implemented. This is indicated to software at the
// highest Exception level by PMCR.N in AArch32 state, and PMCR_EL0.N in AArch64 state.

integer <anchor link="impl-shared.GetNumEventCounters.0" hover="function: integer GetNumEventCounters()">GetNumEventCounters</anchor>()
    return integer IMPLEMENTATION_DEFINED "Number of event counters";</pstext>
    </ps>
    <ps name="shared/debug/pmu/HasElapsed64Cycles" mylink="shared.debug.pmu.HasElapsed64Cycles" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HasElapsed64Cycles()
// ====================
// Returns TRUE if 64 cycles have elapsed between the last count, and FALSE otherwise.

boolean <anchor link="impl-shared.HasElapsed64Cycles.0" hover="function: boolean HasElapsed64Cycles()">HasElapsed64Cycles</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/pmu/HiLoPMUOverflow" mylink="shared.debug.pmu.HiLoPMUOverflow" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HiLoPMUOverflow()
// =================

boolean <anchor link="impl-shared.HiLoPMUOverflow.1" hover="function: boolean HiLoPMUOverflow(boolean resvd_for_el2)">HiLoPMUOverflow</anchor>(boolean resvd_for_el2)
    boolean check_cnten  = FALSE;
    boolean check_e      = FALSE;
    boolean check_inten  = FALSE;
    boolean include_lo   = !resvd_for_el2;
    boolean include_hi   = resvd_for_el2;
    boolean exclude_cyc  = FALSE;
    boolean exclude_sync = FALSE;

    boolean overflow = <a link="impl-shared.PMUOverflowCondition.7" file="shared_pseudocode.xml" hover="function: boolean PMUOverflowCondition(boolean check_e, boolean check_cnten, boolean check_inten, boolean include_hi, boolean include_lo, boolean exclude_cyc, boolean exclude_sync)">PMUOverflowCondition</a>(check_e, check_cnten, check_inten,
                                            include_hi, include_lo,
                                            exclude_cyc, exclude_sync);
    return overflow;</pstext>
    </ps>
    <ps name="shared/debug/pmu/INSTRUCTION_COUNTER_ID" mylink="shared.debug.pmu.INSTRUCTION_COUNTER_ID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="INSTRUCTION_COUNTER_ID" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</anchor> = 32;</pstext>
    </ps>
    <ps name="shared/debug/pmu/IncrementInstructionCounter" mylink="shared.debug.pmu.IncrementInstructionCounter" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IncrementInstructionCounter()
// =============================
// Increment the instruction counter and possibly set overflow bits.

<anchor link="impl-shared.IncrementInstructionCounter.1" hover="function: IncrementInstructionCounter(integer increment)">IncrementInstructionCounter</anchor>(integer increment)
    if <a link="impl-shared.CountPMUEvents.1" file="shared_pseudocode.xml" hover="function: boolean CountPMUEvents(integer idx)">CountPMUEvents</a>(<a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>) then
        integer old_value = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMICNTR_EL0);
        integer new_value = old_value + increment;
        PMICNTR_EL0       = new_value&lt;63:0&gt;;

        // The effective value of PMCR_EL0.LP is '1' for the instruction counter
        if old_value&lt;64&gt; != new_value&lt;64&gt; then
            PMOVSSET_EL0.F0 = '1';
            PMOVSCLR_EL0.F0 = '1';</pstext>
    </ps>
    <ps name="shared/debug/pmu/PMUCountValue" mylink="shared.debug.pmu.PMUCountValue" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PMUCountValue()
// ===============
// Implements the PMU threshold function, if implemented.
// Returns the value to increment event counter 'n' by.
// 'Vb' is the base value of the event that event counter 'n' is configured to count.

integer <anchor link="impl-shared.PMUCountValue.2" hover="function: integer PMUCountValue(integer n, integer Vb)">PMUCountValue</anchor>(integer n, integer Vb)
    if !<a link="impl-shared.HavePMUv3TH.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3TH()">HavePMUv3TH</a>() || !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        return Vb;

    integer T = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PMEVTYPER_EL0[n].TH);
    boolean Vc;

    case PMEVTYPER_EL0[n].TC&lt;2:1&gt; of
        when '00' Vc = (Vb != T);       // Disabled or not-equal
        when '01' Vc = (Vb == T);       // Equals
        when '10' Vc = (Vb &gt;= T);       // Greater-than-or-equal
        when '11' Vc = (Vb &lt;  T);       // Less-than

    if PMEVTYPER_EL0[n].TC&lt;0&gt; == '0' then
        Vt = (if Vc then Vb else 0);    // Count values
    else
        Vt = (if Vc then 1 else 0);     // Count matches

    integer V;
    if <a link="impl-shared.HavePMUv3EDGE.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3EDGE()">HavePMUv3EDGE</a>() &amp;&amp; PMEVTYPER_EL0[n].TE == '1' then
        Vp = PMULastThresholdValue[n];

        tc = PMEVTYPER_EL0[n].TC&lt;1:0&gt;;
        // Check for reserved case
        if tc == '00' then
            <a link="Constraint" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</a> c;
            (c, tc) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESTC" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTC</a>, 2);
            if c == <a link="Constraint_DISABLED" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</a> then tc = '00';
            // Otherwise the value returned by ConstrainUnpredictableBits
            // must be a not-reserved value.

        case tc of
            when '00' V = Vt;                           // Reserved - treat as disabled
            when '10' V = (if Vp != Vc  then 1 else 0); // Both edges
            when 'x1' V = (if !Vp &amp;&amp; Vc then 1 else 0); // Single edge
    else
        V = Vt;

    PMULastThresholdValue[n] = Vc;

    return V;</pstext>
    </ps>
    <ps name="shared/debug/pmu/PMUCounterIsHyp" mylink="shared.debug.pmu.PMUCounterIsHyp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PMUCounterIsHyp()
// =================
// Returns TRUE if a counter is reserved for use by EL2, FALSE otherwise.

boolean <anchor link="impl-shared.PMUCounterIsHyp.1" hover="function: boolean PMUCounterIsHyp(integer n)">PMUCounterIsHyp</anchor>(integer n)
    if n == <a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a> then return FALSE;
    if n == <a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a> then return FALSE;

    boolean resvd_for_el2;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then     // Software can reserve some event counters for EL2
        bits(5) hpmn_bits = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then MDCR_EL2.HPMN else HDCR.HPMN;
        resvd_for_el2 = n &gt;= <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(hpmn_bits);
        if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(hpmn_bits) &gt; <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>() || (!<a link="impl-shared.HaveFeatHPMN0.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatHPMN0()">HaveFeatHPMN0</a>() &amp;&amp; <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(hpmn_bits)) then
            resvd_for_el2 = <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_CounterReservedForEL2" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_CounterReservedForEL2</a>);
    else
        resvd_for_el2 = FALSE;

    return resvd_for_el2;</pstext>
    </ps>
    <ps name="shared/debug/pmu/PMUCounterMask" mylink="shared.debug.pmu.PMUCounterMask" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PMUCounterMask()
// ================
// Return bitmask of accessible PMU counters.

bits(64) <anchor link="impl-shared.PMUCounterMask.0" hover="function: bits(64) PMUCounterMask()">PMUCounterMask</anchor>()
    integer n;
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        n = <a link="AArch32.GetNumEventCountersAccessible.0" file="shared_pseudocode.xml" hover="function: integer AArch32.GetNumEventCountersAccessible()">AArch32.GetNumEventCountersAccessible</a>();
    else
        n = <a link="AArch64.GetNumEventCountersAccessible.0" file="shared_pseudocode.xml" hover="function: integer AArch64.GetNumEventCountersAccessible()">AArch64.GetNumEventCountersAccessible</a>();

    mask = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(n), 64);
    mask&lt;<a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>&gt; = '1';
    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; <a link="impl-shared.HavePMUv3ICNTR.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3ICNTR()">HavePMUv3ICNTR</a>() then mask&lt;<a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>&gt; = '1';
    return mask;</pstext>
    </ps>
    <ps name="shared/debug/pmu/PMUEvent" mylink="shared.debug.pmu.PMUEvent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PMUEvent()
// ==========
// Generate a PMU event. By default, increment by 1.

<anchor link="impl-shared.PMUEvent.1" hover="function: PMUEvent(bits(16) event)">PMUEvent</anchor>(bits(16) event)
    <a link="impl-shared.PMUEvent.2" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event, integer increment)">PMUEvent</a>(event, 1);

// PMUEvent()
// ==========
// Accumulate a PMU Event.

<anchor link="impl-shared.PMUEvent.2" hover="function: PMUEvent(bits(16) event, integer increment)">PMUEvent</anchor>(bits(16) event, integer increment)
    if SPESampleInFlight then
        <a link="impl-aarch64.SPEEvent.1" file="shared_pseudocode.xml" hover="function: SPEEvent(bits(16) event)">SPEEvent</a>(event);
    integer counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();
    if counters != 0 then
        for idx = 0 to counters - 1
            <a link="impl-shared.PMUEvent.3" file="shared_pseudocode.xml" hover="function: PMUEvent(bits(16) event, integer increment, integer idx)">PMUEvent</a>(event, increment, idx);

    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; <a link="impl-shared.HavePMUv3ICNTR.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3ICNTR()">HavePMUv3ICNTR</a>() &amp;&amp; event == PMU_EVENT_INST_RETIRED then
        <a link="impl-shared.IncrementInstructionCounter.1" file="shared_pseudocode.xml" hover="function: IncrementInstructionCounter(integer increment)">IncrementInstructionCounter</a>(increment);

// PMUEvent()
// ==========
// Accumulate a PMU Event for a specific event counter.

<anchor link="impl-shared.PMUEvent.3" hover="function: PMUEvent(bits(16) event, integer increment, integer idx)">PMUEvent</anchor>(bits(16) event, integer increment, integer idx)
    if !<a link="impl-shared.HavePMUv3.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3()">HavePMUv3</a>() then
        return;

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        if PMEVTYPER[idx].evtCount == event then
            PMUEventAccumulator[idx] = PMUEventAccumulator[idx] + increment;
    else
        if PMEVTYPER_EL0[idx].evtCount == event then
            PMUEventAccumulator[idx] = PMUEventAccumulator[idx] + increment;</pstext>
    </ps>
    <ps name="shared/debug/pmu/PMUOverflowCondition" mylink="shared.debug.pmu.PMUOverflowCondition" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PMUOverflowCondition()
// ======================
// Checks for PMU overflow under certain parameter conditions
// If 'check_e' is TRUE, then check the applicable one of PMCR_EL0.E and MDCR_EL2.HPME.
// If 'check_cnten' is TRUE, then check the applicable PMCNTENCLR_EL0 bit.
// If 'check_cnten' is TRUE, then check the applicable PMINTENCLR_EL1 bit.
// If 'include_lo' is TRUE, then check counters in the set [0..(HPMN-1)], CCNTR
//     and ICNTR, unless excluded by other flags.
// If 'include_hi' is TRUE, then check counters in the set [HPMN..(N-1)].
// If 'exclude_cyc' is TRUE, then CCNTR is NOT checked.
// If 'exclude_sync' is TRUE, then counters in synchronous mode are NOT checked.

boolean <anchor link="impl-shared.PMUOverflowCondition.7" hover="function: boolean PMUOverflowCondition(boolean check_e, boolean check_cnten, boolean check_inten, boolean include_hi, boolean include_lo, boolean exclude_cyc, boolean exclude_sync)">PMUOverflowCondition</anchor>(boolean check_e, boolean check_cnten,
                             boolean check_inten,
                             boolean include_hi, boolean include_lo,
                             boolean exclude_cyc, boolean exclude_sync)
    integer counters = <a link="impl-shared.GetNumEventCounters.0" file="shared_pseudocode.xml" hover="function: integer GetNumEventCounters()">GetNumEventCounters</a>();

    bits(64) ovsf;

    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        ovsf = PMOVSCLR_EL0;

        // Remove unimplemented counters - these fields are RES0
        ovsf&lt;63:33&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(31);

        if !<a link="impl-shared.HavePMUv3ICNTR.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3ICNTR()">HavePMUv3ICNTR</a>() then
            ovsf&lt;<a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>&gt; = '0';
    else
        ovsf = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(PMOVSR, 64);

    if counters &lt; 31 then
        ovsf&lt;30:counters&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(31-counters);

    for idx = 0 to counters - 1
        bit E;

        boolean is_hyp = <a link="impl-shared.PMUCounterIsHyp.1" file="shared_pseudocode.xml" hover="function: boolean PMUCounterIsHyp(integer n)">PMUCounterIsHyp</a>(idx);
        if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
            E = (if is_hyp then MDCR_EL2.HPME else PMCR_EL0.E);
        else
            E = (if is_hyp then HDCR.HPME else PMCR.E);

        if check_e then
            ovsf&lt;idx&gt; = ovsf&lt;idx&gt; AND E;

        if (!is_hyp &amp;&amp; !include_lo) || (is_hyp &amp;&amp; !include_hi) then
            ovsf&lt;idx&gt; = '0';

    // Cycle counter
    if exclude_cyc || !include_lo then
        ovsf&lt;<a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>&gt; = '0';

    if check_e then
        ovsf&lt;<a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>&gt; = ovsf&lt;<a link="CYCLE_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer CYCLE_COUNTER_ID = 31">CYCLE_COUNTER_ID</a>&gt; AND PMCR_EL0.E;

    // Instruction counter
    if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; <a link="impl-shared.HavePMUv3ICNTR.0" file="shared_pseudocode.xml" hover="function: boolean HavePMUv3ICNTR()">HavePMUv3ICNTR</a>() then
        if !include_lo then
            ovsf&lt;<a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>&gt; = '0';
        if check_e then
            ovsf&lt;<a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>&gt; = ovsf&lt;<a link="INSTRUCTION_COUNTER_ID" file="shared_pseudocode.xml" hover="constant integer INSTRUCTION_COUNTER_ID = 32">INSTRUCTION_COUNTER_ID</a>&gt; AND PMCR_EL0.E;

    if check_cnten then
        bits(64) cnten = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMCNTENCLR_EL0 else <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(PMCNTENCLR, 64);
        ovsf = ovsf AND cnten;

    if check_inten then
        bits(64) inten = if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then PMINTENCLR_EL1 else <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(PMINTENCLR, 64);
        ovsf = ovsf AND inten;

    return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(ovsf);</pstext>
    </ps>
    <ps name="shared/debug/samplebasedprofiling/CreatePCSample" mylink="shared.debug.samplebasedprofiling.CreatePCSample" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreatePCSample()
// ================

<anchor link="impl-shared.CreatePCSample.0" hover="function: CreatePCSample()">CreatePCSample</anchor>()
    // In a simple sequential execution of the program, CreatePCSample is executed each time the PE
    // executes an instruction that can be sampled. An implementation is not constrained such that
    // reads of EDPCSRlo return the current values of PC, etc.

    pc_sample.valid = <a link="impl-shared.ExternalNoninvasiveDebugAllowed.0" file="shared_pseudocode.xml" hover="function: boolean ExternalNoninvasiveDebugAllowed()">ExternalNoninvasiveDebugAllowed</a>() &amp;&amp; !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>();
    pc_sample.pc = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
    pc_sample.el = PSTATE.EL;
    pc_sample.rw = if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then '0' else '1';
    pc_sample.ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    pc_sample.contextidr = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then CONTEXTIDR else CONTEXTIDR_EL1&lt;31:0&gt;;
    pc_sample.has_el2 = PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    if pc_sample.has_el2 then
        if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            pc_sample.vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR.VMID, 16);
        elsif !<a link="impl-shared.Have16bitVMID.0" file="shared_pseudocode.xml" hover="function: boolean Have16bitVMID()">Have16bitVMID</a>() || VTCR_EL2.VS == '0' then
            pc_sample.vmid = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(VTTBR_EL2.VMID&lt;7:0&gt;, 16);
        else
            pc_sample.vmid = VTTBR_EL2.VMID;
        if (<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() || <a link="impl-shared.HaveV82Debug.0" file="shared_pseudocode.xml" hover="function: boolean HaveV82Debug()">HaveV82Debug</a>()) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            pc_sample.contextidr_el2 = CONTEXTIDR_EL2&lt;31:0&gt;;
        else
            pc_sample.contextidr_el2 = bits(32) UNKNOWN;
        pc_sample.el0h = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>();
    return;</pstext>
    </ps>
    <ps name="shared/debug/samplebasedprofiling/EDPCSRlo" mylink="shared.debug.samplebasedprofiling.EDPCSRlo" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EDPCSRlo[] (read)
// =================

bits(32) <anchor link="impl-shared.EDPCSRlo.read.1" hover="accessor: bits(32) EDPCSRlo[boolean memory_mapped]">EDPCSRlo</anchor>[boolean memory_mapped]

    if EDPRSR&lt;6:5,0&gt; != '001' then                      // Check DLK, OSLK and PU bits
        IMPLEMENTATION_DEFINED "generate error response";
        return bits(32) UNKNOWN;

    // The Software lock is OPTIONAL.
    update = !memory_mapped || EDLSR.SLK == '0';        // Software locked: no side-effects

    bits(32) sample;
    if pc_sample.valid then
        sample = pc_sample.pc&lt;31:0&gt;;
        if update then
            if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; EDSCR.SC2 == '1' then
                EDPCSRhi.PC = (if pc_sample.rw == '0' then <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24) else pc_sample.pc&lt;55:32&gt;);
                EDPCSRhi.EL = pc_sample.el;
                EDPCSRhi.NS = (if pc_sample.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then '0' else '1');
            else
                EDPCSRhi = (if pc_sample.rw == '0' then <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(32) else pc_sample.pc&lt;63:32&gt;);
            EDCIDSR = pc_sample.contextidr;
            if (<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() || <a link="impl-shared.HaveV82Debug.0" file="shared_pseudocode.xml" hover="function: boolean HaveV82Debug()">HaveV82Debug</a>()) &amp;&amp; EDSCR.SC2 == '1' then
                EDVIDSR = (if pc_sample.has_el2 then pc_sample.contextidr_el2
                           else bits(32) UNKNOWN);
            else
                EDVIDSR.VMID = (if pc_sample.has_el2 &amp;&amp; pc_sample.el IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>,<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>}
                                then pc_sample.vmid else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16));
                EDVIDSR.NS = (if pc_sample.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then '0' else '1');
                EDVIDSR.E2 = (if pc_sample.el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then '1' else '0');
                EDVIDSR.E3 = (if pc_sample.el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then '1' else '0') AND pc_sample.rw;
                // The conditions for setting HV are not specified if PCSRhi is zero.
                // An example implementation may be "pc_sample.rw".
                EDVIDSR.HV = (if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(EDPCSRhi) then '1'
                              else bit IMPLEMENTATION_DEFINED "0 or 1");
    else
        sample = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(32);
        if update then
            EDPCSRhi = bits(32) UNKNOWN;
            EDCIDSR = bits(32) UNKNOWN;
            EDVIDSR = bits(32) UNKNOWN;

    return sample;</pstext>
    </ps>
    <ps name="shared/debug/samplebasedprofiling/PCSample" mylink="shared.debug.samplebasedprofiling.PCSample" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions"><a link="PCSample" file="shared_pseudocode.xml" hover="type PCSample is ( boolean valid, bits(64) pc, bits(2) el, bit rw, SecurityState ss, boolean has_el2, bits(32) contextidr, bits(32) contextidr_el2, boolean el0h, bits(16) vmid )">PCSample</a> pc_sample;

// PCSample
// ========

type <anchor link="PCSample" hover="type PCSample is ( boolean valid, bits(64) pc, bits(2) el, bit rw, SecurityState ss, boolean has_el2, bits(32) contextidr, bits(32) contextidr_el2, boolean el0h, bits(16) vmid )">PCSample</anchor> is (
    boolean valid,
    bits(64) pc,
    bits(2) el,
    bit rw,
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss,
    boolean has_el2,
    bits(32) contextidr,
    bits(32) contextidr_el2,
    boolean el0h,
    bits(16) vmid
)</pstext>
    </ps>
    <ps name="shared/debug/samplebasedprofiling/PMPCSR" mylink="shared.debug.samplebasedprofiling.PMPCSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PMPCSR[] (read)
// ===============

bits(32) <anchor link="impl-shared.PMPCSR.read.1" hover="accessor: bits(32) PMPCSR[boolean memory_mapped]">PMPCSR</anchor>[boolean memory_mapped]
    if EDPRSR&lt;6:5,0&gt; != '001' then                      // Check DLK, OSLK and PU bits
        IMPLEMENTATION_DEFINED "generate error response";
        return bits(32) UNKNOWN;

    // The Software lock is OPTIONAL.
    update = !memory_mapped || PMLSR.SLK == '0';        // Software locked: no side-effects

    bits(32) sample;
    if pc_sample.valid then
        sample = pc_sample.pc&lt;31:0&gt;;
        if update then
            PMPCSR&lt;55:32&gt; = (if pc_sample.rw == '0' then <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24) else pc_sample.pc&lt;55:32&gt;);
            PMPCSR.EL = pc_sample.el;
            if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
                case pc_sample.ss of
                    when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
                        PMPCSR.NSE = '0'; PMPCSR.NS = '0';
                    when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
                        PMPCSR.NSE = '0'; PMPCSR.NS = '1';
                    when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>
                        PMPCSR.NSE = '1'; PMPCSR.NS = '0';
                    when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
                        PMPCSR.NSE = '1'; PMPCSR.NS = '1';
            else
                PMPCSR.NS = (if pc_sample.ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then '0' else '1');

            PMCID1SR = pc_sample.contextidr;
            PMCID2SR = if pc_sample.has_el2 then pc_sample.contextidr_el2 else bits(32) UNKNOWN;

            PMVIDSR.VMID = (if pc_sample.has_el2 &amp;&amp; pc_sample.el IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>,<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>} &amp;&amp; !pc_sample.el0h
                            then pc_sample.vmid else bits(16) UNKNOWN);
    else
        sample = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(32);
        if update then
            PMPCSR&lt;55:32&gt;  = bits(24) UNKNOWN;
            PMPCSR.EL = bits(2) UNKNOWN;
            PMPCSR.NS = bit UNKNOWN;

            PMCID1SR = bits(32) UNKNOWN;
            PMCID2SR = bits(32) UNKNOWN;

            PMVIDSR.VMID = bits(16) UNKNOWN;

    return sample;</pstext>
    </ps>
    <ps name="shared/debug/softwarestep/CheckSoftwareStep" mylink="shared.debug.softwarestep.CheckSoftwareStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CheckSoftwareStep()
// ===================
// Take a Software Step exception if in the active-pending state

<anchor link="impl-shared.CheckSoftwareStep.0" hover="function: CheckSoftwareStep()">CheckSoftwareStep</anchor>()

    // Other self-hosted debug functions will call AArch32.GenerateDebugExceptions() if called from
    // AArch32 state. However, because Software Step is only active when the debug target Exception
    // level is using AArch64, CheckSoftwareStep only calls AArch64.GenerateDebugExceptions().
    step_enabled = (!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="impl-shared.DebugTarget.0" file="shared_pseudocode.xml" hover="function: bits(2) DebugTarget()">DebugTarget</a>()) &amp;&amp; <a link="AArch64.GenerateDebugExceptions.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptions()">AArch64.GenerateDebugExceptions</a>() &amp;&amp;
                    MDSCR_EL1.SS == '1');
    if step_enabled &amp;&amp; PSTATE.SS == '0' then
        <a link="AArch64.SoftwareStepException.0" file="shared_pseudocode.xml" hover="function: AArch64.SoftwareStepException()">AArch64.SoftwareStepException</a>();</pstext>
    </ps>
    <ps name="shared/debug/softwarestep/DebugExceptionReturnSS" mylink="shared.debug.softwarestep.DebugExceptionReturnSS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugExceptionReturnSS()
// ========================
// Returns value to write to PSTATE.SS on an exception return or Debug state exit.

bit <anchor link="impl-shared.DebugExceptionReturnSS.1" hover="function: bit DebugExceptionReturnSS(bits(N) spsr)">DebugExceptionReturnSS</anchor>(bits(N) spsr)
    assert <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() || <a link="impl-shared.Restarting.0" file="shared_pseudocode.xml" hover="function: boolean Restarting()">Restarting</a>() ||  PSTATE.EL != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;

    boolean enabled_at_source;
    if <a link="impl-shared.Restarting.0" file="shared_pseudocode.xml" hover="function: boolean Restarting()">Restarting</a>() then
        enabled_at_source = FALSE;
    elsif <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        enabled_at_source = <a link="AArch32.GenerateDebugExceptions.0" file="shared_pseudocode.xml" hover="function: boolean AArch32.GenerateDebugExceptions()">AArch32.GenerateDebugExceptions</a>();
    else
        enabled_at_source = <a link="AArch64.GenerateDebugExceptions.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptions()">AArch64.GenerateDebugExceptions</a>();

    boolean valid;
    bits(2) dest_el;
    if <a link="impl-shared.IllegalExceptionReturn.1" file="shared_pseudocode.xml" hover="function: boolean IllegalExceptionReturn(bits(N) spsr)">IllegalExceptionReturn</a>(spsr) then
        dest_el = PSTATE.EL;
    else
        (valid, dest_el) = <a link="impl-shared.ELFromSPSR.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromSPSR(bits(N) spsr)">ELFromSPSR</a>(spsr);  assert valid;

    dest_ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(dest_el);
    bit mask;
    boolean enabled_at_dest;
    dest_using_32 = (if dest_el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then spsr&lt;4&gt; == '1' else <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(dest_el));
    if dest_using_32 then
        enabled_at_dest = <a link="AArch32.GenerateDebugExceptionsFrom.2" file="shared_pseudocode.xml" hover="function: boolean AArch32.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state)">AArch32.GenerateDebugExceptionsFrom</a>(dest_el, dest_ss);
    else
        mask = spsr&lt;9&gt;;
        enabled_at_dest = <a link="AArch64.GenerateDebugExceptionsFrom.3" file="shared_pseudocode.xml" hover="function: boolean AArch64.GenerateDebugExceptionsFrom(bits(2) from_el, SecurityState from_state, bit mask)">AArch64.GenerateDebugExceptionsFrom</a>(dest_el, dest_ss, mask);

    ELd = <a link="impl-shared.DebugTargetFrom.1" file="shared_pseudocode.xml" hover="function: bits(2) DebugTargetFrom(SecurityState from_state)">DebugTargetFrom</a>(dest_ss);
    bit SS_bit;
    if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(ELd) &amp;&amp; MDSCR_EL1.SS == '1' &amp;&amp; !enabled_at_source &amp;&amp; enabled_at_dest then
        SS_bit = spsr&lt;21&gt;;
    else
        SS_bit = '0';

    return SS_bit;</pstext>
    </ps>
    <ps name="shared/debug/softwarestep/SSAdvance" mylink="shared.debug.softwarestep.SSAdvance" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SSAdvance()
// ===========
// Advance the Software Step state machine.

<anchor link="impl-shared.SSAdvance.0" hover="function: SSAdvance()">SSAdvance</anchor>()

    // A simpler implementation of this function just clears PSTATE.SS to zero regardless of the
    // current Software Step state machine. However, this check is made to illustrate that the
    // processor only needs to consider advancing the state machine from the active-not-pending
    // state.
    target = <a link="impl-shared.DebugTarget.0" file="shared_pseudocode.xml" hover="function: bits(2) DebugTarget()">DebugTarget</a>();
    step_enabled = !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(target) &amp;&amp; MDSCR_EL1.SS == '1';
    active_not_pending = step_enabled &amp;&amp; PSTATE.SS == '1';

    if active_not_pending then PSTATE.SS = '0';

    return;</pstext>
    </ps>
    <ps name="shared/debug/softwarestep/SoftwareStep_DidNotStep" mylink="shared.debug.softwarestep.SoftwareStep_DidNotStep" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SoftwareStep_DidNotStep()
// =========================
// Returns TRUE if the previously executed instruction was executed in the
// inactive state, that is, if it was not itself stepped.
// Might return TRUE or FALSE if the previously executed instruction was an ISB
// or ERET executed in the active-not-pending state, or if another exception
// was taken before the Software Step exception.  Returns FALSE otherwise,
// indicating that the previously executed instruction was executed in the
// active-not-pending state, that is, the instruction was stepped.

boolean <anchor link="impl-shared.SoftwareStep_DidNotStep.0" hover="function: boolean SoftwareStep_DidNotStep()">SoftwareStep_DidNotStep</anchor>();</pstext>
    </ps>
    <ps name="shared/debug/softwarestep/SoftwareStep_SteppedEX" mylink="shared.debug.softwarestep.SoftwareStep_SteppedEX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SoftwareStep_SteppedEX()
// ========================
// Returns a value that describes the previously executed instruction. The
// result is valid only if SoftwareStep_DidNotStep() returns FALSE.
// Might return TRUE or FALSE if the instruction was an AArch32 LDREX or LDAEX
// that failed its condition code test.  Otherwise returns TRUE if the
// instruction was a Load-Exclusive class instruction, and FALSE if the
// instruction was not a Load-Exclusive class instruction.
boolean <anchor link="impl-shared.SoftwareStep_SteppedEX.0" hover="function: boolean SoftwareStep_SteppedEX()">SoftwareStep_SteppedEX</anchor>();</pstext>
    </ps>
    <ps name="shared/exceptions/exceptions/ConditionSyndrome" mylink="shared.exceptions.exceptions.ConditionSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConditionSyndrome()
// ===================
// Return CV and COND fields of instruction syndrome

bits(5) <anchor link="impl-shared.ConditionSyndrome.0" hover="function: bits(5) ConditionSyndrome()">ConditionSyndrome</anchor>()

    bits(5) syndrome;

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        cond = <a link="AArch32.CurrentCond.0" file="shared_pseudocode.xml" hover="function: bits(4) AArch32.CurrentCond()">AArch32.CurrentCond</a>();
        if PSTATE.T == '0' then             // A32
            syndrome&lt;4&gt; = '1';
            // A conditional A32 instruction that is known to pass its condition code check
            // can be presented either with COND set to 0xE, the value for unconditional, or
            // the COND value held in the instruction.
            if <a link="impl-shared.ConditionHolds.1" file="shared_pseudocode.xml" hover="function: boolean ConditionHolds(bits(4) cond)">ConditionHolds</a>(cond) &amp;&amp; <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ESRCONDPASS" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ESRCONDPASS</a>) then
                syndrome&lt;3:0&gt; = '1110';
            else
                syndrome&lt;3:0&gt; = cond;
        else                                // T32
            // When a T32 instruction is trapped, it is IMPLEMENTATION DEFINED whether:
            //  * CV set to 0 and COND is set to an UNKNOWN value
            //  * CV set to 1 and COND is set to the condition code for the condition that
            //    applied to the instruction.
            if boolean IMPLEMENTATION_DEFINED "Condition valid for trapped T32" then
                syndrome&lt;4&gt; = '1';
                syndrome&lt;3:0&gt; = cond;
            else
                syndrome&lt;4&gt; = '0';
                syndrome&lt;3:0&gt; = bits(4) UNKNOWN;
    else
        syndrome&lt;4&gt; = '1';
        syndrome&lt;3:0&gt; = '1110';

    return syndrome;</pstext>
    </ps>
    <ps name="shared/exceptions/exceptions/Exception" mylink="shared.exceptions.exceptions.Exception" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Exception
// =========
// Classes of exception.

enumeration <anchor link="Exception" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</anchor> {
        <anchor link="Exception_Uncategorized" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Uncategorized</anchor>,        // Uncategorized or unknown reason
        <anchor link="Exception_WFxTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_WFxTrap</anchor>,              // Trapped WFI or WFE instruction
        <anchor link="Exception_CP15RTTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RTTrap</anchor>,           // Trapped AArch32 MCR or MRC access, coproc=0b111
        <anchor link="Exception_CP15RRTTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP15RRTTrap</anchor>,          // Trapped AArch32 MCRR or MRRC access, coproc=0b1111
        <anchor link="Exception_CP14RTTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RTTrap</anchor>,           // Trapped AArch32 MCR or MRC access, coproc=0b1110
        <anchor link="Exception_CP14DTTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14DTTrap</anchor>,           // Trapped AArch32 LDC or STC access, coproc=0b1110
        <anchor link="Exception_CP14RRTTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_CP14RRTTrap</anchor>,          // Trapped AArch32 MRRC access, coproc=0b1110
        <anchor link="Exception_AdvSIMDFPAccessTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_AdvSIMDFPAccessTrap</anchor>,  // HCPTR-trapped access to SIMD or FP
        <anchor link="Exception_FPIDTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPIDTrap</anchor>,             // Trapped access to SIMD or FP ID register
        <anchor link="Exception_LDST64BTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_LDST64BTrap</anchor>,          // Trapped access to ST64BV, ST64BV0, ST64B and LD64B
        // Trapped BXJ instruction not supported in Armv8
        <anchor link="Exception_PACTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACTrap</anchor>,               // Trapped invalid PAC use
        <anchor link="Exception_IllegalState" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IllegalState</anchor>,          // Illegal Execution state
        <anchor link="Exception_SupervisorCall" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SupervisorCall</anchor>,        // Supervisor Call
        <anchor link="Exception_HypervisorCall" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_HypervisorCall</anchor>,        // Hypervisor Call
        <anchor link="Exception_MonitorCall" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MonitorCall</anchor>,           // Monitor Call or Trapped SMC instruction
        <anchor link="Exception_SystemRegisterTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegisterTrap</anchor>,    // Trapped MRS or MSR System register access
        <anchor link="Exception_ERetTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_ERetTrap</anchor>,              // Trapped invalid ERET use
        <anchor link="Exception_InstructionAbort" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_InstructionAbort</anchor>,      // Instruction Abort or Prefetch Abort
        <anchor link="Exception_PCAlignment" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PCAlignment</anchor>,           // PC alignment fault
        <anchor link="Exception_DataAbort" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_DataAbort</anchor>,             // Data Abort
        <anchor link="Exception_NV2DataAbort" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2DataAbort</anchor>,          // Data abort at EL1 reported as being from EL2
        <anchor link="Exception_PACFail" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_PACFail</anchor>,               // PAC Authentication failure
        <anchor link="Exception_SPAlignment" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SPAlignment</anchor>,           // SP alignment fault
        <anchor link="Exception_FPTrappedException" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FPTrappedException</anchor>,    // IEEE trapped FP exception
        <anchor link="Exception_SError" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SError</anchor>,                // SError interrupt
        <anchor link="Exception_Breakpoint" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Breakpoint</anchor>,            // (Hardware) Breakpoint
        <anchor link="Exception_SoftwareStep" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareStep</anchor>,          // Software Step
        <anchor link="Exception_Watchpoint" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_Watchpoint</anchor>,            // Watchpoint
        <anchor link="Exception_NV2Watchpoint" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_NV2Watchpoint</anchor>,         // Watchpoint at EL1 reported as being from EL2
        <anchor link="Exception_SoftwareBreakpoint" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SoftwareBreakpoint</anchor>,    // Software Breakpoint Instruction
        <anchor link="Exception_VectorCatch" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_VectorCatch</anchor>,           // AArch32 Vector Catch
        <anchor link="Exception_IRQ" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_IRQ</anchor>,                   // IRQ interrupt
        <anchor link="Exception_SVEAccessTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SVEAccessTrap</anchor>,         // HCPTR trapped access to SVE
        <anchor link="Exception_SMEAccessTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SMEAccessTrap</anchor>,         // HCPTR trapped access to SME
        <anchor link="Exception_TSTARTAccessTrap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_TSTARTAccessTrap</anchor>,      // Trapped TSTART access
        <anchor link="Exception_GPC" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GPC</anchor>,                   // Granule protection check
        <anchor link="Exception_BranchTarget" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_BranchTarget</anchor>,          // Branch Target Identification
        <anchor link="Exception_MemCpyMemSet" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_MemCpyMemSet</anchor>,          // Exception from a CPY* or SET* instruction
        <anchor link="Exception_GCSFail" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_GCSFail</anchor>,               // GCS Exceptions
        <anchor link="Exception_SystemRegister128Trap" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_SystemRegister128Trap</anchor>, // Trapped MRRS or MSRR System register or SYSP access
        <anchor link="Exception_FIQ" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception_FIQ</anchor>};                 // FIQ interrupt</pstext>
    </ps>
    <ps name="shared/exceptions/exceptions/ExceptionRecord" mylink="shared.exceptions.exceptions.ExceptionRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExceptionRecord
// ===============

type <anchor link="ExceptionRecord" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</anchor> is (
    <a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a>   exceptype,           // Exception class
    bits(25)    syndrome,            // Syndrome record
    bits(24)    syndrome2,           // Syndrome record
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> paddress,            // Physical fault address
    bits(64)    vaddress,            // Virtual fault address
    boolean     ipavalid,            // Validity of Intermediate Physical fault address
    boolean     pavalid,             // Validity of Physical fault address
    bit         NS,                  // Intermediate Physical fault address space
    bits(56)    ipaddress,           // Intermediate Physical fault address
    boolean     trappedsyscallinst)  // Trapped SVC or SMC instruction</pstext>
    </ps>
    <ps name="shared/exceptions/exceptions/ExceptionSyndrome" mylink="shared.exceptions.exceptions.ExceptionSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExceptionSyndrome()
// ===================
// Return a blank exception syndrome record for an exception of the given type.

ExceptionRecord <anchor link="impl-shared.ExceptionSyndrome.1" hover="function: ExceptionRecord ExceptionSyndrome(Exception exceptype)">ExceptionSyndrome</anchor>(<a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a> exceptype)

    <a link="ExceptionRecord" file="shared_pseudocode.xml" hover="type ExceptionRecord is ( Exception exceptype, bits(25) syndrome, bits(24) syndrome2, FullAddress paddress, bits(64) vaddress, boolean ipavalid, boolean pavalid, bit NS, bits(56) ipaddress, boolean trappedsyscallinst)">ExceptionRecord</a> r;

    r.exceptype = exceptype;

    // Initialize all other fields
    r.syndrome  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(25);
    r.syndrome2 = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24);
    r.vaddress  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    r.ipavalid  = FALSE;
    r.NS        = '0';
    r.ipaddress = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(56);
    r.paddress.paspace = <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> UNKNOWN;
    r.paddress.address = bits(56) UNKNOWN;
    r.trappedsyscallinst = FALSE;
    return r;</pstext>
    </ps>
    <ps name="shared/functions/aborts/EncodeLDFSC" mylink="shared.functions.aborts.EncodeLDFSC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EncodeLDFSC()
// =============
// Function that gives the Long-descriptor FSC code for types of Fault

bits(6) <anchor link="impl-shared.EncodeLDFSC.2" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode, integer level)
    bits(6) result;

    // 128-bit descriptors will start from level -2 for 4KB to resolve bits IA[55:51]
    if level == -2 then
        assert <a link="impl-shared.Have56BitPAExt.0" file="shared_pseudocode.xml" hover="function: boolean Have56BitPAExt()">Have56BitPAExt</a>();
        case statuscode of
            when <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>          result = '101100';
            when <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>          result = '101010';
            when <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>   result = '010010';
            when <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>     result = '011010'; assert !<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>();
            when <a link="Fault_GPCFOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</a>           result = '100010';
            otherwise                       <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
        return result;

    if level == -1 then
        assert <a link="impl-shared.Have52BitIPAAndPASpaceExt.0" file="shared_pseudocode.xml" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</a>();
        case statuscode of
            when <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>          result = '101001';
            when <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>          result = '101011';
            when <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>   result = '010011';
            when <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>     result = '011011'; assert !<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>();
            when <a link="Fault_GPCFOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</a>           result = '100011';
            otherwise                       <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

        return result;
    case statuscode of
        when <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>         result = '0000':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>          result = '0010':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>          result = '0011':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>         result = '0001':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_SyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</a>        result = '010000';
        when <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>  result = '0101':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a>          result = '011000';
        when <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>    result = '0111':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>         result = '011001';
        when <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>       result = '010001'; assert <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
        when <a link="Fault_TagCheck" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TagCheck</a>            result = '010001'; assert <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>();
        when <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>           result = '100001';
        when <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>               result = '100010';
        when <a link="Fault_GPCFOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</a>          result = '1001':level&lt;1:0&gt;; assert level IN {0,1,2,3};
        when <a link="Fault_GPCFOnOutput" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnOutput</a>        result = '101000';
        when <a link="Fault_TLBConflict" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TLBConflict</a>         result = '110000';
        when <a link="Fault_HWUpdateAccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_HWUpdateAccessFlag</a>  result = '110001';
        when <a link="Fault_Lockdown" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Lockdown</a>            result = '110100';  // IMPLEMENTATION DEFINED
        when <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>           result = '110101';  // IMPLEMENTATION DEFINED
        otherwise                      <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    return result;</pstext>
    </ps>
    <ps name="shared/functions/aborts/IPAValid" mylink="shared.functions.aborts.IPAValid" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IPAValid()
// ==========
// Return TRUE if the IPA is reported for the abort

boolean <anchor link="impl-shared.IPAValid.1" hover="function: boolean IPAValid(FaultRecord fault)">IPAValid</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    if fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
        return fault.secondstage;
    elsif fault.s2fs1walk then
        return fault.statuscode IN {
            <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>,
            <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a>,
            <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>,
            <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>
        };
    elsif fault.secondstage then
        return fault.statuscode IN {
            <a link="Fault_AccessFlag" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</a>,
            <a link="Fault_Translation" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</a>,
            <a link="Fault_AddressSize" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</a>
        };
    else
        return FALSE;</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsAsyncAbort" mylink="shared.functions.aborts.IsAsyncAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsAsyncAbort()
// ==============
// Returns TRUE if the abort currently being processed is an asynchronous abort, and FALSE
// otherwise.

boolean <anchor link="impl-shared.IsAsyncAbort.1" hover="function: boolean IsAsyncAbort(Fault statuscode)">IsAsyncAbort</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode)
    assert statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    return (statuscode IN {<a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>, <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>});

// IsAsyncAbort()
// ==============

boolean <a link="impl-shared.IsAsyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsAsyncAbort(Fault statuscode)">IsAsyncAbort</a>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    return <a link="impl-shared.IsAsyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsAsyncAbort(Fault statuscode)">IsAsyncAbort</a>(fault.statuscode);</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsDebugException" mylink="shared.functions.aborts.IsDebugException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsDebugException()
// ==================

boolean <anchor link="impl-shared.IsDebugException.1" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;
    return fault.statuscode == <a link="Fault_Debug" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</a>;</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsExternalAbort" mylink="shared.functions.aborts.IsExternalAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsExternalAbort()
// =================
// Returns TRUE if the abort currently being processed is an External abort and FALSE otherwise.

boolean <anchor link="impl-shared.IsExternalAbort.1" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode)
    assert statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    return (statuscode IN {
        <a link="Fault_SyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</a>,
        <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a>,
        <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>,
        <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>,
        <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>,
        <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>
    });

// IsExternalAbort()
// =================

boolean <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    return <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault.statuscode) || fault.gpcf.gpf == <a link="GPCF_EABT" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</a>;</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsExternalSyncAbort" mylink="shared.functions.aborts.IsExternalSyncAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsExternalSyncAbort()
// =====================
// Returns TRUE if the abort currently being processed is an external
// synchronous abort and FALSE otherwise.

boolean <anchor link="impl-shared.IsExternalSyncAbort.1" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode)
    assert statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    return (statuscode IN {
        <a link="Fault_SyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</a>,
        <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a>,
        <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>,
        <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>
    });

// IsExternalSyncAbort()
// =====================

boolean <a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    return <a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault.statuscode) || fault.gpcf.gpf == <a link="GPCF_EABT" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</a>;</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsFault" mylink="shared.functions.aborts.IsFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsFault()
// =========
// Return TRUE if a fault is associated with an address descriptor

boolean <anchor link="impl-shared.IsFault.1" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc)
    return addrdesc.fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

// IsFault()
// =========
// Return TRUE if a fault is associated with a memory access.

boolean <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> fault)
    return fault != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

// IsFault()
// =========
// Return TRUE if a fault is associated with status returned by memory.

boolean <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> retstatus)
    return retstatus.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsSErrorInterrupt" mylink="shared.functions.aborts.IsSErrorInterrupt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSErrorInterrupt()
// ===================
// Returns TRUE if the abort currently being processed is an SError interrupt, and FALSE
// otherwise.

boolean <anchor link="impl-shared.IsSErrorInterrupt.1" hover="function: boolean IsSErrorInterrupt(Fault statuscode)">IsSErrorInterrupt</anchor>(<a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode)
    assert statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    return (statuscode IN {<a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>, <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>});

// IsSErrorInterrupt()
// ===================

boolean <a link="impl-shared.IsSErrorInterrupt.1" file="shared_pseudocode.xml" hover="function: boolean IsSErrorInterrupt(Fault statuscode)">IsSErrorInterrupt</a>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    return <a link="impl-shared.IsSErrorInterrupt.1" file="shared_pseudocode.xml" hover="function: boolean IsSErrorInterrupt(Fault statuscode)">IsSErrorInterrupt</a>(fault.statuscode);</pstext>
    </ps>
    <ps name="shared/functions/aborts/IsSecondStage" mylink="shared.functions.aborts.IsSecondStage" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSecondStage()
// ===============

boolean <anchor link="impl-shared.IsSecondStage.1" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert fault.statuscode != <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;

    return fault.secondstage;</pstext>
    </ps>
    <ps name="shared/functions/aborts/LSInstructionSyndrome" mylink="shared.functions.aborts.LSInstructionSyndrome" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LSInstructionSyndrome()
// =======================
// Returns the extended syndrome information for a second stage fault.
//  &lt;10&gt;  - Syndrome valid bit. The syndrome is valid only for certain types of access instruction.
//  &lt;9:8&gt; - Access size.
//  &lt;7&gt;   - Sign extended (for loads).
//  &lt;6:2&gt; - Transfer register.
//  &lt;1&gt;   - Transfer register is 64-bit.
//  &lt;0&gt;   - Instruction has acquire/release semantics.

bits(11) <anchor link="impl-shared.LSInstructionSyndrome.0" hover="function: bits(11) LSInstructionSyndrome()">LSInstructionSyndrome</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/aborts/ReportAsGPCException" mylink="shared.functions.aborts.ReportAsGPCException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportAsGPCException()
// ======================
// Determine whether the given GPCF is reported as a Granule Protection Check Exception
// rather than a Data or Instruction Abort

boolean <anchor link="impl-shared.ReportAsGPCException.1" hover="function: boolean ReportAsGPCException(FaultRecord fault)">ReportAsGPCException</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    assert <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>();
    assert fault.statuscode IN {<a link="Fault_GPCFOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</a>, <a link="Fault_GPCFOnOutput" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnOutput</a>};
    assert fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a>;

    case fault.gpcf.gpf of
        when <a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>        return TRUE;
        when <a link="GPCF_AddressSize" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_AddressSize</a> return TRUE;
        when <a link="GPCF_EABT" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</a>        return TRUE;
        when <a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a>        return SCR_EL3.GPF == '1' &amp;&amp; PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;</pstext>
    </ps>
    <ps name="shared/functions/cache/CACHE_OP" mylink="shared.functions.cache.CACHE_OP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CACHE_OP()
// ==========
// Performs Cache maintenance operations as per CacheRecord.

<anchor link="impl-shared.CACHE_OP.1" hover="function: CACHE_OP(CacheRecord cache)">CACHE_OP</anchor>(<a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache)
    IMPLEMENTATION_DEFINED;</pstext>
    </ps>
    <ps name="shared/functions/cache/CPASAtPAS" mylink="shared.functions.cache.CPASAtPAS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPASAtPAS()
// ===========
// Get cache PA space for given PA space.

CachePASpace <anchor link="impl-shared.CPASAtPAS.1" hover="function: CachePASpace CPASAtPAS(PASpace pas)">CPASAtPAS</anchor>(<a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> pas)
    case pas of
        when <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>
            return <a link="CPAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_NonSecure</a>;
        when <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>
            return <a link="CPAS_Secure" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Secure</a>;
        when <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>
            return <a link="CPAS_Root" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Root</a>;
        when <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>
            return <a link="CPAS_Realm" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Realm</a>;</pstext>
    </ps>
    <ps name="shared/functions/cache/CPASAtSecurityState" mylink="shared.functions.cache.CPASAtSecurityState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CPASAtSecurityState()
// =====================
// Get cache PA space for given security state.

CachePASpace <anchor link="impl-shared.CPASAtSecurityState.1" hover="function: CachePASpace CPASAtSecurityState(SecurityState ss)">CPASAtSecurityState</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    case ss of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            return <a link="CPAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_NonSecure</a>;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            return <a link="CPAS_SecureNonSecure" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_SecureNonSecure</a>;
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>
            return <a link="CPAS_Any" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Any</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            return <a link="CPAS_RealmNonSecure" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_RealmNonSecure</a>;</pstext>
    </ps>
    <ps name="shared/functions/cache/CacheRecord" mylink="shared.functions.cache.CacheRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CacheRecord
// ===========
// Details related to a cache operation.

type <anchor link="CacheRecord" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</anchor> is (
    <a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a>       acctype,           // Access type
    <a link="CacheOp" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp</a>          cacheop,           // Cache operation
    <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a>     opscope,           // Cache operation type
    <a link="CacheType" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</a>        cachetype,         // Cache type
    bits(64)         regval,
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a>      paddress,
    bits(64)         vaddress,          // For VA operations
    integer          set,               // For SW operations
    integer          way,               // For SW operations
    integer          level,             // For SW operations
    <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a>     shareability,
    boolean          translated,
    boolean          is_vmid_valid,     // is vmid valid for current context
    bits(16)         vmid,
    boolean          is_asid_valid,     // is asid valid for current context
    bits(16)         asid,
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a>    security,
    // For cache operations to full cache or by set/way
    // For operations by address, PA space in paddress
    <a link="CachePASpace" file="shared_pseudocode.xml" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CachePASpace</a>     cpas
)</pstext>
    </ps>
    <ps name="shared/functions/cache/DCInstNeedsTranslation" mylink="shared.functions.cache.DCInstNeedsTranslation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DCInstNeedsTranslation()
// ========================
// Check whether Data Cache operation needs translation.

boolean <anchor link="impl-shared.DCInstNeedsTranslation.1" hover="function: boolean DCInstNeedsTranslation(CacheOpScope opscope)">DCInstNeedsTranslation</anchor>(<a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    if opscope == <a link="CacheOpScope_PoE" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoE</a> then
        return FALSE;

    if CLIDR_EL1.LoC == '000' then
        return !(boolean IMPLEMENTATION_DEFINED
                 "No fault generated for DC operations if PoC is before any level of cache");

    if CLIDR_EL1.LoUU == '000' &amp;&amp; opscope == <a link="CacheOpScope_PoU" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoU</a> then
        return !(boolean IMPLEMENTATION_DEFINED
                 "No fault generated for DC operations if PoU is before any level of cache");

    return TRUE;</pstext>
    </ps>
    <ps name="shared/functions/cache/DecodeSW" mylink="shared.functions.cache.DecodeSW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeSW()
// ==========
// Decode input value into set, way and level for SW instructions.

(integer, integer, integer) <anchor link="impl-shared.DecodeSW.2" hover="function: (integer, integer, integer) DecodeSW(bits(64) regval, CacheType cachetype)">DecodeSW</anchor>(bits(64) regval, <a link="CacheType" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</a> cachetype)
    level = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(regval[3:1]);
    (set, way, linesize) = <a link="impl-shared.GetCacheInfo.2" file="shared_pseudocode.xml" hover="function: (integer, integer, integer) GetCacheInfo(integer level, CacheType cachetype)">GetCacheInfo</a>(level, cachetype);
    return (set, way, level);</pstext>
    </ps>
    <ps name="shared/functions/cache/GetCacheInfo" mylink="shared.functions.cache.GetCacheInfo" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetCacheInfo()
// ==============
// Returns numsets, assosciativity &amp; linesize.

(integer, integer, integer) <anchor link="impl-shared.GetCacheInfo.2" hover="function: (integer, integer, integer) GetCacheInfo(integer level, CacheType cachetype)">GetCacheInfo</anchor>(integer level, <a link="CacheType" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</a> cachetype);</pstext>
    </ps>
    <ps name="shared/functions/cache/ICInstNeedsTranslation" mylink="shared.functions.cache.ICInstNeedsTranslation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ICInstNeedsTranslation()
// ========================
// Check whether Instruction Cache operation needs translation.

boolean <anchor link="impl-shared.ICInstNeedsTranslation.1" hover="function: boolean ICInstNeedsTranslation(CacheOpScope opscope)">ICInstNeedsTranslation</anchor>(<a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope)
    return boolean IMPLEMENTATION_DEFINED "Instruction Cache needs translation";</pstext>
    </ps>
    <ps name="shared/functions/common/ASR" mylink="shared.functions.common.ASR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ASR()
// =====

bits(N) <anchor link="impl-shared.ASR.2" hover="function: bits(N) ASR(bits(N) x, integer shift)">ASR</anchor>(bits(N) x, integer shift)
    assert shift &gt;= 0;
    bits(N) result;
    if shift == 0 then
        result = x;
    else
        (result, -) = <a link="impl-shared.ASR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) ASR_C(bits(N) x, integer shift)">ASR_C</a>(x, shift);
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/ASR_C" mylink="shared.functions.common.ASR_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ASR_C()
// =======

(bits(N), bit) <anchor link="impl-shared.ASR_C.2" hover="function: (bits(N), bit) ASR_C(bits(N) x, integer shift)">ASR_C</anchor>(bits(N) x, integer shift)
    assert shift &gt; 0 &amp;&amp; shift &lt; 256;
    extended_x = <a link="impl-shared.SignExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) SignExtend(bits(M) x, integer N)">SignExtend</a>(x, shift+N);
    result = extended_x&lt;(shift+N)-1:shift&gt;;
    carry_out = extended_x&lt;shift-1&gt;;
    return (result, carry_out);</pstext>
    </ps>
    <ps name="shared/functions/common/Abs" mylink="shared.functions.common.Abs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Abs()
// =====

integer <anchor link="impl-shared.Abs.1" hover="function: integer Abs(integer x)">Abs</anchor>(integer x)
    return if x &gt;= 0 then x else -x;

// Abs()
// =====

real <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(real x)
    return if x &gt;= 0.0 then x else -x;</pstext>
    </ps>
    <ps name="shared/functions/common/Align" mylink="shared.functions.common.Align" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Align()
// =======

integer <anchor link="impl-shared.Align.2" hover="function: integer Align(integer x, integer y)">Align</anchor>(integer x, integer y)
    return y * (x DIV y);

// Align()
// =======

bits(N) <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(bits(N) x, integer y)
    return <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(x), y)&lt;N-1:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/common/BitCount" mylink="shared.functions.common.BitCount" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BitCount()
// ==========

integer <anchor link="impl-shared.BitCount.1" hover="function: integer BitCount(bits(N) x)">BitCount</anchor>(bits(N) x)
    integer result = 0;
    for i = 0 to N-1
        if x&lt;i&gt; == '1' then
            result = result + 1;
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/CountLeadingSignBits" mylink="shared.functions.common.CountLeadingSignBits" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CountLeadingSignBits()
// ======================

integer <anchor link="impl-shared.CountLeadingSignBits.1" hover="function: integer CountLeadingSignBits(bits(N) x)">CountLeadingSignBits</anchor>(bits(N) x)
    return <a link="impl-shared.CountLeadingZeroBits.1" file="shared_pseudocode.xml" hover="function: integer CountLeadingZeroBits(bits(N) x)">CountLeadingZeroBits</a>(x&lt;N-1:1&gt; EOR x&lt;N-2:0&gt;);</pstext>
    </ps>
    <ps name="shared/functions/common/CountLeadingZeroBits" mylink="shared.functions.common.CountLeadingZeroBits" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CountLeadingZeroBits()
// ======================

integer <anchor link="impl-shared.CountLeadingZeroBits.1" hover="function: integer CountLeadingZeroBits(bits(N) x)">CountLeadingZeroBits</anchor>(bits(N) x)
    return N - (<a link="impl-shared.HighestSetBit.1" file="shared_pseudocode.xml" hover="function: integer HighestSetBit(bits(N) x)">HighestSetBit</a>(x) + 1);</pstext>
    </ps>
    <ps name="shared/functions/common/Elem" mylink="shared.functions.common.Elem" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Elem[] - non-assignment form
// ============================

bits(size) <anchor link="impl-shared.Elem.read.3" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</anchor>[bits(N) vector, integer e, integer size]
    assert e &gt;= 0 &amp;&amp; (e+1)*size &lt;= N;
    return vector&lt;(e*size+size)-1 : e*size&gt;;

// Elem[] - assignment form
// ========================

<anchor link="impl-shared.Elem.write.3" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</anchor>[bits(N) &amp;vector, integer e, integer size] = bits(size) value
    assert e &gt;= 0 &amp;&amp; (e+1)*size &lt;= N;
    vector&lt;(e+1)*size-1:e*size&gt; = value;
    return;</pstext>
    </ps>
    <ps name="shared/functions/common/Extend" mylink="shared.functions.common.Extend" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Extend()
// ========

bits(N) <anchor link="impl-shared.Extend.3" hover="function: bits(N) Extend(bits(M) x, integer N, boolean unsigned)">Extend</anchor>(bits(M) x, integer N, boolean unsigned)
    return if unsigned then <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(x, N) else <a link="impl-shared.SignExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) SignExtend(bits(M) x, integer N)">SignExtend</a>(x, N);</pstext>
    </ps>
    <ps name="shared/functions/common/HighestSetBit" mylink="shared.functions.common.HighestSetBit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HighestSetBit()
// ===============

integer <anchor link="impl-shared.HighestSetBit.1" hover="function: integer HighestSetBit(bits(N) x)">HighestSetBit</anchor>(bits(N) x)
    for i = N-1 downto 0
        if x&lt;i&gt; == '1' then return i;
    return -1;</pstext>
    </ps>
    <ps name="shared/functions/common/Int" mylink="shared.functions.common.Int" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Int()
// =====

integer <anchor link="impl-shared.Int.2" hover="function: integer Int(bits(N) x, boolean unsigned)">Int</anchor>(bits(N) x, boolean unsigned)
    result = if unsigned then <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(x) else <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(x);
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/IsAligned" mylink="shared.functions.common.IsAligned" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsAligned()
// ===========

boolean <anchor link="impl-shared.IsAligned.2" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</anchor>(integer x, integer y)
    return x == <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(x, y);

// IsAligned()
// ===========

boolean <a link="impl-shared.IsAligned.2" file="shared_pseudocode.xml" hover="function: boolean IsAligned(integer x, integer y)">IsAligned</a>(bits(N) x, integer y)
    return x == <a link="impl-shared.Align.2" file="shared_pseudocode.xml" hover="function: integer Align(integer x, integer y)">Align</a>(x, y);</pstext>
    </ps>
    <ps name="shared/functions/common/IsOnes" mylink="shared.functions.common.IsOnes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsOnes()
// ========

boolean <anchor link="impl-shared.IsOnes.1" hover="function: boolean IsOnes(bits(N) x)">IsOnes</anchor>(bits(N) x)
    return x == <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(N);</pstext>
    </ps>
    <ps name="shared/functions/common/IsZero" mylink="shared.functions.common.IsZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsZero()
// ========

boolean <anchor link="impl-shared.IsZero.1" hover="function: boolean IsZero(bits(N) x)">IsZero</anchor>(bits(N) x)
    return x == <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);</pstext>
    </ps>
    <ps name="shared/functions/common/IsZeroBit" mylink="shared.functions.common.IsZeroBit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsZeroBit()
// ===========

bit <anchor link="impl-shared.IsZeroBit.1" hover="function: bit IsZeroBit(bits(N) x)">IsZeroBit</anchor>(bits(N) x)
    return if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(x) then '1' else '0';</pstext>
    </ps>
    <ps name="shared/functions/common/LSL" mylink="shared.functions.common.LSL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LSL()
// =====

bits(N) <anchor link="impl-shared.LSL.2" hover="function: bits(N) LSL(bits(N) x, integer shift)">LSL</anchor>(bits(N) x, integer shift)
    assert shift &gt;= 0;
    bits(N) result;
    if shift == 0 then
        result = x;
    else
        (result, -) = <a link="impl-shared.LSL_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) LSL_C(bits(N) x, integer shift)">LSL_C</a>(x, shift);
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/LSL_C" mylink="shared.functions.common.LSL_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LSL_C()
// =======

(bits(N), bit) <anchor link="impl-shared.LSL_C.2" hover="function: (bits(N), bit) LSL_C(bits(N) x, integer shift)">LSL_C</anchor>(bits(N) x, integer shift)
    assert shift &gt; 0 &amp;&amp; shift &lt; 256;
    extended_x = x : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(shift);
    result = extended_x&lt;N-1:0&gt;;
    carry_out = extended_x&lt;N&gt;;
    return (result, carry_out);</pstext>
    </ps>
    <ps name="shared/functions/common/LSR" mylink="shared.functions.common.LSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LSR()
// =====

bits(N) <anchor link="impl-shared.LSR.2" hover="function: bits(N) LSR(bits(N) x, integer shift)">LSR</anchor>(bits(N) x, integer shift)
    assert shift &gt;= 0;
    bits(N) result;
    if shift == 0 then
        result = x;
    else
        (result, -) = <a link="impl-shared.LSR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) LSR_C(bits(N) x, integer shift)">LSR_C</a>(x, shift);
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/LSR_C" mylink="shared.functions.common.LSR_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LSR_C()
// =======

(bits(N), bit) <anchor link="impl-shared.LSR_C.2" hover="function: (bits(N), bit) LSR_C(bits(N) x, integer shift)">LSR_C</anchor>(bits(N) x, integer shift)
    assert shift &gt; 0 &amp;&amp; shift &lt; 256;
    extended_x = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(x, shift+N);
    result = extended_x&lt;(shift+N)-1:shift&gt;;
    carry_out = extended_x&lt;shift-1&gt;;
    return (result, carry_out);</pstext>
    </ps>
    <ps name="shared/functions/common/LowestSetBit" mylink="shared.functions.common.LowestSetBit" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LowestSetBit()
// ==============

integer <anchor link="impl-shared.LowestSetBit.1" hover="function: integer LowestSetBit(bits(N) x)">LowestSetBit</anchor>(bits(N) x)
    for i = 0 to N-1
        if x&lt;i&gt; == '1' then return i;
    return N;</pstext>
    </ps>
    <ps name="shared/functions/common/Max" mylink="shared.functions.common.Max" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Max()
// =====

integer <anchor link="impl-shared.Max.2" hover="function: integer Max(integer a, integer b)">Max</anchor>(integer a, integer b)
    return if a &gt;= b then a else b;

// Max()
// =====

real <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>(real a, real b)
    return if a &gt;= b then a else b;</pstext>
    </ps>
    <ps name="shared/functions/common/Min" mylink="shared.functions.common.Min" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Min()
// =====

integer <anchor link="impl-shared.Min.2" hover="function: integer Min(integer a, integer b)">Min</anchor>(integer a, integer b)
    return if a &lt;= b then a else b;

// Min()
// =====

real <a link="impl-shared.Min.2" file="shared_pseudocode.xml" hover="function: integer Min(integer a, integer b)">Min</a>(real a, real b)
    return if a &lt;= b then a else b;</pstext>
    </ps>
    <ps name="shared/functions/common/Ones" mylink="shared.functions.common.Ones" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Ones()
// ======

bits(N) <anchor link="impl-shared.Ones.1" hover="function: bits(N) Ones(integer N)">Ones</anchor>(integer N)
    return <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>('1',N);</pstext>
    </ps>
    <ps name="shared/functions/common/ROR" mylink="shared.functions.common.ROR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ROR()
// =====

bits(N) <anchor link="impl-shared.ROR.2" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</anchor>(bits(N) x, integer shift)
    assert shift &gt;= 0;
    bits(N) result;
    if shift == 0 then
        result = x;
    else
        (result, -) = <a link="impl-shared.ROR_C.2" file="shared_pseudocode.xml" hover="function: (bits(N), bit) ROR_C(bits(N) x, integer shift)">ROR_C</a>(x, shift);
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/ROR_C" mylink="shared.functions.common.ROR_C" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ROR_C()
// =======

(bits(N), bit) <anchor link="impl-shared.ROR_C.2" hover="function: (bits(N), bit) ROR_C(bits(N) x, integer shift)">ROR_C</anchor>(bits(N) x, integer shift)
    assert shift != 0 &amp;&amp; shift &lt; 256;
    m = shift MOD N;
    result = <a link="impl-shared.LSR.2" file="shared_pseudocode.xml" hover="function: bits(N) LSR(bits(N) x, integer shift)">LSR</a>(x,m) OR <a link="impl-shared.LSL.2" file="shared_pseudocode.xml" hover="function: bits(N) LSL(bits(N) x, integer shift)">LSL</a>(x,N-m);
    carry_out = result&lt;N-1&gt;;
    return (result, carry_out);</pstext>
    </ps>
    <ps name="shared/functions/common/Replicate" mylink="shared.functions.common.Replicate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Replicate()
// ===========

bits(M*N) <anchor link="impl-shared.Replicate.2" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</anchor>(bits(M) x, integer N);</pstext>
    </ps>
    <ps name="shared/functions/common/RoundDown" mylink="shared.functions.common.RoundDown" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RoundDown()
// ===========

integer <anchor link="impl-shared.RoundDown.1" hover="function: integer RoundDown(real x)">RoundDown</anchor>(real x);</pstext>
    </ps>
    <ps name="shared/functions/common/RoundTowardsZero" mylink="shared.functions.common.RoundTowardsZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RoundTowardsZero()
// ==================

integer <anchor link="impl-shared.RoundTowardsZero.1" hover="function: integer RoundTowardsZero(real x)">RoundTowardsZero</anchor>(real x)
    return if x == 0.0 then 0 else if x &gt;= 0.0 then <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(x) else <a link="impl-shared.RoundUp.1" file="shared_pseudocode.xml" hover="function: integer RoundUp(real x)">RoundUp</a>(x);</pstext>
    </ps>
    <ps name="shared/functions/common/RoundUp" mylink="shared.functions.common.RoundUp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RoundUp()
// =========

integer <anchor link="impl-shared.RoundUp.1" hover="function: integer RoundUp(real x)">RoundUp</anchor>(real x);</pstext>
    </ps>
    <ps name="shared/functions/common/SInt" mylink="shared.functions.common.SInt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SInt()
// ======

integer <anchor link="impl-shared.SInt.1" hover="function: integer SInt(bits(N) x)">SInt</anchor>(bits(N) x)
    result = 0;
    for i = 0 to N-1
        if x&lt;i&gt; == '1' then result = result + 2^i;
    if x&lt;N-1&gt; == '1' then result = result - 2^N;
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/SignExtend" mylink="shared.functions.common.SignExtend" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SignExtend()
// ============

bits(N) <anchor link="impl-shared.SignExtend.2" hover="function: bits(N) SignExtend(bits(M) x, integer N)">SignExtend</anchor>(bits(M) x, integer N)
    assert N &gt;= M;
    return <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(x&lt;M-1&gt;, N-M) : x;</pstext>
    </ps>
    <ps name="shared/functions/common/Split64to32" mylink="shared.functions.common.Split64to32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Split64to32()
// =============

(bits(32), bits(32)) <anchor link="impl-shared.Split64to32.1" hover="function: (bits(32), bits(32)) Split64to32(bits(64) value)">Split64to32</anchor>(bits(64) value)
    return (value&lt;63:32&gt;, value&lt;31:0&gt;);</pstext>
    </ps>
    <ps name="shared/functions/common/UInt" mylink="shared.functions.common.UInt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UInt()
// ======

integer <anchor link="impl-shared.UInt.1" hover="function: integer UInt(bits(N) x)">UInt</anchor>(bits(N) x)
    result = 0;
    for i = 0 to N-1
        if x&lt;i&gt; == '1' then result = result + 2^i;
    return result;</pstext>
    </ps>
    <ps name="shared/functions/common/ZeroExtend" mylink="shared.functions.common.ZeroExtend" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ZeroExtend()
// ============

bits(N) <anchor link="impl-shared.ZeroExtend.2" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</anchor>(bits(M) x, integer N)
    assert N &gt;= M;
    return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N-M) : x;</pstext>
    </ps>
    <ps name="shared/functions/common/Zeros" mylink="shared.functions.common.Zeros" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Zeros()
// =======

bits(N) <anchor link="impl-shared.Zeros.1" hover="function: bits(N) Zeros(integer N)">Zeros</anchor>(integer N)
    return <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>('0',N);</pstext>
    </ps>
    <ps name="shared/functions/counters/AArch32.CheckTimerConditions" mylink="shared.functions.counters.AArch32.CheckTimerConditions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.CheckTimerConditions()
// ==============================
// Checking timer conditions for all A32 timer registers

<anchor link="AArch32.CheckTimerConditions.0" hover="function: AArch32.CheckTimerConditions()">AArch32.CheckTimerConditions</anchor>()
    boolean status;
    bits(64) offset;
    offset = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    assert !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>();

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if CNTP_CTL_S.ENABLE == '1' then
            status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(offset, CNTP_CVAL_S,
                                         CNTP_CTL_S.IMASK, <a link="InterruptID_CNTPS" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTPS</a>);
            CNTP_CTL_S.ISTATUS = if status then '1' else '0';

        if CNTP_CTL_NS.ENABLE == '1' then
            status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(offset, CNTP_CVAL_NS,
                                         CNTP_CTL_NS.IMASK, <a link="InterruptID_CNTP" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTP</a>);
            CNTP_CTL_NS.ISTATUS = if status then '1' else '0';
    else
        if CNTP_CTL.ENABLE == '1' then
            status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(offset, CNTP_CVAL,
                                         CNTP_CTL.IMASK, <a link="InterruptID_CNTP" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTP</a>);
            CNTP_CTL.ISTATUS = if status then '1' else '0';

    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; CNTHP_CTL.ENABLE == '1' then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(offset, CNTHP_CVAL,
                                     CNTHP_CTL.IMASK, <a link="InterruptID_CNTHP" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHP</a>);
        CNTHP_CTL.ISTATUS = if status then '1' else '0';

    if CNTV_CTL_EL0.ENABLE == '1' then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(CNTVOFF_EL2, CNTV_CVAL_EL0,
                                     CNTV_CTL_EL0.IMASK, <a link="InterruptID_CNTV" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTV</a>);
        CNTV_CTL_EL0.ISTATUS = if status then '1' else '0';

    return;</pstext>
    </ps>
    <ps name="shared/functions/counters/AArch64.CheckTimerConditions" mylink="shared.functions.counters.AArch64.CheckTimerConditions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.CheckTimerConditions()
// ==============================
// Checking timer conditions for all A64 timer registers

<anchor link="AArch64.CheckTimerConditions.0" hover="function: AArch64.CheckTimerConditions()">AArch64.CheckTimerConditions</anchor>()
    boolean status;
    bits(64) offset;
    bit imask;
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss = <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>();
    boolean ecv = FALSE;
    if <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() then
        ecv = CNTHCTL_EL2.ECV == '1' &amp;&amp; SCR_EL3.ECVEn == '1' &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    if ecv then
        offset = CNTPOFF_EL2;
    else
        offset = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    if CNTP_CTL_EL0.ENABLE == '1' then
        imask = CNTP_CTL_EL0.IMASK;
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; ss IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>} &amp;&amp; CNTHCTL_EL2.CNTPMASK == '1' then
            imask = '1';
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(offset, CNTP_CVAL_EL0,
                                     imask, <a link="InterruptID_CNTP" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTP</a>);
        CNTP_CTL_EL0.ISTATUS = if status then '1' else '0';
    if ((<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; !<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>())) &amp;&amp;
       CNTHP_CTL_EL2.ENABLE == '1') then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64), CNTHP_CVAL_EL2,
                                     CNTHP_CTL_EL2.IMASK, <a link="InterruptID_CNTHP" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHP</a>);
        CNTHP_CTL_EL2.ISTATUS = if status then '1' else '0';
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; CNTHPS_CTL_EL2.ENABLE == '1' then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64), CNTHPS_CVAL_EL2,
                                     CNTHPS_CTL_EL2.IMASK, <a link="InterruptID_CNTHPS" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHPS</a>);
        CNTHPS_CTL_EL2.ISTATUS = if status then '1' else '0';

    if CNTPS_CTL_EL1.ENABLE == '1' then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(offset, CNTPS_CVAL_EL1,
                                     CNTPS_CTL_EL1.IMASK, <a link="InterruptID_CNTPS" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTPS</a>);
        CNTPS_CTL_EL1.ISTATUS = if status then '1' else '0';

    if CNTV_CTL_EL0.ENABLE == '1' then
        imask = CNTV_CTL_EL0.IMASK;
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; ss IN {<a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>, <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>} &amp;&amp; CNTHCTL_EL2.CNTVMASK == '1' then
            imask = '1';
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(CNTVOFF_EL2, CNTV_CVAL_EL0,
                                     imask, <a link="InterruptID_CNTV" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTV</a>);
        CNTV_CTL_EL0.ISTATUS = if status then '1' else '0';

    if ((<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || !<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>())) &amp;&amp;
        CNTHV_CTL_EL2.ENABLE == '1') then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64), CNTHV_CVAL_EL2,
                                     CNTHV_CTL_EL2.IMASK, <a link="InterruptID_CNTHV" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHV</a>);
        CNTHV_CTL_EL2.ISTATUS = if status then '1' else '0';

    if ((<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>()) &amp;&amp;
        CNTHVS_CTL_EL2.ENABLE == '1') then
        status = <a link="impl-shared.IsTimerConditionMet.4" file="shared_pseudocode.xml" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64), CNTHVS_CVAL_EL2,
                                     CNTHVS_CTL_EL2.IMASK, <a link="InterruptID_CNTHVS" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHVS</a>);
        CNTHVS_CTL_EL2.ISTATUS = if status then '1' else '0';
    return;</pstext>
    </ps>
    <ps name="shared/functions/counters/GenericCounterTick" mylink="shared.functions.counters.GenericCounterTick" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GenericCounterTick()
// ====================
// Increments PhysicalCount value for every clock tick.

<anchor link="impl-shared.GenericCounterTick.0" hover="function: GenericCounterTick()">GenericCounterTick</anchor>()
    bits(64) prev_physical_count;
    if CNTCR.EN == '0' then
        if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
            <a link="AArch32.CheckTimerConditions.0" file="shared_pseudocode.xml" hover="function: AArch32.CheckTimerConditions()">AArch32.CheckTimerConditions</a>();
        else
            <a link="AArch64.CheckTimerConditions.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckTimerConditions()">AArch64.CheckTimerConditions</a>();
        return;
    prev_physical_count = <a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>();
    if <a link="impl-shared.HaveCNTSCExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveCNTSCExt()">HaveCNTSCExt</a>() &amp;&amp; CNTCR.SCEN == '1' then
        PhysicalCount = PhysicalCount + <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(CNTSCR, 88);
    else
        PhysicalCount&lt;87:24&gt; = PhysicalCount&lt;87:24&gt; + 1;
    if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        <a link="AArch32.CheckTimerConditions.0" file="shared_pseudocode.xml" hover="function: AArch32.CheckTimerConditions()">AArch32.CheckTimerConditions</a>();
    else
        <a link="AArch64.CheckTimerConditions.0" file="shared_pseudocode.xml" hover="function: AArch64.CheckTimerConditions()">AArch64.CheckTimerConditions</a>();
    <a link="impl-shared.TestEventCNTP.2" file="shared_pseudocode.xml" hover="function: TestEventCNTP(bits(64) prev_physical_count, bits(64) current_physical_count)">TestEventCNTP</a>(prev_physical_count, <a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>());
    <a link="impl-shared.TestEventCNTV.2" file="shared_pseudocode.xml" hover="function: TestEventCNTV(bits(64) prev_physical_count, bits(64) current_physical_count)">TestEventCNTV</a>(prev_physical_count, <a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>());
    return;</pstext>
    </ps>
    <ps name="shared/functions/counters/IsTimerConditionMet" mylink="shared.functions.counters.IsTimerConditionMet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsTimerConditionMet()
// =====================

boolean <anchor link="impl-shared.IsTimerConditionMet.4" hover="function: boolean IsTimerConditionMet(bits(64) offset, bits(64) compare_value, bits(1) imask, InterruptID intid)">IsTimerConditionMet</anchor>(bits(64) offset, bits(64) compare_value,
                            bits(1) imask, <a link="InterruptID" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID</a> intid)
    boolean conditon_met;
    signal level;
    condition_met = (<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(<a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>() - offset) -
                                        <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(compare_value)) &gt;= 0;
    level = if condition_met &amp;&amp; imask == '0' then HIGH else LOW;
    SetInterruptRequestLevel(intid, level);
    return condition_met;</pstext>
    </ps>
    <ps name="shared/functions/counters/PhysicalCount" mylink="shared.functions.counters.PhysicalCount" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(88) PhysicalCount;</pstext>
    </ps>
    <ps name="shared/functions/counters/SetEventRegister" mylink="shared.functions.counters.SetEventRegister" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetEventRegister()
// ==================
// Sets the Event Register of this PE

<anchor link="impl-shared.SetEventRegister.0" hover="function: SetEventRegister()">SetEventRegister</anchor>()
    EventRegister = '1';
    return;</pstext>
    </ps>
    <ps name="shared/functions/counters/TestEventCNTP" mylink="shared.functions.counters.TestEventCNTP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TestEventCNTP()
// ===============
// Generate Event stream from the physical counter

<anchor link="impl-shared.TestEventCNTP.2" hover="function: TestEventCNTP(bits(64) prev_physical_count, bits(64) current_physical_count)">TestEventCNTP</anchor>(bits(64) prev_physical_count, bits(64) current_physical_count)
    bits(64) offset;
    bits(1) samplebit, previousbit;
    if CNTHCTL_EL2.EVNTEN == '1' then
        n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(CNTHCTL_EL2.EVNTI);
        if <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() &amp;&amp; CNTHCTL_EL2.EVNTIS == '1' then
            n = n + 8;
        boolean ecv = FALSE;
        if <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() then
            ecv = (<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; CNTHCTL_EL2.ECV == '1' &amp;&amp;
                   SCR_EL3.ECVEn == '1');
            offset = if ecv then CNTPOFF_EL2 else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        samplebit   = (current_physical_count - offset)&lt;n&gt;;
        previousbit = (prev_physical_count - offset)&lt;n&gt;;
        if CNTHCTL_EL2.EVNTDIR == '0' then
            if previousbit == '0' &amp;&amp; samplebit == '1' then <a link="impl-shared.SetEventRegister.0" file="shared_pseudocode.xml" hover="function: SetEventRegister()">SetEventRegister</a>();
        else
            if previousbit == '1' &amp;&amp; samplebit == '0' then <a link="impl-shared.SetEventRegister.0" file="shared_pseudocode.xml" hover="function: SetEventRegister()">SetEventRegister</a>();
    return;</pstext>
    </ps>
    <ps name="shared/functions/counters/TestEventCNTV" mylink="shared.functions.counters.TestEventCNTV" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TestEventCNTV()
// ===============
// Generate Event stream from the virtual counter

<anchor link="impl-shared.TestEventCNTV.2" hover="function: TestEventCNTV(bits(64) prev_physical_count, bits(64) current_physical_count)">TestEventCNTV</anchor>(bits(64) prev_physical_count, bits(64) current_physical_count)
    bits(64) offset;
    bits(1) samplebit, previousbit;
    if (!(<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.&lt;E2H,TGE&gt; == '11') &amp;&amp;
        CNTKCTL_EL1.EVNTEN == '1') then
        n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(CNTKCTL_EL1.EVNTI);
        if <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() &amp;&amp; CNTKCTL_EL1.EVNTIS == '1' then
            n = n + 8;
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (!<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() || HCR_EL2.&lt;E2H,TGE&gt; != '11') then
            offset = CNTVOFF_EL2;
        else
            offset = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        samplebit   = (current_physical_count - offset)&lt;n&gt;;
        previousbit = (prev_physical_count - offset)&lt;n&gt;;
        if CNTKCTL_EL1.EVNTDIR == '0' then
            if previousbit == '0' &amp;&amp; samplebit == '1' then <a link="impl-shared.SetEventRegister.0" file="shared_pseudocode.xml" hover="function: SetEventRegister()">SetEventRegister</a>();
        else
            if previousbit == '1' &amp;&amp; samplebit == '0' then <a link="impl-shared.SetEventRegister.0" file="shared_pseudocode.xml" hover="function: SetEventRegister()">SetEventRegister</a>();
    return;</pstext>
    </ps>
    <ps name="shared/functions/crc/BitReverse" mylink="shared.functions.crc.BitReverse" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BitReverse()
// ============

bits(N) <anchor link="impl-shared.BitReverse.1" hover="function: bits(N) BitReverse(bits(N) data)">BitReverse</anchor>(bits(N) data)
    bits(N) result;
    for i = 0 to N-1
        result&lt;(N-i)-1&gt; = data&lt;i&gt;;
    return result;</pstext>
    </ps>
    <ps name="shared/functions/crc/HaveCRCExt" mylink="shared.functions.crc.HaveCRCExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveCRCExt()
// ============

boolean <anchor link="impl-shared.HaveCRCExt.0" hover="function: boolean HaveCRCExt()">HaveCRCExt</anchor>()
    return IsFeatureImplemented(FEAT_CRC32);</pstext>
    </ps>
    <ps name="shared/functions/crc/Poly32Mod2" mylink="shared.functions.crc.Poly32Mod2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Poly32Mod2()
// ============

// Poly32Mod2 on a bitstring does a polynomial Modulus over {0,1} operation

bits(32) <anchor link="impl-shared.Poly32Mod2.2" hover="function: bits(32) Poly32Mod2(bits(N) data_in, bits(32) poly)">Poly32Mod2</anchor>(bits(N) data_in, bits(32) poly)
    assert N &gt; 32;
    bits(N) data = data_in;
    for i = N-1 downto 32
        if data&lt;i&gt; == '1' then
            data&lt;i-1:0&gt; = data&lt;i-1:0&gt; EOR (poly:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(i-32));
    return data&lt;31:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/AESInvMixColumns" mylink="shared.functions.crypto.AESInvMixColumns" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AESInvMixColumns()
// ==================
// Transformation in the Inverse Cipher that is the inverse of AESMixColumns.

bits(128) <anchor link="impl-shared.AESInvMixColumns.1" hover="function: bits(128) AESInvMixColumns(bits (128) op)">AESInvMixColumns</anchor>(bits (128) op)
    bits(4*8) in0 = op&lt; 96+:8&gt; : op&lt; 64+:8&gt; : op&lt; 32+:8&gt; : op&lt;  0+:8&gt;;
    bits(4*8) in1 = op&lt;104+:8&gt; : op&lt; 72+:8&gt; : op&lt; 40+:8&gt; : op&lt;  8+:8&gt;;
    bits(4*8) in2 = op&lt;112+:8&gt; : op&lt; 80+:8&gt; : op&lt; 48+:8&gt; : op&lt; 16+:8&gt;;
    bits(4*8) in3 = op&lt;120+:8&gt; : op&lt; 88+:8&gt; : op&lt; 56+:8&gt; : op&lt; 24+:8&gt;;

    bits(4*8) out0;
    bits(4*8) out1;
    bits(4*8) out2;
    bits(4*8) out3;

    for c = 0 to 3
        out0&lt;c*8+:8&gt; =  (<a link="impl-shared.FFmul0E.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0E(bits(8) b)">FFmul0E</a>(in0&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul0B.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0B(bits(8) b)">FFmul0B</a>(in1&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul0D.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0D(bits(8) b)">FFmul0D</a>(in2&lt;c*8+:8&gt;) EOR
                         <a link="impl-shared.FFmul09.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul09(bits(8) b)">FFmul09</a>(in3&lt;c*8+:8&gt;));
        out1&lt;c*8+:8&gt; =  (<a link="impl-shared.FFmul09.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul09(bits(8) b)">FFmul09</a>(in0&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul0E.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0E(bits(8) b)">FFmul0E</a>(in1&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul0B.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0B(bits(8) b)">FFmul0B</a>(in2&lt;c*8+:8&gt;) EOR
                         <a link="impl-shared.FFmul0D.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0D(bits(8) b)">FFmul0D</a>(in3&lt;c*8+:8&gt;));
        out2&lt;c*8+:8&gt; =  (<a link="impl-shared.FFmul0D.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0D(bits(8) b)">FFmul0D</a>(in0&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul09.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul09(bits(8) b)">FFmul09</a>(in1&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul0E.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0E(bits(8) b)">FFmul0E</a>(in2&lt;c*8+:8&gt;) EOR
                         <a link="impl-shared.FFmul0B.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0B(bits(8) b)">FFmul0B</a>(in3&lt;c*8+:8&gt;));
        out3&lt;c*8+:8&gt; =  (<a link="impl-shared.FFmul0B.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0B(bits(8) b)">FFmul0B</a>(in0&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul0D.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0D(bits(8) b)">FFmul0D</a>(in1&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul09.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul09(bits(8) b)">FFmul09</a>(in2&lt;c*8+:8&gt;) EOR
                         <a link="impl-shared.FFmul0E.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul0E(bits(8) b)">FFmul0E</a>(in3&lt;c*8+:8&gt;));

    return (
        out3&lt;3*8+:8&gt; : out2&lt;3*8+:8&gt; : out1&lt;3*8+:8&gt; : out0&lt;3*8+:8&gt; :
        out3&lt;2*8+:8&gt; : out2&lt;2*8+:8&gt; : out1&lt;2*8+:8&gt; : out0&lt;2*8+:8&gt; :
        out3&lt;1*8+:8&gt; : out2&lt;1*8+:8&gt; : out1&lt;1*8+:8&gt; : out0&lt;1*8+:8&gt; :
        out3&lt;0*8+:8&gt; : out2&lt;0*8+:8&gt; : out1&lt;0*8+:8&gt; : out0&lt;0*8+:8&gt;
    );</pstext>
    </ps>
    <ps name="shared/functions/crypto/AESInvShiftRows" mylink="shared.functions.crypto.AESInvShiftRows" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AESInvShiftRows()
// =================
// Transformation in the Inverse Cipher that is inverse of AESShiftRows.

bits(128) <anchor link="impl-shared.AESInvShiftRows.1" hover="function: bits(128) AESInvShiftRows(bits(128) op)">AESInvShiftRows</anchor>(bits(128) op)
    return (
        op&lt; 31: 24&gt; : op&lt; 55: 48&gt; : op&lt; 79: 72&gt; : op&lt;103: 96&gt; :
        op&lt;127:120&gt; : op&lt; 23: 16&gt; : op&lt; 47: 40&gt; : op&lt; 71: 64&gt; :
        op&lt; 95: 88&gt; : op&lt;119:112&gt; : op&lt; 15:  8&gt; : op&lt; 39: 32&gt; :
        op&lt; 63: 56&gt; : op&lt; 87: 80&gt; : op&lt;111:104&gt; : op&lt;  7:  0&gt;
    );</pstext>
    </ps>
    <ps name="shared/functions/crypto/AESInvSubBytes" mylink="shared.functions.crypto.AESInvSubBytes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AESInvSubBytes()
// ================
// Transformation in the Inverse Cipher that is the inverse of AESSubBytes.

bits(128) <anchor link="impl-shared.AESInvSubBytes.1" hover="function: bits(128) AESInvSubBytes(bits(128) op)">AESInvSubBytes</anchor>(bits(128) op)
    // Inverse S-box values
    bits(16*16*8) GF2_inv = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0x7d0c2155631469e126d677ba7e042b17&lt;127:0&gt; :
        /*E*/ 0x619953833cbbebc8b0f52aae4d3be0a0&lt;127:0&gt; :
        /*D*/ 0xef9cc9939f7ae52d0d4ab519a97f5160&lt;127:0&gt; :
        /*C*/ 0x5fec8027591012b131c7078833a8dd1f&lt;127:0&gt; :
        /*B*/ 0xf45acd78fec0db9a2079d2c64b3e56fc&lt;127:0&gt; :
        /*A*/ 0x1bbe18aa0e62b76f89c5291d711af147&lt;127:0&gt; :
        /*9*/ 0x6edf751ce837f9e28535ade72274ac96&lt;127:0&gt; :
        /*8*/ 0x73e6b4f0cecff297eadc674f4111913a&lt;127:0&gt; :
        /*7*/ 0x6b8a130103bdafc1020f3fca8f1e2cd0&lt;127:0&gt; :
        /*6*/ 0x0645b3b80558e4f70ad3bc8c00abd890&lt;127:0&gt; :
        /*5*/ 0x849d8da75746155edab9edfd5048706c&lt;127:0&gt; :
        /*4*/ 0x92b6655dcc5ca4d41698688664f6f872&lt;127:0&gt; :
        /*3*/ 0x25d18b6d49a25b76b224d92866a12e08&lt;127:0&gt; :
        /*2*/ 0x4ec3fa420b954cee3d23c2a632947b54&lt;127:0&gt; :
        /*1*/ 0xcbe9dec444438e3487ff2f9b8239e37c&lt;127:0&gt; :
        /*0*/ 0xfbd7f3819ea340bf38a53630d56a0952&lt;127:0&gt;
    );
    bits(128) out;
    for i = 0 to 15
        out&lt;i*8+:8&gt; = GF2_inv&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(op&lt;i*8+:8&gt;)*8+:8&gt;;
    return out;</pstext>
    </ps>
    <ps name="shared/functions/crypto/AESMixColumns" mylink="shared.functions.crypto.AESMixColumns" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AESMixColumns()
// ===============
// Transformation in the Cipher that takes all of the columns of the
// State and mixes their data (independently of one another) to
// produce new columns.

bits(128) <anchor link="impl-shared.AESMixColumns.1" hover="function: bits(128) AESMixColumns(bits (128) op)">AESMixColumns</anchor>(bits (128) op)
    bits(4*8) in0 = op&lt; 96+:8&gt; : op&lt; 64+:8&gt; : op&lt; 32+:8&gt; : op&lt;  0+:8&gt;;
    bits(4*8) in1 = op&lt;104+:8&gt; : op&lt; 72+:8&gt; : op&lt; 40+:8&gt; : op&lt;  8+:8&gt;;
    bits(4*8) in2 = op&lt;112+:8&gt; : op&lt; 80+:8&gt; : op&lt; 48+:8&gt; : op&lt; 16+:8&gt;;
    bits(4*8) in3 = op&lt;120+:8&gt; : op&lt; 88+:8&gt; : op&lt; 56+:8&gt; : op&lt; 24+:8&gt;;

    bits(4*8) out0;
    bits(4*8) out1;
    bits(4*8) out2;
    bits(4*8) out3;

    for c = 0 to 3
        out0&lt;c*8+:8&gt; = (<a link="impl-shared.FFmul02.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul02(bits(8) b)">FFmul02</a>(in0&lt;c*8+:8&gt;) EOR <a link="impl-shared.FFmul03.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul03(bits(8) b)">FFmul03</a>(in1&lt;c*8+:8&gt;) EOR
                                 in2&lt;c*8+:8&gt;  EOR         in3&lt;c*8+:8&gt;);
        out1&lt;c*8+:8&gt; = (<a link="impl-shared.FFmul02.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul02(bits(8) b)">FFmul02</a>(in1&lt;c*8+:8&gt;)  EOR <a link="impl-shared.FFmul03.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul03(bits(8) b)">FFmul03</a>(in2&lt;c*8+:8&gt;) EOR
                                in3&lt;c*8+:8&gt;   EOR         in0&lt;c*8+:8&gt;);
        out2&lt;c*8+:8&gt; = (<a link="impl-shared.FFmul02.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul02(bits(8) b)">FFmul02</a>(in2&lt;c*8+:8&gt;)  EOR <a link="impl-shared.FFmul03.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul03(bits(8) b)">FFmul03</a>(in3&lt;c*8+:8&gt;) EOR
                                in0&lt;c*8+:8&gt;   EOR         in1&lt;c*8+:8&gt;);
        out3&lt;c*8+:8&gt; = (<a link="impl-shared.FFmul02.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul02(bits(8) b)">FFmul02</a>(in3&lt;c*8+:8&gt;)  EOR <a link="impl-shared.FFmul03.1" file="shared_pseudocode.xml" hover="function: bits(8) FFmul03(bits(8) b)">FFmul03</a>(in0&lt;c*8+:8&gt;) EOR
                                in1&lt;c*8+:8&gt;   EOR         in2&lt;c*8+:8&gt;);

    return (
        out3&lt;3*8+:8&gt; : out2&lt;3*8+:8&gt; : out1&lt;3*8+:8&gt; : out0&lt;3*8+:8&gt; :
        out3&lt;2*8+:8&gt; : out2&lt;2*8+:8&gt; : out1&lt;2*8+:8&gt; : out0&lt;2*8+:8&gt; :
        out3&lt;1*8+:8&gt; : out2&lt;1*8+:8&gt; : out1&lt;1*8+:8&gt; : out0&lt;1*8+:8&gt; :
        out3&lt;0*8+:8&gt; : out2&lt;0*8+:8&gt; : out1&lt;0*8+:8&gt; : out0&lt;0*8+:8&gt;
    );</pstext>
    </ps>
    <ps name="shared/functions/crypto/AESShiftRows" mylink="shared.functions.crypto.AESShiftRows" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AESShiftRows()
// ==============
// Transformation in the Cipher that processes the State by cyclically
// shifting the last three rows of the State by different offsets.

bits(128) <anchor link="impl-shared.AESShiftRows.1" hover="function: bits(128) AESShiftRows(bits(128) op)">AESShiftRows</anchor>(bits(128) op)
    return (
        op&lt; 95: 88&gt; : op&lt; 55: 48&gt; : op&lt; 15:  8&gt; : op&lt;103: 96&gt; :
        op&lt; 63: 56&gt; : op&lt; 23: 16&gt; : op&lt;111:104&gt; : op&lt; 71: 64&gt; :
        op&lt; 31: 24&gt; : op&lt;119:112&gt; : op&lt; 79: 72&gt; : op&lt; 39: 32&gt; :
        op&lt;127:120&gt; : op&lt; 87: 80&gt; : op&lt; 47: 40&gt; : op&lt;  7:  0&gt;
    );</pstext>
    </ps>
    <ps name="shared/functions/crypto/AESSubBytes" mylink="shared.functions.crypto.AESSubBytes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AESSubBytes()
// =============
// Transformation in the Cipher that processes the State using a nonlinear
// byte substitution table (S-box) that operates on each of the State bytes
// independently.

bits(128) <anchor link="impl-shared.AESSubBytes.1" hover="function: bits(128) AESSubBytes(bits(128) op)">AESSubBytes</anchor>(bits(128) op)
    // S-box values
    bits(16*16*8) GF2 = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0x16bb54b00f2d99416842e6bf0d89a18c&lt;127:0&gt; :
        /*E*/ 0xdf2855cee9871e9b948ed9691198f8e1&lt;127:0&gt; :
        /*D*/ 0x9e1dc186b95735610ef6034866b53e70&lt;127:0&gt; :
        /*C*/ 0x8a8bbd4b1f74dde8c6b4a61c2e2578ba&lt;127:0&gt; :
        /*B*/ 0x08ae7a65eaf4566ca94ed58d6d37c8e7&lt;127:0&gt; :
        /*A*/ 0x79e4959162acd3c25c2406490a3a32e0&lt;127:0&gt; :
        /*9*/ 0xdb0b5ede14b8ee4688902a22dc4f8160&lt;127:0&gt; :
        /*8*/ 0x73195d643d7ea7c41744975fec130ccd&lt;127:0&gt; :
        /*7*/ 0xd2f3ff1021dab6bcf5389d928f40a351&lt;127:0&gt; :
        /*6*/ 0xa89f3c507f02f94585334d43fbaaefd0&lt;127:0&gt; :
        /*5*/ 0xcf584c4a39becb6a5bb1fc20ed00d153&lt;127:0&gt; :
        /*4*/ 0x842fe329b3d63b52a05a6e1b1a2c8309&lt;127:0&gt; :
        /*3*/ 0x75b227ebe28012079a059618c323c704&lt;127:0&gt; :
        /*2*/ 0x1531d871f1e5a534ccf73f362693fdb7&lt;127:0&gt; :
        /*1*/ 0xc072a49cafa2d4adf04759fa7dc982ca&lt;127:0&gt; :
        /*0*/ 0x76abd7fe2b670130c56f6bf27b777c63&lt;127:0&gt;
    );
    bits(128) out;
    for i = 0 to 15
        out&lt;i*8+:8&gt; = GF2&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(op&lt;i*8+:8&gt;)*8+:8&gt;;
    return out;</pstext>
    </ps>
    <ps name="shared/functions/crypto/FFmul02" mylink="shared.functions.crypto.FFmul02" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFmul02()
// =========

bits(8) <anchor link="impl-shared.FFmul02.1" hover="function: bits(8) FFmul02(bits(8) b)">FFmul02</anchor>(bits(8) b)
    bits(256*8) FFmul_02 = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0xE5E7E1E3EDEFE9EBF5F7F1F3FDFFF9FB&lt;127:0&gt; :
        /*E*/ 0xC5C7C1C3CDCFC9CBD5D7D1D3DDDFD9DB&lt;127:0&gt; :
        /*D*/ 0xA5A7A1A3ADAFA9ABB5B7B1B3BDBFB9BB&lt;127:0&gt; :
        /*C*/ 0x858781838D8F898B959791939D9F999B&lt;127:0&gt; :
        /*B*/ 0x656761636D6F696B757771737D7F797B&lt;127:0&gt; :
        /*A*/ 0x454741434D4F494B555751535D5F595B&lt;127:0&gt; :
        /*9*/ 0x252721232D2F292B353731333D3F393B&lt;127:0&gt; :
        /*8*/ 0x050701030D0F090B151711131D1F191B&lt;127:0&gt; :
        /*7*/ 0xFEFCFAF8F6F4F2F0EEECEAE8E6E4E2E0&lt;127:0&gt; :
        /*6*/ 0xDEDCDAD8D6D4D2D0CECCCAC8C6C4C2C0&lt;127:0&gt; :
        /*5*/ 0xBEBCBAB8B6B4B2B0AEACAAA8A6A4A2A0&lt;127:0&gt; :
        /*4*/ 0x9E9C9A98969492908E8C8A8886848280&lt;127:0&gt; :
        /*3*/ 0x7E7C7A78767472706E6C6A6866646260&lt;127:0&gt; :
        /*2*/ 0x5E5C5A58565452504E4C4A4846444240&lt;127:0&gt; :
        /*1*/ 0x3E3C3A38363432302E2C2A2826242220&lt;127:0&gt; :
        /*0*/ 0x1E1C1A18161412100E0C0A0806040200&lt;127:0&gt;
    );
    return FFmul_02&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(b)*8+:8&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/FFmul03" mylink="shared.functions.crypto.FFmul03" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFmul03()
// =========

bits(8) <anchor link="impl-shared.FFmul03.1" hover="function: bits(8) FFmul03(bits(8) b)">FFmul03</anchor>(bits(8) b)
    bits(256*8) FFmul_03 = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0x1A191C1F16151013020104070E0D080B&lt;127:0&gt; :
        /*E*/ 0x2A292C2F26252023323134373E3D383B&lt;127:0&gt; :
        /*D*/ 0x7A797C7F76757073626164676E6D686B&lt;127:0&gt; :
        /*C*/ 0x4A494C4F46454043525154575E5D585B&lt;127:0&gt; :
        /*B*/ 0xDAD9DCDFD6D5D0D3C2C1C4C7CECDC8CB&lt;127:0&gt; :
        /*A*/ 0xEAE9ECEFE6E5E0E3F2F1F4F7FEFDF8FB&lt;127:0&gt; :
        /*9*/ 0xBAB9BCBFB6B5B0B3A2A1A4A7AEADA8AB&lt;127:0&gt; :
        /*8*/ 0x8A898C8F86858083929194979E9D989B&lt;127:0&gt; :
        /*7*/ 0x818287848D8E8B88999A9F9C95969390&lt;127:0&gt; :
        /*6*/ 0xB1B2B7B4BDBEBBB8A9AAAFACA5A6A3A0&lt;127:0&gt; :
        /*5*/ 0xE1E2E7E4EDEEEBE8F9FAFFFCF5F6F3F0&lt;127:0&gt; :
        /*4*/ 0xD1D2D7D4DDDEDBD8C9CACFCCC5C6C3C0&lt;127:0&gt; :
        /*3*/ 0x414247444D4E4B48595A5F5C55565350&lt;127:0&gt; :
        /*2*/ 0x717277747D7E7B78696A6F6C65666360&lt;127:0&gt; :
        /*1*/ 0x212227242D2E2B28393A3F3C35363330&lt;127:0&gt; :
        /*0*/ 0x111217141D1E1B18090A0F0C05060300&lt;127:0&gt;
    );
    return FFmul_03&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(b)*8+:8&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/FFmul09" mylink="shared.functions.crypto.FFmul09" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFmul09()
// =========

bits(8) <anchor link="impl-shared.FFmul09.1" hover="function: bits(8) FFmul09(bits(8) b)">FFmul09</anchor>(bits(8) b)
    bits(256*8) FFmul_09 = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0x464F545D626B70790E071C152A233831&lt;127:0&gt; :
        /*E*/ 0xD6DFC4CDF2FBE0E99E978C85BAB3A8A1&lt;127:0&gt; :
        /*D*/ 0x7D746F6659504B42353C272E1118030A&lt;127:0&gt; :
        /*C*/ 0xEDE4FFF6C9C0DBD2A5ACB7BE8188939A&lt;127:0&gt; :
        /*B*/ 0x3039222B141D060F78716A635C554E47&lt;127:0&gt; :
        /*A*/ 0xA0A9B2BB848D969FE8E1FAF3CCC5DED7&lt;127:0&gt; :
        /*9*/ 0x0B0219102F263D34434A5158676E757C&lt;127:0&gt; :
        /*8*/ 0x9B928980BFB6ADA4D3DAC1C8F7FEE5EC&lt;127:0&gt; :
        /*7*/ 0xAAA3B8B18E879C95E2EBF0F9C6CFD4DD&lt;127:0&gt; :
        /*6*/ 0x3A3328211E170C05727B6069565F444D&lt;127:0&gt; :
        /*5*/ 0x9198838AB5BCA7AED9D0CBC2FDF4EFE6&lt;127:0&gt; :
        /*4*/ 0x0108131A252C373E49405B526D647F76&lt;127:0&gt; :
        /*3*/ 0xDCD5CEC7F8F1EAE3949D868FB0B9A2AB&lt;127:0&gt; :
        /*2*/ 0x4C455E5768617A73040D161F2029323B&lt;127:0&gt; :
        /*1*/ 0xE7EEF5FCC3CAD1D8AFA6BDB48B829990&lt;127:0&gt; :
        /*0*/ 0x777E656C535A41483F362D241B120900&lt;127:0&gt;
    );
    return FFmul_09&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(b)*8+:8&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/FFmul0B" mylink="shared.functions.crypto.FFmul0B" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFmul0B()
// =========

bits(8) <anchor link="impl-shared.FFmul0B.1" hover="function: bits(8) FFmul0B(bits(8) b)">FFmul0B</anchor>(bits(8) b)
    bits(256*8) FFmul_0B = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0xA3A8B5BE8F849992FBF0EDE6D7DCC1CA&lt;127:0&gt; :
        /*E*/ 0x1318050E3F3429224B405D56676C717A&lt;127:0&gt; :
        /*D*/ 0xD8D3CEC5F4FFE2E9808B969DACA7BAB1&lt;127:0&gt; :
        /*C*/ 0x68637E75444F5259303B262D1C170A01&lt;127:0&gt; :
        /*B*/ 0x555E434879726F640D061B10212A373C&lt;127:0&gt; :
        /*A*/ 0xE5EEF3F8C9C2DFD4BDB6ABA0919A878C&lt;127:0&gt; :
        /*9*/ 0x2E2538330209141F767D606B5A514C47&lt;127:0&gt; :
        /*8*/ 0x9E958883B2B9A4AFC6CDD0DBEAE1FCF7&lt;127:0&gt; :
        /*7*/ 0x545F424978736E650C071A11202B363D&lt;127:0&gt; :
        /*6*/ 0xE4EFF2F9C8C3DED5BCB7AAA1909B868D&lt;127:0&gt; :
        /*5*/ 0x2F2439320308151E777C616A5B504D46&lt;127:0&gt; :
        /*4*/ 0x9F948982B3B8A5AEC7CCD1DAEBE0FDF6&lt;127:0&gt; :
        /*3*/ 0xA2A9B4BF8E859893FAF1ECE7D6DDC0CB&lt;127:0&gt; :
        /*2*/ 0x1219040F3E3528234A415C57666D707B&lt;127:0&gt; :
        /*1*/ 0xD9D2CFC4F5FEE3E8818A979CADA6BBB0&lt;127:0&gt; :
        /*0*/ 0x69627F74454E5358313A272C1D160B00&lt;127:0&gt;
    );
    return FFmul_0B&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(b)*8+:8&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/FFmul0D" mylink="shared.functions.crypto.FFmul0D" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFmul0D()
// =========

bits(8) <anchor link="impl-shared.FFmul0D.1" hover="function: bits(8) FFmul0D(bits(8) b)">FFmul0D</anchor>(bits(8) b)
    bits(256*8) FFmul_0D = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0x979A8D80A3AEB9B4FFF2E5E8CBC6D1DC&lt;127:0&gt; :
        /*E*/ 0x474A5D50737E69642F2235381B16010C&lt;127:0&gt; :
        /*D*/ 0x2C21363B1815020F44495E53707D6A67&lt;127:0&gt; :
        /*C*/ 0xFCF1E6EBC8C5D2DF94998E83A0ADBAB7&lt;127:0&gt; :
        /*B*/ 0xFAF7E0EDCEC3D4D9929F8885A6ABBCB1&lt;127:0&gt; :
        /*A*/ 0x2A27303D1E130409424F5855767B6C61&lt;127:0&gt; :
        /*9*/ 0x414C5B5675786F622924333E1D10070A&lt;127:0&gt; :
        /*8*/ 0x919C8B86A5A8BFB2F9F4E3EECDC0D7DA&lt;127:0&gt; :
        /*7*/ 0x4D40575A7974636E25283F32111C0B06&lt;127:0&gt; :
        /*6*/ 0x9D90878AA9A4B3BEF5F8EFE2C1CCDBD6&lt;127:0&gt; :
        /*5*/ 0xF6FBECE1C2CFD8D59E938489AAA7B0BD&lt;127:0&gt; :
        /*4*/ 0x262B3C31121F08054E4354597A77606D&lt;127:0&gt; :
        /*3*/ 0x202D3A3714190E034845525F7C71666B&lt;127:0&gt; :
        /*2*/ 0xF0FDEAE7C4C9DED39895828FACA1B6BB&lt;127:0&gt; :
        /*1*/ 0x9B96818CAFA2B5B8F3FEE9E4C7CADDD0&lt;127:0&gt; :
        /*0*/ 0x4B46515C7F726568232E3934171A0D00&lt;127:0&gt;
    );
    return FFmul_0D&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(b)*8+:8&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/FFmul0E" mylink="shared.functions.crypto.FFmul0E" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FFmul0E()
// =========

bits(8) <anchor link="impl-shared.FFmul0E.1" hover="function: bits(8) FFmul0E(bits(8) b)">FFmul0E</anchor>(bits(8) b)
    bits(256*8) FFmul_0E = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0x8D83919FB5BBA9A7FDF3E1EFC5CBD9D7&lt;127:0&gt; :
        /*E*/ 0x6D63717F555B49471D13010F252B3937&lt;127:0&gt; :
        /*D*/ 0x56584A446E60727C26283A341E10020C&lt;127:0&gt; :
        /*C*/ 0xB6B8AAA48E80929CC6C8DAD4FEF0E2EC&lt;127:0&gt; :
        /*B*/ 0x202E3C321816040A505E4C426866747A&lt;127:0&gt; :
        /*A*/ 0xC0CEDCD2F8F6E4EAB0BEACA28886949A&lt;127:0&gt; :
        /*9*/ 0xFBF5E7E9C3CDDFD18B859799B3BDAFA1&lt;127:0&gt; :
        /*8*/ 0x1B150709232D3F316B657779535D4F41&lt;127:0&gt; :
        /*7*/ 0xCCC2D0DEF4FAE8E6BCB2A0AE848A9896&lt;127:0&gt; :
        /*6*/ 0x2C22303E141A08065C52404E646A7876&lt;127:0&gt; :
        /*5*/ 0x17190B052F21333D67697B755F51434D&lt;127:0&gt; :
        /*4*/ 0xF7F9EBE5CFC1D3DD87899B95BFB1A3AD&lt;127:0&gt; :
        /*3*/ 0x616F7D735957454B111F0D032927353B&lt;127:0&gt; :
        /*2*/ 0x818F9D93B9B7A5ABF1FFEDE3C9C7D5DB&lt;127:0&gt; :
        /*1*/ 0xBAB4A6A8828C9E90CAC4D6D8F2FCEEE0&lt;127:0&gt; :
        /*0*/ 0x5A544648626C7E702A243638121C0E00&lt;127:0&gt;
    );
    return FFmul_0E&lt;<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(b)*8+:8&gt;;</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveAESExt" mylink="shared.functions.crypto.HaveAESExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAESExt()
// ============
// TRUE if AES cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveAESExt.0" hover="function: boolean HaveAESExt()">HaveAESExt</anchor>()
    return IsFeatureImplemented(FEAT_AES);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveBit128PMULLExt" mylink="shared.functions.crypto.HaveBit128PMULLExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveBit128PMULLExt()
// ====================
// TRUE if 128 bit form of PMULL instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveBit128PMULLExt.0" hover="function: boolean HaveBit128PMULLExt()">HaveBit128PMULLExt</anchor>()
    return IsFeatureImplemented(FEAT_PMULL);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveSHA1Ext" mylink="shared.functions.crypto.HaveSHA1Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSHA1Ext()
// =============
// TRUE if SHA1 cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveSHA1Ext.0" hover="function: boolean HaveSHA1Ext()">HaveSHA1Ext</anchor>()
    return IsFeatureImplemented(FEAT_SHA1);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveSHA256Ext" mylink="shared.functions.crypto.HaveSHA256Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSHA256Ext()
// ===============
// TRUE if SHA256 cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveSHA256Ext.0" hover="function: boolean HaveSHA256Ext()">HaveSHA256Ext</anchor>()
    return IsFeatureImplemented(FEAT_SHA256);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveSHA3Ext" mylink="shared.functions.crypto.HaveSHA3Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSHA3Ext()
// =============
// TRUE if SHA3 cryptographic instructions support is implemented,
// and when SHA1 and SHA2 basic cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveSHA3Ext.0" hover="function: boolean HaveSHA3Ext()">HaveSHA3Ext</anchor>()
    return IsFeatureImplemented(FEAT_SHA3);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveSHA512Ext" mylink="shared.functions.crypto.HaveSHA512Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSHA512Ext()
// ===============
// TRUE if SHA512 cryptographic instructions support is implemented,
// and when SHA1 and SHA2 basic cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveSHA512Ext.0" hover="function: boolean HaveSHA512Ext()">HaveSHA512Ext</anchor>()
    return IsFeatureImplemented(FEAT_SHA512);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveSM3Ext" mylink="shared.functions.crypto.HaveSM3Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSM3Ext()
// ============
// TRUE if SM3 cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveSM3Ext.0" hover="function: boolean HaveSM3Ext()">HaveSM3Ext</anchor>()
    return IsFeatureImplemented(FEAT_SM3);</pstext>
    </ps>
    <ps name="shared/functions/crypto/HaveSM4Ext" mylink="shared.functions.crypto.HaveSM4Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSM4Ext()
// ============
// TRUE if SM4 cryptographic instructions support is implemented,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveSM4Ext.0" hover="function: boolean HaveSM4Ext()">HaveSM4Ext</anchor>()
    return IsFeatureImplemented(FEAT_SM4);</pstext>
    </ps>
    <ps name="shared/functions/crypto/ROL" mylink="shared.functions.crypto.ROL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ROL()
// =====

bits(N) <anchor link="impl-shared.ROL.2" hover="function: bits(N) ROL(bits(N) x, integer shift)">ROL</anchor>(bits(N) x, integer shift)
    assert shift &gt;= 0 &amp;&amp; shift &lt;= N;
    if (shift == 0) then
        return x;
    return <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, N-shift);</pstext>
    </ps>
    <ps name="shared/functions/crypto/SHA256hash" mylink="shared.functions.crypto.SHA256hash" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SHA256hash()
// ============

bits(128) <anchor link="impl-shared.SHA256hash.4" hover="function: bits(128) SHA256hash(bits (128) x_in, bits(128) y_in, bits(128) w, boolean part1)">SHA256hash</anchor>(bits (128) x_in, bits(128) y_in, bits(128) w, boolean part1)
    bits(32) chs, maj, t;
    bits(128) x = x_in;
    bits(128) y = y_in;

    for e = 0 to 3
        chs = <a link="impl-shared.SHAchoose.3" file="shared_pseudocode.xml" hover="function: bits(32) SHAchoose(bits(32) x, bits(32) y, bits(32) z)">SHAchoose</a>(y&lt;31:0&gt;, y&lt;63:32&gt;, y&lt;95:64&gt;);
        maj = <a link="impl-shared.SHAmajority.3" file="shared_pseudocode.xml" hover="function: bits(32) SHAmajority(bits(32) x, bits(32) y, bits(32) z)">SHAmajority</a>(x&lt;31:0&gt;, x&lt;63:32&gt;, x&lt;95:64&gt;);
        t = y&lt;127:96&gt; + <a link="impl-shared.SHAhashSIGMA1.1" file="shared_pseudocode.xml" hover="function: bits(32) SHAhashSIGMA1(bits(32) x)">SHAhashSIGMA1</a>(y&lt;31:0&gt;) + chs + <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[w, e, 32];
        x&lt;127:96&gt; = t + x&lt;127:96&gt;;
        y&lt;127:96&gt; = t + <a link="impl-shared.SHAhashSIGMA0.1" file="shared_pseudocode.xml" hover="function: bits(32) SHAhashSIGMA0(bits(32) x)">SHAhashSIGMA0</a>(x&lt;31:0&gt;) + maj;
        &lt;y, x&gt; = <a link="impl-shared.ROL.2" file="shared_pseudocode.xml" hover="function: bits(N) ROL(bits(N) x, integer shift)">ROL</a>(y : x, 32);
    return (if part1 then x else y);</pstext>
    </ps>
    <ps name="shared/functions/crypto/SHAchoose" mylink="shared.functions.crypto.SHAchoose" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SHAchoose()
// ===========

bits(32) <anchor link="impl-shared.SHAchoose.3" hover="function: bits(32) SHAchoose(bits(32) x, bits(32) y, bits(32) z)">SHAchoose</anchor>(bits(32) x, bits(32) y, bits(32) z)
    return (((y EOR z) AND x) EOR z);</pstext>
    </ps>
    <ps name="shared/functions/crypto/SHAhashSIGMA0" mylink="shared.functions.crypto.SHAhashSIGMA0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SHAhashSIGMA0()
// ===============

bits(32) <anchor link="impl-shared.SHAhashSIGMA0.1" hover="function: bits(32) SHAhashSIGMA0(bits(32) x)">SHAhashSIGMA0</anchor>(bits(32) x)
    return <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, 2) EOR <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, 13) EOR <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, 22);</pstext>
    </ps>
    <ps name="shared/functions/crypto/SHAhashSIGMA1" mylink="shared.functions.crypto.SHAhashSIGMA1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SHAhashSIGMA1()
// ===============

bits(32) <anchor link="impl-shared.SHAhashSIGMA1.1" hover="function: bits(32) SHAhashSIGMA1(bits(32) x)">SHAhashSIGMA1</anchor>(bits(32) x)
    return <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, 6) EOR <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, 11) EOR <a link="impl-shared.ROR.2" file="shared_pseudocode.xml" hover="function: bits(N) ROR(bits(N) x, integer shift)">ROR</a>(x, 25);</pstext>
    </ps>
    <ps name="shared/functions/crypto/SHAmajority" mylink="shared.functions.crypto.SHAmajority" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SHAmajority()
// =============

bits(32) <anchor link="impl-shared.SHAmajority.3" hover="function: bits(32) SHAmajority(bits(32) x, bits(32) y, bits(32) z)">SHAmajority</anchor>(bits(32) x, bits(32) y, bits(32) z)
    return ((x AND y) OR ((x OR y) AND z));</pstext>
    </ps>
    <ps name="shared/functions/crypto/SHAparity" mylink="shared.functions.crypto.SHAparity" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SHAparity()
// ===========

bits(32) <anchor link="impl-shared.SHAparity.3" hover="function: bits(32) SHAparity(bits(32) x, bits(32) y, bits(32) z)">SHAparity</anchor>(bits(32) x, bits(32) y, bits(32) z)
    return (x EOR y EOR z);</pstext>
    </ps>
    <ps name="shared/functions/crypto/Sbox" mylink="shared.functions.crypto.Sbox" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Sbox()
// ======
// Used in SM4E crypto instruction

bits(8) <anchor link="impl-shared.Sbox.1" hover="function: bits(8) Sbox(bits(8) sboxin)">Sbox</anchor>(bits(8) sboxin)
    bits(8) sboxout;
    bits(2048) sboxstring = (
        /*       F E D C B A 9 8 7 6 5 4 3 2 1 0       */
        /*F*/ 0xd690e9fecce13db716b614c228fb2c05&lt;127:0&gt; :
        /*E*/ 0x2b679a762abe04c3aa44132649860699&lt;127:0&gt; :
        /*D*/ 0x9c4250f491ef987a33540b43edcfac62&lt;127:0&gt; :
        /*C*/ 0xe4b31ca9c908e89580df94fa758f3fa6&lt;127:0&gt; :
        /*B*/ 0x4707a7fcf37317ba83593c19e6854fa8&lt;127:0&gt; :
        /*A*/ 0x686b81b27164da8bf8eb0f4b70569d35&lt;127:0&gt; :
        /*9*/ 0x1e240e5e6358d1a225227c3b01217887&lt;127:0&gt; :
        /*8*/ 0xd40046579fd327524c3602e7a0c4c89e&lt;127:0&gt; :
        /*7*/ 0xeabf8ad240c738b5a3f7f2cef96115a1&lt;127:0&gt; :
        /*6*/ 0xe0ae5da49b341a55ad933230f58cb1e3&lt;127:0&gt; :
        /*5*/ 0x1df6e22e8266ca60c02923ab0d534e6f&lt;127:0&gt; :
        /*4*/ 0xd5db3745defd8e2f03ff6a726d6c5b51&lt;127:0&gt; :
        /*3*/ 0x8d1baf92bbddbc7f11d95c411f105ad8&lt;127:0&gt; :
        /*2*/ 0x0ac13188a5cd7bbd2d74d012b8e5b4b0&lt;127:0&gt; :
        /*1*/ 0x8969974a0c96777e65b9f109c56ec684&lt;127:0&gt; :
        /*0*/ 0x18f07dec3adc4d2079ee5f3ed7cb3948&lt;127:0&gt;
    );

    sboxout = sboxstring&lt;(255-<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(sboxin))*8+7:(255-<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(sboxin))*8&gt;;
    return sboxout;</pstext>
    </ps>
    <ps name="shared/functions/exclusive/ClearExclusiveByAddress" mylink="shared.functions.exclusive.ClearExclusiveByAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearExclusiveByAddress()
// =========================
// Clear the global Exclusives monitors for all PEs EXCEPT processorid if they
// record any part of the physical address region of size bytes starting at paddress.
// It is IMPLEMENTATION DEFINED whether the global Exclusives monitor for processorid
// is also cleared if it records any part of the address region.

<anchor link="impl-shared.ClearExclusiveByAddress.3" hover="function: ClearExclusiveByAddress(FullAddress paddress, integer processorid, integer size)">ClearExclusiveByAddress</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> paddress, integer processorid, integer size);</pstext>
    </ps>
    <ps name="shared/functions/exclusive/ClearExclusiveLocal" mylink="shared.functions.exclusive.ClearExclusiveLocal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearExclusiveLocal()
// =====================
// Clear the local Exclusives monitor for the specified processorid.

<anchor link="impl-shared.ClearExclusiveLocal.1" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</anchor>(integer processorid);</pstext>
    </ps>
    <ps name="shared/functions/exclusive/ClearExclusiveMonitors" mylink="shared.functions.exclusive.ClearExclusiveMonitors" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearExclusiveMonitors()
// ========================
// Clear the local Exclusives monitor for the executing PE.

<anchor link="impl-shared.ClearExclusiveMonitors.0" hover="function: ClearExclusiveMonitors()">ClearExclusiveMonitors</anchor>()
    <a link="impl-shared.ClearExclusiveLocal.1" file="shared_pseudocode.xml" hover="function: ClearExclusiveLocal(integer processorid)">ClearExclusiveLocal</a>(<a link="impl-shared.ProcessorID.0" file="shared_pseudocode.xml" hover="function: integer ProcessorID()">ProcessorID</a>());</pstext>
    </ps>
    <ps name="shared/functions/exclusive/ExclusiveMonitorsStatus" mylink="shared.functions.exclusive.ExclusiveMonitorsStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExclusiveMonitorsStatus()
// =========================
// Returns '0' to indicate success if the last memory write by this PE was to
// the same physical address region endorsed by ExclusiveMonitorsPass().
// Returns '1' to indicate failure if address translation resulted in a different
// physical address.

bit <anchor link="impl-shared.ExclusiveMonitorsStatus.0" hover="function: bit ExclusiveMonitorsStatus()">ExclusiveMonitorsStatus</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/exclusive/IsExclusiveGlobal" mylink="shared.functions.exclusive.IsExclusiveGlobal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsExclusiveGlobal()
// ===================
// Return TRUE if the global Exclusives monitor for processorid includes all of
// the physical address region of size bytes starting at paddress.

boolean <anchor link="impl-shared.IsExclusiveGlobal.3" hover="function: boolean IsExclusiveGlobal(FullAddress paddress, integer processorid, integer size)">IsExclusiveGlobal</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> paddress, integer processorid, integer size);</pstext>
    </ps>
    <ps name="shared/functions/exclusive/IsExclusiveLocal" mylink="shared.functions.exclusive.IsExclusiveLocal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsExclusiveLocal()
// ==================
// Return TRUE if the local Exclusives monitor for processorid includes all of
// the physical address region of size bytes starting at paddress.

boolean <anchor link="impl-shared.IsExclusiveLocal.3" hover="function: boolean IsExclusiveLocal(FullAddress paddress, integer processorid, integer size)">IsExclusiveLocal</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> paddress, integer processorid, integer size);</pstext>
    </ps>
    <ps name="shared/functions/exclusive/MarkExclusiveGlobal" mylink="shared.functions.exclusive.MarkExclusiveGlobal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MarkExclusiveGlobal()
// =====================
// Record the physical address region of size bytes starting at paddress in
// the global Exclusives monitor for processorid.

<anchor link="impl-shared.MarkExclusiveGlobal.3" hover="function: MarkExclusiveGlobal(FullAddress paddress, integer processorid, integer size)">MarkExclusiveGlobal</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> paddress, integer processorid, integer size);</pstext>
    </ps>
    <ps name="shared/functions/exclusive/MarkExclusiveLocal" mylink="shared.functions.exclusive.MarkExclusiveLocal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MarkExclusiveLocal()
// ====================
// Record the physical address region of size bytes starting at paddress in
// the local Exclusives monitor for processorid.

<anchor link="impl-shared.MarkExclusiveLocal.3" hover="function: MarkExclusiveLocal(FullAddress paddress, integer processorid, integer size)">MarkExclusiveLocal</anchor>(<a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> paddress, integer processorid, integer size);</pstext>
    </ps>
    <ps name="shared/functions/exclusive/ProcessorID" mylink="shared.functions.exclusive.ProcessorID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ProcessorID()
// =============
// Return the ID of the currently executing PE.

integer <anchor link="impl-shared.ProcessorID.0" hover="function: integer ProcessorID()">ProcessorID</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/extension/AArch32.HaveHPDExt" mylink="shared.functions.extension.AArch32.HaveHPDExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.HaveHPDExt()
// ====================

boolean <anchor link="AArch32.HaveHPDExt.0" hover="function: boolean AArch32.HaveHPDExt()">AArch32.HaveHPDExt</anchor>()
    return IsFeatureImplemented(FEAT_AA32HPD);</pstext>
    </ps>
    <ps name="shared/functions/extension/AArch64.HaveHPDExt" mylink="shared.functions.extension.AArch64.HaveHPDExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.HaveHPDExt()
// ====================

boolean <anchor link="AArch64.HaveHPDExt.0" hover="function: boolean AArch64.HaveHPDExt()">AArch64.HaveHPDExt</anchor>()
    return IsFeatureImplemented(FEAT_HPDS);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have128BitDescriptorExt" mylink="shared.functions.extension.Have128BitDescriptorExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have128BitDescriptorExt()
// =========================
// Returns TRUE if 128-bit Descriptor extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Have128BitDescriptorExt.0" hover="function: boolean Have128BitDescriptorExt()">Have128BitDescriptorExt</anchor>()
    return IsFeatureImplemented(FEAT_D128);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have16bitVMID" mylink="shared.functions.extension.Have16bitVMID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have16bitVMID()
// ===============
// Returns TRUE if EL2 and support for a 16-bit VMID are implemented.

boolean <anchor link="impl-shared.Have16bitVMID.0" hover="function: boolean Have16bitVMID()">Have16bitVMID</anchor>()
    return IsFeatureImplemented(FEAT_VMID16);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have52BitIPAAndPASpaceExt" mylink="shared.functions.extension.Have52BitIPAAndPASpaceExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have52BitIPAAndPASpaceExt()
// ===========================
// Returns TRUE if 52-bit IPA and PA extension support
// is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.Have52BitIPAAndPASpaceExt.0" hover="function: boolean Have52BitIPAAndPASpaceExt()">Have52BitIPAAndPASpaceExt</anchor>()
    return IsFeatureImplemented(FEAT_LPA2);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have52BitPAExt" mylink="shared.functions.extension.Have52BitPAExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have52BitPAExt()
// ================
// Returns TRUE if Large Physical Address extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Have52BitPAExt.0" hover="function: boolean Have52BitPAExt()">Have52BitPAExt</anchor>()
    return IsFeatureImplemented(FEAT_LPA);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have52BitVAExt" mylink="shared.functions.extension.Have52BitVAExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have52BitVAExt()
// ================
// Returns TRUE if Large Virtual Address extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Have52BitVAExt.0" hover="function: boolean Have52BitVAExt()">Have52BitVAExt</anchor>()
    return IsFeatureImplemented(FEAT_LVA);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have56BitPAExt" mylink="shared.functions.extension.Have56BitPAExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have56BitPAExt()
// ================
// Returns TRUE if 56-bit Physical Address extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Have56BitPAExt.0" hover="function: boolean Have56BitPAExt()">Have56BitPAExt</anchor>()
    return IsFeatureImplemented(FEAT_D128);</pstext>
    </ps>
    <ps name="shared/functions/extension/Have56BitVAExt" mylink="shared.functions.extension.Have56BitVAExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Have56BitVAExt()
// ================
// Returns TRUE if 56-bit Virtual Address extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Have56BitVAExt.0" hover="function: boolean Have56BitVAExt()">Have56BitVAExt</anchor>()
    return IsFeatureImplemented(FEAT_LVA3);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAArch32BF16Ext" mylink="shared.functions.extension.HaveAArch32BF16Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAArch32BF16Ext()
// ====================
// Returns TRUE if AArch32 BFloat16 instruction support is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveAArch32BF16Ext.0" hover="function: boolean HaveAArch32BF16Ext()">HaveAArch32BF16Ext</anchor>()
    return IsFeatureImplemented(FEAT_AA32BF16);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAArch32Int8MatMulExt" mylink="shared.functions.extension.HaveAArch32Int8MatMulExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAArch32Int8MatMulExt()
// ==========================
// Returns TRUE if AArch32 8-bit integer matrix multiply instruction support
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveAArch32Int8MatMulExt.0" hover="function: boolean HaveAArch32Int8MatMulExt()">HaveAArch32Int8MatMulExt</anchor>()
    return IsFeatureImplemented(FEAT_AA32I8MM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAIEExt" mylink="shared.functions.extension.HaveAIEExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAIEExt()
// ============
// Returns TRUE if AIE extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveAIEExt.0" hover="function: boolean HaveAIEExt()">HaveAIEExt</anchor>()
    return IsFeatureImplemented(FEAT_AIE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAccessFlagUpdateExt" mylink="shared.functions.extension.HaveAccessFlagUpdateExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAccessFlagUpdateExt()
// =========================

boolean <anchor link="impl-shared.HaveAccessFlagUpdateExt.0" hover="function: boolean HaveAccessFlagUpdateExt()">HaveAccessFlagUpdateExt</anchor>()
    return IsFeatureImplemented(FEAT_HAFDBS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAccessFlagUpdateForTableExt" mylink="shared.functions.extension.HaveAccessFlagUpdateForTableExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAccessFlagUpdateForTableExt()
// =================================
// Returns TRUE if support for Access Flag Update for Table Descriptors
// is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveAccessFlagUpdateForTableExt.0" hover="function: boolean HaveAccessFlagUpdateForTableExt()">HaveAccessFlagUpdateForTableExt</anchor>()
    return IsFeatureImplemented(FEAT_HAFT);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAltFP" mylink="shared.functions.extension.HaveAltFP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAltFP()
// ===========
// Returns TRUE if alternative Floating-point extension support
// is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveAltFP.0" hover="function: boolean HaveAltFP()">HaveAltFP</anchor>()
    return IsFeatureImplemented(FEAT_AFP);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveAtomicExt" mylink="shared.functions.extension.HaveAtomicExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAtomicExt()
// ===============

boolean <anchor link="impl-shared.HaveAtomicExt.0" hover="function: boolean HaveAtomicExt()">HaveAtomicExt</anchor>()
    return IsFeatureImplemented(FEAT_LSE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveBF16Ext" mylink="shared.functions.extension.HaveBF16Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveBF16Ext()
// =============
// Returns TRUE if AArch64 BFloat16 instruction support is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveBF16Ext.0" hover="function: boolean HaveBF16Ext()">HaveBF16Ext</anchor>()
    return IsFeatureImplemented(FEAT_BF16);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveBRBEv1p1" mylink="shared.functions.extension.HaveBRBEv1p1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveBRBEv1p1()
// ==============
// Returns TRUE if BRBEv1p1 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveBRBEv1p1.0" hover="function: boolean HaveBRBEv1p1()">HaveBRBEv1p1</anchor>()
    return IsFeatureImplemented(FEAT_BRBEv1p1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveBRBExt" mylink="shared.functions.extension.HaveBRBExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveBRBExt()
// ============
// Returns TRUE if Branch Record Buffer Extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveBRBExt.0" hover="function: boolean HaveBRBExt()">HaveBRBExt</anchor>()
    return IsFeatureImplemented(FEAT_BRBE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveBTIExt" mylink="shared.functions.extension.HaveBTIExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveBTIExt()
// ============
// Returns TRUE if support for Branch Target Indentification is implemented.

boolean <anchor link="impl-shared.HaveBTIExt.0" hover="function: boolean HaveBTIExt()">HaveBTIExt</anchor>()
    return IsFeatureImplemented(FEAT_BTI);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveBlockBBM" mylink="shared.functions.extension.HaveBlockBBM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveBlockBBM()
// ==============
// Returns TRUE if support for changing block size without requiring
// break-before-make is implemented.

boolean <anchor link="impl-shared.HaveBlockBBM.0" hover="function: boolean HaveBlockBBM()">HaveBlockBBM</anchor>()
    return IsFeatureImplemented(FEAT_BBM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveCNTSCExt" mylink="shared.functions.extension.HaveCNTSCExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveCNTSCExt()
// ==============
// Returns TRUE if the Generic Counter Scaling is implemented, and FALSE
// otherwise.

boolean <anchor link="impl-shared.HaveCNTSCExt.0" hover="function: boolean HaveCNTSCExt()">HaveCNTSCExt</anchor>()
    return IsFeatureImplemented(FEAT_CNTSC);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveCSSC" mylink="shared.functions.extension.HaveCSSC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveCSSC()
// ==========
// Returns TRUE if the Common Short Sequence Compression instructions extension is implemented,
// and FALSE otherwise.

boolean <anchor link="impl-shared.HaveCSSC.0" hover="function: boolean HaveCSSC()">HaveCSSC</anchor>()
    return IsFeatureImplemented(FEAT_CSSC);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveCommonNotPrivateTransExt" mylink="shared.functions.extension.HaveCommonNotPrivateTransExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveCommonNotPrivateTransExt()
// ==============================

boolean <anchor link="impl-shared.HaveCommonNotPrivateTransExt.0" hover="function: boolean HaveCommonNotPrivateTransExt()">HaveCommonNotPrivateTransExt</anchor>()
    return IsFeatureImplemented(FEAT_TTCNP);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDGHExt" mylink="shared.functions.extension.HaveDGHExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDGHExt()
// ============
// Returns TRUE if Data Gathering Hint instruction support is implemented, and
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveDGHExt.0" hover="function: boolean HaveDGHExt()">HaveDGHExt</anchor>()
    return IsFeatureImplemented(FEAT_DGH);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDITExt" mylink="shared.functions.extension.HaveDITExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDITExt()
// ============

boolean <anchor link="impl-shared.HaveDITExt.0" hover="function: boolean HaveDITExt()">HaveDITExt</anchor>()
    return IsFeatureImplemented(FEAT_DIT);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDOTPExt" mylink="shared.functions.extension.HaveDOTPExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDOTPExt()
// =============
// Returns TRUE if Dot Product feature support is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveDOTPExt.0" hover="function: boolean HaveDOTPExt()">HaveDOTPExt</anchor>()
    return IsFeatureImplemented(FEAT_DotProd);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDirtyBitModifierExt" mylink="shared.functions.extension.HaveDirtyBitModifierExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDirtyBitModifierExt()
// =========================

boolean <anchor link="impl-shared.HaveDirtyBitModifierExt.0" hover="function: boolean HaveDirtyBitModifierExt()">HaveDirtyBitModifierExt</anchor>()
    return IsFeatureImplemented(FEAT_HAFDBS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDoPD" mylink="shared.functions.extension.HaveDoPD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDoPD()
// ==========
// Returns TRUE if Debug Over Power Down extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveDoPD.0" hover="function: boolean HaveDoPD()">HaveDoPD</anchor>()
    return IsFeatureImplemented(FEAT_DoPD);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDoubleFault2Ext" mylink="shared.functions.extension.HaveDoubleFault2Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDoubleFault2Ext()
// =====================
// Returns TRUE if support for the DoubleFault2 feature is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveDoubleFault2Ext.0" hover="function: boolean HaveDoubleFault2Ext()">HaveDoubleFault2Ext</anchor>()
    return IsFeatureImplemented(FEAT_DoubleFault2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDoubleFaultExt" mylink="shared.functions.extension.HaveDoubleFaultExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDoubleFaultExt()
// ====================

boolean <anchor link="impl-shared.HaveDoubleFaultExt.0" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</anchor>()
    return IsFeatureImplemented(FEAT_DoubleFault);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveDoubleLock" mylink="shared.functions.extension.HaveDoubleLock" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveDoubleLock()
// ================
// Returns TRUE if support for the OS Double Lock is implemented.

boolean <anchor link="impl-shared.HaveDoubleLock.0" hover="function: boolean HaveDoubleLock()">HaveDoubleLock</anchor>()
    return IsFeatureImplemented(FEAT_DoubleLock);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveE0PDExt" mylink="shared.functions.extension.HaveE0PDExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveE0PDExt()
// =============
// Returns TRUE if support for constant fault times for unprivileged accesses
// to the memory map is implemented.

boolean <anchor link="impl-shared.HaveE0PDExt.0" hover="function: boolean HaveE0PDExt()">HaveE0PDExt</anchor>()
    return IsFeatureImplemented(FEAT_E0PD);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveEBF16" mylink="shared.functions.extension.HaveEBF16" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveEBF16()
// ===========
// Returns TRUE if the EBF16 extension is implemented, FALSE otherwise.

boolean <anchor link="impl-shared.HaveEBF16.0" hover="function: boolean HaveEBF16()">HaveEBF16</anchor>()
    return IsFeatureImplemented(FEAT_EBF16);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveECVExt" mylink="shared.functions.extension.HaveECVExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveECVExt()
// ============
// Returns TRUE if Enhanced Counter Virtualization extension
// support is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveECVExt.0" hover="function: boolean HaveECVExt()">HaveECVExt</anchor>()
    return IsFeatureImplemented(FEAT_ECV);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveETExt" mylink="shared.functions.extension.HaveETExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveETExt()
// ===========
// Returns TRUE if Embedded Trace Extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveETExt.0" hover="function: boolean HaveETExt()">HaveETExt</anchor>()
    return IsFeatureImplemented(FEAT_ETE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveExtendedCacheSets" mylink="shared.functions.extension.HaveExtendedCacheSets" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveExtendedCacheSets()
// =======================

boolean <anchor link="impl-shared.HaveExtendedCacheSets.0" hover="function: boolean HaveExtendedCacheSets()">HaveExtendedCacheSets</anchor>()
    return IsFeatureImplemented(FEAT_CCIDX);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveExtendedECDebugEvents" mylink="shared.functions.extension.HaveExtendedECDebugEvents" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveExtendedECDebugEvents()
// ===========================

boolean <anchor link="impl-shared.HaveExtendedECDebugEvents.0" hover="function: boolean HaveExtendedECDebugEvents()">HaveExtendedECDebugEvents</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveExtendedExecuteNeverExt" mylink="shared.functions.extension.HaveExtendedExecuteNeverExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveExtendedExecuteNeverExt()
// =============================

boolean <anchor link="impl-shared.HaveExtendedExecuteNeverExt.0" hover="function: boolean HaveExtendedExecuteNeverExt()">HaveExtendedExecuteNeverExt</anchor>()
    return IsFeatureImplemented(FEAT_XNX);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFCADDExt" mylink="shared.functions.extension.HaveFCADDExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFCADDExt()
// ==============

boolean <anchor link="impl-shared.HaveFCADDExt.0" hover="function: boolean HaveFCADDExt()">HaveFCADDExt</anchor>()
    return IsFeatureImplemented(FEAT_FCMA);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFGTExt" mylink="shared.functions.extension.HaveFGTExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFGTExt()
// ============
// Returns TRUE if Fine Grained Trap is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFGTExt.0" hover="function: boolean HaveFGTExt()">HaveFGTExt</anchor>()
    return IsFeatureImplemented(FEAT_FGT);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFJCVTZSExt" mylink="shared.functions.extension.HaveFJCVTZSExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFJCVTZSExt()
// ================

boolean <anchor link="impl-shared.HaveFJCVTZSExt.0" hover="function: boolean HaveFJCVTZSExt()">HaveFJCVTZSExt</anchor>()
    return IsFeatureImplemented(FEAT_JSCVT);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFP16MulNoRoundingToFP32Ext" mylink="shared.functions.extension.HaveFP16MulNoRoundingToFP32Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFP16MulNoRoundingToFP32Ext()
// ================================
// Returns TRUE if has FP16 multiply with no intermediate rounding accumulate
// to FP32 instructions, and FALSE otherwise

boolean <anchor link="impl-shared.HaveFP16MulNoRoundingToFP32Ext.0" hover="function: boolean HaveFP16MulNoRoundingToFP32Ext()">HaveFP16MulNoRoundingToFP32Ext</anchor>()
    return IsFeatureImplemented(FEAT_FHM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatCLRBHB" mylink="shared.functions.extension.HaveFeatCLRBHB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatCLRBHB()
// ================
// Returns TRUE if the CLRBHB instruction is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatCLRBHB.0" hover="function: boolean HaveFeatCLRBHB()">HaveFeatCLRBHB</anchor>()
    return IsFeatureImplemented(FEAT_CLRBHB);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatCMOW" mylink="shared.functions.extension.HaveFeatCMOW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatCMOW()
// ==============
// Returns TRUE if the SCTLR_EL1.CMOW bit is implemented and the SCTLR_EL2.CMOW and
// HCRX_EL2.CMOW bits are implemented if EL2 is implemented.

boolean <anchor link="impl-shared.HaveFeatCMOW.0" hover="function: boolean HaveFeatCMOW()">HaveFeatCMOW</anchor>()
    return IsFeatureImplemented(FEAT_CMOW);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatEBEP" mylink="shared.functions.extension.HaveFeatEBEP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatEBEP()
// ==============
// Returns TRUE if the PMU exception is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatEBEP.0" hover="function: boolean HaveFeatEBEP()">HaveFeatEBEP</anchor>()
    return IsFeatureImplemented(FEAT_EBEP);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatHBC" mylink="shared.functions.extension.HaveFeatHBC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatHBC()
// =============
// Returns TRUE if the BC instruction is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatHBC.0" hover="function: boolean HaveFeatHBC()">HaveFeatHBC</anchor>()
    return IsFeatureImplemented(FEAT_HBC);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatHCX" mylink="shared.functions.extension.HaveFeatHCX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatHCX()
// =============
// Returns TRUE if HCRX_EL2 Trap Control register is implemented,
// and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatHCX.0" hover="function: boolean HaveFeatHCX()">HaveFeatHCX</anchor>()
    return IsFeatureImplemented(FEAT_HCX);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatHPMN0" mylink="shared.functions.extension.HaveFeatHPMN0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatHPMN0()
// ===============
// Returns TRUE if HDCR.HPMN or MDCR_EL2.HPMN is permitted to be 0 without
// generating UNPREDICTABLE behavior, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatHPMN0.0" hover="function: boolean HaveFeatHPMN0()">HaveFeatHPMN0</anchor>()
    return IsFeatureImplemented(FEAT_HPMN0);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatLS64" mylink="shared.functions.extension.HaveFeatLS64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatLS64()
// ==============
// Returns TRUE if the LD64B, ST64B instructions are
// supported, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatLS64.0" hover="function: boolean HaveFeatLS64()">HaveFeatLS64</anchor>()
    return IsFeatureImplemented(FEAT_LS64);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatLS64_ACCDATA" mylink="shared.functions.extension.HaveFeatLS64_ACCDATA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatLS64_ACCDATA()
// ======================
// Returns TRUE if the ST64BV0 instruction is
// supported, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatLS64_ACCDATA.0" hover="function: boolean HaveFeatLS64_ACCDATA()">HaveFeatLS64_ACCDATA</anchor>()
    return IsFeatureImplemented(FEAT_LS64_ACCDATA);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatLS64_V" mylink="shared.functions.extension.HaveFeatLS64_V" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatLS64_V()
// ================
// Returns TRUE if the ST64BV instruction is
// supported, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatLS64_V.0" hover="function: boolean HaveFeatLS64_V()">HaveFeatLS64_V</anchor>()
    return IsFeatureImplemented(FEAT_LS64_V);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatMEC" mylink="shared.functions.extension.HaveFeatMEC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatMEC()
// =============
// Returns TRUE if Memory Encryption Contexts are implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatMEC.0" hover="function: boolean HaveFeatMEC()">HaveFeatMEC</anchor>()
    return IsFeatureImplemented(FEAT_MEC);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatMOPS" mylink="shared.functions.extension.HaveFeatMOPS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatMOPS()
// ==============
// Returns TRUE if the CPY* and SET* instructions are supported, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatMOPS.0" hover="function: boolean HaveFeatMOPS()">HaveFeatMOPS</anchor>()
    return IsFeatureImplemented(FEAT_MOPS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatNMI" mylink="shared.functions.extension.HaveFeatNMI" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatNMI()
// =============
// Returns TRUE if the Non-Maskable Interrupt extension is
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatNMI.0" hover="function: boolean HaveFeatNMI()">HaveFeatNMI</anchor>()
    return IsFeatureImplemented(FEAT_NMI);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatRPRES" mylink="shared.functions.extension.HaveFeatRPRES" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatRPRES()
// ===============
// Returns TRUE if reciprocal estimate implements 12-bit precision
// when FPCR.AH=1, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatRPRES.0" hover="function: boolean HaveFeatRPRES()">HaveFeatRPRES</anchor>()
    return IsFeatureImplemented(FEAT_RPRES);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatSCTLR2" mylink="shared.functions.extension.HaveFeatSCTLR2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatSCTLR2()
// ================
// Returns TRUE if SCTLR2 extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatSCTLR2.0" hover="function: boolean HaveFeatSCTLR2()">HaveFeatSCTLR2</anchor>()
    return IsFeatureImplemented(FEAT_SCTLR2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatTCR2" mylink="shared.functions.extension.HaveFeatTCR2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatTCR2()
// ==============
// Returns TRUE if TCR2 extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatTCR2.0" hover="function: boolean HaveFeatTCR2()">HaveFeatTCR2</anchor>()
    return IsFeatureImplemented(FEAT_TCR2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatTIDCP1" mylink="shared.functions.extension.HaveFeatTIDCP1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatTIDCP1()
// ================
// Returns TRUE if the SCTLR_EL1.TIDCP bit is implemented and the SCTLR_EL2.TIDCP bit
// is implemented if EL2 is implemented.

boolean <anchor link="impl-shared.HaveFeatTIDCP1.0" hover="function: boolean HaveFeatTIDCP1()">HaveFeatTIDCP1</anchor>()
    return IsFeatureImplemented(FEAT_TIDCP1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatTRBEExt" mylink="shared.functions.extension.HaveFeatTRBEExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatTRBEExt()
// =================
// Returns TRUE if the Trace Buffer Extension external mode is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatTRBEExt.0" hover="function: boolean HaveFeatTRBEExt()">HaveFeatTRBEExt</anchor>()
    return IsFeatureImplemented(FEAT_TRBE_EXT);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatWFxT" mylink="shared.functions.extension.HaveFeatWFxT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatWFxT()
// ==============
// Returns TRUE if WFET and WFIT instruction support is implemented,
// and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatWFxT.0" hover="function: boolean HaveFeatWFxT()">HaveFeatWFxT</anchor>()
    return IsFeatureImplemented(FEAT_WFxT);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFeatXS" mylink="shared.functions.extension.HaveFeatXS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFeatXS()
// ============
// Returns TRUE if XS attribute and the TLBI and DSB instructions with nXS qualifier
// are supported, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveFeatXS.0" hover="function: boolean HaveFeatXS()">HaveFeatXS</anchor>()
    return IsFeatureImplemented(FEAT_XS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFlagFormatExt" mylink="shared.functions.extension.HaveFlagFormatExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFlagFormatExt()
// ===================
// Returns TRUE if flag format conversion instructions implemented.

boolean <anchor link="impl-shared.HaveFlagFormatExt.0" hover="function: boolean HaveFlagFormatExt()">HaveFlagFormatExt</anchor>()
    return IsFeatureImplemented(FEAT_FlagM2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFlagManipulateExt" mylink="shared.functions.extension.HaveFlagManipulateExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFlagManipulateExt()
// =======================
// Returns TRUE if flag manipulate instructions are implemented.

boolean <anchor link="impl-shared.HaveFlagManipulateExt.0" hover="function: boolean HaveFlagManipulateExt()">HaveFlagManipulateExt</anchor>()
    return IsFeatureImplemented(FEAT_FlagM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveFrintExt" mylink="shared.functions.extension.HaveFrintExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFrintExt()
// ==============
// Returns TRUE if FRINT instructions are implemented.

boolean <anchor link="impl-shared.HaveFrintExt.0" hover="function: boolean HaveFrintExt()">HaveFrintExt</anchor>()
    return IsFeatureImplemented(FEAT_FRINTTS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveGCS" mylink="shared.functions.extension.HaveGCS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveGCS()
// =========
// Returns TRUE if support for Guarded Control Stack is
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveGCS.0" hover="function: boolean HaveGCS()">HaveGCS</anchor>()
    return IsFeatureImplemented(FEAT_GCS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveGTGExt" mylink="shared.functions.extension.HaveGTGExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveGTGExt()
// ============
// Returns TRUE if support for guest translation granule size is implemented.

boolean <anchor link="impl-shared.HaveGTGExt.0" hover="function: boolean HaveGTGExt()">HaveGTGExt</anchor>()
    return IsFeatureImplemented(FEAT_GTG);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveHPMDExt" mylink="shared.functions.extension.HaveHPMDExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveHPMDExt()
// =============

boolean <anchor link="impl-shared.HaveHPMDExt.0" hover="function: boolean HaveHPMDExt()">HaveHPMDExt</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3p1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveIDSExt" mylink="shared.functions.extension.HaveIDSExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveIDSExt()
// ============
// Returns TRUE if ID register handling feature is implemented.

boolean <anchor link="impl-shared.HaveIDSExt.0" hover="function: boolean HaveIDSExt()">HaveIDSExt</anchor>()
    return IsFeatureImplemented(FEAT_IDST);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveIESB" mylink="shared.functions.extension.HaveIESB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveIESB()
// ==========

boolean <anchor link="impl-shared.HaveIESB.0" hover="function: boolean HaveIESB()">HaveIESB</anchor>()
    return IsFeatureImplemented(FEAT_IESB);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveInt8MatMulExt" mylink="shared.functions.extension.HaveInt8MatMulExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveInt8MatMulExt()
// ===================
// Returns TRUE if AArch64 8-bit integer matrix multiply instruction support
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveInt8MatMulExt.0" hover="function: boolean HaveInt8MatMulExt()">HaveInt8MatMulExt</anchor>()
    return IsFeatureImplemented(FEAT_I8MM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveLRCPC3Ext" mylink="shared.functions.extension.HaveLRCPC3Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveLRCPC3Ext()
// ===============
// Returns TRUE if FEAT_LRCPC3 instructions are supported, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveLRCPC3Ext.0" hover="function: boolean HaveLRCPC3Ext()">HaveLRCPC3Ext</anchor>()
    return IsFeatureImplemented(FEAT_LRCPC3);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveLSE128" mylink="shared.functions.extension.HaveLSE128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveLSE128()
// ============
// Returns TRUE if LSE128 is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveLSE128.0" hover="function: boolean HaveLSE128()">HaveLSE128</anchor>()
    return IsFeatureImplemented(FEAT_LSE128);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveLSE2Ext" mylink="shared.functions.extension.HaveLSE2Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveLSE2Ext()
// =============
// Returns TRUE if LSE2 is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveLSE2Ext.0" hover="function: boolean HaveLSE2Ext()">HaveLSE2Ext</anchor>()
    return IsFeatureImplemented(FEAT_LSE2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMPAMExt" mylink="shared.functions.extension.HaveMPAMExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMPAMExt()
// =============
// Returns TRUE if MPAM is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMPAMExt.0" hover="function: boolean HaveMPAMExt()">HaveMPAMExt</anchor>()
    return IsFeatureImplemented(FEAT_MPAM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMPAMv0p1Ext" mylink="shared.functions.extension.HaveMPAMv0p1Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMPAMv0p1Ext()
// =================
// Returns TRUE if MPAMv0p1 is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMPAMv0p1Ext.0" hover="function: boolean HaveMPAMv0p1Ext()">HaveMPAMv0p1Ext</anchor>()
    return IsFeatureImplemented(FEAT_MPAMv0p1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMPAMv1p1Ext" mylink="shared.functions.extension.HaveMPAMv1p1Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMPAMv1p1Ext()
// =================
// Returns TRUE if MPAMv1p1 is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMPAMv1p1Ext.0" hover="function: boolean HaveMPAMv1p1Ext()">HaveMPAMv1p1Ext</anchor>()
    return IsFeatureImplemented(FEAT_MPAMv1p1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTE2Ext" mylink="shared.functions.extension.HaveMTE2Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTE2Ext()
// =============
// Returns TRUE if MTE support is beyond EL0, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTE2Ext.0" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</anchor>()
    return IsFeatureImplemented(FEAT_MTE2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTE4Ext" mylink="shared.functions.extension.HaveMTE4Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTE4Ext()
// =============
// Returns TRUE if functionality in FEAT_MTE4 is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTE4Ext.0" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</anchor>()
    return IsFeatureImplemented(FEAT_MTE4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTEAsymFaultExt" mylink="shared.functions.extension.HaveMTEAsymFaultExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTEAsymFaultExt()
// =====================
// Returns TRUE if MTE Asymmetric Fault Handling support is
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTEAsymFaultExt.0" hover="function: boolean HaveMTEAsymFaultExt()">HaveMTEAsymFaultExt</anchor>()
    return IsFeatureImplemented(FEAT_MTE4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTEAsyncExt" mylink="shared.functions.extension.HaveMTEAsyncExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTEAsyncExt()
// =================
// Returns TRUE if MTE supports Asynchronous faulting, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTEAsyncExt.0" hover="function: boolean HaveMTEAsyncExt()">HaveMTEAsyncExt</anchor>()
    return IsFeatureImplemented(FEAT_MTE4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTECanonicalTagCheckingExt" mylink="shared.functions.extension.HaveMTECanonicalTagCheckingExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTECanonicalTagCheckingExt()
// ================================
// Returns TRUE if MTE Canonical Tag Checking functionality is
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTECanonicalTagCheckingExt.0" hover="function: boolean HaveMTECanonicalTagCheckingExt()">HaveMTECanonicalTagCheckingExt</anchor>()
    return IsFeatureImplemented(FEAT_MTE_CANONICAL_TAGS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTEExt" mylink="shared.functions.extension.HaveMTEExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTEExt()
// ============
// Returns TRUE if instruction-only MTE implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTEExt.0" hover="function: boolean HaveMTEExt()">HaveMTEExt</anchor>()
    return IsFeatureImplemented(FEAT_MTE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTEPermExt" mylink="shared.functions.extension.HaveMTEPermExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTEPermExt()
// ================
// Returns TRUE if MTE_PERM implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTEPermExt.0" hover="function: boolean HaveMTEPermExt()">HaveMTEPermExt</anchor>()
    return IsFeatureImplemented(FEAT_MTE_PERM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveMTEStoreOnlyExt" mylink="shared.functions.extension.HaveMTEStoreOnlyExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveMTEStoreOnlyExt()
// =====================
// Returns TRUE if MTE Store-only Tag Checking functionality is
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveMTEStoreOnlyExt.0" hover="function: boolean HaveMTEStoreOnlyExt()">HaveMTEStoreOnlyExt</anchor>()
    return IsFeatureImplemented(FEAT_MTE_STORE_ONLY);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveNV2Ext" mylink="shared.functions.extension.HaveNV2Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveNV2Ext()
// ============
// Returns TRUE if Enhanced Nested Virtualization is implemented.

boolean <anchor link="impl-shared.HaveNV2Ext.0" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</anchor>()
    return IsFeatureImplemented(FEAT_NV2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveNVExt" mylink="shared.functions.extension.HaveNVExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveNVExt()
// ===========
// Returns TRUE if Nested Virtualization is implemented.

boolean <anchor link="impl-shared.HaveNVExt.0" hover="function: boolean HaveNVExt()">HaveNVExt</anchor>()
    return IsFeatureImplemented(FEAT_NV);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveNoSecurePMUDisableOverride" mylink="shared.functions.extension.HaveNoSecurePMUDisableOverride" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveNoSecurePMUDisableOverride()
// ================================

boolean <anchor link="impl-shared.HaveNoSecurePMUDisableOverride.0" hover="function: boolean HaveNoSecurePMUDisableOverride()">HaveNoSecurePMUDisableOverride</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveNoninvasiveDebugAuth" mylink="shared.functions.extension.HaveNoninvasiveDebugAuth" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveNoninvasiveDebugAuth()
// ==========================
// Returns TRUE if the Non-invasive debug controls are implemented.

boolean <anchor link="impl-shared.HaveNoninvasiveDebugAuth.0" hover="function: boolean HaveNoninvasiveDebugAuth()">HaveNoninvasiveDebugAuth</anchor>()
    return !IsFeatureImplemented(FEAT_Debugv8p4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePAN3Ext" mylink="shared.functions.extension.HavePAN3Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePAN3Ext()
// =============
// Returns TRUE if SCTLR_EL1.EPAN and SCTLR_EL2.EPAN support is implemented,
// and FALSE otherwise.

boolean <anchor link="impl-shared.HavePAN3Ext.0" hover="function: boolean HavePAN3Ext()">HavePAN3Ext</anchor>()
    return IsFeatureImplemented(FEAT_PAN3);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePANExt" mylink="shared.functions.extension.HavePANExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePANExt()
// ============

boolean <anchor link="impl-shared.HavePANExt.0" hover="function: boolean HavePANExt()">HavePANExt</anchor>()
    return IsFeatureImplemented(FEAT_PAN);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePFAR" mylink="shared.functions.extension.HavePFAR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePFAR()
// ==========
// Returns TRUE if the Physical Fault Address Extension is implemented, and FALSE
// otherwise.

boolean <anchor link="impl-shared.HavePFAR.0" hover="function: boolean HavePFAR()">HavePFAR</anchor>()
    return IsFeatureImplemented(FEAT_PFAR);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3" mylink="shared.functions.extension.HavePMUv3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3()
// ===========
// Returns TRUE if the Performance Monitors extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3.0" hover="function: boolean HavePMUv3()">HavePMUv3</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3EDGE" mylink="shared.functions.extension.HavePMUv3EDGE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3EDGE()
// ===============
// Returns TRUE if support for PMU event edge detection is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3EDGE.0" hover="function: boolean HavePMUv3EDGE()">HavePMUv3EDGE</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3_EDGE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3ICNTR" mylink="shared.functions.extension.HavePMUv3ICNTR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3ICNTR()
// ================
// Returns TRUE if support for the Fixed-function instruction counter is
// implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3ICNTR.0" hover="function: boolean HavePMUv3ICNTR()">HavePMUv3ICNTR</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3_ICNTR);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3TH" mylink="shared.functions.extension.HavePMUv3TH" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3TH()
// =============
// Returns TRUE if the PMUv3 threshold extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3TH.0" hover="function: boolean HavePMUv3TH()">HavePMUv3TH</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3_TH);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3p1" mylink="shared.functions.extension.HavePMUv3p1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3p1()
// =============
// Returns TRUE if the Performance Monitors extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3p1.0" hover="function: boolean HavePMUv3p1()">HavePMUv3p1</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3p1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3p4" mylink="shared.functions.extension.HavePMUv3p4" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3p4()
// =============
// Returns TRUE if the PMUv3.4 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3p4.0" hover="function: boolean HavePMUv3p4()">HavePMUv3p4</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3p4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3p5" mylink="shared.functions.extension.HavePMUv3p5" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3p5()
// =============
// Returns TRUE if the PMUv3.5 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3p5.0" hover="function: boolean HavePMUv3p5()">HavePMUv3p5</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3p5);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3p7" mylink="shared.functions.extension.HavePMUv3p7" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3p7()
// =============
// Returns TRUE if the PMUv3.7 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3p7.0" hover="function: boolean HavePMUv3p7()">HavePMUv3p7</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3p7);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePMUv3p9" mylink="shared.functions.extension.HavePMUv3p9" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePMUv3p9()
// =============
// Returns TRUE if the PMUv3.9 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HavePMUv3p9.0" hover="function: boolean HavePMUv3p9()">HavePMUv3p9</anchor>()
    return IsFeatureImplemented(FEAT_PMUv3p9);</pstext>
    </ps>
    <ps name="shared/functions/extension/HavePageBasedHardwareAttributes" mylink="shared.functions.extension.HavePageBasedHardwareAttributes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HavePageBasedHardwareAttributes()
// =================================

boolean <anchor link="impl-shared.HavePageBasedHardwareAttributes.0" hover="function: boolean HavePageBasedHardwareAttributes()">HavePageBasedHardwareAttributes</anchor>()
    return IsFeatureImplemented(FEAT_HPDS2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveQRDMLAHExt" mylink="shared.functions.extension.HaveQRDMLAHExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveQRDMLAHExt()
// ================

boolean <anchor link="impl-shared.HaveQRDMLAHExt.0" hover="function: boolean HaveQRDMLAHExt()">HaveQRDMLAHExt</anchor>()
    return IsFeatureImplemented(FEAT_RDM);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveRASExt" mylink="shared.functions.extension.HaveRASExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveRASExt()
// ============

boolean <anchor link="impl-shared.HaveRASExt.0" hover="function: boolean HaveRASExt()">HaveRASExt</anchor>()
    return IsFeatureImplemented(FEAT_RAS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveRASv2Ext" mylink="shared.functions.extension.HaveRASv2Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveRASv2Ext()
// ==============
// Returns TRUE if support for RASv2 is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveRASv2Ext.0" hover="function: boolean HaveRASv2Ext()">HaveRASv2Ext</anchor>()
    return IsFeatureImplemented(FEAT_RASv2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveRME" mylink="shared.functions.extension.HaveRME" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveRME()
// =========
// Returns TRUE if the Realm Management Extension is implemented, and FALSE
// otherwise.

boolean <anchor link="impl-shared.HaveRME.0" hover="function: boolean HaveRME()">HaveRME</anchor>()
    return IsFeatureImplemented(FEAT_RME);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveRNG" mylink="shared.functions.extension.HaveRNG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveRNG()
// =========
// Returns TRUE if Random Number Generator extension
// support is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveRNG.0" hover="function: boolean HaveRNG()">HaveRNG</anchor>()
    return IsFeatureImplemented(FEAT_RNG);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveS1PIExt" mylink="shared.functions.extension.HaveS1PIExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveS1PIExt()
// =============
// Returns TRUE if the S1 Permission Indirection extension is
// implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveS1PIExt.0" hover="function: boolean HaveS1PIExt()">HaveS1PIExt</anchor>()
    return IsFeatureImplemented(FEAT_S1PIE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveS1POExt" mylink="shared.functions.extension.HaveS1POExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveS1POExt()
// =============
// Returns TRUE if the S1 Permission Overlay extension is
// implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveS1POExt.0" hover="function: boolean HaveS1POExt()">HaveS1POExt</anchor>()
    return IsFeatureImplemented(FEAT_S1POE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveS2PIExt" mylink="shared.functions.extension.HaveS2PIExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveS2PIExt()
// =============
// Returns TRUE if the S2 Permission Indirection extension is
// implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveS2PIExt.0" hover="function: boolean HaveS2PIExt()">HaveS2PIExt</anchor>()
    return IsFeatureImplemented(FEAT_S2PIE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveS2POExt" mylink="shared.functions.extension.HaveS2POExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveS2POExt()
// =============
// Returns TRUE if the S2 Permission Overlay extension is
// implemented and FALSE otherwise.

boolean <anchor link="impl-shared.HaveS2POExt.0" hover="function: boolean HaveS2POExt()">HaveS2POExt</anchor>()
    return IsFeatureImplemented(FEAT_S2POE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSBExt" mylink="shared.functions.extension.HaveSBExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSBExt()
// ===========
// Returns TRUE if support for SB is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveSBExt.0" hover="function: boolean HaveSBExt()">HaveSBExt</anchor>()
    return IsFeatureImplemented(FEAT_SB);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSSBSExt" mylink="shared.functions.extension.HaveSSBSExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSSBSExt()
// =============
// Returns TRUE if support for SSBS is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveSSBSExt.0" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</anchor>()
    return IsFeatureImplemented(FEAT_SSBS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSecureEL2Ext" mylink="shared.functions.extension.HaveSecureEL2Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSecureEL2Ext()
// ==================
// Returns TRUE if Secure EL2 is implemented.

boolean <anchor link="impl-shared.HaveSecureEL2Ext.0" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</anchor>()
    return IsFeatureImplemented(FEAT_SEL2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSecureExtDebugView" mylink="shared.functions.extension.HaveSecureExtDebugView" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSecureExtDebugView()
// ========================
// Returns TRUE if support for Secure and Non-secure views of debug peripherals
// is implemented.

boolean <anchor link="impl-shared.HaveSecureExtDebugView.0" hover="function: boolean HaveSecureExtDebugView()">HaveSecureExtDebugView</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSelfHostedTrace" mylink="shared.functions.extension.HaveSelfHostedTrace" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSelfHostedTrace()
// =====================

boolean <anchor link="impl-shared.HaveSelfHostedTrace.0" hover="function: boolean HaveSelfHostedTrace()">HaveSelfHostedTrace</anchor>()
    return IsFeatureImplemented(FEAT_TRF);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSmallTranslationTblExt" mylink="shared.functions.extension.HaveSmallTranslationTblExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSmallTranslationTblExt()
// ============================
// Returns TRUE if Small Translation Table Support is implemented.

boolean <anchor link="impl-shared.HaveSmallTranslationTableExt.0" hover="function: boolean HaveSmallTranslationTableExt()">HaveSmallTranslationTableExt</anchor>()
    return IsFeatureImplemented(FEAT_TTST);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSoftwareLock" mylink="shared.functions.extension.HaveSoftwareLock" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSoftwareLock()
// ==================
// Returns TRUE if Software Lock is implemented.

boolean <anchor link="impl-shared.HaveSoftwareLock.1" hover="function: boolean HaveSoftwareLock(Component component)">HaveSoftwareLock</anchor>(<a link="Component" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component</a> component)
    if <a link="impl-shared.Havev8p4Debug.0" file="shared_pseudocode.xml" hover="function: boolean Havev8p4Debug()">Havev8p4Debug</a>() then
        return FALSE;
    if <a link="impl-shared.HaveDoPD.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoPD()">HaveDoPD</a>() &amp;&amp; component != <a link="Component_CTI" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_CTI</a> then
        return FALSE;
    case component of
        when <a link="Component_Debug" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_Debug</a>
            return boolean IMPLEMENTATION_DEFINED "Debug has Software Lock";
        when <a link="Component_PMU" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_PMU</a>
            return boolean IMPLEMENTATION_DEFINED "PMU has Software Lock";
        when <a link="Component_CTI" file="shared_pseudocode.xml" hover="enumeration Component { Component_PMU, Component_Debug, Component_CTI }">Component_CTI</a>
            return boolean IMPLEMENTATION_DEFINED "CTI has Software Lock";
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveStage2MemAttrControl" mylink="shared.functions.extension.HaveStage2MemAttrControl" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveStage2MemAttrControl()
// ==========================
// Returns TRUE if support for Stage2 control of memory types and cacheability
// attributes is implemented.

boolean <anchor link="impl-shared.HaveStage2MemAttrControl.0" hover="function: boolean HaveStage2MemAttrControl()">HaveStage2MemAttrControl</anchor>()
    return IsFeatureImplemented(FEAT_S2FWB);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveStatisticalProfiling" mylink="shared.functions.extension.HaveStatisticalProfiling" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveStatisticalProfiling()
// ==========================
// Returns TRUE if Statistical Profiling Extension is implemented,
// and FALSE otherwise.

boolean <anchor link="impl-shared.HaveStatisticalProfiling.0" hover="function: boolean HaveStatisticalProfiling()">HaveStatisticalProfiling</anchor>()
    return IsFeatureImplemented(FEAT_SPE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveStatisticalProfilingFDS" mylink="shared.functions.extension.HaveStatisticalProfilingFDS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveStatisticalProfilingFDS()
// =============================
// Returns TRUE if the SPE_FDS extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveStatisticalProfilingFDS.0" hover="function: boolean HaveStatisticalProfilingFDS()">HaveStatisticalProfilingFDS</anchor>()
    return IsFeatureImplemented(FEAT_SPE_FDS);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveStatisticalProfilingv1p1" mylink="shared.functions.extension.HaveStatisticalProfilingv1p1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveStatisticalProfilingv1p1()
// ==============================
// Returns TRUE if the SPEv1p1 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveStatisticalProfilingv1p1.0" hover="function: boolean HaveStatisticalProfilingv1p1()">HaveStatisticalProfilingv1p1</anchor>()
    return IsFeatureImplemented(FEAT_SPEv1p1);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveStatisticalProfilingv1p2" mylink="shared.functions.extension.HaveStatisticalProfilingv1p2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveStatisticalProfilingv1p2()
// ==============================
// Returns TRUE if the SPEv1p2 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveStatisticalProfilingv1p2.0" hover="function: boolean HaveStatisticalProfilingv1p2()">HaveStatisticalProfilingv1p2</anchor>()
    return IsFeatureImplemented(FEAT_SPEv1p2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveStatisticalProfilingv1p4" mylink="shared.functions.extension.HaveStatisticalProfilingv1p4" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveStatisticalProfilingv1p4()
// ==============================
// Returns TRUE if the SPEv1p4 extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveStatisticalProfilingv1p4.0" hover="function: boolean HaveStatisticalProfilingv1p4()">HaveStatisticalProfilingv1p4</anchor>()
    return IsFeatureImplemented(FEAT_SPEv1p4);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSysInstr128" mylink="shared.functions.extension.HaveSysInstr128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSysInstr128()
// =================
// Returns TRUE if support for System Instructions that can
// take 128-bit inputs is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveSysInstr128.0" hover="function: boolean HaveSysInstr128()">HaveSysInstr128</anchor>()
    return IsFeatureImplemented(FEAT_SYSINSTR128);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveSysReg128" mylink="shared.functions.extension.HaveSysReg128" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSysReg128()
// ===============
// Returns TRUE if support for 128-bit System Registers is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveSysReg128.0" hover="function: boolean HaveSysReg128()">HaveSysReg128</anchor>()
    return IsFeatureImplemented(FEAT_SYSREG128);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveTHExt" mylink="shared.functions.extension.HaveTHExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveTHExt()
// ===========
// Returns TRUE if support for Translation Hardening Extension is implemented.

boolean <anchor link="impl-shared.HaveTHExt.0" hover="function: boolean HaveTHExt()">HaveTHExt</anchor>()
    return IsFeatureImplemented(FEAT_THE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveTME" mylink="shared.functions.extension.HaveTME" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveTME()
// =========

boolean <anchor link="impl-shared.HaveTME.0" hover="function: boolean HaveTME()">HaveTME</anchor>()
    return IsFeatureImplemented(FEAT_TME);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveTWEDExt" mylink="shared.functions.extension.HaveTWEDExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveTWEDExt()
// =============
// Returns TRUE if Delayed Trapping of WFE instruction support is implemented,
// and FALSE otherwise.

boolean <anchor link="impl-shared.HaveTWEDExt.0" hover="function: boolean HaveTWEDExt()">HaveTWEDExt</anchor>()
    return IsFeatureImplemented(FEAT_TWED);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveTraceBufferExtension" mylink="shared.functions.extension.HaveTraceBufferExtension" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveTraceBufferExtension()
// ==========================
// Returns TRUE if Trace Buffer Extension is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.HaveTraceBufferExtension.0" hover="function: boolean HaveTraceBufferExtension()">HaveTraceBufferExtension</anchor>()
    return IsFeatureImplemented(FEAT_TRBE);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveTraceExt" mylink="shared.functions.extension.HaveTraceExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveTraceExt()
// ==============
// Returns TRUE if Trace functionality as described by the Trace Architecture
// is implemented.

boolean <anchor link="impl-shared.HaveTraceExt.0" hover="function: boolean HaveTraceExt()">HaveTraceExt</anchor>()
    return boolean IMPLEMENTATION_DEFINED "Has Trace Architecture functionality";</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveTrapLoadStoreMultipleDeviceExt" mylink="shared.functions.extension.HaveTrapLoadStoreMultipleDeviceExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveTrapLoadStoreMultipleDeviceExt()
// ====================================

boolean <anchor link="impl-shared.HaveTrapLoadStoreMultipleDeviceExt.0" hover="function: boolean HaveTrapLoadStoreMultipleDeviceExt()">HaveTrapLoadStoreMultipleDeviceExt</anchor>()
    return IsFeatureImplemented(FEAT_LSMAOC);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveUAOExt" mylink="shared.functions.extension.HaveUAOExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveUAOExt()
// ============

boolean <anchor link="impl-shared.HaveUAOExt.0" hover="function: boolean HaveUAOExt()">HaveUAOExt</anchor>()
    return IsFeatureImplemented(FEAT_UAO);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveV82Debug" mylink="shared.functions.extension.HaveV82Debug" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveV82Debug()
// ==============

boolean <anchor link="impl-shared.HaveV82Debug.0" hover="function: boolean HaveV82Debug()">HaveV82Debug</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p2);</pstext>
    </ps>
    <ps name="shared/functions/extension/HaveVirtHostExt" mylink="shared.functions.extension.HaveVirtHostExt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveVirtHostExt()
// =================

boolean <anchor link="impl-shared.HaveVirtHostExt.0" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</anchor>()
    return IsFeatureImplemented(FEAT_VHE);</pstext>
    </ps>
    <ps name="shared/functions/extension/Havev8p4Debug" mylink="shared.functions.extension.Havev8p4Debug" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Havev8p4Debug()
// ===============
// Returns TRUE if support for the Debugv8p4 feature is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Havev8p4Debug.0" hover="function: boolean Havev8p4Debug()">Havev8p4Debug</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p4);</pstext>
    </ps>
    <ps name="shared/functions/extension/Havev8p8Debug" mylink="shared.functions.extension.Havev8p8Debug" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Havev8p8Debug()
// ===============
// Returns TRUE if support for the Debugv8p8 feature is implemented and FALSE otherwise.

boolean <anchor link="impl-shared.Havev8p8Debug.0" hover="function: boolean Havev8p8Debug()">Havev8p8Debug</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p8);</pstext>
    </ps>
    <ps name="shared/functions/extension/Havev8p9Debug" mylink="shared.functions.extension.Havev8p9Debug" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Havev8p9Debug()
// ===============
// Returns TRUE if support for the Debugv8p9 feature is implemented, and FALSE otherwise.

boolean <anchor link="impl-shared.Havev8p9Debug.0" hover="function: boolean Havev8p9Debug()">Havev8p9Debug</anchor>()
    return IsFeatureImplemented(FEAT_Debugv8p9);</pstext>
    </ps>
    <ps name="shared/functions/extension/InsertIESBBeforeException" mylink="shared.functions.extension.InsertIESBBeforeException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InsertIESBBeforeException()
// ===========================
// Returns an implementation defined choice whether to insert an implicit error synchronization
// barrier before exception.
// If SCTLR_ELx.IESB is 1 when an exception is generated to ELx, any pending Unrecoverable
// SError interrupt must be taken before executing any instructions in the exception handler.
// However, this can be before the branch to the exception handler is made.

boolean <anchor link="impl-shared.InsertIESBBeforeException.1" hover="function: boolean InsertIESBBeforeException(bits(2) el)">InsertIESBBeforeException</anchor>(bits(2) el)
    return (<a link="impl-shared.HaveIESB.0" file="shared_pseudocode.xml" hover="function: boolean HaveIESB()">HaveIESB</a>() &amp;&amp; boolean IMPLEMENTATION_DEFINED
            "Has Implicit Error Synchronization Barrier before <a link="Exception" file="shared_pseudocode.xml" hover="enumeration Exception { Exception_Uncategorized, Exception_WFxTrap, Exception_CP15RTTrap, Exception_CP15RRTTrap, Exception_CP14RTTrap, Exception_CP14DTTrap, Exception_CP14RRTTrap, Exception_AdvSIMDFPAccessTrap, Exception_FPIDTrap, Exception_LDST64BTrap,  Exception_PACTrap, Exception_IllegalState, Exception_SupervisorCall, Exception_HypervisorCall, Exception_MonitorCall, Exception_SystemRegisterTrap, Exception_ERetTrap, Exception_InstructionAbort, Exception_PCAlignment, Exception_DataAbort, Exception_NV2DataAbort, Exception_PACFail, Exception_SPAlignment, Exception_FPTrappedException, Exception_SError, Exception_Breakpoint, Exception_SoftwareStep, Exception_Watchpoint, Exception_NV2Watchpoint, Exception_SoftwareBreakpoint, Exception_VectorCatch, Exception_IRQ, Exception_SVEAccessTrap, Exception_SMEAccessTrap, Exception_TSTARTAccessTrap, Exception_GPC, Exception_BranchTarget, Exception_MemCpyMemSet, Exception_GCSFail, Exception_SystemRegister128Trap, Exception_FIQ}">Exception</a>");</pstext>
    </ps>
    <ps name="shared/functions/extension/IsG1ActivityMonitorImplemented" mylink="shared.functions.extension.IsG1ActivityMonitorImplemented" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsG1ActivityMonitorImplemented()
// ================================
// Returns TRUE if a G1 activity monitor is implemented for the counter
// and FALSE otherwise.

boolean <anchor link="impl-shared.IsG1ActivityMonitorImplemented.1" hover="function: boolean IsG1ActivityMonitorImplemented(integer i)">IsG1ActivityMonitorImplemented</anchor>(integer i);</pstext>
    </ps>
    <ps name="shared/functions/extension/IsG1ActivityMonitorOffsetImplemented" mylink="shared.functions.extension.IsG1ActivityMonitorOffsetImplemented" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsG1ActivityMonitorOffsetImplemented()
// ======================================
// Returns TRUE if a G1 activity monitor offset is implemented for the counter,
// and FALSE otherwise.

boolean <anchor link="impl-shared.IsG1ActivityMonitorOffsetImplemented.1" hover="function: boolean IsG1ActivityMonitorOffsetImplemented(integer i)">IsG1ActivityMonitorOffsetImplemented</anchor>(integer i);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/AArch32.PEErrorState" mylink="shared.functions.externalaborts.AArch32.PEErrorState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch32.PEErrorState()
// ======================
// Returns the error state by PE on taking an SError Interrupt
// to AArch32 level.

ErrorState <anchor link="AArch32.PEErrorState.1" hover="function: ErrorState AArch32.PEErrorState(FaultRecord fault)">AArch32.PEErrorState</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    if (!<a link="impl-shared.ErrorIsContained.0" file="shared_pseudocode.xml" hover="function: boolean ErrorIsContained()">ErrorIsContained</a>() ||
        (!<a link="impl-shared.ErrorIsSynchronized.0" file="shared_pseudocode.xml" hover="function: boolean ErrorIsSynchronized()">ErrorIsSynchronized</a>() &amp;&amp; !<a link="impl-shared.StateIsRecoverable.0" file="shared_pseudocode.xml" hover="function: boolean StateIsRecoverable()">StateIsRecoverable</a>()) ||
         <a link="impl-shared.ReportErrorAsUC.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUC()">ReportErrorAsUC</a>()) then
        return <a link="ErrorState_UC" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</a>;

    if !<a link="impl-shared.StateIsRecoverable.0" file="shared_pseudocode.xml" hover="function: boolean StateIsRecoverable()">StateIsRecoverable</a>() || <a link="impl-shared.ReportErrorAsUEU.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUEU()">ReportErrorAsUEU</a>() then
        return <a link="ErrorState_UEU" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEU</a>;

    if <a link="impl-shared.ActionRequired.0" file="shared_pseudocode.xml" hover="function: boolean ActionRequired()">ActionRequired</a>() || <a link="impl-shared.ReportErrorAsUER.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUER()">ReportErrorAsUER</a>() then
        return <a link="ErrorState_UER" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UER</a>;

    return <a link="ErrorState_UEO" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEO</a>;</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/AArch64.PEErrorState" mylink="shared.functions.externalaborts.AArch64.PEErrorState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.PEErrorState()
// ======================
// Returns the error state by PE on taking a Synchronous
// or Asynchronous exception.

ErrorState <anchor link="AArch64.PEErrorState.1" hover="function: ErrorState AArch64.PEErrorState(FaultRecord fault)">AArch64.PEErrorState</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    if !<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) &amp;&amp; <a link="impl-shared.ExtAbortToA64.1" file="shared_pseudocode.xml" hover="function: boolean ExtAbortToA64(FaultRecord fault)">ExtAbortToA64</a>(fault) then
        if <a link="impl-shared.ReportErrorAsUncategorized.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUncategorized()">ReportErrorAsUncategorized</a>() then
            return <a link="ErrorState_Uncategorized" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_Uncategorized</a>;
        if <a link="impl-shared.ReportErrorAsIMPDEF.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsIMPDEF()">ReportErrorAsIMPDEF</a>() then
            return <a link="ErrorState_IMPDEF" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_IMPDEF</a>;

    assert !<a link="impl-shared.FaultIsCorrected.0" file="shared_pseudocode.xml" hover="function: boolean FaultIsCorrected()">FaultIsCorrected</a>();
    if (!<a link="impl-shared.ErrorIsContained.0" file="shared_pseudocode.xml" hover="function: boolean ErrorIsContained()">ErrorIsContained</a>() ||
        (!<a link="impl-shared.ErrorIsSynchronized.0" file="shared_pseudocode.xml" hover="function: boolean ErrorIsSynchronized()">ErrorIsSynchronized</a>() &amp;&amp; !<a link="impl-shared.StateIsRecoverable.0" file="shared_pseudocode.xml" hover="function: boolean StateIsRecoverable()">StateIsRecoverable</a>()) ||
         <a link="impl-shared.ReportErrorAsUC.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUC()">ReportErrorAsUC</a>()) then
        return <a link="ErrorState_UC" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</a>;

    if !<a link="impl-shared.StateIsRecoverable.0" file="shared_pseudocode.xml" hover="function: boolean StateIsRecoverable()">StateIsRecoverable</a>() || <a link="impl-shared.ReportErrorAsUEU.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUEU()">ReportErrorAsUEU</a>() then
        if <a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) then  // Implies taken to AArch64
            return <a link="ErrorState_UC" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</a>;
        else
            return <a link="ErrorState_UEU" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEU</a>;

    if (<a link="impl-shared.ActionRequired.0" file="shared_pseudocode.xml" hover="function: boolean ActionRequired()">ActionRequired</a>() || <a link="impl-shared.ReportErrorAsUER.0" file="shared_pseudocode.xml" hover="function: boolean ReportErrorAsUER()">ReportErrorAsUER</a>()) then
        return <a link="ErrorState_UER" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UER</a>;

    return <a link="ErrorState_UEO" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEO</a>;</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ActionRequired" mylink="shared.functions.externalaborts.ActionRequired" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ActionRequired()
// ================
// Return an implementation specific value:
// returns TRUE if action is required, FALSE otherwise.

boolean <anchor link="impl-shared.ActionRequired.0" hover="function: boolean ActionRequired()">ActionRequired</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ClearPendingPhysicalSError" mylink="shared.functions.externalaborts.ClearPendingPhysicalSError" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearPendingPhysicalSError()
// ============================
// Clear a pending physical SError interrupt.

<anchor link="impl-shared.ClearPendingPhysicalSError.0" hover="function: ClearPendingPhysicalSError()">ClearPendingPhysicalSError</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ClearPendingVirtualSError" mylink="shared.functions.externalaborts.ClearPendingVirtualSError" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearPendingVirtualSError()
// ===========================
// Clear a pending virtual SError interrupt.

<anchor link="impl-shared.ClearPendingVirtualSError.0" hover="function: ClearPendingVirtualSError()">ClearPendingVirtualSError</anchor>()
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        HCR.VA = '0';
    else
        HCR_EL2.VSE = '0';</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ErrorIsContained" mylink="shared.functions.externalaborts.ErrorIsContained" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ErrorIsContained()
// ==================
// Return an implementation specific value:
// TRUE if Error is contained by the PE, FALSE otherwise.

boolean <anchor link="impl-shared.ErrorIsContained.0" hover="function: boolean ErrorIsContained()">ErrorIsContained</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ErrorIsSynchronized" mylink="shared.functions.externalaborts.ErrorIsSynchronized" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ErrorIsSynchronized()
// =====================
// Return an implementation specific value:
// returns TRUE if Error is synchronized by any synchronization event
// FALSE otherwise.

boolean <anchor link="impl-shared.ErrorIsSynchronized.0" hover="function: boolean ErrorIsSynchronized()">ErrorIsSynchronized</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ExtAbortToA64" mylink="shared.functions.externalaborts.ExtAbortToA64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExtAbortToA64()
// ===============
// Returns TRUE if synchronous exception is being taken to A64 exception
// level.

boolean <anchor link="impl-shared.ExtAbortToA64.1" hover="function: boolean ExtAbortToA64(FaultRecord fault)">ExtAbortToA64</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    // Check if routed to AArch64 state
    route_to_aarch64 = PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);

    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        route_to_aarch64 = (HCR_EL2.TGE == '1' || <a link="impl-shared.IsSecondStage.1" file="shared_pseudocode.xml" hover="function: boolean IsSecondStage(FaultRecord fault)">IsSecondStage</a>(fault) ||
                            (<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; HCR_EL2.TEA == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault)) ||
                            (<a link="impl-shared.IsDebugException.1" file="shared_pseudocode.xml" hover="function: boolean IsDebugException(FaultRecord fault)">IsDebugException</a>(fault) &amp;&amp; MDCR_EL2.TDE == '1'));

    if !route_to_aarch64 &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        route_to_aarch64 = <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].EA == '1' &amp;&amp; <a link="impl-shared.IsExternalAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbort(Fault statuscode)">IsExternalAbort</a>(fault);

    return route_to_aarch64 &amp;&amp; <a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault.statuscode);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/FaultIsCorrected" mylink="shared.functions.externalaborts.FaultIsCorrected" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FaultIsCorrected()
// ==================
// Return an implementation specific value:
// TRUE if fault is corrected by the PE, FALSE otherwise.

boolean <anchor link="impl-shared.FaultIsCorrected.0" hover="function: boolean FaultIsCorrected()">FaultIsCorrected</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/GetPendingPhysicalSError" mylink="shared.functions.externalaborts.GetPendingPhysicalSError" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetPendingPhysicalSError()
// ==========================
// Returns the FaultRecord containing details of pending Physical SError
// interrupt.

FaultRecord <anchor link="impl-shared.GetPendingPhysicalSError.0" hover="function: FaultRecord GetPendingPhysicalSError()">GetPendingPhysicalSError</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/HandleExternalAbort" mylink="shared.functions.externalaborts.HandleExternalAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HandleExternalAbort()
// =====================
// Takes a Synchronous/Asynchronous abort based on fault.

<anchor link="impl-shared.HandleExternalAbort.5" hover="function: HandleExternalAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalAbort</anchor>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memretstatus, boolean iswrite,
                    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc, integer size,
                    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    assert (memretstatus.statuscode IN {<a link="Fault_SyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</a>, <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>} ||
           (!<a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() &amp;&amp; memretstatus.statuscode IN {<a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a>,
                                                         <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>}));

    fault = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(accdesc);
    fault.statuscode = memretstatus.statuscode;
    fault.write      = iswrite;
    fault.extflag    = memretstatus.extflag;
    // It is implementation specific whether External aborts signaled
    // in-band synchronously are taken synchronously or asynchronously
    if (<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) &amp;&amp;
            !<a link="impl-shared.IsExternalAbortTakenSynchronously.5" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbortTakenSynchronously(PhysMemRetStatus memstatus, boolean iswrite, AddressDescriptor desc, integer size, AccessDescriptor accdesc)">IsExternalAbortTakenSynchronously</a>(memretstatus, iswrite, memaddrdesc,
                                               size, accdesc)) then
        if fault.statuscode == <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a> then
            fault.statuscode = <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>;
        else
            fault.statuscode = <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>;

    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() then
        fault.merrorstate = memretstatus.merrorstate;

    if <a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(fault) then
        if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
            <a link="AArch32.Abort.2" file="shared_pseudocode.xml" hover="function: AArch32.Abort(bits(32) vaddress, FaultRecord fault)">AArch32.Abort</a>(memaddrdesc.vaddress&lt;31:0&gt;, fault);
        else
            <a link="AArch64.Abort.2" file="shared_pseudocode.xml" hover="function: AArch64.Abort(bits(64) vaddress, FaultRecord fault)">AArch64.Abort</a>(memaddrdesc.vaddress, fault);

    else
        <a link="impl-shared.PendSErrorInterrupt.1" file="shared_pseudocode.xml" hover="function: PendSErrorInterrupt(FaultRecord fault)">PendSErrorInterrupt</a>(fault);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/HandleExternalReadAbort" mylink="shared.functions.externalaborts.HandleExternalReadAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HandleExternalReadAbort()
// =========================
// Wrapper function for HandleExternalAbort function in case of an External
// Abort on memory read.

<anchor link="impl-shared.HandleExternalReadAbort.4" hover="function: HandleExternalReadAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalReadAbort</anchor>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc,
                        integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    iswrite = FALSE;
    <a link="impl-shared.HandleExternalAbort.5" file="shared_pseudocode.xml" hover="function: HandleExternalAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalAbort</a>(memstatus, iswrite, memaddrdesc, size, accdesc);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/HandleExternalTTWAbort" mylink="shared.functions.externalaborts.HandleExternalTTWAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HandleExternalTTWAbort()
// ========================
// Take Asynchronous abort or update FaultRecord for Translation Table Walk
// based on PhysMemRetStatus.

FaultRecord <anchor link="impl-shared.HandleExternalTTWAbort.6" hover="function: FaultRecord HandleExternalTTWAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, AccessDescriptor accdesc, integer size, FaultRecord input_fault)">HandleExternalTTWAbort</anchor>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memretstatus, boolean iswrite,
                                   <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc,
                                   <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc, integer size,
                                   <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> input_fault)
    output_fault = input_fault;
    output_fault.extflag = memretstatus.extflag;
    output_fault.statuscode = memretstatus.statuscode;
    if (<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(output_fault) &amp;&amp;
            !<a link="impl-shared.IsExternalAbortTakenSynchronously.5" file="shared_pseudocode.xml" hover="function: boolean IsExternalAbortTakenSynchronously(PhysMemRetStatus memstatus, boolean iswrite, AddressDescriptor desc, integer size, AccessDescriptor accdesc)">IsExternalAbortTakenSynchronously</a>(memretstatus, iswrite, memaddrdesc,
                                               size, accdesc)) then
        if output_fault.statuscode == <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a> then
            output_fault.statuscode = <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>;
        else
            output_fault.statuscode = <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>;

    // If a synchronous fault is on a translation table walk, then update
    // the fault type
    if <a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(output_fault) then
        if output_fault.statuscode == <a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a> then
            output_fault.statuscode = <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>;
        else
            output_fault.statuscode = <a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>;
    if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() then
        output_fault.merrorstate = memretstatus.merrorstate;
    if !<a link="impl-shared.IsExternalSyncAbort.1" file="shared_pseudocode.xml" hover="function: boolean IsExternalSyncAbort(Fault statuscode)">IsExternalSyncAbort</a>(output_fault) then
        <a link="impl-shared.PendSErrorInterrupt.1" file="shared_pseudocode.xml" hover="function: PendSErrorInterrupt(FaultRecord fault)">PendSErrorInterrupt</a>(output_fault);
        output_fault.statuscode = <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;
    return output_fault;</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/HandleExternalWriteAbort" mylink="shared.functions.externalaborts.HandleExternalWriteAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HandleExternalWriteAbort()
// ==========================
// Wrapper function for HandleExternalAbort function in case of an External
// Abort on memory write.

<anchor link="impl-shared.HandleExternalWriteAbort.4" hover="function: HandleExternalWriteAbort(PhysMemRetStatus memstatus, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalWriteAbort</anchor>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> memaddrdesc,
                         integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    iswrite = TRUE;
    <a link="impl-shared.HandleExternalAbort.5" file="shared_pseudocode.xml" hover="function: HandleExternalAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, integer size, AccessDescriptor accdesc)">HandleExternalAbort</a>(memstatus, iswrite, memaddrdesc, size, accdesc);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/IsExternalAbortTakenSynchronously" mylink="shared.functions.externalaborts.IsExternalAbortTakenSynchronously" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsExternalAbortTakenSynchronously()
// ===================================
// Return an implementation specific value:
// TRUE if the fault returned for the access can be taken synchronously,
// FALSE otherwise.
//
// This might vary between accesses, for example depending on the error type
// or memory type being accessed.
// External aborts on data accesses and translation table walks on data accesses
// can be either synchronous or asynchronous.
//
// When FEAT_DoubleFault is not implemented, External aborts on instruction
// fetches and translation table walks on instruction fetches can be either
// synchronous or asynchronous.
// When FEAT_DoubleFault is implemented, all External abort exceptions on
// instruction fetches and translation table walks on instruction fetches
// must be synchronous.

boolean <anchor link="impl-shared.IsExternalAbortTakenSynchronously.5" hover="function: boolean IsExternalAbortTakenSynchronously(PhysMemRetStatus memstatus, boolean iswrite, AddressDescriptor desc, integer size, AccessDescriptor accdesc)">IsExternalAbortTakenSynchronously</anchor>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus,
                                          boolean iswrite,
                                          <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> desc,
                                          integer size,
                                          <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/IsPhysicalSErrorPending" mylink="shared.functions.externalaborts.IsPhysicalSErrorPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsPhysicalSErrorPending()
// =========================
// Returns TRUE if a physical SError interrupt is pending.

boolean <anchor link="impl-shared.IsPhysicalSErrorPending.0" hover="function: boolean IsPhysicalSErrorPending()">IsPhysicalSErrorPending</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/IsSErrorEdgeTriggered" mylink="shared.functions.externalaborts.IsSErrorEdgeTriggered" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSErrorEdgeTriggered()
// =======================
// Returns TRUE if the physical SError interrupt is edge-triggered
// and FALSE otherwise.

boolean <anchor link="impl-shared.IsSErrorEdgeTriggered.0" hover="function: boolean IsSErrorEdgeTriggered()">IsSErrorEdgeTriggered</anchor>()
    if <a link="impl-shared.HaveDoubleFaultExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDoubleFaultExt()">HaveDoubleFaultExt</a>() then
        return TRUE;
    else
        return boolean IMPLEMENTATION_DEFINED "Edge-triggered SError";</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/IsSynchronizablePhysicalSErrorPending" mylink="shared.functions.externalaborts.IsSynchronizablePhysicalSErrorPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSynchronizablePhysicalSErrorPending()
// =======================================
// Returns TRUE if a synchronizable physical SError interrupt is pending.

boolean <anchor link="impl-shared.IsSynchronizablePhysicalSErrorPending.0" hover="function: boolean IsSynchronizablePhysicalSErrorPending()">IsSynchronizablePhysicalSErrorPending</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/IsVirtualSErrorPending" mylink="shared.functions.externalaborts.IsVirtualSErrorPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsVirtualSErrorPending()
// ========================
// Return TRUE if a virtual SError interrupt is pending.

boolean <anchor link="impl-shared.IsVirtualSErrorPending.0" hover="function: boolean IsVirtualSErrorPending()">IsVirtualSErrorPending</anchor>()
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        return HCR.VA == '1';
    else
        return HCR_EL2.VSE == '1';</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/PendSErrorInterrupt" mylink="shared.functions.externalaborts.PendSErrorInterrupt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PendSErrorInterrupt()
// =====================
// Pend the SError Interrupt.

<anchor link="impl-shared.PendSErrorInterrupt.1" hover="function: PendSErrorInterrupt(FaultRecord fault)">PendSErrorInterrupt</anchor>(<a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault);</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ReportErrorAsIMPDEF" mylink="shared.functions.externalaborts.ReportErrorAsIMPDEF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportErrorAsIMPDEF()
// =====================
// Return an implementation specific value:
// returns TRUE if Error is IMPDEF, FALSE otherwise.

boolean <anchor link="impl-shared.ReportErrorAsIMPDEF.0" hover="function: boolean ReportErrorAsIMPDEF()">ReportErrorAsIMPDEF</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ReportErrorAsUC" mylink="shared.functions.externalaborts.ReportErrorAsUC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportErrorAsUC()
// =================
// Return an implementation specific value:
// returns TRUE if Error is Uncontainable, FALSE otherwise.

boolean <anchor link="impl-shared.ReportErrorAsUC.0" hover="function: boolean ReportErrorAsUC()">ReportErrorAsUC</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ReportErrorAsUER" mylink="shared.functions.externalaborts.ReportErrorAsUER" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportErrorAsUER()
// ==================
// Return an implementation specific value:
// returns TRUE if Error is Recoverable, FALSE otherwise.

boolean <anchor link="impl-shared.ReportErrorAsUER.0" hover="function: boolean ReportErrorAsUER()">ReportErrorAsUER</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ReportErrorAsUEU" mylink="shared.functions.externalaborts.ReportErrorAsUEU" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportErrorAsUEU()
// ==================
// Return an implementation specific value:
// returns TRUE if Error is Unrecoverable, FALSE otherwise.

boolean <anchor link="impl-shared.ReportErrorAsUEU.0" hover="function: boolean ReportErrorAsUEU()">ReportErrorAsUEU</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/ReportErrorAsUncategorized" mylink="shared.functions.externalaborts.ReportErrorAsUncategorized" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportErrorAsUncategorized()
// ===========================
// Return an implementation specific value:
// returns TRUE if Error is uncategorized, FALSE otherwise.

boolean <anchor link="impl-shared.ReportErrorAsUncategorized.0" hover="function: boolean ReportErrorAsUncategorized()">ReportErrorAsUncategorized</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/externalaborts/StateIsRecoverable" mylink="shared.functions.externalaborts.StateIsRecoverable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StateIsRecoverable()
// =====================
// Return an implementation specific value:
// returns TRUE is PE State is unrecoverable else FALSE.

boolean <anchor link="impl-shared.StateIsRecoverable.0" hover="function: boolean StateIsRecoverable()">StateIsRecoverable</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFAdd" mylink="shared.functions.float.bfloat.BFAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFAdd()
// =======
// Non-widening BFloat16 addition used by SVE2 instructions.

bits(16) <anchor link="impl-shared.BFAdd.3" hover="function: bits(16) BFAdd(bits(16) op1, bits(16) op2, FPCRType fpcr)">BFAdd</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;
    return <a link="impl-shared.BFAdd.4" file="shared_pseudocode.xml" hover="function: bits(16) BFAdd(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFAdd</a>(op1, op2, fpcr, fpexc);

// BFAdd()
// =======
// Non-widening BFloat16 addition following computational behaviors
// corresponding to instructions that read and write BFloat16 values.
// Calculates op1 + op2.
// The 'fpcr' argument supplies the FPCR control bits.

bits(16) <anchor link="impl-shared.BFAdd.4" hover="function: bits(16) BFAdd(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFAdd</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    boolean done;
    bits(32) result;

    bits(32) op1_s = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op2_s = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1_s, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2_s, fpcr, fpexc);

    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1_s, op2_s, fpcr, fpexc);

    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if inf1 &amp;&amp; inf2 &amp;&amp; sign1 == NOT(sign2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif (inf1 &amp;&amp; sign1 == '0') || (inf2 &amp;&amp; sign2 == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', 32);
        elsif (inf1 &amp;&amp; sign1 == '1') || (inf2 &amp;&amp; sign2 == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', 32);
        elsif zero1 &amp;&amp; zero2 &amp;&amp; sign1 == sign2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1, 32);
        else
            result_value = value1 + value2;
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, 32);
            else
                result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(result_value, fpcr, rounding, fpexc);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, 32, fpcr);

    return result&lt;31:16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFAdd_ZA" mylink="shared.functions.float.bfloat.BFAdd_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFAdd_ZA()
// ==========
// Non-widening BFloat16 addition used by SME2 ZA-targeting instructions.

bits(16) <anchor link="impl-shared.BFAdd_ZA.3" hover="function: bits(16) BFAdd_ZA(bits(16) op1, bits(16) op2, FPCRType fpcr_in)">BFAdd_ZA</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    boolean fpexc = FALSE;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.DN = '1';          // Generate default NaN values
    return <a link="impl-shared.BFAdd.4" file="shared_pseudocode.xml" hover="function: bits(16) BFAdd(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFAdd</a>(op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFDotAdd" mylink="shared.functions.float.bfloat.BFDotAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFDotAdd()
// ==========
// BFloat16 2-way dot-product and add to single-precision
// result = addend + op1_a*op2_a + op1_b*op2_b

bits(32) <anchor link="impl-shared.BFDotAdd.6" hover="function: bits(32) BFDotAdd(bits(32) addend, bits(16) op1_a, bits(16) op1_b, bits(16) op2_a, bits(16) op2_b, FPCRType fpcr_in)">BFDotAdd</anchor>(bits(32) addend, bits(16) op1_a, bits(16) op1_b,
                  bits(16) op2_a, bits(16) op2_b, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;

    bits(32) prod;

    bits(32) result;
    if !<a link="impl-shared.HaveEBF16.0" file="shared_pseudocode.xml" hover="function: boolean HaveEBF16()">HaveEBF16</a>() || fpcr.EBF == '0' then   // Standard BFloat16 behaviors
        prod = <a link="impl-shared.FPAdd_BF16.2" file="shared_pseudocode.xml" hover="function: bits(32) FPAdd_BF16(bits(32) op1, bits(32) op2)">FPAdd_BF16</a>(<a link="impl-shared.BFMulH.2" file="shared_pseudocode.xml" hover="function: bits(32) BFMulH(bits(16) op1, bits(16) op2)">BFMulH</a>(op1_a, op2_a), <a link="impl-shared.BFMulH.2" file="shared_pseudocode.xml" hover="function: bits(32) BFMulH(bits(16) op1, bits(16) op2)">BFMulH</a>(op1_b, op2_b));
        result = <a link="impl-shared.FPAdd_BF16.2" file="shared_pseudocode.xml" hover="function: bits(32) FPAdd_BF16(bits(32) op1, bits(32) op2)">FPAdd_BF16</a>(addend, prod);
    else                                      // Extended BFloat16 behaviors
        boolean isbfloat16 = TRUE;
        boolean fpexc = FALSE;  // Do not generate floating-point exceptions
        fpcr.DN = '1';          // Generate default NaN values
        prod = <a link="impl-shared.FPDot.7" file="shared_pseudocode.xml" hover="function: bits(N) FPDot(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr_in, boolean isbfloat16, boolean fpexc)">FPDot</a>(op1_a, op1_b, op2_a, op2_b, fpcr, isbfloat16, fpexc);
        result = <a link="impl-shared.FPAdd.4" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPAdd</a>(addend, prod, fpcr, fpexc);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFInfinity" mylink="shared.functions.float.bfloat.BFInfinity" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFInfinity()
// ============

bits(16) <anchor link="impl-shared.BFInfinity.1" hover="function: bits(16) BFInfinity(bit sign)">BFInfinity</anchor>(bit sign)
    return sign : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(8) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(7);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMatMulAdd" mylink="shared.functions.float.bfloat.BFMatMulAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMatMulAdd()
// =============
// BFloat16 matrix multiply and add to single-precision matrix
// result[2, 2] = addend[2, 2] + (op1[2, 4] * op2[4, 2])

bits(N) <anchor link="impl-shared.BFMatMulAdd.3" hover="function: bits(N) BFMatMulAdd(bits(N) addend, bits(N) op1, bits(N) op2)">BFMatMulAdd</anchor>(bits(N) addend, bits(N) op1, bits(N) op2)

    assert N == 128;

    bits(N) result;
    bits(32) sum;

    for i = 0 to 1
        for j = 0 to 1
            sum = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[addend, 2*i + j, 32];
            for k = 0 to 1
                bits(16) elt1_a = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op1, 4*i + 2*k + 0, 16];
                bits(16) elt1_b = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op1, 4*i + 2*k + 1, 16];
                bits(16) elt2_a = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op2, 4*j + 2*k + 0, 16];
                bits(16) elt2_b = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op2, 4*j + 2*k + 1, 16];
                sum = <a link="impl-shared.BFDotAdd.6" file="shared_pseudocode.xml" hover="function: bits(32) BFDotAdd(bits(32) addend, bits(16) op1_a, bits(16) op1_b, bits(16) op2_a, bits(16) op2_b, FPCRType fpcr_in)">BFDotAdd</a>(sum, elt1_a, elt1_b, elt2_a, elt2_b, FPCR[]);
            <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, 2*i + j, 32] = sum;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMax" mylink="shared.functions.float.bfloat.BFMax" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMax()
// =======
// BFloat16 maximum.

bits(16) <anchor link="impl-shared.BFMax.3" hover="function: bits(16) BFMax(bits(16) op1, bits(16) op2, FPCRType fpcr)">BFMax</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    return <a link="impl-shared.BFMax.4" file="shared_pseudocode.xml" hover="function: bits(16) BFMax(bits(16) op1, bits(16) op2, FPCRType fpcr_in, boolean altfp)">BFMax</a>(op1, op2, fpcr, altfp);

// BFMax()
// =======
// BFloat16 maximum following computational behaviors
// corresponding to instructions that read and write BFloat16 values.
// Compare op1 and op2 and return the larger value after rounding.
// The 'fpcr' argument supplies the FPCR control bits and 'altfp' determines
// if the function should use alternative floating-point behavior.

bits(16) <anchor link="impl-shared.BFMax.4" hover="function: bits(16) BFMax(bits(16) op1, bits(16) op2, FPCRType fpcr_in, boolean altfp)">BFMax</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean altfp)

    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean fpexc = TRUE;
    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    boolean done;
    bits(32) result;

    bits(32) op1_s = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op2_s = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1_s, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2_s, fpcr, fpexc);

    if altfp &amp;&amp; type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; sign1 != sign2 then
        // Alternate handling of zeros with differing sign
        return <a link="impl-shared.BFZero.1" file="shared_pseudocode.xml" hover="function: bits(16) BFZero(bit sign)">BFZero</a>(sign2);
    elsif altfp &amp;&amp; (type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>}) then
        // Alternate handling of NaN inputs
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        return (if type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then <a link="impl-shared.BFZero.1" file="shared_pseudocode.xml" hover="function: bits(16) BFZero(bit sign)">BFZero</a>(sign2) else op2);

    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1_s, op2_s, fpcr);
    if !done then
        <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype;
        bit sign;
        real value;
        if value1 &gt; value2 then
            (fptype,sign,value) = (type1,sign1,value1);
        else
            (fptype,sign,value) = (type2,sign2,value2);
        if fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, 32);
        elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
            sign = sign1 AND sign2;              // Use most positive sign
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, 32);
        else
            if altfp then    // Denormal output is not flushed to zero
                fpcr.FZ = '0';
            result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(value, fpcr, rounding, fpexc);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, 32, fpcr);

    return result&lt;31:16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMaxNum" mylink="shared.functions.float.bfloat.BFMaxNum" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMaxNum()
// ==========
// BFloat16 maximum number following computational behaviors corresponding
// to instructions that read and write BFloat16 values.
// Compare op1 and op2 and return the smaller number operand after rounding.
// The 'fpcr' argument supplies the FPCR control bits.

bits(16) <anchor link="impl-shared.BFMaxNum.3" hover="function: bits(16) BFMaxNum(bits(16) op1_in, bits(16) op2_in, FPCRType fpcr)">BFMaxNum</anchor>(bits(16) op1_in, bits(16) op2_in, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    boolean fpexc = TRUE;
    boolean isbfloat16 = TRUE;
    bits(16) op1 = op1_in;
    bits(16) op2 = op2_in;
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    bits(16) result;

    (type1,-,-) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op1, fpcr, fpexc, isbfloat16);
    (type2,-,-) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op2, fpcr, fpexc, isbfloat16);

    boolean type1_nan = type1 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    boolean type2_nan = type2 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};

    if !(altfp &amp;&amp; type1_nan &amp;&amp; type2_nan) then
        // Treat a single quiet-NaN as -Infinity.
        if type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op1 = <a link="impl-shared.BFInfinity.1" file="shared_pseudocode.xml" hover="function: bits(16) BFInfinity(bit sign)">BFInfinity</a>('1');
        elsif type1 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op2 = <a link="impl-shared.BFInfinity.1" file="shared_pseudocode.xml" hover="function: bits(16) BFInfinity(bit sign)">BFInfinity</a>('1');

    boolean altfmaxfmin = FALSE;    // Do not use alternate NaN handling
    result = <a link="impl-shared.BFMax.4" file="shared_pseudocode.xml" hover="function: bits(16) BFMax(bits(16) op1, bits(16) op2, FPCRType fpcr_in, boolean altfp)">BFMax</a>(op1, op2, fpcr, altfmaxfmin);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMin" mylink="shared.functions.float.bfloat.BFMin" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMin()
// =======
// BFloat16 minimum.

bits(16) <anchor link="impl-shared.BFMin.3" hover="function: bits(16) BFMin(bits(16) op1, bits(16) op2, FPCRType fpcr)">BFMin</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    return <a link="impl-shared.BFMin.4" file="shared_pseudocode.xml" hover="function: bits(16) BFMin(bits(16) op1, bits(16) op2, FPCRType fpcr_in, boolean altfp)">BFMin</a>(op1, op2, fpcr, altfp);

// BFMin()
// =======
// BFloat16 minimum following computational behaviors
// corresponding to instructions that read and write BFloat16 values.
// Compare op1 and op2 and return the smaller value after rounding.
// The 'fpcr' argument supplies the FPCR control bits and 'altfp' determines
// if the function should use alternative floating-point behavior.

bits(16) <anchor link="impl-shared.BFMin.4" hover="function: bits(16) BFMin(bits(16) op1, bits(16) op2, FPCRType fpcr_in, boolean altfp)">BFMin</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean altfp)

    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean fpexc = TRUE;
    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    boolean done;
    bits(32) result;

    bits(32) op1_s = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op2_s = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1_s, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2_s, fpcr, fpexc);

    if altfp &amp;&amp; type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; sign1 != sign2 then
        // Alternate handling of zeros with differing sign
        return <a link="impl-shared.BFZero.1" file="shared_pseudocode.xml" hover="function: bits(16) BFZero(bit sign)">BFZero</a>(sign2);
    elsif altfp &amp;&amp; (type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>}) then
        // Alternate handling of NaN inputs
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        return (if type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then <a link="impl-shared.BFZero.1" file="shared_pseudocode.xml" hover="function: bits(16) BFZero(bit sign)">BFZero</a>(sign2) else op2);

    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1_s, op2_s, fpcr);
    if !done then
        <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype;
        bit sign;
        real value;
        if value1 &lt; value2 then
            (fptype,sign,value) = (type1,sign1,value1);
        else
            (fptype,sign,value) = (type2,sign2,value2);
        if fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, 32);
        elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
            sign = sign1 OR sign2;              // Use most negative sign
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, 32);
        else
            if altfp then    // Denormal output is not flushed to zero
                fpcr.FZ = '0';
            result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(value, fpcr, rounding, fpexc);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, 32, fpcr);

    return result&lt;31:16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMinNum" mylink="shared.functions.float.bfloat.BFMinNum" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMinNum()
// ==========
// BFloat16 minimum number following computational behaviors corresponding
// to instructions that read and write BFloat16 values.
// Compare op1 and op2 and return the smaller number operand after rounding.
// The 'fpcr' argument supplies the FPCR control bits.

bits(16) <anchor link="impl-shared.BFMinNum.3" hover="function: bits(16) BFMinNum(bits(16) op1_in, bits(16) op2_in, FPCRType fpcr)">BFMinNum</anchor>(bits(16) op1_in, bits(16) op2_in, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    boolean fpexc = TRUE;
    boolean isbfloat16 = TRUE;
    bits(16) op1 = op1_in;
    bits(16) op2 = op2_in;
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    bits(16) result;

    (type1,-,-) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op1, fpcr, fpexc, isbfloat16);
    (type2,-,-) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op2, fpcr, fpexc, isbfloat16);

    boolean type1_nan = type1 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    boolean type2_nan = type2 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};

    if !(altfp &amp;&amp; type1_nan &amp;&amp; type2_nan) then
        // Treat a single quiet-NaN as +Infinity.
        if type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op1 = <a link="impl-shared.BFInfinity.1" file="shared_pseudocode.xml" hover="function: bits(16) BFInfinity(bit sign)">BFInfinity</a>('0');
        elsif type1 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op2 = <a link="impl-shared.BFInfinity.1" file="shared_pseudocode.xml" hover="function: bits(16) BFInfinity(bit sign)">BFInfinity</a>('0');

    boolean altfmaxfmin = FALSE;    // Do not use alternate NaN handling
    result = <a link="impl-shared.BFMin.4" file="shared_pseudocode.xml" hover="function: bits(16) BFMin(bits(16) op1, bits(16) op2, FPCRType fpcr_in, boolean altfp)">BFMin</a>(op1, op2, fpcr, altfmaxfmin);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMul" mylink="shared.functions.float.bfloat.BFMul" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMul()
// =======
// Non-widening BFloat16 multiply used by SVE2 instructions.

bits(16) <anchor link="impl-shared.BFMul.3" hover="function: bits(16) BFMul(bits(16) op1, bits(16) op2, FPCRType fpcr)">BFMul</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;
    return <a link="impl-shared.BFMul.4" file="shared_pseudocode.xml" hover="function: bits(16) BFMul(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFMul</a>(op1, op2, fpcr, fpexc);

// BFMul()
// =======
// Non-widening BFloat16 multiply following computational behaviors
// corresponding to instructions that read and write BFloat16 values.
// Calculates op1 * op2.
// The 'fpcr' argument supplies the FPCR control bits.

bits(16) <anchor link="impl-shared.BFMul.4" hover="function: bits(16) BFMul(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFMul</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    boolean done;
    bits(32) result;

    bits(32) op1_s = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op2_s = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1_s, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2_s, fpcr, fpexc);

    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1_s, op2_s, fpcr, fpexc);

    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif inf1 || inf2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, 32);
        elsif zero1 || zero2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1 EOR sign2, 32);
        else
            result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(value1*value2, fpcr, rounding, fpexc);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, 32, fpcr);

    return result&lt;31:16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMulAdd" mylink="shared.functions.float.bfloat.BFMulAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMulAdd()
// ==========
// Non-widening BFloat16 fused multiply-add used by SVE2 instructions.

bits(16) <anchor link="impl-shared.BFMulAdd.4" hover="function: bits(16) BFMulAdd(bits(16) addend, bits(16) op1, bits(16) op2, FPCRType fpcr)">BFMulAdd</anchor>(bits(16) addend, bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;
    return <a link="impl-shared.BFMulAdd.5" file="shared_pseudocode.xml" hover="function: bits(16) BFMulAdd(bits(16) addend, bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFMulAdd</a>(addend, op1, op2, fpcr, fpexc);

// BFMulAdd()
// ==========
// Non-widening BFloat16 fused multiply-add following computational behaviors
// corresponding to instructions that read and write BFloat16 values.
// Calculates addend + op1*op2 with a single rounding.
// The 'fpcr' argument supplies the FPCR control bits.

bits(16) <anchor link="impl-shared.BFMulAdd.5" hover="function: bits(16) BFMulAdd(bits(16) addend, bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFMulAdd</anchor>(bits(16) addend, bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    boolean done;
    bits(32) result;

    bits(32) addend_s = addend : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op1_s = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op2_s = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    (typeA,signA,valueA) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(addend_s, fpcr, fpexc);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1_s, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2_s, fpcr, fpexc);

    inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
    inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
    zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
    zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

    (done,result) = <a link="impl-shared.FPProcessNaNs3.8" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs3(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N) op2, bits(N) op3, FPCRType fpcr, boolean fpexc)">FPProcessNaNs3</a>(typeA, type1, type2, addend_s, op1_s, op2_s, fpcr, fpexc);

    if !(<a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1') then
        if typeA == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; ((inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2)) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

    if !done then
        infA = (typeA == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zeroA = (typeA == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        // Determine sign and type product will have if it does not cause an
        // Invalid Operation.
        signP = sign1 EOR sign2;
        infP  = inf1 || inf2;
        zeroP = zero1 || zero2;

        // Non SNaN-generated Invalid Operation cases are multiplies of zero
        // by infinity and additions of opposite-signed infinities.
        invalidop = (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) || (infA &amp;&amp; infP &amp;&amp; signA != signP);

        if invalidop then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

        // Other cases involving infinities produce an infinity of the same sign.
        elsif (infA &amp;&amp; signA == '0') || (infP &amp;&amp; signP == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', 32);
        elsif (infA &amp;&amp; signA == '1') || (infP &amp;&amp; signP == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', 32);

        // Cases where the result is exactly zero and its sign is not determined by the
        // rounding mode are additions of same-signed zeros.
        elsif zeroA &amp;&amp; zeroP &amp;&amp; signA == signP then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(signA, 32);

        // Otherwise calculate numerical result and round it.
        else
            result_value = valueA + (value1 * value2);
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, 32);
            else
                result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(result_value, fpcr, rounding, fpexc);

        if !invalidop &amp;&amp; fpexc then
            <a link="impl-shared.FPProcessDenorms3.5" file="shared_pseudocode.xml" hover="function: FPProcessDenorms3(FPType type1, FPType type2, FPType type3, integer N, FPCRType fpcr)">FPProcessDenorms3</a>(typeA, type1, type2, 32, fpcr);

    return result&lt;31:16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMulAddH" mylink="shared.functions.float.bfloat.BFMulAddH" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMulAddH()
// ===========
// Used by BFMLALB, BFMLALT, BFMLSLB and BFMLSLT instructions.

bits(N) <anchor link="impl-shared.BFMulAddH.4" hover="function: bits(N) BFMulAddH(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr_in)">BFMulAddH</anchor>(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    bits(N) value1 = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N DIV 2);
    bits(N) value2 = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N DIV 2);
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; fpcr.AH == '1';  // When TRUE:
    boolean fpexc = !altfp;                         //     Do not generate floating point exceptions
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';             //     Flush denormal input and output to zero
    if altfp then fpcr.RMode    = '00';             //     Use RNE rounding mode
    return <a link="impl-shared.FPMulAdd.5" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPMulAdd</a>(addend, value1, value2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMulAddH_ZA" mylink="shared.functions.float.bfloat.BFMulAddH_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMulAddH_ZA()
// ==============
// Used by SME2 ZA-targeting BFMLAL and BFMLSL instructions.

bits(N) <anchor link="impl-shared.BFMulAddH_ZA.4" hover="function: bits(N) BFMulAddH_ZA(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr)">BFMulAddH_ZA</anchor>(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    bits(N) value1 = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N DIV 2);
    bits(N) value2 = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N DIV 2);
    return <a link="impl-shared.FPMulAdd_ZA.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAdd_ZA(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr_in)">FPMulAdd_ZA</a>(addend, value1, value2, fpcr);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMulAdd_ZA" mylink="shared.functions.float.bfloat.BFMulAdd_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMulAdd_ZA()
// =============
// Non-widening BFloat16 fused multiply-add used by SME2 ZA-targeting instructions.

bits(16) <anchor link="impl-shared.BFMulAdd_ZA.4" hover="function: bits(16) BFMulAdd_ZA(bits(16) addend, bits(16) op1, bits(16) op2, FPCRType fpcr_in)">BFMulAdd_ZA</anchor>(bits(16) addend, bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    boolean fpexc = FALSE;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.DN = '1';          // Generate default NaN values
    return <a link="impl-shared.BFMulAdd.5" file="shared_pseudocode.xml" hover="function: bits(16) BFMulAdd(bits(16) addend, bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFMulAdd</a>(addend, op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFMulH" mylink="shared.functions.float.bfloat.BFMulH" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFMulH()
// ========
// BFloat16 widening multiply to single-precision following BFloat16
// computation behaviors.

bits(32) <anchor link="impl-shared.BFMulH.2" hover="function: bits(32) BFMulH(bits(16) op1, bits(16) op2)">BFMulH</anchor>(bits(16) op1, bits(16) op2)

    bits(32) result;

    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
    (type1,sign1,value1) = <a link="impl-shared.BFUnpack.1" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) BFUnpack(bits(N) fpval)">BFUnpack</a>(op1);
    (type2,sign2,value2) = <a link="impl-shared.BFUnpack.1" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) BFUnpack(bits(N) fpval)">BFUnpack</a>(op2);
    if type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> || type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
    else
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
        elsif inf1 || inf2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, 32);
        elsif zero1 || zero2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1 EOR sign2, 32);
        else
            result = <a link="impl-shared.BFRound.1" file="shared_pseudocode.xml" hover="function: bits(32) BFRound(real op)">BFRound</a>(value1*value2);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFNeg" mylink="shared.functions.float.bfloat.BFNeg" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFNeg()
// =======

bits(16) <anchor link="impl-shared.BFNeg.1" hover="function: bits(16) BFNeg(bits(16) op)">BFNeg</anchor>(bits(16) op)
    boolean honor_altfp = TRUE;    // Honor alternate handling
    return <a link="impl-shared.BFNeg.2" file="shared_pseudocode.xml" hover="function: bits(16) BFNeg(bits(16) op, boolean honor_altfp)">BFNeg</a>(op, honor_altfp);

// BFNeg()
// =======

bits(16) <anchor link="impl-shared.BFNeg.2" hover="function: bits(16) BFNeg(bits(16) op, boolean honor_altfp)">BFNeg</anchor>(bits(16) op, boolean honor_altfp)

    if honor_altfp &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() then
        <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
        if fpcr.AH == '1' then
            boolean fpexc = FALSE;
            boolean isbfloat16 = TRUE;
            (fptype, -, -) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op, fpcr, fpexc, isbfloat16);
            if fptype IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then

                return op;        // When fpcr.AH=1, sign of NaN has no consequence

    return NOT(op&lt;15&gt;) : op&lt;14:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFRound" mylink="shared.functions.float.bfloat.BFRound" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFRound()
// =========
// Converts a real number OP into a single-precision value using the
// Round to Odd rounding mode and following BFloat16 computation behaviors.

bits(32) <anchor link="impl-shared.BFRound.1" hover="function: bits(32) BFRound(real op)">BFRound</anchor>(real op)

    assert op != 0.0;
    bits(32) result;

    // Format parameters - minimum exponent, numbers of exponent and fraction bits.
    minimum_exp = -126;  E = 8;  F = 23;

    // Split value into sign, unrounded mantissa and exponent.
    bit sign;
    real mantissa;
    if op &lt; 0.0 then
        sign = '1';  mantissa = -op;
    else
        sign = '0';  mantissa = op;
    exponent = 0;
    while mantissa &lt; 1.0 do
        mantissa = mantissa * 2.0;  exponent = exponent - 1;
    while mantissa &gt;= 2.0 do
        mantissa = mantissa / 2.0;  exponent = exponent + 1;

    // Fixed Flush-to-zero.
    if exponent &lt; minimum_exp then
        return <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, 32);

    // Start creating the exponent value for the result. Start by biasing the actual exponent
    // so that the minimum exponent becomes 1, lower values 0 (indicating possible underflow).
    biased_exp = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>((exponent - minimum_exp) + 1, 0);
    if biased_exp == 0 then mantissa = mantissa / 2.0^(minimum_exp - exponent);

    // Get the unrounded mantissa as an integer, and the "units in last place" rounding error.
    int_mant = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(mantissa * 2.0^F);  // &lt; 2.0^F if biased_exp == 0, &gt;= 2.0^F if not
    error = mantissa * 2.0^F - Real(int_mant);

    // Round to Odd
    if error != 0.0 then
        int_mant&lt;0&gt; = '1';

    // Deal with overflow and generate result.
    if biased_exp &gt;= 2^E - 1 then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, 32);      // Overflows generate appropriately-signed Infinity
    else
        result = sign : biased_exp&lt;30-F:0&gt; : int_mant&lt;F-1:0&gt;;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFSub" mylink="shared.functions.float.bfloat.BFSub" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFSub()
// =======
// Non-widening BFloat16 subtraction used by SVE2 instructions.

bits(16) <anchor link="impl-shared.BFSub.3" hover="function: bits(16) BFSub(bits(16) op1, bits(16) op2, FPCRType fpcr)">BFSub</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;
    return <a link="impl-shared.BFSub.4" file="shared_pseudocode.xml" hover="function: bits(16) BFSub(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFSub</a>(op1, op2, fpcr, fpexc);

// BFSub()
// =======
// Non-widening BFloat16 subtraction following computational behaviors
// corresponding to instructions that read and write BFloat16 values.
// Calculates op1 - op2.
// The 'fpcr' argument supplies the FPCR control bits.

bits(16) <anchor link="impl-shared.BFSub.4" hover="function: bits(16) BFSub(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFSub</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    boolean done;
    bits(32) result;

    bits(32) op1_s = op1 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    bits(32) op2_s = op2 : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1_s, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2_s, fpcr, fpexc);

    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1_s, op2_s, fpcr, fpexc);

    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if inf1 &amp;&amp; inf2 &amp;&amp; sign1 == sign2 then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif (inf1 &amp;&amp; sign1 == '0') || (inf2 &amp;&amp; sign2 == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', 32);
        elsif (inf1 &amp;&amp; sign1 == '1') || (inf2 &amp;&amp; sign2 == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', 32);
        elsif zero1 &amp;&amp; zero2 &amp;&amp; sign1 == NOT(sign2) then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1, 32);
        else
            result_value = value1 - value2;
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, 32);
            else
                result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(result_value, fpcr, rounding, fpexc);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, 32, fpcr);

    return result&lt;31:16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFSub_ZA" mylink="shared.functions.float.bfloat.BFSub_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFSub_ZA()
// ==========
// Non-widening BFloat16 subtraction used by SME2 ZA-targeting instructions.

bits(16) <anchor link="impl-shared.BFSub_ZA.3" hover="function: bits(16) BFSub_ZA(bits(16) op1, bits(16) op2, FPCRType fpcr_in)">BFSub_ZA</anchor>(bits(16) op1, bits(16) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    boolean fpexc = FALSE;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.DN = '1';          // Generate default NaN values
    return <a link="impl-shared.BFSub.4" file="shared_pseudocode.xml" hover="function: bits(16) BFSub(bits(16) op1, bits(16) op2, FPCRType fpcr, boolean fpexc)">BFSub</a>(op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFUnpack" mylink="shared.functions.float.bfloat.BFUnpack" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFUnpack()
// ==========
// Unpacks a BFloat16 or single-precision value into its type,
// sign bit and real number that it represents.
// The real number result has the correct sign for numbers and infinities,
// is very large in magnitude for infinities, and is 0.0 for NaNs.
// (These values are chosen to simplify the description of
// comparisons and conversions.)

(FPType, bit, real) <anchor link="impl-shared.BFUnpack.1" hover="function: (FPType, bit, real) BFUnpack(bits(N) fpval)">BFUnpack</anchor>(bits(N) fpval)

    assert N IN {16,32};

    bit sign;
    bits(8) exp;
    bits(23) frac;
    if N == 16 then
        sign   = fpval&lt;15&gt;;
        exp    = fpval&lt;14:7&gt;;
        frac   = fpval&lt;6:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
    else  // N == 32
        sign   = fpval&lt;31&gt;;
        exp    = fpval&lt;30:23&gt;;
        frac   = fpval&lt;22:0&gt;;

    <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype;
    real value;
    if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(exp) then
        fptype = <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;  value = 0.0;    // Fixed Flush to Zero
    elsif <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(exp) then
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac) then
            fptype = <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>;  value = 2.0^1000000;
        else    // no SNaN for BF16 arithmetic
            fptype = <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>; value = 0.0;
    else
        fptype = <a link="FPType_Nonzero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Nonzero</a>;
        value = 2.0^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(exp)-127) * (1.0 + Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac)) * 2.0^-23);

    if sign == '1' then value = -value;

    return (fptype, sign, value);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/BFZero" mylink="shared.functions.float.bfloat.BFZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BFZero()
// ========

bits(16) <anchor link="impl-shared.BFZero.1" hover="function: bits(16) BFZero(bit sign)">BFZero</anchor>(bit sign)
    return sign : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8) : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(7);</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/FPAdd_BF16" mylink="shared.functions.float.bfloat.FPAdd_BF16" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPAdd_BF16()
// ============
// Single-precision add following BFloat16 computation behaviors.

bits(32) <anchor link="impl-shared.FPAdd_BF16.2" hover="function: bits(32) FPAdd_BF16(bits(32) op1, bits(32) op2)">FPAdd_BF16</anchor>(bits(32) op1, bits(32) op2)

    bits(32) result;

    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
    (type1,sign1,value1) = <a link="impl-shared.BFUnpack.1" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) BFUnpack(bits(N) fpval)">BFUnpack</a>(op1);
    (type2,sign2,value2) = <a link="impl-shared.BFUnpack.1" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) BFUnpack(bits(N) fpval)">BFUnpack</a>(op2);
    if type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> || type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
    else
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        if inf1 &amp;&amp; inf2 &amp;&amp; sign1 == NOT(sign2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
        elsif (inf1 &amp;&amp; sign1 == '0') || (inf2 &amp;&amp; sign2 == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', 32);
        elsif (inf1 &amp;&amp; sign1 == '1') || (inf2 &amp;&amp; sign2 == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', 32);
        elsif zero1 &amp;&amp; zero2 &amp;&amp; sign1 == sign2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1, 32);
        else
            result_value = value1 + value2;
            if result_value == 0.0 then
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>('0', 32);    // Positive sign when Round to Odd
            else
                result = <a link="impl-shared.BFRound.1" file="shared_pseudocode.xml" hover="function: bits(32) BFRound(real op)">BFRound</a>(result_value);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/FPConvertBF" mylink="shared.functions.float.bfloat.FPConvertBF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPConvertBF()
// =============
// Converts a single-precision OP to BFloat16 value with using rounding mode of
// Round to Nearest Even when executed from AArch64 state and
// FPCR.AH == '1', otherwise rounding is controlled by FPCR/FPSCR.

bits(16) <anchor link="impl-shared.FPConvertBF.3" hover="function: bits(16) FPConvertBF(bits(32) op, FPCRType fpcr_in, FPRounding rounding_in)">FPConvertBF</anchor>(bits(32) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding_in)

    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = rounding_in;
    bits(32) result;                                // BF16 value in top 16 bits
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    boolean fpexc = !altfp;                         // Generate no floating-point exceptions
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';             // Flush denormal input and output to zero
    if altfp then rounding = <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>;    // Use RNE rounding mode

    // Unpack floating-point operand, with always flush-to-zero if fpcr.AH == '1'.
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, fpexc);

    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        if fpcr.DN == '1' then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, 32);
        else
            result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(op, 32);
        if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, 32);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, 32);
    else
        result = <a link="impl-shared.FPRoundBF.4" file="shared_pseudocode.xml" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</a>(value, fpcr, rounding, fpexc);

    // Returns correctly rounded BF16 value from top 16 bits
    return result&lt;31:16&gt;;

// FPConvertBF()
// =============
// Converts a single-precision operand to BFloat16 value.

bits(16) <anchor link="impl-shared.FPConvertBF.2" hover="function: bits(16) FPConvertBF(bits(32) op, FPCRType fpcr)">FPConvertBF</anchor>(bits(32) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    return <a link="impl-shared.FPConvertBF.3" file="shared_pseudocode.xml" hover="function: bits(16) FPConvertBF(bits(32) op, FPCRType fpcr_in, FPRounding rounding_in)">FPConvertBF</a>(op, fpcr, <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr));</pstext>
    </ps>
    <ps name="shared/functions/float/bfloat/FPRoundBF" mylink="shared.functions.float.bfloat.FPRoundBF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRoundBF()
// ===========
// Converts a real number OP into a BFloat16 value using the supplied
// rounding mode RMODE. The 'fpexc' argument controls the generation of
// floating-point exceptions.

bits(32) <anchor link="impl-shared.FPRoundBF.4" hover="function: bits(32) FPRoundBF(real op, FPCRType fpcr, FPRounding rounding, boolean fpexc)">FPRoundBF</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, boolean fpexc)
    boolean isbfloat16 = TRUE;
    return <a link="impl-shared.FPRoundBase.6" file="shared_pseudocode.xml" hover="function: bits(N) FPRoundBase(real op, FPCRType fpcr, FPRounding rounding, boolean isbfloat16, boolean fpexc, integer N)">FPRoundBase</a>(op, fpcr, rounding, isbfloat16, fpexc, 32);</pstext>
    </ps>
    <ps name="shared/functions/float/fixedtofp/FixedToFP" mylink="shared.functions.float.fixedtofp.FixedToFP" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FixedToFP()
// ===========

// Convert M-bit fixed point 'op' with FBITS fractional bits to
// N-bit precision floating point, controlled by UNSIGNED and ROUNDING.

bits(N) <anchor link="impl-shared.FixedToFP.6" hover="function: bits(N) FixedToFP(bits(M) op, integer fbits, boolean unsigned, FPCRType fpcr, FPRounding rounding, integer N)">FixedToFP</anchor>(bits(M) op, integer fbits, boolean unsigned, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr,
                  <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer N)

    assert N IN {16,32,64};
    assert M IN {16,32,64};
    bits(N) result;
    assert fbits &gt;= 0;
    assert rounding != <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a>;

    // Correct signed-ness
    int_operand = <a link="impl-shared.Int.2" file="shared_pseudocode.xml" hover="function: integer Int(bits(N) x, boolean unsigned)">Int</a>(op, unsigned);

    // Scale by fractional bits and generate a real value
    real_operand = Real(int_operand) / 2.0^fbits;

    if real_operand == 0.0 then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>('0', N);
    else
        result = <a link="impl-shared.FPRound.4" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRound</a>(real_operand, fpcr, rounding, N);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpabs/FPAbs" mylink="shared.functions.float.fpabs.FPAbs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPAbs()
// =======

bits(N) <anchor link="impl-shared.FPAbs.1" hover="function: bits(N) FPAbs(bits(N) op)">FPAbs</anchor>(bits(N) op)

    assert N IN {16,32,64};
    if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() then
        <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
        if fpcr.AH == '1' then
            (fptype, -, -) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, FALSE);
            if fptype IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then
                return op;        // When fpcr.AH=1, sign of NaN has no consequence

    return '0' : op&lt;N-2:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/fpadd/FPAdd" mylink="shared.functions.float.fpadd.FPAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPAdd()
// =======

bits(N) <anchor link="impl-shared.FPAdd.3" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPAdd</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;       // Generate floating-point exceptions
    return <a link="impl-shared.FPAdd.4" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPAdd</a>(op1, op2, fpcr, fpexc);

// FPAdd()
// =======

bits(N) <anchor link="impl-shared.FPAdd.4" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPAdd</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {16,32,64};
    rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);

    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2, fpcr, fpexc);

    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr, fpexc);
    if !done then
        inf1  = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);  inf2  = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);      zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        if inf1 &amp;&amp; inf2 &amp;&amp; sign1 == NOT(sign2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif (inf1 &amp;&amp; sign1 == '0') || (inf2 &amp;&amp; sign2 == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif (inf1 &amp;&amp; sign1 == '1') || (inf2 &amp;&amp; sign2 == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);
        elsif zero1 &amp;&amp; zero2 &amp;&amp; sign1 == sign2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1, N);
        else
            result_value = value1 + value2;
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpadd/FPAdd_ZA" mylink="shared.functions.float.fpadd.FPAdd_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPAdd_ZA()
// ==========
// Calculates op1+op2 for SME2 ZA-targeting instructions.

bits(N) <anchor link="impl-shared.FPAdd_ZA.3" hover="function: bits(N) FPAdd_ZA(bits(N) op1, bits(N) op2, FPCRType fpcr_in)">FPAdd_ZA</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean fpexc = FALSE;      // Do not generate floating-point exceptions
    fpcr.DN = '1';              // Generate default NaN values
    return <a link="impl-shared.FPAdd.4" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPAdd</a>(op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/fpcompare/FPCompare" mylink="shared.functions.float.fpcompare.FPCompare" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPCompare()
// ===========

bits(4) <anchor link="impl-shared.FPCompare.4" hover="function: bits(4) FPCompare(bits(N) op1, bits(N) op2, boolean signal_nans, FPCRType fpcr)">FPCompare</anchor>(bits(N) op1, bits(N) op2, boolean signal_nans, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    bits(4) result;
    if type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then
        result = '0011';
        if type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || signal_nans then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    else
        // All non-NaN cases can be evaluated on the values produced by FPUnpack()
        if value1 == value2 then
            result = '0110';
        elsif value1 &lt; value2 then
            result = '1000';
        else  // value1 &gt; value2
            result = '0010';

        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpcompareeq/FPCompareEQ" mylink="shared.functions.float.fpcompareeq.FPCompareEQ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPCompareEQ()
// =============

boolean <anchor link="impl-shared.FPCompareEQ.3" hover="function: boolean FPCompareEQ(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPCompareEQ</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    boolean result;
    if type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then
        result = FALSE;
        if type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    else
        // All non-NaN cases can be evaluated on the values produced by FPUnpack()
        result = (value1 == value2);
        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpcomparege/FPCompareGE" mylink="shared.functions.float.fpcomparege.FPCompareGE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPCompareGE()
// =============

boolean <anchor link="impl-shared.FPCompareGE.3" hover="function: boolean FPCompareGE(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPCompareGE</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    boolean result;
    if type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then
        result = FALSE;
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    else
        // All non-NaN cases can be evaluated on the values produced by FPUnpack()
        result = (value1 &gt;= value2);
        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpcomparegt/FPCompareGT" mylink="shared.functions.float.fpcomparegt.FPCompareGT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPCompareGT()
// =============

boolean <anchor link="impl-shared.FPCompareGT.3" hover="function: boolean FPCompareGT(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPCompareGT</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    boolean result;
    if type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then
        result = FALSE;
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    else
        // All non-NaN cases can be evaluated on the values produced by FPUnpack()
        result = (value1 &gt; value2);
        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpconvert/FPConvert" mylink="shared.functions.float.fpconvert.FPConvert" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPConvert()
// ===========

// Convert floating point 'op' with N-bit precision to M-bit precision,
// with rounding controlled by ROUNDING.
// This is used by the FP-to-FP conversion instructions and so for
// half-precision data ignores FZ16, but observes AHP.

bits(M) <anchor link="impl-shared.FPConvert.4" hover="function: bits(M) FPConvert(bits(N) op, FPCRType fpcr, FPRounding rounding, integer M)">FPConvert</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer M)

    assert M IN {16,32,64};
    assert N IN {16,32,64};
    bits(M) result;

    // Unpack floating-point operand optionally with flush-to-zero.
    (fptype,sign,value) = <a link="impl-shared.FPUnpackCV.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackCV(bits(N) fpval, FPCRType fpcr_in)">FPUnpackCV</a>(op, fpcr);

    alt_hp = (M == 16) &amp;&amp; (fpcr.AHP == '1');

    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        if alt_hp then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, M);
        elsif fpcr.DN == '1' then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, M);
        else
            result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(op, M);
        if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || alt_hp then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>,fpcr);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        if alt_hp then
            result = sign:<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(M-1);
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        else
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, M);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, M);
    else
        result = <a link="impl-shared.FPRoundCV.4" file="shared_pseudocode.xml" hover="function: bits(N) FPRoundCV(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRoundCV</a>(value, fpcr, rounding, M);
        <a link="impl-shared.FPProcessDenorm.3" file="shared_pseudocode.xml" hover="function: FPProcessDenorm(FPType fptype, integer N, FPCRType fpcr)">FPProcessDenorm</a>(fptype, N, fpcr);

    return result;

// FPConvert()
// ===========

bits(M) <anchor link="impl-shared.FPConvert.3" hover="function: bits(M) FPConvert(bits(N) op, FPCRType fpcr, integer M)">FPConvert</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, integer M)
    return <a link="impl-shared.FPConvert.4" file="shared_pseudocode.xml" hover="function: bits(M) FPConvert(bits(N) op, FPCRType fpcr, FPRounding rounding, integer M)">FPConvert</a>(op, fpcr, <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr), M);</pstext>
    </ps>
    <ps name="shared/functions/float/fpconvertnan/FPConvertNaN" mylink="shared.functions.float.fpconvertnan.FPConvertNaN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPConvertNaN()
// ==============
// Converts a NaN of one floating-point type to another

bits(M) <anchor link="impl-shared.FPConvertNaN.2" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</anchor>(bits(N) op, integer M)

    assert N IN {16,32,64};
    assert M IN {16,32,64};
    bits(M) result;
    bits(51) frac;

    sign = op&lt;N-1&gt;;

    // Unpack payload from input NaN
    case N of
        when 64 frac = op&lt;50:0&gt;;
        when 32 frac = op&lt;21:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(29);
        when 16 frac = op&lt;8:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(42);

    // Repack payload into output NaN, while
    // converting an SNaN to a QNaN.
    case M of
        when 64 result = sign:<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(M-52):frac;
        when 32 result = sign:<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(M-23):frac&lt;50:29&gt;;
        when 16 result = sign:<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(M-10):frac&lt;50:42&gt;;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpcrtype/FPCRType" mylink="shared.functions.float.fpcrtype.FPCRType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="FPCRType" hover="type FPCRType">FPCRType</anchor>;</pstext>
    </ps>
    <ps name="shared/functions/float/fpdecoderm/FPDecodeRM" mylink="shared.functions.float.fpdecoderm.FPDecodeRM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDecodeRM()
// ============

// Decode most common AArch32 floating-point rounding encoding.

FPRounding <anchor link="impl-shared.FPDecodeRM.1" hover="function: FPRounding FPDecodeRM(bits(2) rm)">FPDecodeRM</anchor>(bits(2) rm)

    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> result;
    case rm of
        when '00' result = <a link="FPRounding_TIEAWAY" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEAWAY</a>; // A
        when '01' result = <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>; // N
        when '10' result = <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>;  // P
        when '11' result = <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>;  // M

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpdecoderounding/FPDecodeRounding" mylink="shared.functions.float.fpdecoderounding.FPDecodeRounding" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDecodeRounding()
// ==================

// Decode floating-point rounding mode and common AArch64 encoding.

FPRounding <anchor link="impl-shared.FPDecodeRounding.1" hover="function: FPRounding FPDecodeRounding(bits(2) rmode)">FPDecodeRounding</anchor>(bits(2) rmode)
    case rmode of
        when '00' return <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>; // N
        when '01' return <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>;  // P
        when '10' return <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>;  // M
        when '11' return <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>;    // Z</pstext>
    </ps>
    <ps name="shared/functions/float/fpdefaultnan/FPDefaultNaN" mylink="shared.functions.float.fpdefaultnan.FPDefaultNaN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDefaultNaN()
// ==============

bits(N) <anchor link="impl-shared.FPDefaultNaN.1" hover="function: bits(N) FPDefaultNaN(integer N)">FPDefaultNaN</anchor>(integer N)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
    return <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);

bits(N) <anchor link="impl-shared.FPDefaultNaN.2" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</anchor>(<a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    bit sign = if <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then fpcr.AH else '0';

    bits(E) exp  = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(E);
    bits(F) frac = '1':<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F-1);

    return sign : exp : frac;</pstext>
    </ps>
    <ps name="shared/functions/float/fpdiv/FPDiv" mylink="shared.functions.float.fpdiv.FPDiv" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDiv()
// =======

bits(N) <anchor link="impl-shared.FPDiv.3" hover="function: bits(N) FPDiv(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPDiv</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);
    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);

    if !done then
        inf1  = type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>;
        inf2  = type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>;
        zero1 = type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;
        zero2 = type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;

        if (inf1 &amp;&amp; inf2) || (zero1 &amp;&amp; zero2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif inf1 || zero2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, N);
            if !inf1 then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_DivideByZero" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_DivideByZero</a>, fpcr);
        elsif zero1 || inf2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1 EOR sign2, N);
        else
            result = <a link="impl-shared.FPRound.3" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</a>(value1/value2, fpcr, N);

        if !zero2 then
            <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpdot/FPDot" mylink="shared.functions.float.fpdot.FPDot" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDot()
// =======
// Calculates single-precision result of 2-way 16-bit floating-point dot-product
// with a single rounding.
// The 'fpcr' argument supplies the FPCR control bits and 'isbfloat16'
// determines whether input operands are BFloat16 or half-precision type.
// and 'fpexc' controls the generation of floating-point exceptions.

bits(N) <anchor link="impl-shared.FPDot.6" hover="function: bits(N) FPDot(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr, boolean isbfloat16)">FPDot</anchor>(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a,
              bits(N DIV 2) op2_b, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean isbfloat16)
    boolean fpexc = TRUE;       // Generate floating-point exceptions
    return <a link="impl-shared.FPDot.7" file="shared_pseudocode.xml" hover="function: bits(N) FPDot(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr_in, boolean isbfloat16, boolean fpexc)">FPDot</a>(op1_a, op1_b, op2_a, op2_b, fpcr, isbfloat16, fpexc);

bits(N) <anchor link="impl-shared.FPDot.7" hover="function: bits(N) FPDot(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr_in, boolean isbfloat16, boolean fpexc)">FPDot</anchor>(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a,
              bits(N DIV 2) op2_b, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean isbfloat16, boolean fpexc)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;

    assert N == 32;
    bits(N) result;
    boolean done;
    fpcr.AHP = '0';           // Ignore alternative half-precision option
    rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);

    (type1_a,sign1_a,value1_a) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op1_a, fpcr, fpexc, isbfloat16);
    (type1_b,sign1_b,value1_b) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op1_b, fpcr, fpexc, isbfloat16);
    (type2_a,sign2_a,value2_a) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op2_a, fpcr, fpexc, isbfloat16);
    (type2_b,sign2_b,value2_b) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(op2_b, fpcr, fpexc, isbfloat16);

    inf1_a = (type1_a == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero1_a = (type1_a == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
    inf1_b = (type1_b == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero1_b = (type1_b == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
    inf2_a = (type2_a == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero2_a = (type2_a == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
    inf2_b = (type2_b == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero2_b = (type2_b == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

    (done,result) = <a link="impl-shared.FPProcessNaNs4.10" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs4(FPType type1, FPType type2, FPType type3, FPType type4, bits(N DIV 2) op1, bits(N DIV 2) op2, bits(N DIV 2) op3, bits(N DIV 2) op4, FPCRType fpcr, boolean fpexc)">FPProcessNaNs4</a>(type1_a, type1_b, type2_a, type2_b,
                                   op1_a, op1_b, op2_a, op2_b, fpcr, fpexc);

    if (((inf1_a &amp;&amp; zero2_a) || (zero1_a &amp;&amp; inf2_a)) &amp;&amp;
        ((inf1_b &amp;&amp; zero2_b) || (zero1_b &amp;&amp; inf2_b))) then
        result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

    if !done then
        // Determine sign and type products will have if it does not cause an Invalid
        // Operation.
        signPa = sign1_a EOR sign2_a;
        signPb = sign1_b EOR sign2_b;
        infPa = inf1_a || inf2_a;
        infPb = inf1_b || inf2_b;
        zeroPa = zero1_a || zero2_a;
        zeroPb = zero1_b || zero2_b;

        // Non SNaN-generated Invalid Operation cases are multiplies of zero
        // by infinity and additions of opposite-signed infinities.
        invalidop = ((inf1_a &amp;&amp; zero2_a) || (zero1_a &amp;&amp; inf2_a) ||
            (inf1_b &amp;&amp; zero2_b) || (zero1_b &amp;&amp; inf2_b) || (infPa &amp;&amp; infPb &amp;&amp; signPa != signPb));

        if invalidop then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

       // Other cases involving infinities produce an infinity of the same sign.
        elsif (infPa &amp;&amp; signPa == '0') || (infPb &amp;&amp; signPb == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif (infPa &amp;&amp; signPa == '1') || (infPb &amp;&amp; signPb == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);

        // Cases where the result is exactly zero and its sign is not determined by the
        // rounding mode are additions of same-signed zeros.
        elsif zeroPa &amp;&amp; zeroPb &amp;&amp; signPa == signPb then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(signPa, N);

        // Otherwise calculate fused sum of products and round it.
        else
            result_value = (value1_a * value2_a) + (value1_b * value2_b);
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpdot/FPDotAdd" mylink="shared.functions.float.fpdot.FPDotAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDotAdd()
// ==========
// Half-precision 2-way dot-product and add to single-precision.

bits(N) <anchor link="impl-shared.FPDotAdd.6" hover="function: bits(N) FPDotAdd(bits(N) addend, bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr)">FPDotAdd</anchor>(bits(N) addend, bits(N DIV 2) op1_a, bits(N DIV 2) op1_b,
                 bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    assert N == 32;

    bits(N) prod;
    boolean isbfloat16 = FALSE;
    boolean fpexc = TRUE;     // Generate floating-point exceptions
    prod = <a link="impl-shared.FPDot.7" file="shared_pseudocode.xml" hover="function: bits(N) FPDot(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr_in, boolean isbfloat16, boolean fpexc)">FPDot</a>(op1_a, op1_b, op2_a, op2_b, fpcr, isbfloat16, fpexc);
    result = <a link="impl-shared.FPAdd.4" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPAdd</a>(addend, prod, fpcr, fpexc);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpdot/FPDotAdd_ZA" mylink="shared.functions.float.fpdot.FPDotAdd_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPDotAdd_ZA()
// =============
// Half-precision 2-way dot-product and add to single-precision
// for SME ZA-targeting instructions.

bits(N) <anchor link="impl-shared.FPDotAdd_ZA.6" hover="function: bits(N) FPDotAdd_ZA(bits(N) addend, bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr_in)">FPDotAdd_ZA</anchor>(bits(N) addend, bits(N DIV 2) op1_a, bits(N DIV 2) op1_b,
                    bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    assert N == 32;

    bits(N) prod;
    boolean isbfloat16 = FALSE;
    boolean fpexc = FALSE;    // Do not generate floating-point exceptions
    fpcr.DN = '1';            // Generate default NaN values
    prod = <a link="impl-shared.FPDot.7" file="shared_pseudocode.xml" hover="function: bits(N) FPDot(bits(N DIV 2) op1_a, bits(N DIV 2) op1_b, bits(N DIV 2) op2_a, bits(N DIV 2) op2_b, FPCRType fpcr_in, boolean isbfloat16, boolean fpexc)">FPDot</a>(op1_a, op1_b, op2_a, op2_b, fpcr, isbfloat16, fpexc);
    result = <a link="impl-shared.FPAdd.4" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPAdd</a>(addend, prod, fpcr, fpexc);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpexc/FPExc" mylink="shared.functions.float.fpexc.FPExc" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPExc
// =====

enumeration <anchor link="FPExc" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc</anchor>       {<anchor link="FPExc_InvalidOp" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</anchor>, <anchor link="FPExc_DivideByZero" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_DivideByZero</anchor>, <anchor link="FPExc_Overflow" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Overflow</anchor>,
                         <anchor link="FPExc_Underflow" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Underflow</anchor>, <anchor link="FPExc_Inexact" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</anchor>, <anchor link="FPExc_InputDenorm" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/float/fpinfinity/FPInfinity" mylink="shared.functions.float.fpinfinity.FPInfinity" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPInfinity()
// ============

bits(N) <anchor link="impl-shared.FPInfinity.2" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</anchor>(bit sign, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    bits(E) exp  = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(E);
    bits(F) frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);

    return sign : exp : frac;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmatmul/FPMatMulAdd" mylink="shared.functions.float.fpmatmul.FPMatMulAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMatMulAdd()
// =============
//
// Floating point matrix multiply and add to same precision matrix
// result[2, 2] = addend[2, 2] + (op1[2, 2] * op2[2, 2])

bits(N) <anchor link="impl-shared.FPMatMulAdd.5" hover="function: bits(N) FPMatMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, integer esize, FPCRType fpcr)">FPMatMulAdd</anchor>(bits(N) addend, bits(N) op1, bits(N) op2, integer esize, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N == esize * 2 * 2;
    bits(N)  result;
    bits(esize) prod0, prod1, sum;

    for i = 0 to 1
        for j = 0 to 1
            sum   = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[addend, 2*i + j, esize];
            prod0 = <a link="impl-shared.FPMul.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMul</a>(<a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op1, 2*i + 0, esize],
                          <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op2, 2*j + 0, esize], fpcr);
            prod1 = <a link="impl-shared.FPMul.3" file="shared_pseudocode.xml" hover="function: bits(N) FPMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMul</a>(<a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op1, 2*i + 1, esize],
                          <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op2, 2*j + 1, esize], fpcr);
            sum   = <a link="impl-shared.FPAdd.3" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPAdd</a>(sum, <a link="impl-shared.FPAdd.3" file="shared_pseudocode.xml" hover="function: bits(N) FPAdd(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPAdd</a>(prod0, prod1, fpcr), fpcr);
            <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, 2*i + j, esize] = sum;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmax/FPMax" mylink="shared.functions.float.fpmax.FPMax" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMax()
// =======

bits(N) <anchor link="impl-shared.FPMax.3" hover="function: bits(N) FPMax(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMax</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    return <a link="impl-shared.FPMax.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMax(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMax</a>(op1, op2, fpcr, altfp);

// FPMax()
// =======
// Compare two inputs and return the larger value after rounding. The
// 'fpcr' argument supplies the FPCR control bits and 'altfp' determines
// if the function should use alternative floating-point behavior.

bits(N) <anchor link="impl-shared.FPMax.4" hover="function: bits(N) FPMax(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMax</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean altfp)

    assert N IN {16,32,64};
    boolean done;
    bits(N) result;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    if altfp &amp;&amp; type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; sign1 != sign2 then
        // Alternate handling of zeros with differing sign
        return <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign2, N);
    elsif altfp &amp;&amp; (type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>}) then
        // Alternate handling of NaN inputs
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        return (if type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign2, N) else op2);

    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype;
        bit sign;
        real value;
        if value1 &gt; value2 then
            (fptype,sign,value) = (type1,sign1,value1);
        else
            (fptype,sign,value) = (type2,sign2,value2);
        if fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
        elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
            sign = sign1 AND sign2;         // Use most positive sign
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
        else
            // The use of FPRound() covers the case where there is a trapped underflow exception
            // for a denormalized number even though the result is exact.
            rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
            if altfp then    // Denormal output is not flushed to zero
                fpcr.FZ = '0';
                fpcr.FZ16 = '0';

            result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(value, fpcr, rounding, TRUE, N);

        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmaxnormal/FPMaxNormal" mylink="shared.functions.float.fpmaxnormal.FPMaxNormal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMaxNormal()
// =============

bits(N) <anchor link="impl-shared.FPMaxNormal.2" hover="function: bits(N) FPMaxNormal(bit sign, integer N)">FPMaxNormal</anchor>(bit sign, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp  = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(E-1):'0';
    frac = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(F);

    return sign : exp : frac;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmaxnum/FPMaxNum" mylink="shared.functions.float.fpmaxnum.FPMaxNum" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMaxNum()
// ==========

bits(N) <anchor link="impl-shared.FPMaxNum.3" hover="function: bits(N) FPMaxNum(bits(N) op1_in, bits(N) op2_in, FPCRType fpcr)">FPMaxNum</anchor>(bits(N) op1_in, bits(N) op2_in, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    bits(N) op1 = op1_in;
    bits(N) op2 = op2_in;
    (type1,-,-) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,-,-) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    boolean type1_nan = type1 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    boolean type2_nan = type2 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';

    if !(altfp &amp;&amp; type1_nan &amp;&amp; type2_nan) then
        // Treat a single quiet-NaN as -Infinity.
        if type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op1 = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);
        elsif type1 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op2 = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);

    altfmaxfmin = FALSE;    // Restrict use of FMAX/FMIN NaN propagation rules
    result = <a link="impl-shared.FPMax.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMax(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMax</a>(op1, op2, fpcr, altfmaxfmin);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmerge/IsMerging" mylink="shared.functions.float.fpmerge.IsMerging" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsMerging()
// ===========
// Returns TRUE if the output elements other than the lowest are taken from
// the destination register.

boolean <anchor link="impl-shared.IsMerging.1" hover="function: boolean IsMerging(FPCRType fpcr)">IsMerging</anchor>(<a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    bit nep = if <a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' &amp;&amp; !<a link="impl-aarch64.IsFullA64Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsFullA64Enabled()">IsFullA64Enabled</a>() then '0' else fpcr.NEP;
    return <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; nep == '1';</pstext>
    </ps>
    <ps name="shared/functions/float/fpmin/FPMin" mylink="shared.functions.float.fpmin.FPMin" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMin()
// =======

bits(N) <anchor link="impl-shared.FPMin.3" hover="function: bits(N) FPMin(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMin</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    return <a link="impl-shared.FPMin.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMin(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMin</a>(op1, op2, fpcr, altfp);

// FPMin()
// =======
// Compare two operands and return the smaller operand after rounding. The
// 'fpcr' argument supplies the FPCR control bits and 'altfp' determines
// if the function should use alternative behavior.

bits(N) <anchor link="impl-shared.FPMin.4" hover="function: bits(N) FPMin(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMin</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean altfp)

    assert N IN {16,32,64};
    boolean done;
    bits(N) result;
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    if altfp &amp;&amp; type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> &amp;&amp; sign1 != sign2 then
        // Alternate handling of zeros with differing sign
        return <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign2, N);
    elsif altfp &amp;&amp; (type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} || type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>}) then
        // Alternate handling of NaN inputs
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        return (if type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign2, N) else op2);

    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype;
        bit sign;
        real value;
        <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding;
        if value1 &lt; value2 then
            (fptype,sign,value) = (type1,sign1,value1);
        else
            (fptype,sign,value) = (type2,sign2,value2);
        if fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
        elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
            sign = sign1 OR sign2;              // Use most negative sign
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
        else
            // The use of FPRound() covers the case where there is a trapped underflow exception
            // for a denormalized number even though the result is exact.
            rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
            if altfp then    // Denormal output is not flushed to zero
                fpcr.FZ = '0';
                fpcr.FZ16 = '0';

            result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(value, fpcr, rounding, TRUE, N);

        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpminnum/FPMinNum" mylink="shared.functions.float.fpminnum.FPMinNum" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMinNum()
// ==========

bits(N) <anchor link="impl-shared.FPMinNum.3" hover="function: bits(N) FPMinNum(bits(N) op1_in, bits(N) op2_in, FPCRType fpcr)">FPMinNum</anchor>(bits(N) op1_in, bits(N) op2_in, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    bits(N) op1 = op1_in;
    bits(N) op2 = op2_in;
    (type1,-,-) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,-,-) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    boolean type1_nan = type1 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    boolean type2_nan = type2 IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';

    if !(altfp &amp;&amp; type1_nan &amp;&amp; type2_nan) then
        // Treat a single quiet-NaN as +Infinity.
        if type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op1 = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif type1 != <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
            op2 = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);

    altfmaxfmin = FALSE;    // Restrict use of FMAX/FMIN NaN propagation rules
    result = <a link="impl-shared.FPMin.4" file="shared_pseudocode.xml" hover="function: bits(N) FPMin(bits(N) op1, bits(N) op2, FPCRType fpcr_in, boolean altfp)">FPMin</a>(op1, op2, fpcr, altfmaxfmin);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmul/FPMul" mylink="shared.functions.float.fpmul.FPMul" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMul()
// =======

bits(N) <anchor link="impl-shared.FPMul.3" hover="function: bits(N) FPMul(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMul</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);
    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif inf1 || inf2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, N);
        elsif zero1 || zero2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1 EOR sign2, N);
        else
            result = <a link="impl-shared.FPRound.3" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</a>(value1*value2, fpcr, N);

        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmuladd/FPMulAdd" mylink="shared.functions.float.fpmuladd.FPMulAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMulAdd()
// ==========

bits(N) <anchor link="impl-shared.FPMulAdd.4" hover="function: bits(N) FPMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMulAdd</anchor>(bits(N) addend, bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;       // Generate floating-point exceptions
    return <a link="impl-shared.FPMulAdd.5" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPMulAdd</a>(addend, op1, op2, fpcr, fpexc);

// FPMulAdd()
// ==========
//
// Calculates addend + op1*op2 with a single rounding. The 'fpcr' argument
// supplies the FPCR control bits, and 'fpexc' controls the generation of
// floating-point exceptions.

bits(N) <anchor link="impl-shared.FPMulAdd.5" hover="function: bits(N) FPMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPMulAdd</anchor>(bits(N) addend, bits(N) op1, bits(N) op2,
                 <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {16,32,64};

    (typeA,signA,valueA) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(addend, fpcr, fpexc);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2, fpcr, fpexc);
    rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
    inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

    (done,result) = <a link="impl-shared.FPProcessNaNs3.8" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs3(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N) op2, bits(N) op3, FPCRType fpcr, boolean fpexc)">FPProcessNaNs3</a>(typeA, type1, type2, addend, op1, op2, fpcr, fpexc);

    if !(<a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1') then
        if typeA == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; ((inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2)) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

    if !done then
        infA = (typeA == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zeroA = (typeA == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        // Determine sign and type product will have if it does not cause an
        // Invalid Operation.
        signP = sign1 EOR sign2;
        infP  = inf1 || inf2;
        zeroP = zero1 || zero2;

        // Non SNaN-generated Invalid Operation cases are multiplies of zero
        // by infinity and additions of opposite-signed infinities.
        invalidop = (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) || (infA &amp;&amp; infP &amp;&amp; signA != signP);

        if invalidop then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        // Other cases involving infinities produce an infinity of the same sign.
        elsif (infA &amp;&amp; signA == '0') || (infP &amp;&amp; signP == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif (infA &amp;&amp; signA == '1') || (infP &amp;&amp; signP == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);

        // Cases where the result is exactly zero and its sign is not determined by the
        // rounding mode are additions of same-signed zeros.
        elsif zeroA &amp;&amp; zeroP &amp;&amp; signA == signP then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(signA, N);

        // Otherwise calculate numerical result and round it.
        else
            result_value = valueA + (value1 * value2);
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

        if !invalidop &amp;&amp; fpexc then
            <a link="impl-shared.FPProcessDenorms3.5" file="shared_pseudocode.xml" hover="function: FPProcessDenorms3(FPType type1, FPType type2, FPType type3, integer N, FPCRType fpcr)">FPProcessDenorms3</a>(typeA, type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmuladd/FPMulAdd_ZA" mylink="shared.functions.float.fpmuladd.FPMulAdd_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMulAdd_ZA()
// =============
// Calculates addend + op1*op2 with a single rounding for SME ZA-targeting
// instructions.

bits(N) <anchor link="impl-shared.FPMulAdd_ZA.4" hover="function: bits(N) FPMulAdd_ZA(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr_in)">FPMulAdd_ZA</anchor>(bits(N) addend, bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean fpexc = FALSE;      // Do not generate floating-point exceptions
    fpcr.DN = '1';              // Generate default NaN values
    return <a link="impl-shared.FPMulAdd.5" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPMulAdd</a>(addend, op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/fpmuladdh/FPMulAddH" mylink="shared.functions.float.fpmuladdh.FPMulAddH" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMulAddH()
// ===========
// Calculates addend + op1*op2.

bits(N) <anchor link="impl-shared.FPMulAddH.4" hover="function: bits(N) FPMulAddH(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr)">FPMulAddH</anchor>(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;       // Generate floating-point exceptions
    return <a link="impl-shared.FPMulAddH.5" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAddH(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr, boolean fpexc)">FPMulAddH</a>(addend, op1, op2, fpcr, fpexc);

// FPMulAddH()
// ===========
// Calculates addend + op1*op2.

bits(N) <anchor link="impl-shared.FPMulAddH.5" hover="function: bits(N) FPMulAddH(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr, boolean fpexc)">FPMulAddH</anchor>(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2,
                  <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N == 32;
    rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    (typeA,signA,valueA) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(addend, fpcr, fpexc);
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2, fpcr, fpexc);
    inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
    inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

    (done,result) = <a link="impl-shared.FPProcessNaNs3H.8" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs3H(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N DIV 2) op2, bits(N DIV 2) op3, FPCRType fpcr, boolean fpexc)">FPProcessNaNs3H</a>(typeA, type1, type2, addend, op1, op2, fpcr, fpexc);

    if !(<a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1') then
        if typeA == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> &amp;&amp; ((inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2)) then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

    if !done then
        infA = (typeA == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>); zeroA = (typeA == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        // Determine sign and type product will have if it does not cause an
        // Invalid Operation.
        signP = sign1 EOR sign2;
        infP = inf1 || inf2;
        zeroP = zero1 || zero2;

        // Non SNaN-generated Invalid Operation cases are multiplies of zero by infinity and
        // additions of opposite-signed infinities.
        invalidop = (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) || (infA &amp;&amp; infP &amp;&amp; signA != signP);

        if invalidop then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

        // Other cases involving infinities produce an infinity of the same sign.
        elsif (infA &amp;&amp; signA == '0') || (infP &amp;&amp; signP == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif (infA &amp;&amp; signA == '1') || (infP &amp;&amp; signP == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);

        // Cases where the result is exactly zero and its sign is not determined by the
        // rounding mode are additions of same-signed zeros.
        elsif zeroA &amp;&amp; zeroP &amp;&amp; signA == signP then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(signA, N);

        // Otherwise calculate numerical result and round it.
        else
            result_value = valueA + (value1 * value2);
            if result_value == 0.0 then // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

        if !invalidop &amp;&amp; fpexc then
            <a link="impl-shared.FPProcessDenorm.3" file="shared_pseudocode.xml" hover="function: FPProcessDenorm(FPType fptype, integer N, FPCRType fpcr)">FPProcessDenorm</a>(typeA, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpmuladdh/FPMulAddH_ZA" mylink="shared.functions.float.fpmuladdh.FPMulAddH_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMulAddH_ZA()
// ==============
// Calculates addend + op1*op2 for SME2 ZA-targeting instructions.

bits(N) <anchor link="impl-shared.FPMulAddH_ZA.4" hover="function: bits(N) FPMulAddH_ZA(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr_in)">FPMulAddH_ZA</anchor>(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean fpexc = FALSE;      // Do not generate floating-point exceptions
    fpcr.DN = '1';              // Generate default NaN values
    return <a link="impl-shared.FPMulAddH.5" file="shared_pseudocode.xml" hover="function: bits(N) FPMulAddH(bits(N) addend, bits(N DIV 2) op1, bits(N DIV 2) op2, FPCRType fpcr, boolean fpexc)">FPMulAddH</a>(addend, op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/fpmuladdh/FPProcessNaNs3H" mylink="shared.functions.float.fpmuladdh.FPProcessNaNs3H" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessNaNs3H()
// =================

(boolean, bits(N)) <anchor link="impl-shared.FPProcessNaNs3H.8" hover="function: (boolean, bits(N)) FPProcessNaNs3H(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N DIV 2) op2, bits(N DIV 2) op3, FPCRType fpcr, boolean fpexc)">FPProcessNaNs3H</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type3,
                                   bits(N) op1, bits(N DIV 2) op2, bits(N DIV 2) op3,
                                   <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {32,64};

    bits(N) result;
    <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type_nan;
    // When TRUE, use alternative NaN propagation rules.
    boolean altfp   = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    boolean op1_nan = type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    boolean op2_nan = type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    boolean op3_nan = type3 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    if altfp then
        if (type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type3 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>) then
            type_nan = <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>;
        else
            type_nan = <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>;

    boolean done;
    if altfp &amp;&amp; op1_nan &amp;&amp; op2_nan &amp;&amp; op3_nan then          // &lt;n&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op2, fpcr, fpexc), N);
    elsif altfp &amp;&amp; op2_nan &amp;&amp; (op1_nan || op3_nan) then     // &lt;n&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op2, fpcr, fpexc), N);
    elsif altfp &amp;&amp; op3_nan &amp;&amp; op1_nan then                  // &lt;m&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op3, fpcr, fpexc), N);
    elsif type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE; result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc);
    elsif type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE; result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc), N);
    elsif type3 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE; result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type3, op3, fpcr, fpexc), N);
    elsif type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE; result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc);
    elsif type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE; result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc), N);
    elsif type3 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE; result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type3, op3, fpcr, fpexc), N);
    else
        done = FALSE; result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N); // 'Don't care' result
    return (done, result);</pstext>
    </ps>
    <ps name="shared/functions/float/fpmulx/FPMulX" mylink="shared.functions.float.fpmulx.FPMulX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPMulX()
// ========

bits(N) <anchor link="impl-shared.FPMulX.3" hover="function: bits(N) FPMulX(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPMulX</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    bits(N) result;
    boolean done;
    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op1, fpcr);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op2, fpcr);

    (done,result) = <a link="impl-shared.FPProcessNaNs.5" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr);
    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if (inf1 &amp;&amp; zero2) || (zero1 &amp;&amp; inf2) then
            result = <a link="impl-shared.FPTwo.2" file="shared_pseudocode.xml" hover="function: bits(N) FPTwo(bit sign, integer N)">FPTwo</a>(sign1 EOR sign2, N);
        elsif inf1 || inf2 then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign1 EOR sign2, N);
        elsif zero1 || zero2 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1 EOR sign2, N);
        else
            result = <a link="impl-shared.FPRound.3" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</a>(value1*value2, fpcr, N);

        <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpneg/FPNeg" mylink="shared.functions.float.fpneg.FPNeg" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPNeg()
// =======

bits(N) <anchor link="impl-shared.FPNeg.1" hover="function: bits(N) FPNeg(bits(N) op)">FPNeg</anchor>(bits(N) op)

    assert N IN {16,32,64};
    if !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() then
        <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = FPCR[];
        if fpcr.AH == '1' then
            (fptype, -, -) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, FALSE);
            if fptype IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>} then

                return op;        // When fpcr.AH=1, sign of NaN has no consequence

    return NOT(op&lt;N-1&gt;) : op&lt;N-2:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/float/fponepointfive/FPOnePointFive" mylink="shared.functions.float.fponepointfive.FPOnePointFive" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPOnePointFive()
// ================

bits(N) <anchor link="impl-shared.FPOnePointFive.2" hover="function: bits(N) FPOnePointFive(bit sign, integer N)">FPOnePointFive</anchor>(bit sign, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp  = '0':<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(E-1);
    frac = '1':<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F-1);
    result = sign : exp : frac;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessdenorms/FPProcessDenorm" mylink="shared.functions.float.fpprocessdenorms.FPProcessDenorm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessDenorm()
// =================
// Handles denormal input in case of single-precision or double-precision
// when using alternative floating-point mode.

<anchor link="impl-shared.FPProcessDenorm.3" hover="function: FPProcessDenorm(FPType fptype, integer N, FPCRType fpcr)">FPProcessDenorm</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype, integer N, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    if altfp &amp;&amp; N != 16 &amp;&amp; fptype == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>, fpcr);</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessdenorms/FPProcessDenorms" mylink="shared.functions.float.fpprocessdenorms.FPProcessDenorms" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessDenorms()
// ==================
// Handles denormal input in case of single-precision or double-precision
// when using alternative floating-point mode.

<anchor link="impl-shared.FPProcessDenorms.4" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, integer N, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    if altfp &amp;&amp; N != 16 &amp;&amp; (type1 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> || type2 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a>) then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>, fpcr);</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessdenorms/FPProcessDenorms3" mylink="shared.functions.float.fpprocessdenorms.FPProcessDenorms3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessDenorms3()
// ===================
// Handles denormal input in case of single-precision or double-precision
// when using alternative floating-point mode.

<anchor link="impl-shared.FPProcessDenorms3.5" hover="function: FPProcessDenorms3(FPType type1, FPType type2, FPType type3, integer N, FPCRType fpcr)">FPProcessDenorms3</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type3, integer N, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    if altfp &amp;&amp; N != 16 &amp;&amp; (type1 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> || type2 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> ||
        type3 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a>) then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>, fpcr);</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessdenorms/FPProcessDenorms4" mylink="shared.functions.float.fpprocessdenorms.FPProcessDenorms4" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessDenorms4()
// ===================
// Handles denormal input in case of single-precision or double-precision
// when using alternative floating-point mode.

<anchor link="impl-shared.FPProcessDenorms4.6" hover="function: FPProcessDenorms4(FPType type1, FPType type2, FPType type3, FPType type4, integer N, FPCRType fpcr)">FPProcessDenorms4</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type3, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type4, integer N, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    if altfp &amp;&amp; N != 16 &amp;&amp; (type1 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> || type2 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> ||
        type3 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a> || type4 == <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a>) then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>, fpcr);</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessexception/FPProcessException" mylink="shared.functions.float.fpprocessexception.FPProcessException" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessException()
// ====================
//
// The 'fpcr' argument supplies FPCR control bits. Status information is
// updated directly in the FPSR where appropriate.

<anchor link="impl-shared.FPProcessException.2" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</anchor>(<a link="FPExc" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc</a> exception, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    integer cumul;
    // Determine the cumulative exception bit number
    case exception of
        when <a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>     cumul = 0;
        when <a link="FPExc_DivideByZero" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_DivideByZero</a>  cumul = 1;
        when <a link="FPExc_Overflow" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Overflow</a>      cumul = 2;
        when <a link="FPExc_Underflow" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Underflow</a>     cumul = 3;
        when <a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>       cumul = 4;
        when <a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>   cumul = 7;
    enable = cumul + 8;
    if fpcr&lt;enable&gt; == '1' &amp;&amp; (!<a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() || PSTATE.SM == '0' || <a link="impl-aarch64.IsFullA64Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsFullA64Enabled()">IsFullA64Enabled</a>()) then
        // Trapping of the exception enabled.
        // It is IMPLEMENTATION DEFINED whether the enable bit may be set at all,
        // and if so then how exceptions and in what order that they may be
        // accumulated before calling FPTrappedException().
        bits(8) accumulated_exceptions = <a link="impl-shared.GetAccumulatedFPExceptions.0" file="shared_pseudocode.xml" hover="function: bits(8) GetAccumulatedFPExceptions()">GetAccumulatedFPExceptions</a>();
        accumulated_exceptions&lt;cumul&gt; = '1';
        if boolean IMPLEMENTATION_DEFINED "Support trapping of floating-point exceptions" then
            if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
                <a link="AArch32.FPTrappedException.1" file="shared_pseudocode.xml" hover="function: AArch32.FPTrappedException(bits(8) accumulated_exceptions)">AArch32.FPTrappedException</a>(accumulated_exceptions);
            else
                is_ase = <a link="impl-shared.IsASEInstruction.0" file="shared_pseudocode.xml" hover="function: boolean IsASEInstruction()">IsASEInstruction</a>();
                <a link="AArch64.FPTrappedException.2" file="shared_pseudocode.xml" hover="function: AArch64.FPTrappedException(boolean is_ase, bits(8) accumulated_exceptions)">AArch64.FPTrappedException</a>(is_ase, accumulated_exceptions);
        else
            // The exceptions generated by this instruction are accumulated by the PE and
            // FPTrappedException is called later during its execution, before the next
            // instruction is executed. This field is cleared at the start of each FP instruction.
            <a link="impl-shared.SetAccumulatedFPExceptions.1" file="shared_pseudocode.xml" hover="function: SetAccumulatedFPExceptions(bits(8) accumulated_exceptions)">SetAccumulatedFPExceptions</a>(accumulated_exceptions);
    elsif <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        // Set the cumulative exception bit
        FPSCR&lt;cumul&gt; = '1';
    else
        // Set the cumulative exception bit
        FPSR&lt;cumul&gt; = '1';

    return;</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessnan/FPProcessNaN" mylink="shared.functions.float.fpprocessnan.FPProcessNaN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessNaN()
// ==============

bits(N) <anchor link="impl-shared.FPProcessNaN.3" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr)">FPProcessNaN</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype, bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;   // Generate floating-point exceptions
    return <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(fptype, op, fpcr, fpexc);

// FPProcessNaN()
// ==============
// Handle NaN input operands, returning the operand or default NaN value
// if fpcr.DN is selected. The 'fpcr' argument supplies the FPCR control bits.
// The 'fpexc' argument controls the generation of exceptions, regardless of
// whether 'fptype' is a signalling NaN or a quiet NaN.

bits(N) <anchor link="impl-shared.FPProcessNaN.4" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype, bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {16,32,64};
    assert fptype IN {<a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>};
    integer topfrac;

    case N of
        when 16 topfrac =  9;
        when 32 topfrac = 22;
        when 64 topfrac = 51;

    result = op;
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        result&lt;topfrac&gt; = '1';
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    if fpcr.DN == '1' then  // DefaultNaN requested
        result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessnans/FPProcessNaNs" mylink="shared.functions.float.fpprocessnans.FPProcessNaNs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessNaNs()
// ===============

(boolean, bits(N)) <anchor link="impl-shared.FPProcessNaNs.5" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr)">FPProcessNaNs</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, bits(N) op1,
                                 bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc       = TRUE;     // Generate floating-point exceptions
    return <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr, fpexc);

// FPProcessNaNs()
// ===============
//
// The boolean part of the return value says whether a NaN has been found and
// processed. The bits(N) part is only relevant if it has and supplies the
// result of the operation.
//
// The 'fpcr' argument supplies FPCR control bits and 'altfmaxfmin' controls
// alternative floating-point behavior for FMAX, FMIN and variants. 'fpexc'
// controls the generation of floating-point exceptions. Status information
// is updated directly in the FPSR where appropriate.

(boolean, bits(N)) <anchor link="impl-shared.FPProcessNaNs.6" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, bits(N) op1, bits(N) op2,
                                 <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {16,32,64};
    boolean done;
    bits(N) result;
    boolean altfp    = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    boolean op1_nan  = type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    boolean op2_nan  = type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    boolean any_snan = type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>;
    <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a>  type_nan = if any_snan then <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> else <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>;

    if altfp &amp;&amp; op1_nan &amp;&amp; op2_nan then
        // &lt;n&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op1, fpcr, fpexc);
    elsif type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc);
    elsif type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc);
    elsif type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc);
    elsif type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc);
    else
        done = FALSE;  result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);  // 'Don't care' result

    return (done, result);</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessnans3/FPProcessNaNs3" mylink="shared.functions.float.fpprocessnans3.FPProcessNaNs3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessNaNs3()
// ================

(boolean, bits(N)) <anchor link="impl-shared.FPProcessNaNs3.7" hover="function: (boolean, bits(N)) FPProcessNaNs3(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N) op2, bits(N) op3, FPCRType fpcr)">FPProcessNaNs3</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type3,
                                  bits(N) op1, bits(N) op2, bits(N) op3,
                                  <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;   // Generate floating-point exceptions
    return <a link="impl-shared.FPProcessNaNs3.8" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs3(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N) op2, bits(N) op3, FPCRType fpcr, boolean fpexc)">FPProcessNaNs3</a>(type1, type2, type3, op1, op2, op3, fpcr, fpexc);

// FPProcessNaNs3()
// ================
// The boolean part of the return value says whether a NaN has been found and
// processed. The bits(N) part is only relevant if it has and supplies the
// result of the operation.
//
// The 'fpcr' argument supplies FPCR control bits and 'fpexc' controls the
// generation of floating-point exceptions. Status information is updated
// directly in the FPSR where appropriate.

(boolean, bits(N)) <anchor link="impl-shared.FPProcessNaNs3.8" hover="function: (boolean, bits(N)) FPProcessNaNs3(FPType type1, FPType type2, FPType type3, bits(N) op1, bits(N) op2, bits(N) op3, FPCRType fpcr, boolean fpexc)">FPProcessNaNs3</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type3,
                                  bits(N) op1, bits(N) op2, bits(N) op3,
                                  <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {16,32,64};
    bits(N) result;
    boolean op1_nan = type1 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    boolean op2_nan = type2 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};
    boolean op3_nan = type3 IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>};

    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type_nan;
    if altfp then
        if type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || type3 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
            type_nan = <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>;
        else
            type_nan = <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>;

    boolean done;
    if altfp &amp;&amp; op1_nan &amp;&amp; op2_nan &amp;&amp; op3_nan then
        // &lt;n&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op2, fpcr, fpexc);
    elsif altfp &amp;&amp; op2_nan &amp;&amp; (op1_nan || op3_nan) then
        // &lt;n&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op2, fpcr, fpexc);
    elsif altfp &amp;&amp; op3_nan &amp;&amp; op1_nan then
        // &lt;m&gt; register NaN selected
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type_nan, op3, fpcr, fpexc);
    elsif type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc);
    elsif type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc);
    elsif type3 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type3, op3, fpcr, fpexc);
    elsif type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc);
    elsif type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc);
    elsif type3 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type3, op3, fpcr, fpexc);
    else
        done = FALSE;  result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);  // 'Don't care' result

    return (done, result);</pstext>
    </ps>
    <ps name="shared/functions/float/fpprocessnans4/FPProcessNaNs4" mylink="shared.functions.float.fpprocessnans4.FPProcessNaNs4" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPProcessNaNs4()
// ================
// The boolean part of the return value says whether a NaN has been found and
// processed. The bits(N) part is only relevant if it has and supplies the
// result of the operation.
//
// The 'fpcr' argument supplies FPCR control bits.
// Status information is updated directly in the FPSR where appropriate.
// The 'fpexc' controls the generation of floating-point exceptions.

(boolean, bits(N)) <anchor link="impl-shared.FPProcessNaNs4.10" hover="function: (boolean, bits(N)) FPProcessNaNs4(FPType type1, FPType type2, FPType type3, FPType type4, bits(N DIV 2) op1, bits(N DIV 2) op2, bits(N DIV 2) op3, bits(N DIV 2) op4, FPCRType fpcr, boolean fpexc)">FPProcessNaNs4</anchor>(<a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type1, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type2, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type3, <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> type4,
                                  bits(N DIV 2) op1, bits(N DIV 2) op2, bits(N DIV 2) op3,
                                  bits(N DIV 2) op4, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N == 32;

    bits(N) result;
    boolean done;
    // The FPCR.AH control does not affect these checks
    if type1 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc), N);
    elsif type2 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc), N);
    elsif type3 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type3, op3, fpcr, fpexc), N);
    elsif type4 == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type4, op4, fpcr, fpexc), N);
    elsif type1 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type1, op1, fpcr, fpexc), N);
    elsif type2 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type2, op2, fpcr, fpexc), N);
    elsif type3 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type3, op3, fpcr, fpexc), N);
    elsif type4 == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        done = TRUE;  result = <a link="impl-shared.FPConvertNaN.2" file="shared_pseudocode.xml" hover="function: bits(M) FPConvertNaN(bits(N) op, integer M)">FPConvertNaN</a>(<a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(type4, op4, fpcr, fpexc), N);
    else
        done = FALSE;  result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);  // 'Don't care' result

    return (done, result);</pstext>
    </ps>
    <ps name="shared/functions/float/fprecipestimate/FPRecipEstimate" mylink="shared.functions.float.fprecipestimate.FPRecipEstimate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRecipEstimate()
// =================

bits(N) <anchor link="impl-shared.FPRecipEstimate.2" hover="function: bits(N) FPRecipEstimate(bits(N) operand, FPCRType fpcr_in)">FPRecipEstimate</anchor>(bits(N) operand, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)

    assert N IN {16,32,64};
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    bits(N) result;
    boolean overflow_to_inf;
    // When using alternative floating-point behavior, do not generate
    // floating-point exceptions, flush denormal input and output to zero,
    // and use RNE rounding mode.
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    boolean fpexc = !altfp;
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';
    if altfp then fpcr.RMode    = '00';

    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(operand, fpcr, fpexc);

    <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(fptype, operand, fpcr, fpexc);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_DivideByZero" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_DivideByZero</a>, fpcr);
    elsif (
            (N == 16 &amp;&amp; <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value) &lt; 2.0^-16) ||
            (N == 32 &amp;&amp; <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value) &lt; 2.0^-128) ||
            (N == 64 &amp;&amp; <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value) &lt; 2.0^-1024)
          ) then
        case rounding of
            when <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>
                overflow_to_inf = TRUE;
            when <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>
                overflow_to_inf = (sign == '0');
            when <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>
                overflow_to_inf = (sign == '1');
            when <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>
                overflow_to_inf = FALSE;
        result = if overflow_to_inf then <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N) else <a link="impl-shared.FPMaxNormal.2" file="shared_pseudocode.xml" hover="function: bits(N) FPMaxNormal(bit sign, integer N)">FPMaxNormal</a>(sign, N);
        if fpexc then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Overflow" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Overflow</a>, fpcr);
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);
    elsif ((fpcr.FZ == '1' &amp;&amp; N != 16) || (fpcr.FZ16 == '1' &amp;&amp; N == 16))
          &amp;&amp; (
               (N == 16 &amp;&amp; <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value) &gt;= 2.0^14) ||
               (N == 32 &amp;&amp; <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value) &gt;= 2.0^126) ||
               (N == 64 &amp;&amp; <a link="impl-shared.Abs.1" file="shared_pseudocode.xml" hover="function: integer Abs(integer x)">Abs</a>(value) &gt;= 2.0^1022)
             ) then
        // Result flushed to zero of correct sign
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);

        // Flush-to-zero never generates a trapped exception.
        if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
            FPSCR.UFC = '1';
        else
            if fpexc then FPSR.UFC = '1';
    else
        // Scale to a fixed point value in the range 0.5 &lt;= x &lt; 1.0 in steps of 1/512, and
        // calculate result exponent. Scaled value has copied sign bit,
        // exponent = 1022 = double-precision biased version of -1,
        // fraction = original fraction
        bits(52) fraction;
        integer exp;
        case N of
            when 16
                fraction = operand&lt;9:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(42);
                exp = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;14:10&gt;);
            when 32
                fraction = operand&lt;22:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(29);
                exp = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;30:23&gt;);
            when 64
                fraction = operand&lt;51:0&gt;;
                exp = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;62:52&gt;);

        if exp == 0 then
            if fraction&lt;51&gt; == '0' then
                exp = -1;
                fraction = fraction&lt;49:0&gt;:'00';
            else
                fraction = fraction&lt;50:0&gt;:'0';

        integer scaled;
        boolean increasedprecision = N==32 &amp;&amp; <a link="impl-shared.HaveFeatRPRES.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatRPRES()">HaveFeatRPRES</a>() &amp;&amp; altfp;

        if !increasedprecision then
            scaled = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>('1':fraction&lt;51:44&gt;);
        else
            scaled = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>('1':fraction&lt;51:41&gt;);

        integer result_exp;
        case N of
            when 16 result_exp =   29 - exp; // In range 29-30 = -1 to 29+1 = 30
            when 32 result_exp =  253 - exp; // In range 253-254 = -1 to 253+1 = 254
            when 64 result_exp = 2045 - exp; // In range 2045-2046 = -1 to 2045+1 = 2046

        // Scaled is in range 256 .. 511 or 2048 .. 4095 range representing a
        // fixed-point number in range [0.5 .. 1.0].
        estimate = <a link="impl-shared.RecipEstimate.2" file="shared_pseudocode.xml" hover="function: integer RecipEstimate(integer a_in, boolean increasedprecision)">RecipEstimate</a>(scaled, increasedprecision);

        // Estimate is in the range 256 .. 511 or 4096 .. 8191 representing a
        // fixed-point result in the range [1.0 .. 2.0].
        // Convert to scaled floating point result with copied sign bit,
        // high-order bits from estimate, and exponent calculated above.
        if !increasedprecision then
            fraction = estimate&lt;7:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(44);
        else
            fraction = estimate&lt;11:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(40);

        if result_exp == 0 then
            fraction = '1' : fraction&lt;51:1&gt;;
        elsif result_exp == -1 then
            fraction = '01' : fraction&lt;51:2&gt;;
            result_exp = 0;

        case N of
            when 16 result = sign : result_exp&lt;N-12:0&gt; : fraction&lt;51:42&gt;;
            when 32 result = sign : result_exp&lt;N-25:0&gt; : fraction&lt;51:29&gt;;
            when 64 result = sign : result_exp&lt;N-54:0&gt; : fraction&lt;51:0&gt;;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fprecipestimate/RecipEstimate" mylink="shared.functions.float.fprecipestimate.RecipEstimate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RecipEstimate()
// ===============
// Compute estimate of reciprocal of 9-bit fixed-point number.
//
// a is in range 256 .. 511 or 2048 .. 4096 representing a number in
// the range 0.5 &lt;= x &lt; 1.0.
// increasedprecision determines if the mantissa is 8-bit or 12-bit.
// result is in the range 256 .. 511 or 4096 .. 8191 representing a
// number in the range 1.0 to 511/256 or 1.00 to 8191/4096.

integer <anchor link="impl-shared.RecipEstimate.2" hover="function: integer RecipEstimate(integer a_in, boolean increasedprecision)">RecipEstimate</anchor>(integer a_in, boolean increasedprecision)

    integer a = a_in;
    integer r;
    if !increasedprecision then
        assert 256 &lt;= a &amp;&amp; a &lt; 512;
        a = a*2+1;                       // Round to nearest
        integer b = (2 ^ 19) DIV a;
        r = (b+1) DIV 2;                 // Round to nearest
        assert 256 &lt;= r &amp;&amp; r &lt; 512;
    else
        assert 2048 &lt;= a &amp;&amp; a &lt; 4096;
        a = a*2+1;                       // Round to nearest
        real real_val = Real(2^25)/Real(a);
        r = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(real_val);
        real error = real_val - Real(r);
        boolean round_up = error &gt; 0.5;  // Error cannot be exactly 0.5 so do not need tie case
        if round_up then r = r+1;
        assert 4096 &lt;= r &amp;&amp; r &lt; 8192;

    return r;</pstext>
    </ps>
    <ps name="shared/functions/float/fprecpx/FPRecpX" mylink="shared.functions.float.fprecpx.FPRecpX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRecpX()
// =========

bits(N) <anchor link="impl-shared.FPRecpX.2" hover="function: bits(N) FPRecpX(bits(N) op, FPCRType fpcr_in)">FPRecpX</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)

    assert N IN {16,32,64};
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    integer esize;
    case N of
        when 16 esize =  5;
        when 32 esize =  8;
        when 64 esize = 11;

    bits(N)           result;
    bits(esize)       exp;
    bits(esize)       max_exp;
    bits(N-(esize+1)) frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N-(esize+1));

    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; fpcr.AH == '1';
    boolean fpexc = !altfp;                 // Generate no floating-point exceptions
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';     // Flush denormal input and output to zero
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, fpexc);

    case N of
        when 16 exp = op&lt;(10+esize)-1:10&gt;;
        when 32 exp = op&lt;(23+esize)-1:23&gt;;
        when 64 exp = op&lt;(52+esize)-1:52&gt;;

    max_exp = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(esize) - 1;

    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(fptype, op, fpcr, fpexc);
    else
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(exp) then                 // Zero and denormals
            result = sign:max_exp:frac;
        else                                // Infinities and normals
            result = sign:NOT(exp):frac;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpround/FPRound" mylink="shared.functions.float.fpround.FPRound" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRound()
// =========
// Generic conversion from precise, unbounded real data type to IEEE format.

bits(N) <anchor link="impl-shared.FPRound.3" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, integer N)
    return <a link="impl-shared.FPRound.4" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRound</a>(op, fpcr, <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr), N);

// FPRound()
// =========
// For directed FP conversion, includes an explicit 'rounding' argument.

bits(N) <anchor link="impl-shared.FPRound.4" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRound</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer N)
    boolean fpexc = TRUE;    // Generate floating-point exceptions
    return <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(op, fpcr_in, rounding, fpexc, N);

// FPRound()
// =========
// For AltFP, includes an explicit FPEXC argument to disable exception
// generation and switches off Arm alternate half-precision mode.

bits(N) <anchor link="impl-shared.FPRound.5" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, boolean fpexc, integer N)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.AHP = '0';
    boolean isbfloat16 = FALSE;
    return <a link="impl-shared.FPRoundBase.6" file="shared_pseudocode.xml" hover="function: bits(N) FPRoundBase(real op, FPCRType fpcr, FPRounding rounding, boolean isbfloat16, boolean fpexc, integer N)">FPRoundBase</a>(op, fpcr, rounding, isbfloat16, fpexc, N);</pstext>
    </ps>
    <ps name="shared/functions/float/fpround/FPRoundBase" mylink="shared.functions.float.fpround.FPRoundBase" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRoundBase()
// =============
// For BFloat16, includes an explicit 'isbfloat16' argument.

bits(N) <anchor link="impl-shared.FPRoundBase.5" hover="function: bits(N) FPRoundBase(real op, FPCRType fpcr, FPRounding rounding, boolean isbfloat16, integer N)">FPRoundBase</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, boolean isbfloat16, integer N)
    boolean fpexc = TRUE;    // Generate floating-point exceptions
    return <a link="impl-shared.FPRoundBase.6" file="shared_pseudocode.xml" hover="function: bits(N) FPRoundBase(real op, FPCRType fpcr, FPRounding rounding, boolean isbfloat16, boolean fpexc, integer N)">FPRoundBase</a>(op, fpcr, rounding, isbfloat16, fpexc, N);

// FPRoundBase()
// =============
// Convert a real number 'op' into an N-bit floating-point value using the
// supplied rounding mode 'rounding'.
//
// The 'fpcr' argument supplies FPCR control bits and 'fpexc' controls the
// generation of floating-point exceptions. Status information is updated
// directly in the FPSR where appropriate.

bits(N) <anchor link="impl-shared.FPRoundBase.6" hover="function: bits(N) FPRoundBase(real op, FPCRType fpcr, FPRounding rounding, boolean isbfloat16, boolean fpexc, integer N)">FPRoundBase</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding,
                    boolean isbfloat16, boolean fpexc, integer N)

    assert N IN {16,32,64};
    assert op != 0.0;
    assert rounding != <a link="FPRounding_TIEAWAY" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEAWAY</a>;
    bits(N) result;

    // Obtain format parameters - minimum exponent, numbers of exponent and fraction bits.
    integer minimum_exp;
    integer F;
    integer E;
    if N == 16 then
        minimum_exp = -14;  E = 5;  F = 10;
    elsif N == 32 &amp;&amp; isbfloat16 then
        minimum_exp = -126;  E = 8;  F = 7;
    elsif N == 32 then
        minimum_exp = -126;  E = 8;  F = 23;
    else  // N == 64
        minimum_exp = -1022;  E = 11;  F = 52;

    // Split value into sign, unrounded mantissa and exponent.
    bit sign;
    real mantissa;
    if op &lt; 0.0 then
        sign = '1';  mantissa = -op;
    else
        sign = '0';  mantissa = op;
    exponent = 0;
    while mantissa &lt; 1.0 do
        mantissa = mantissa * 2.0;  exponent = exponent - 1;
    while mantissa &gt;= 2.0 do
        mantissa = mantissa / 2.0;  exponent = exponent + 1;

    // When TRUE, detection of underflow occurs after rounding and the test for a
    // denormalized number for single and double precision values occurs after rounding.
    altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';

    // Deal with flush-to-zero before rounding if FPCR.AH != '1'.
    if (!altfp &amp;&amp; ((fpcr.FZ == '1' &amp;&amp; N != 16) || (fpcr.FZ16 == '1' &amp;&amp; N == 16)) &amp;&amp;
        exponent &lt; minimum_exp) then
        // Flush-to-zero never generates a trapped exception.
        if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
            FPSCR.UFC = '1';
        else
            if fpexc then FPSR.UFC = '1';
        return <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);

    biased_exp_unconstrained = (exponent - minimum_exp) + 1;
    int_mant_unconstrained = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(mantissa * 2.0^F);
    error_unconstrained = mantissa * 2.0^F - Real(int_mant_unconstrained);

    // Start creating the exponent value for the result. Start by biasing the actual exponent
    // so that the minimum exponent becomes 1, lower values 0 (indicating possible underflow).
    biased_exp = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>((exponent - minimum_exp) + 1, 0);
    if biased_exp == 0 then mantissa = mantissa / 2.0^(minimum_exp - exponent);

    // Get the unrounded mantissa as an integer, and the "units in last place" rounding error.
    int_mant = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(mantissa * 2.0^F);  // &lt; 2.0^F if biased_exp == 0, &gt;= 2.0^F if not
    error = mantissa * 2.0^F - Real(int_mant);

    // Underflow occurs if exponent is too small before rounding, and result is inexact or
    // the Underflow exception is trapped. This applies before rounding if FPCR.AH != '1'.
    boolean trapped_UF = fpcr.UFE == '1' &amp;&amp; (!<a link="impl-aarch64.InStreamingMode.0" file="shared_pseudocode.xml" hover="function: boolean InStreamingMode()">InStreamingMode</a>() || <a link="impl-aarch64.IsFullA64Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsFullA64Enabled()">IsFullA64Enabled</a>());
    if !altfp &amp;&amp; biased_exp == 0 &amp;&amp; (error != 0.0 || trapped_UF) then
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Underflow" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Underflow</a>, fpcr);

    // Round result according to rounding mode.
    boolean round_up_unconstrained;
    boolean round_up;
    boolean overflow_to_inf;
    if altfp then

        case rounding of
            when <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>
                round_up_unconstrained = (error_unconstrained &gt; 0.5 ||
                   (error_unconstrained == 0.5 &amp;&amp; int_mant_unconstrained&lt;0&gt; == '1'));
                round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_mant&lt;0&gt; == '1'));
                overflow_to_inf = TRUE;
            when <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>
                round_up_unconstrained = (error_unconstrained != 0.0 &amp;&amp; sign == '0');
                round_up = (error != 0.0 &amp;&amp; sign == '0');
                overflow_to_inf = (sign == '0');
            when <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>
                round_up_unconstrained = (error_unconstrained != 0.0 &amp;&amp; sign == '1');
                round_up = (error != 0.0 &amp;&amp; sign == '1');
                overflow_to_inf = (sign == '1');
            when <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>, <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a>
                round_up_unconstrained = FALSE;
                round_up = FALSE;
                overflow_to_inf = FALSE;

        if round_up_unconstrained then
            int_mant_unconstrained = int_mant_unconstrained + 1;
            if int_mant_unconstrained == 2^(F+1) then    // Rounded up to next exponent
                biased_exp_unconstrained = biased_exp_unconstrained + 1;
                int_mant_unconstrained   = int_mant_unconstrained DIV 2;

        // Deal with flush-to-zero and underflow after rounding if FPCR.AH == '1'.
        if biased_exp_unconstrained &lt; 1 &amp;&amp; int_mant_unconstrained != 0 then
            // the result of unconstrained rounding is less than the minimum normalized number
            if (fpcr.FZ == '1' &amp;&amp; N != 16) || (fpcr.FZ16 == '1' &amp;&amp; N == 16) then   // Flush-to-zero
                if fpexc then
                    FPSR.UFC = '1';
                    <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);
                return <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
            elsif error != 0.0 || trapped_UF then
                if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Underflow" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Underflow</a>, fpcr);
    else    // altfp == FALSE
        case rounding of
            when <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>
                round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_mant&lt;0&gt; == '1'));
                overflow_to_inf = TRUE;
            when <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>
                round_up = (error != 0.0 &amp;&amp; sign == '0');
                overflow_to_inf = (sign == '0');
            when <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>
                round_up = (error != 0.0 &amp;&amp; sign == '1');
                overflow_to_inf = (sign == '1');
            when <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>, <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a>
                round_up = FALSE;
                overflow_to_inf = FALSE;

    if round_up then
        int_mant = int_mant + 1;
        if int_mant == 2^F then      // Rounded up from denormalized to normalized
            biased_exp = 1;
        if int_mant == 2^(F+1) then  // Rounded up to next exponent
            biased_exp = biased_exp + 1;
            int_mant = int_mant DIV 2;

    // Handle rounding to odd
    if error != 0.0 &amp;&amp; rounding == <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a> then
        int_mant&lt;0&gt; = '1';

    // Deal with overflow and generate result.
    if N != 16 || fpcr.AHP == '0' then  // Single, double or IEEE half precision
        if biased_exp &gt;= 2^E - 1 then
            result = if overflow_to_inf then <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N) else <a link="impl-shared.FPMaxNormal.2" file="shared_pseudocode.xml" hover="function: bits(N) FPMaxNormal(bit sign, integer N)">FPMaxNormal</a>(sign, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Overflow" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Overflow</a>, fpcr);
            error = 1.0;  // Ensure that an Inexact exception occurs
        else
            result = sign : biased_exp&lt;E-1:0&gt; : int_mant&lt;F-1:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N-(E+F+1));
    else                                     // Alternative half precision
        if biased_exp &gt;= 2^E then
            result = sign : <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(N-1);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
            error = 0.0;  // Ensure that an Inexact exception does not occur
        else
            result = sign : biased_exp&lt;E-1:0&gt; : int_mant&lt;F-1:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N-(E+F+1));

    // Deal with Inexact exception.
    if error != 0.0 then
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpround/FPRoundCV" mylink="shared.functions.float.fpround.FPRoundCV" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRoundCV()
// ===========
// Used for FP to FP conversion instructions.
// For half-precision data ignores FZ16 and observes AHP.

bits(N) <anchor link="impl-shared.FPRoundCV.4" hover="function: bits(N) FPRoundCV(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRoundCV</anchor>(real op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer N)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.FZ16 = '0';
    boolean fpexc = TRUE;    // Generate floating-point exceptions
    boolean isbfloat16 = FALSE;
    return <a link="impl-shared.FPRoundBase.6" file="shared_pseudocode.xml" hover="function: bits(N) FPRoundBase(real op, FPCRType fpcr, FPRounding rounding, boolean isbfloat16, boolean fpexc, integer N)">FPRoundBase</a>(op, fpcr, rounding, isbfloat16, fpexc, N);</pstext>
    </ps>
    <ps name="shared/functions/float/fprounding/FPRounding" mylink="shared.functions.float.fprounding.FPRounding" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRounding
// ==========
// The conversion and rounding functions take an explicit
// rounding mode enumeration instead of booleans or FPCR values.

enumeration <anchor link="FPRounding" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</anchor>  {<anchor link="FPRounding_TIEEVEN" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</anchor>, <anchor link="FPRounding_POSINF" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</anchor>,
                         <anchor link="FPRounding_NEGINF" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</anchor>,  <anchor link="FPRounding_ZERO" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</anchor>,
                         <anchor link="FPRounding_TIEAWAY" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEAWAY</anchor>, <anchor link="FPRounding_ODD" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/float/fproundingmode/FPRoundingMode" mylink="shared.functions.float.fproundingmode.FPRoundingMode" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRoundingMode()
// ================
// Return the current floating-point rounding mode.

FPRounding <anchor link="impl-shared.FPRoundingMode.1" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</anchor>(<a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    return <a link="impl-shared.FPDecodeRounding.1" file="shared_pseudocode.xml" hover="function: FPRounding FPDecodeRounding(bits(2) rmode)">FPDecodeRounding</a>(fpcr.RMode);</pstext>
    </ps>
    <ps name="shared/functions/float/fproundint/FPRoundInt" mylink="shared.functions.float.fproundint.FPRoundInt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRoundInt()
// ============

// Round op to nearest integral floating point value using rounding mode in FPCR/FPSCR.
// If EXACT is TRUE, set FPSR.IXC if result is not numerically equal to op.

bits(N) <anchor link="impl-shared.FPRoundInt.4" hover="function: bits(N) FPRoundInt(bits(N) op, FPCRType fpcr, FPRounding rounding, boolean exact)">FPRoundInt</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, boolean exact)

    assert rounding != <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a>;
    assert N IN {16,32,64};

    // When alternative floating-point support is TRUE, do not generate
    // Input Denormal floating-point exceptions.
    altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    fpexc = !altfp;

    // Unpack using FPCR to determine if subnormals are flushed-to-zero.
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, fpexc);

    bits(N) result;
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPProcessNaN.3" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr)">FPProcessNaN</a>(fptype, op, fpcr);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
    else
        // Extract integer component.
        int_result = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(value);
        error = value - Real(int_result);

        // Determine whether supplied rounding mode requires an increment.
        boolean round_up;
        case rounding of
            when <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>
                round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_result&lt;0&gt; == '1'));
            when <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>
                round_up = (error != 0.0);
            when <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>
                round_up = FALSE;
            when <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>
                round_up = (error != 0.0 &amp;&amp; int_result &lt; 0);
            when <a link="FPRounding_TIEAWAY" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEAWAY</a>
                round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_result &gt;= 0));

        if round_up then int_result = int_result + 1;

        // Convert integer value into an equivalent real value.
        real_result = Real(int_result);

        // Re-encode as a floating-point value, result is always exact.
        if real_result == 0.0 then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
        else
            result = <a link="impl-shared.FPRound.4" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRound</a>(real_result, fpcr, <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>, N);

        // Generate inexact exceptions.
        if error != 0.0 &amp;&amp; exact then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fproundintn/FPRoundIntN" mylink="shared.functions.float.fproundintn.FPRoundIntN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRoundIntN()
// =============

bits(N) <anchor link="impl-shared.FPRoundIntN.4" hover="function: bits(N) FPRoundIntN(bits(N) op, FPCRType fpcr, FPRounding rounding, integer intsize)">FPRoundIntN</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer intsize)
    assert rounding != <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a>;
    assert N IN {32,64};
    assert intsize IN {32, 64};
    integer exp;
    bits(N) result;
    boolean round_up;
    constant integer E = (if N == 32 then 8 else 11);
    constant integer F = N - (E + 1);

    // When alternative floating-point support is TRUE, do not generate
    // Input Denormal floating-point exceptions.
    altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    fpexc = !altfp;

    // Unpack using FPCR to determine if subnormals are flushed-to-zero.
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, fpexc);

    if fptype IN {<a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>, <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a>, <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>} then
        if N == 32 then
            exp = 126 + intsize;
            result = '1':exp&lt;(E-1):0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
        else
            exp = 1022+intsize;
            result = '1':exp&lt;(E-1):0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
    else
        // Extract integer component.
        int_result = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(value);
        error = value - Real(int_result);

        // Determine whether supplied rounding mode requires an increment.
        case rounding of
            when <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>
                round_up = error &gt; 0.5 || (error == 0.5 &amp;&amp; int_result&lt;0&gt; == '1');
            when <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>
                round_up = error != 0.0;
            when <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>
                round_up = FALSE;
            when <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>
                round_up = error != 0.0 &amp;&amp; int_result &lt; 0;
            when <a link="FPRounding_TIEAWAY" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEAWAY</a>
                round_up = error &gt; 0.5 || (error == 0.5 &amp;&amp; int_result &gt;= 0);

        if round_up then int_result = int_result + 1;
        overflow = int_result &gt; 2^(intsize-1)-1 || int_result &lt; -1*2^(intsize-1);

        if overflow then
            if N == 32 then
                exp = 126 + intsize;
                result = '1':exp&lt;(E-1):0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
            else
                exp = 1022 + intsize;
                result = '1':exp&lt;(E-1):0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
            // This case shouldn't set Inexact.
            error = 0.0;

        else
            // Convert integer value into an equivalent real value.
            real_result = Real(int_result);

            // Re-encode as a floating-point value, result is always exact.
            if real_result == 0.0 then
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
            else
                result = <a link="impl-shared.FPRound.4" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, integer N)">FPRound</a>(real_result, fpcr, <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>, N);

        // Generate inexact exceptions.
        if error != 0.0 then
            <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fprsqrtestimate/FPRSqrtEstimate" mylink="shared.functions.float.fprsqrtestimate.FPRSqrtEstimate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPRSqrtEstimate()
// =================

bits(N) <anchor link="impl-shared.FPRSqrtEstimate.2" hover="function: bits(N) FPRSqrtEstimate(bits(N) operand, FPCRType fpcr_in)">FPRSqrtEstimate</anchor>(bits(N) operand, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)

    assert N IN {16,32,64};
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;

    // When using alternative floating-point behavior, do not generate
    // floating-point exceptions and flush denormal input to zero.
    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    boolean fpexc = !altfp;
    if altfp then fpcr.&lt;FIZ,FZ&gt; = '11';

    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(operand, fpcr, fpexc);

    bits(N) result;
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPProcessNaN.4" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr, boolean fpexc)">FPProcessNaN</a>(fptype, operand, fpcr, fpexc);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_DivideByZero" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_DivideByZero</a>, fpcr);
    elsif sign == '1' then
        result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
        if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>('0', N);
    else
        // Scale to a fixed-point value in the range 0.25 &lt;= x &lt; 1.0 in steps of 512, with the
        // evenness or oddness of the exponent unchanged, and calculate result exponent.
        // Scaled value has copied sign bit, exponent = 1022 or 1021 = double-precision
        // biased version of -1 or -2, fraction = original fraction extended with zeros.

        bits(52) fraction;
        integer exp;
        case N of
            when 16
                fraction = operand&lt;9:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(42);
                exp = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;14:10&gt;);
            when 32
                fraction = operand&lt;22:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(29);
                exp = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;30:23&gt;);
            when 64
                fraction = operand&lt;51:0&gt;;
                exp = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;62:52&gt;);

        if exp == 0 then
            while fraction&lt;51&gt; == '0' do
                fraction = fraction&lt;50:0&gt; : '0';
                exp = exp - 1;
            fraction = fraction&lt;50:0&gt; : '0';

        integer scaled;
        boolean increasedprecision = N==32 &amp;&amp; <a link="impl-shared.HaveFeatRPRES.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatRPRES()">HaveFeatRPRES</a>() &amp;&amp; altfp;

        if !increasedprecision then
            if exp&lt;0&gt; == '0' then
                scaled = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>('1':fraction&lt;51:44&gt;);
            else
                scaled = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>('01':fraction&lt;51:45&gt;);
        else
            if exp&lt;0&gt; == '0' then
                scaled = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>('1':fraction&lt;51:41&gt;);
            else
                scaled = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>('01':fraction&lt;51:42&gt;);

        integer result_exp;
        case N of
            when 16 result_exp = (  44 - exp) DIV 2;
            when 32 result_exp = ( 380 - exp) DIV 2;
            when 64 result_exp = (3068 - exp) DIV 2;

        estimate = <a link="impl-shared.RecipSqrtEstimate.2" file="shared_pseudocode.xml" hover="function: integer RecipSqrtEstimate(integer a_in, boolean increasedprecision)">RecipSqrtEstimate</a>(scaled, increasedprecision);

        // Estimate is in the range 256 .. 511 or 4096 .. 8191 representing a
        // fixed-point result in the range [1.0 .. 2.0].
        // Convert to scaled floating point result with copied sign bit and high-order
        // fraction bits, and exponent calculated above.
        case N of
            when 16 result = '0' : result_exp&lt;N-12:0&gt; : estimate&lt;7:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(2);
            when 32
                if !increasedprecision then
                    result = '0' : result_exp&lt;N-25:0&gt; : estimate&lt;7:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(15);
                else
                    result = '0' : result_exp&lt;N-25:0&gt; : estimate&lt;11:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(11);
            when 64 result = '0' : result_exp&lt;N-54:0&gt; : estimate&lt;7:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(44);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fprsqrtestimate/RecipSqrtEstimate" mylink="shared.functions.float.fprsqrtestimate.RecipSqrtEstimate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RecipSqrtEstimate()
// ===================
// Compute estimate of reciprocal square root of 9-bit fixed-point number.
//
// a_in is in range 128 .. 511 or 1024 .. 4095, with increased precision,
// representing a number in the range 0.25 &lt;= x &lt; 1.0.
// increasedprecision determines if the mantissa is 8-bit or 12-bit.
// result is in the range 256 .. 511 or 4096 .. 8191, with increased precision,
// representing a number in the range 1.0 to 511/256 or 8191/4096.

integer <anchor link="impl-shared.RecipSqrtEstimate.2" hover="function: integer RecipSqrtEstimate(integer a_in, boolean increasedprecision)">RecipSqrtEstimate</anchor>(integer a_in, boolean increasedprecision)

    integer a = a_in;
    integer r;
    if !increasedprecision then
        assert 128 &lt;= a &amp;&amp; a &lt; 512;
        if a &lt; 256 then                      // 0.25 .. 0.5
            a = a*2+1;                       // a in units of 1/512 rounded to nearest
        else                                 // 0.5 .. 1.0
            a = (a &gt;&gt; 1) &lt;&lt; 1;               // Discard bottom bit
            a = (a+1)*2;                     // a in units of 1/256 rounded to nearest
        integer b = 512;
        while a*(b+1)*(b+1) &lt; 2^28 do
            b = b+1;
        // b = largest b such that b &lt; 2^14 / sqrt(a)
        r = (b+1) DIV 2;                     // Round to nearest
        assert 256 &lt;= r &amp;&amp; r &lt; 512;
    else
        assert 1024 &lt;= a &amp;&amp; a &lt; 4096;
        real real_val;
        real error;
        integer int_val;

        if a &lt; 2048 then                     // 0.25... 0.5
            a = a*2 + 1;                     // Take 10 bits of fraction and force a 1 at the bottom
            real_val = Real(a)/2.0;
        else                                 // 0.5..1.0
            a = (a &gt;&gt; 1) &lt;&lt; 1;               // Discard bottom bit
            a = a+1;                         // Take 10 bits of fraction and force a 1 at the bottom
            real_val = Real(a);

        real_val = Sqrt(real_val);           // This number will lie in the range of 32 to 64
                                             // Round to nearest even for a DP float number
        real_val = real_val * Real(2^47);    // The integer is the size of the whole DP mantissa
        int_val  = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(real_val);      // Calculate rounding value
        error    = real_val - Real(int_val);
        round_up = error &gt; 0.5;              // Error cannot be exactly 0.5 so do not need tie case
        if round_up then int_val = int_val+1;

        real_val = Real(2^65)/Real(int_val); // Lies in the range 4096 &lt;= real_val &lt; 8192
        int_val  = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(real_val);      // Round that (to nearest even) to give integer
        error    = real_val - Real(int_val);
        round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_val&lt;0&gt; == '1'));
        if round_up then int_val = int_val+1;

        r = int_val;
        assert 4096 &lt;= r &amp;&amp; r &lt; 8192;

    return r;</pstext>
    </ps>
    <ps name="shared/functions/float/fpsqrt/FPSqrt" mylink="shared.functions.float.fpsqrt.FPSqrt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPSqrt()
// ========

bits(N) <anchor link="impl-shared.FPSqrt.2" hover="function: bits(N) FPSqrt(bits(N) op, FPCRType fpcr)">FPSqrt</anchor>(bits(N) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)

    assert N IN {16,32,64};
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.2" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</a>(op, fpcr);

    bits(N) result;
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        result = <a link="impl-shared.FPProcessNaN.3" file="shared_pseudocode.xml" hover="function: bits(N) FPProcessNaN(FPType fptype, bits(N) op, FPCRType fpcr)">FPProcessNaN</a>(fptype, op, fpcr);
    elsif fptype == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a> then
        result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign, N);
    elsif fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> &amp;&amp; sign == '0' then
        result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>(sign, N);
    elsif sign == '1' then
        result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    else
        result = <a link="impl-shared.FPRound.3" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr, integer N)">FPRound</a>(Sqrt(value), fpcr, N);
        <a link="impl-shared.FPProcessDenorm.3" file="shared_pseudocode.xml" hover="function: FPProcessDenorm(FPType fptype, integer N, FPCRType fpcr)">FPProcessDenorm</a>(fptype, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpsub/FPSub" mylink="shared.functions.float.fpsub.FPSub" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPSub()
// =======

bits(N) <anchor link="impl-shared.FPSub.3" hover="function: bits(N) FPSub(bits(N) op1, bits(N) op2, FPCRType fpcr)">FPSub</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr)
    boolean fpexc = TRUE;       // Generate floating-point exceptions
    return <a link="impl-shared.FPSub.4" file="shared_pseudocode.xml" hover="function: bits(N) FPSub(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPSub</a>(op1, op2, fpcr, fpexc);

// FPSub()
// =======

bits(N) <anchor link="impl-shared.FPSub.4" hover="function: bits(N) FPSub(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPSub</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)

    assert N IN {16,32,64};
    rounding = <a link="impl-shared.FPRoundingMode.1" file="shared_pseudocode.xml" hover="function: FPRounding FPRoundingMode(FPCRType fpcr)">FPRoundingMode</a>(fpcr);

    (type1,sign1,value1) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op1, fpcr, fpexc);
    (type2,sign2,value2) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op2, fpcr, fpexc);

    (done,result) = <a link="impl-shared.FPProcessNaNs.6" file="shared_pseudocode.xml" hover="function: (boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2, bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPProcessNaNs</a>(type1, type2, op1, op2, fpcr, fpexc);
    if !done then
        inf1 = (type1 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        inf2 = (type2 == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>);
        zero1 = (type1 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);
        zero2 = (type2 == <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>);

        if inf1 &amp;&amp; inf2 &amp;&amp; sign1 == sign2 then
            result = <a link="impl-shared.FPDefaultNaN.2" file="shared_pseudocode.xml" hover="function: bits(N) FPDefaultNaN(FPCRType fpcr, integer N)">FPDefaultNaN</a>(fpcr, N);
            if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        elsif (inf1 &amp;&amp; sign1 == '0') || (inf2 &amp;&amp; sign2 == '1') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('0', N);
        elsif (inf1 &amp;&amp; sign1 == '1') || (inf2 &amp;&amp; sign2 == '0') then
            result = <a link="impl-shared.FPInfinity.2" file="shared_pseudocode.xml" hover="function: bits(N) FPInfinity(bit sign, integer N)">FPInfinity</a>('1', N);
        elsif zero1 &amp;&amp; zero2 &amp;&amp; sign1 == NOT(sign2) then
            result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(sign1, N);
        else
            result_value = value1 - value2;
            if result_value == 0.0 then  // Sign of exact zero result depends on rounding mode
                result_sign = if rounding == <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a> then '1' else '0';
                result = <a link="impl-shared.FPZero.2" file="shared_pseudocode.xml" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</a>(result_sign, N);
            else
                result = <a link="impl-shared.FPRound.5" file="shared_pseudocode.xml" hover="function: bits(N) FPRound(real op, FPCRType fpcr_in, FPRounding rounding, boolean fpexc, integer N)">FPRound</a>(result_value, fpcr, rounding, fpexc, N);

        if fpexc then <a link="impl-shared.FPProcessDenorms.4" file="shared_pseudocode.xml" hover="function: FPProcessDenorms(FPType type1, FPType type2, integer N, FPCRType fpcr)">FPProcessDenorms</a>(type1, type2, N, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fpsub/FPSub_ZA" mylink="shared.functions.float.fpsub.FPSub_ZA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPSub_ZA()
// ==========
// Calculates op1-op2 for SME2 ZA-targeting instructions.

bits(N) <anchor link="impl-shared.FPSub_ZA.3" hover="function: bits(N) FPSub_ZA(bits(N) op1, bits(N) op2, FPCRType fpcr_in)">FPSub_ZA</anchor>(bits(N) op1, bits(N) op2, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    boolean fpexc = FALSE;      // Do not generate floating-point exceptions
    fpcr.DN = '1';              // Generate default NaN values
    return <a link="impl-shared.FPSub.4" file="shared_pseudocode.xml" hover="function: bits(N) FPSub(bits(N) op1, bits(N) op2, FPCRType fpcr, boolean fpexc)">FPSub</a>(op1, op2, fpcr, fpexc);</pstext>
    </ps>
    <ps name="shared/functions/float/fpthree/FPThree" mylink="shared.functions.float.fpthree.FPThree" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPThree()
// =========

bits(N) <anchor link="impl-shared.FPThree.2" hover="function: bits(N) FPThree(bit sign, integer N)">FPThree</anchor>(bit sign, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp  = '1':<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(E-1);
    frac = '1':<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F-1);
    result = sign : exp : frac;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fptofixed/FPToFixed" mylink="shared.functions.float.fptofixed.FPToFixed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPToFixed()
// ===========

// Convert N-bit precision floating point 'op' to M-bit fixed point with
// FBITS fractional bits, controlled by UNSIGNED and ROUNDING.

bits(M) <anchor link="impl-shared.FPToFixed.6" hover="function: bits(M) FPToFixed(bits(N) op, integer fbits, boolean unsigned, FPCRType fpcr, FPRounding rounding, integer M)">FPToFixed</anchor>(bits(N) op, integer fbits, boolean unsigned, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr,
                  <a link="FPRounding" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding</a> rounding, integer M)

    assert N IN {16,32,64};
    assert M IN {16,32,64};
    assert fbits &gt;= 0;
    assert rounding != <a link="FPRounding_ODD" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ODD</a>;

    // When alternative floating-point support is TRUE, do not generate
    // Input Denormal floating-point exceptions.
    altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1';
    fpexc = !altfp;

    // Unpack using fpcr to determine if subnormals are flushed-to-zero.
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, fpexc);

    // If NaN, set cumulative flag or take exception.
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);

    // Scale by fractional bits and produce integer rounded towards minus-infinity.
    value = value * 2.0^fbits;
    int_result = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(value);
    error = value - Real(int_result);

    // Determine whether supplied rounding mode requires an increment.
    boolean round_up;
    case rounding of
        when <a link="FPRounding_TIEEVEN" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEEVEN</a>
            round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_result&lt;0&gt; == '1'));
        when <a link="FPRounding_POSINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_POSINF</a>
            round_up = (error != 0.0);
        when <a link="FPRounding_NEGINF" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_NEGINF</a>
            round_up = FALSE;
        when <a link="FPRounding_ZERO" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_ZERO</a>
            round_up = (error != 0.0 &amp;&amp; int_result &lt; 0);
        when <a link="FPRounding_TIEAWAY" file="shared_pseudocode.xml" hover="enumeration FPRounding  {FPRounding_TIEEVEN, FPRounding_POSINF, FPRounding_NEGINF,  FPRounding_ZERO, FPRounding_TIEAWAY, FPRounding_ODD}">FPRounding_TIEAWAY</a>
            round_up = (error &gt; 0.5 || (error == 0.5 &amp;&amp; int_result &gt;= 0));

    if round_up then int_result = int_result + 1;

    // Generate saturated result and exceptions.
    (result, overflow) = <a link="impl-shared.SatQ.3" file="shared_pseudocode.xml" hover="function: (bits(N), boolean) SatQ(integer i, integer N, boolean unsigned)">SatQ</a>(int_result, M, unsigned);
    if overflow then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
    elsif error != 0.0 then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fptofixedjs/FPToFixedJS" mylink="shared.functions.float.fptofixedjs.FPToFixedJS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPToFixedJS()
// =============

// Converts a double precision floating point input value
// to a signed integer, with rounding to zero.

(bits(N), bit) <anchor link="impl-shared.FPToFixedJS.4" hover="function: (bits(N), bit) FPToFixedJS(bits(M) op, FPCRType fpcr, boolean Is64, integer N)">FPToFixedJS</anchor>(bits(M) op, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean Is64, integer N)

    assert M == 64 &amp;&amp; N == 32;

    // If FALSE, never generate Input Denormal floating-point exceptions.
    fpexc_idenorm = !(<a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; fpcr.AH == '1');

    // Unpack using fpcr to determine if subnormals are flushed-to-zero.
    (fptype,sign,value) = <a link="impl-shared.FPUnpack.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</a>(op, fpcr, fpexc_idenorm);

    z = '1';
    // If NaN, set cumulative flag or take exception.
    if fptype == <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a> || fptype == <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        z = '0';

    int_result = <a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(value);
    error = value - Real(int_result);

    // Determine whether supplied rounding mode requires an increment.

    round_it_up = (error != 0.0 &amp;&amp; int_result &lt; 0);
    if round_it_up then int_result = int_result + 1;

    integer result;
    if int_result &lt; 0 then
        result = int_result - 2^32*<a link="impl-shared.RoundUp.1" file="shared_pseudocode.xml" hover="function: integer RoundUp(real x)">RoundUp</a>(Real(int_result)/Real(2^32));
    else
        result = int_result - 2^32*<a link="impl-shared.RoundDown.1" file="shared_pseudocode.xml" hover="function: integer RoundDown(real x)">RoundDown</a>(Real(int_result)/Real(2^32));

    // Generate exceptions.
    if int_result &lt; -(2^31) || int_result &gt; (2^31)-1 then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InvalidOp" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InvalidOp</a>, fpcr);
        z = '0';
    elsif error != 0.0 then
        <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_Inexact" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_Inexact</a>, fpcr);
        z = '0';
    elsif sign == '1' &amp;&amp; value == 0.0 then
        z = '0';
    elsif sign == '0' &amp;&amp; value == 0.0 &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(op&lt;51:0&gt;) then
        z = '0';

    if fptype == <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a> then result = 0;

    return (result&lt;N-1:0&gt;, z);</pstext>
    </ps>
    <ps name="shared/functions/float/fptwo/FPTwo" mylink="shared.functions.float.fptwo.FPTwo" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPTwo()
// =======

bits(N) <anchor link="impl-shared.FPTwo.2" hover="function: bits(N) FPTwo(bit sign, integer N)">FPTwo</anchor>(bit sign, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp  = '1':<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(E-1);
    frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
    result = sign : exp : frac;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/fptype/FPType" mylink="shared.functions.float.fptype.FPType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPType
// ======

enumeration <anchor link="FPType" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</anchor> {<anchor link="FPType_Zero" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</anchor>,
                    <anchor link="FPType_Denormal" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</anchor>,
                    <anchor link="FPType_Nonzero" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Nonzero</anchor>,
                    <anchor link="FPType_Infinity" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</anchor>,
                    <anchor link="FPType_QNaN" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</anchor>,
                    <anchor link="FPType_SNaN" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/float/fpunpack/FPUnpack" mylink="shared.functions.float.fpunpack.FPUnpack" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPUnpack()
// ==========

(FPType, bit, real) <anchor link="impl-shared.FPUnpack.2" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in)">FPUnpack</anchor>(bits(N) fpval, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.AHP = '0';
    boolean fpexc = TRUE;   // Generate floating-point exceptions
    (fp_type, sign, value) = <a link="impl-shared.FPUnpackBase.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr, boolean fpexc)">FPUnpackBase</a>(fpval, fpcr, fpexc);
    return (fp_type, sign, value);

// FPUnpack()
// ==========
//
// Used by data processing, int/fixed to FP and FP to int/fixed conversion instructions.
// For half-precision data it ignores AHP, and observes FZ16.

(FPType, bit, real) <anchor link="impl-shared.FPUnpack.3" hover="function: (FPType, bit, real) FPUnpack(bits(N) fpval, FPCRType fpcr_in, boolean fpexc)">FPUnpack</anchor>(bits(N) fpval, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean fpexc)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.AHP = '0';
    (fp_type, sign, value) = <a link="impl-shared.FPUnpackBase.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr, boolean fpexc)">FPUnpackBase</a>(fpval, fpcr, fpexc);
    return (fp_type, sign, value);</pstext>
    </ps>
    <ps name="shared/functions/float/fpunpack/FPUnpackBase" mylink="shared.functions.float.fpunpack.FPUnpackBase" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPUnpackBase()
// ==============

(FPType, bit, real) <anchor link="impl-shared.FPUnpackBase.3" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr, boolean fpexc)">FPUnpackBase</anchor>(bits(N) fpval, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr, boolean fpexc)
    boolean isbfloat16 = FALSE;
    (fp_type, sign, value) = <a link="impl-shared.FPUnpackBase.4" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</a>(fpval, fpcr, fpexc, isbfloat16);
    return (fp_type, sign, value);

// FPUnpackBase()
// ==============
//
// Unpack a floating-point number into its type, sign bit and the real number
// that it represents. The real number result has the correct sign for numbers
// and infinities, is very large in magnitude for infinities, and is 0.0 for
// NaNs. (These values are chosen to simplify the description of comparisons
// and conversions.)
//
// The 'fpcr_in' argument supplies FPCR control bits, 'fpexc' controls the
// generation of floating-point exceptions and 'isbfloat16' determines whether
// N=16 signifies BFloat16 or half-precision type. Status information is updated
// directly in the FPSR where appropriate.

(FPType, bit, real) <anchor link="impl-shared.FPUnpackBase.4" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr_in, boolean fpexc, boolean isbfloat16)">FPUnpackBase</anchor>(bits(N) fpval, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in, boolean fpexc,
                                 boolean isbfloat16)

    assert N IN {16,32,64};

    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;

    boolean altfp = <a link="impl-shared.HaveAltFP.0" file="shared_pseudocode.xml" hover="function: boolean HaveAltFP()">HaveAltFP</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    boolean fiz   = altfp &amp;&amp; fpcr.FIZ == '1';
    boolean fz    = fpcr.FZ == '1' &amp;&amp; !(altfp &amp;&amp; fpcr.AH == '1');
    real value;
    bit sign;
    <a link="FPType" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType</a> fptype;

    if N == 16 &amp;&amp; !isbfloat16 then
        sign   = fpval&lt;15&gt;;
        exp16  = fpval&lt;14:10&gt;;
        frac16 = fpval&lt;9:0&gt;;
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(exp16) then
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac16) || fpcr.FZ16 == '1' then
                fptype = <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;  value = 0.0;
            else
                fptype = <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a>;  value = 2.0^-14 * (Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac16)) * 2.0^-10);
        elsif <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(exp16) &amp;&amp; fpcr.AHP == '0' then  // Infinity or NaN in IEEE format
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac16) then
                fptype = <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>;  value = 2.0^1000000;
            else
                fptype = if frac16&lt;9&gt; == '1' then <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> else <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>;
                value = 0.0;
        else
            fptype = <a link="FPType_Nonzero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Nonzero</a>;
            value = 2.0^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(exp16)-15) * (1.0 + Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac16)) * 2.0^-10);

    elsif N == 32 || isbfloat16 then
        bits(8) exp32;
        bits(23) frac32;
        if isbfloat16 then
            sign   = fpval&lt;15&gt;;
            exp32  = fpval&lt;14:7&gt;;
            frac32 = fpval&lt;6:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
        else
            sign   = fpval&lt;31&gt;;
            exp32  = fpval&lt;30:23&gt;;
            frac32 = fpval&lt;22:0&gt;;

        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(exp32) then
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac32) then
                // Produce zero if value is zero.
                fptype = <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;  value = 0.0;
            elsif fz || fiz then        // Flush-to-zero if FIZ==1 or AH,FZ==01
                fptype = <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;  value = 0.0;
                // Check whether to raise Input Denormal floating-point exception.
                // fpcr.FIZ==1 does not raise Input Denormal exception.
                if fz then
                    // Denormalized input flushed to zero
                    if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>, fpcr);
            else
                fptype = <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a>;  value = 2.0^-126 * (Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac32)) * 2.0^-23);
        elsif <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(exp32) then
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac32) then
                fptype = <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>;  value = 2.0^1000000;
            else
                fptype = if frac32&lt;22&gt; == '1' then <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> else <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>;
                value = 0.0;
        else
            fptype = <a link="FPType_Nonzero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Nonzero</a>;
            value = 2.0^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(exp32)-127) * (1.0 + Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac32)) * 2.0^-23);

    else // N == 64
        sign   = fpval&lt;63&gt;;
        exp64  = fpval&lt;62:52&gt;;
        frac64 = fpval&lt;51:0&gt;;

        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(exp64) then
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac64) then
                // Produce zero if value is zero.
                fptype = <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;  value = 0.0;
            elsif fz || fiz then        // Flush-to-zero if FIZ==1 or AH,FZ==01
                fptype = <a link="FPType_Zero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Zero</a>;  value = 0.0;
                // Check whether to raise Input Denormal floating-point exception.
                // fpcr.FIZ==1 does not raise Input Denormal exception.
                if fz then
                    // Denormalized input flushed to zero
                    if fpexc then <a link="impl-shared.FPProcessException.2" file="shared_pseudocode.xml" hover="function: FPProcessException(FPExc exception, FPCRType fpcr)">FPProcessException</a>(<a link="FPExc_InputDenorm" file="shared_pseudocode.xml" hover="enumeration FPExc       {FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow, FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm}">FPExc_InputDenorm</a>, fpcr);
            else
                fptype = <a link="FPType_Denormal" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Denormal</a>;  value = 2.0^-1022 * (Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac64)) * 2.0^-52);
        elsif <a link="impl-shared.IsOnes.1" file="shared_pseudocode.xml" hover="function: boolean IsOnes(bits(N) x)">IsOnes</a>(exp64) then
            if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(frac64) then
                fptype = <a link="FPType_Infinity" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Infinity</a>;  value = 2.0^1000000;
            else
                fptype = if frac64&lt;51&gt; == '1' then <a link="FPType_QNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_QNaN</a> else <a link="FPType_SNaN" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_SNaN</a>;
                value = 0.0;
        else
            fptype = <a link="FPType_Nonzero" file="shared_pseudocode.xml" hover="enumeration FPType {FPType_Zero, FPType_Denormal, FPType_Nonzero, FPType_Infinity, FPType_QNaN, FPType_SNaN}">FPType_Nonzero</a>;
            value = 2.0^(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(exp64)-1023) * (1.0 + Real(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(frac64)) * 2.0^-52);

    if sign == '1' then value = -value;

    return (fptype, sign, value);</pstext>
    </ps>
    <ps name="shared/functions/float/fpunpack/FPUnpackCV" mylink="shared.functions.float.fpunpack.FPUnpackCV" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPUnpackCV()
// ============
//
// Used for FP to FP conversion instructions.
// For half-precision data ignores FZ16 and observes AHP.

(FPType, bit, real) <anchor link="impl-shared.FPUnpackCV.2" hover="function: (FPType, bit, real) FPUnpackCV(bits(N) fpval, FPCRType fpcr_in)">FPUnpackCV</anchor>(bits(N) fpval, <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr_in)
    <a link="FPCRType" file="shared_pseudocode.xml" hover="type FPCRType">FPCRType</a> fpcr = fpcr_in;
    fpcr.FZ16 = '0';
    boolean fpexc = TRUE;   // Generate floating-point exceptions
    (fp_type, sign, value) = <a link="impl-shared.FPUnpackBase.3" file="shared_pseudocode.xml" hover="function: (FPType, bit, real) FPUnpackBase(bits(N) fpval, FPCRType fpcr, boolean fpexc)">FPUnpackBase</a>(fpval, fpcr, fpexc);
    return (fp_type, sign, value);</pstext>
    </ps>
    <ps name="shared/functions/float/fpzero/FPZero" mylink="shared.functions.float.fpzero.FPZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FPZero()
// ========

bits(N) <anchor link="impl-shared.FPZero.2" hover="function: bits(N) FPZero(bit sign, integer N)">FPZero</anchor>(bit sign, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = N - (E + 1);
    exp  = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(E);
    frac = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F);
    result = sign : exp : frac;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/float/vfpexpandimm/VFPExpandImm" mylink="shared.functions.float.vfpexpandimm.VFPExpandImm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VFPExpandImm()
// ==============

bits(N) <anchor link="impl-shared.VFPExpandImm.2" hover="function: bits(N) VFPExpandImm(bits(8) imm8, integer N)">VFPExpandImm</anchor>(bits(8) imm8, integer N)

    assert N IN {16,32,64};
    constant integer E = (if N == 16 then 5 elsif N == 32 then 8 else 11);
    constant integer F = (N - E) - 1;
    sign = imm8&lt;7&gt;;
    exp  = NOT(imm8&lt;6&gt;):<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;6&gt;,E-3):imm8&lt;5:4&gt;;
    frac = imm8&lt;3:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(F-4);
    result = sign : exp : frac;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/integer/AddWithCarry" mylink="shared.functions.integer.AddWithCarry" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddWithCarry()
// ==============
// Integer addition with carry input, returning result and NZCV flags

(bits(N), bits(4)) <anchor link="impl-shared.AddWithCarry.3" hover="function: (bits(N), bits(4)) AddWithCarry(bits(N) x, bits(N) y, bit carry_in)">AddWithCarry</anchor>(bits(N) x, bits(N) y, bit carry_in)
    integer unsigned_sum = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(x) + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(y) + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(carry_in);
    integer signed_sum = <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(x) + <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(y) + <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(carry_in);
    bits(N) result = unsigned_sum&lt;N-1:0&gt;; // same value as signed_sum&lt;N-1:0&gt;
    bit n = result&lt;N-1&gt;;
    bit z = if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(result) then '1' else '0';
    bit c = if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(result) == unsigned_sum then '0' else '1';
    bit v = if <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(result) == signed_sum then '0' else '1';
    return (result, n:z:c:v);</pstext>
    </ps>
    <ps name="shared/functions/interrupts/InterruptID" mylink="shared.functions.interrupts.InterruptID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InterruptID
// ===========

enumeration <anchor link="InterruptID" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID</anchor> {
    <anchor link="InterruptID_PMUIRQ" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_PMUIRQ</anchor>,
    <anchor link="InterruptID_COMMIRQ" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_COMMIRQ</anchor>,
    <anchor link="InterruptID_CTIIRQ" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CTIIRQ</anchor>,
    <anchor link="InterruptID_COMMRX" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_COMMRX</anchor>,
    <anchor link="InterruptID_COMMTX" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_COMMTX</anchor>,
    <anchor link="InterruptID_CNTP" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTP</anchor>,
    <anchor link="InterruptID_CNTHP" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHP</anchor>,
    <anchor link="InterruptID_CNTHPS" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHPS</anchor>,
    <anchor link="InterruptID_CNTPS" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTPS</anchor>,
    <anchor link="InterruptID_CNTV" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTV</anchor>,
    <anchor link="InterruptID_CNTHV" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHV</anchor>,
    <anchor link="InterruptID_CNTHVS" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_CNTHVS</anchor>,
    <anchor link="InterruptID_PMBIRQ" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID_PMBIRQ</anchor>,
};</pstext>
    </ps>
    <ps name="shared/functions/interrupts/SetInterruptRequestLevel" mylink="shared.functions.interrupts.SetInterruptRequestLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetInterruptRequestLevel()
// ==========================
// Set a level-sensitive interrupt to the specified level.

SetInterruptRequestLevel(<a link="InterruptID" file="shared_pseudocode.xml" hover="enumeration InterruptID { InterruptID_PMUIRQ, InterruptID_COMMIRQ, InterruptID_CTIIRQ, InterruptID_COMMRX, InterruptID_COMMTX, InterruptID_CNTP, InterruptID_CNTHP, InterruptID_CNTHPS, InterruptID_CNTPS, InterruptID_CNTV, InterruptID_CNTHV, InterruptID_CNTHVS, InterruptID_PMBIRQ, }">InterruptID</a> id, signal level);</pstext>
    </ps>
    <ps name="shared/functions/memory/AArch64.BranchAddr" mylink="shared.functions.memory.AArch64.BranchAddr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.BranchAddr()
// ====================
// Return the virtual address with tag bits removed.
// This is typically used when the address will be stored to the program counter.

bits(64) <anchor link="AArch64.BranchAddr.2" hover="function: bits(64) AArch64.BranchAddr(bits(64) vaddress, bits(2) el)">AArch64.BranchAddr</anchor>(bits(64) vaddress, bits(2) el)
    assert !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    msbit = <a link="impl-shared.AddrTop.3" file="shared_pseudocode.xml" hover="function: integer AddrTop(bits(64) address, boolean IsInstr, bits(2) el)">AddrTop</a>(vaddress, TRUE, el);
    if msbit == 63 then
        return vaddress;
    elsif (el IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} || <a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>()) &amp;&amp; vaddress&lt;msbit&gt; == '1' then
        return <a link="impl-shared.SignExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) SignExtend(bits(M) x, integer N)">SignExtend</a>(vaddress&lt;msbit:0&gt;, 64);
    else
        return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(vaddress&lt;msbit:0&gt;, 64);</pstext>
    </ps>
    <ps name="shared/functions/memory/AccessDescriptor" mylink="shared.functions.memory.AccessDescriptor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AccessDescriptor
// ================
// Memory access or translation invocation details that steer architectural behavior

type <anchor link="AccessDescriptor" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</anchor> is (
    <a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype,
    bits(2) el,             // Acting EL for the access
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss,       // Acting Security State for the access
    boolean acqsc,          // Acquire with Sequential Consistency
    boolean acqpc,          // FEAT_LRCPC: Acquire with Processor Consistency
    boolean relsc,          // Release with Sequential Consistency
    boolean limitedordered, // FEAT_LOR: Acquire/Release with limited ordering
    boolean exclusive,      // Access has Exclusive semantics
    boolean atomicop,       // FEAT_LSE: Atomic read-modify-write access
    <a link="MemAtomicOp" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp</a> modop,      // FEAT_LSE: The modification operation in the 'atomicop' access
    boolean nontemporal,    // Hints the access is non-temporal
    boolean read,           // Read from memory or only require read permissions
    boolean write,          // Write to memory or only require write permissions
    <a link="CacheOp" file="shared_pseudocode.xml" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp</a> cacheop,        // DC/IC: Cache operation
    <a link="CacheOpScope" file="shared_pseudocode.xml" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</a> opscope,   // DC/IC: Scope of cache operation
    <a link="CacheType" file="shared_pseudocode.xml" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</a> cachetype,    // DC/IC: Type of target cache
    boolean pan,            // FEAT_PAN: The access is subject to PSTATE.PAN
    boolean transactional,  // FEAT_TME: Access is part of a transaction
    boolean nonfault,       // SVE: Non-faulting load
    boolean firstfault,     // SVE: First-fault load
    boolean first,          // SVE: First-fault load for the first active element
    boolean contiguous,     // SVE: Contiguous load/store not gather load/scatter store
    boolean streamingsve,   // SME: Access made by PE while in streaming SVE mode
    boolean ls64,           // FEAT_LS64: Accesses by accelerator support loads/stores
    boolean mops,           // FEAT_MOPS: Memory operation (CPY/SET) accesses
    boolean rcw,            // FEAT_THE: Read-Check-Write access
    boolean rcws,           // FEAT_THE: Read-Check-Write Software access
    boolean toplevel,       // FEAT_THE: Translation table walk access for TTB address
    <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange,        // FEAT_THE: The corresponding TTBR supplying the TTB
    boolean a32lsmd,        // A32 Load/Store Multiple Data access
    boolean tagchecked,     // FEAT_MTE2: Access is tag checked
    boolean tagaccess,      // FEAT_MTE: Access targets the tag bits
    <a link="MPAMinfo" file="shared_pseudocode.xml" hover="type MPAMinfo is ( PARTIDspaceType mpam_sp, PARTIDtype partid, PMGtype pmg )">MPAMinfo</a> mpam           // FEAT_MPAM: MPAM information
)</pstext>
    </ps>
    <ps name="shared/functions/memory/AccessType" mylink="shared.functions.memory.AccessType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AccessType
// ==========

enumeration <anchor link="AccessType" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</anchor> {
    <anchor link="AccessType_IFETCH" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</anchor>,  // Instruction FETCH
    <anchor link="AccessType_GPR" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</anchor>,     // Software load/store to a General Purpose Register
    <anchor link="AccessType_ASIMD" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_ASIMD</anchor>,   // Software ASIMD extension load/store instructions
    <anchor link="AccessType_SVE" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SVE</anchor>,     // Software SVE load/store instructions
    <anchor link="AccessType_SME" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SME</anchor>,     // Software SME load/store instructions
    <anchor link="AccessType_IC" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</anchor>,      // Sysop IC
    <anchor link="AccessType_DC" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</anchor>,      // Sysop DC (not DC {Z,G,GZ}VA)
    <anchor link="AccessType_DCZero" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DCZero</anchor>,  // Sysop DC {Z,G,GZ}VA
    <anchor link="AccessType_AT" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</anchor>,      // Sysop AT
    <anchor link="AccessType_NV2" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</anchor>,     // NV2 memory redirected access
    <anchor link="AccessType_SPE" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</anchor>,     // Statistical Profiling buffer access
    <anchor link="AccessType_GCS" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</anchor>,     // Guarded Control Stack access
    <anchor link="AccessType_TRBE" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TRBE</anchor>,    // Trace Buffer access
    <anchor link="AccessType_GPTW" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPTW</anchor>,    // Granule Protection Table Walk
    <anchor link="AccessType_TTW" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</anchor>      // Translation Table Walk
};</pstext>
    </ps>
    <ps name="shared/functions/memory/AddrTop" mylink="shared.functions.memory.AddrTop" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AddrTop()
// =========
// Return the MSB number of a virtual address in the stage 1 translation regime for "el".
// If EL1 is using AArch64 then addresses from EL0 using AArch32 are zero-extended to 64 bits.

integer <anchor link="impl-shared.AddrTop.3" hover="function: integer AddrTop(bits(64) address, boolean IsInstr, bits(2) el)">AddrTop</anchor>(bits(64) address, boolean IsInstr, bits(2) el)
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el);
    regime = <a link="impl-shared.S1TranslationRegime.1" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</a>(el);
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(regime) then
        // AArch32 translation regime.
        return 31;
    else
        if <a link="impl-shared.EffectiveTBI.3" file="shared_pseudocode.xml" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</a>(address, IsInstr, el) == '1' then
            return 55;
        else
            return 63;</pstext>
    </ps>
    <ps name="shared/functions/memory/AlignmentEnforced" mylink="shared.functions.memory.AlignmentEnforced" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AlignmentEnforced()
// ===================
// For the active translation regime, determine if alignment is required by all accesses

boolean <anchor link="impl-shared.AlignmentEnforced.0" hover="function: boolean AlignmentEnforced()">AlignmentEnforced</anchor>()
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime = <a link="impl-shared.TranslationRegime.1" file="shared_pseudocode.xml" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</a>(PSTATE.EL);

    bit A;
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  A = SCTLR_EL3.A;
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> A = SCTLR.A;
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  A = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then HSCTLR.A else SCTLR_EL2.A;
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> A = SCTLR_EL2.A;
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> A = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then SCTLR.A  else SCTLR_EL1.A;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    return A == '1';</pstext>
    </ps>
    <ps name="shared/functions/memory/Allocation" mylink="shared.functions.memory.Allocation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(2) <anchor link="MemHint_No" hover="constant bits(2) MemHint_No = '00'">MemHint_No</anchor> = '00';     // No Read-Allocate, No Write-Allocate
constant bits(2) <anchor link="MemHint_WA" hover="constant bits(2) MemHint_WA = '01'">MemHint_WA</anchor> = '01';     // No Read-Allocate, Write-Allocate
constant bits(2) <anchor link="MemHint_RA" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</anchor> = '10';     // Read-Allocate, No Write-Allocate
constant bits(2) <anchor link="MemHint_RWA" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</anchor> = '11';    // Read-Allocate, Write-Allocate</pstext>
    </ps>
    <ps name="shared/functions/memory/BigEndian" mylink="shared.functions.memory.BigEndian" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BigEndian()
// ===========

boolean <anchor link="impl-shared.BigEndian.1" hover="function: boolean BigEndian(AccessType acctype)">BigEndian</anchor>(<a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype)
    boolean bigend;
    if <a link="impl-shared.HaveNV2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveNV2Ext()">HaveNV2Ext</a>() &amp;&amp; acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then
        return SCTLR_EL2.EE == '1';

    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        bigend = (PSTATE.E != '0');
    elsif PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        bigend = (<a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].E0E != '0');
    else
        bigend = (<a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[].EE != '0');
    return bigend;</pstext>
    </ps>
    <ps name="shared/functions/memory/BigEndianReverse" mylink="shared.functions.memory.BigEndianReverse" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BigEndianReverse()
// ==================

bits(width) <anchor link="impl-shared.BigEndianReverse.1" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</anchor> (bits(width) value)
    assert width IN {8, 16, 32, 64, 128};
    integer half = width DIV 2;
    if width == 8 then return value;
    return <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value&lt;half-1:0&gt;) : <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(value&lt;width-1:half&gt;);</pstext>
    </ps>
    <ps name="shared/functions/memory/Cacheability" mylink="shared.functions.memory.Cacheability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(2) <anchor link="MemAttr_NC" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</anchor> = '00';     // Non-cacheable
constant bits(2) <anchor link="MemAttr_WT" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</anchor> = '10';     // Write-through
constant bits(2) <anchor link="MemAttr_WB" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</anchor> = '11';     // Write-back</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescA32LSMD" mylink="shared.functions.memory.CreateAccDescA32LSMD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescA32LSMD()
// ======================
// Access descriptor for A32 loads/store multiple general purpose registers

AccessDescriptor <anchor link="impl-shared.CreateAccDescA32LSMD.1" hover="function: AccessDescriptor CreateAccDescA32LSMD(MemOp memop)">CreateAccDescA32LSMD</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.a32lsmd         = TRUE;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescASIMD" mylink="shared.functions.memory.CreateAccDescASIMD" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescASIMD()
// ====================
// Access descriptor for ASIMD&amp;FP loads/stores

AccessDescriptor <anchor link="impl-shared.CreateAccDescASIMD.3" hover="function: AccessDescriptor CreateAccDescASIMD(MemOp memop, boolean nontemporal, boolean tagchecked)">CreateAccDescASIMD</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean nontemporal, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_ASIMD" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_ASIMD</a>);

    accdesc.nontemporal     = nontemporal;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.streamingsve    = <a link="impl-aarch64.InStreamingMode.0" file="shared_pseudocode.xml" hover="function: boolean InStreamingMode()">InStreamingMode</a>();
    if (accdesc.streamingsve &amp;&amp; boolean IMPLEMENTATION_DEFINED
          "No tag checking of SIMD&amp;FP loads and stores in Streaming SVE mode") then
        accdesc.tagchecked  = FALSE;
    else
        accdesc.tagchecked  = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescASIMDAcqRel" mylink="shared.functions.memory.CreateAccDescASIMDAcqRel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescASIMDAcqRel()
// ==========================
// Access descriptor for ASIMD&amp;FP loads/stores with ordering semantics

AccessDescriptor <anchor link="impl-shared.CreateAccDescASIMDAcqRel.2" hover="function: AccessDescriptor CreateAccDescASIMDAcqRel(MemOp memop, boolean tagchecked)">CreateAccDescASIMDAcqRel</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_ASIMD" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_ASIMD</a>);

    accdesc.acqpc           = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.relsc           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.streamingsve    = <a link="impl-aarch64.InStreamingMode.0" file="shared_pseudocode.xml" hover="function: boolean InStreamingMode()">InStreamingMode</a>();
    if (accdesc.streamingsve &amp;&amp; boolean IMPLEMENTATION_DEFINED
          "No tag checking of SIMD&amp;FP loads and stores in Streaming SVE mode") then
        accdesc.tagchecked  = FALSE;
    else
        accdesc.tagchecked  = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescAT" mylink="shared.functions.memory.CreateAccDescAT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescAT()
// =================
// Access descriptor for address translation operations

AccessDescriptor <anchor link="impl-shared.CreateAccDescAT.4" hover="function: AccessDescriptor CreateAccDescAT(SecurityState ss, bits(2) el, boolean write, boolean pan)">CreateAccDescAT</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(2) el, boolean write, boolean pan)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>);

    accdesc.el              = el;
    accdesc.ss              = ss;
    accdesc.read            = !write;
    accdesc.write           = write;
    accdesc.pan             = pan;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescAcqRel" mylink="shared.functions.memory.CreateAccDescAcqRel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescAcqRel()
// =====================
// Access descriptor for general purpose register loads/stores with ordering semantics

AccessDescriptor <anchor link="impl-shared.CreateAccDescAcqRel.2" hover="function: AccessDescriptor CreateAccDescAcqRel(MemOp memop, boolean tagchecked)">CreateAccDescAcqRel</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.acqsc           = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.relsc           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescAtomicOp" mylink="shared.functions.memory.CreateAccDescAtomicOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescAtomicOp()
// =======================
// Access descriptor for atomic read-modify-write memory accesses

AccessDescriptor <anchor link="impl-shared.CreateAccDescAtomicOp.4" hover="function: AccessDescriptor CreateAccDescAtomicOp(MemAtomicOp modop, boolean acquire, boolean release, boolean tagchecked)">CreateAccDescAtomicOp</anchor>(<a link="MemAtomicOp" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp</a> modop, boolean acquire, boolean release,
                                       boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.acqsc           = acquire;
    accdesc.relsc           = release;
    accdesc.atomicop        = TRUE;
    accdesc.modop           = modop;
    accdesc.read            = TRUE;
    accdesc.write           = TRUE;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescDC" mylink="shared.functions.memory.CreateAccDescDC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescDC()
// =================
// Access descriptor for data cache operations

AccessDescriptor <anchor link="impl-shared.CreateAccDescDC.1" hover="function: AccessDescriptor CreateAccDescDC(CacheRecord cache)">CreateAccDescDC</anchor>(<a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>);

    accdesc.cacheop         = cache.cacheop;
    accdesc.cachetype       = cache.cachetype;
    accdesc.opscope         = cache.opscope;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescDCZero" mylink="shared.functions.memory.CreateAccDescDCZero" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescDCZero()
// =====================
// Access descriptor for data cache zero operations

AccessDescriptor <anchor link="impl-shared.CreateAccDescDCZero.2" hover="function: AccessDescriptor CreateAccDescDCZero(boolean tagaccess, boolean tagchecked)">CreateAccDescDCZero</anchor>(boolean tagaccess, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_DCZero" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DCZero</a>);

    accdesc.write           = TRUE;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.tagaccess       = tagaccess;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescExLDST" mylink="shared.functions.memory.CreateAccDescExLDST" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescExLDST()
// =====================
// Access descriptor for general purpose register loads/stores with exclusive semantics

AccessDescriptor <anchor link="impl-shared.CreateAccDescExLDST.3" hover="function: AccessDescriptor CreateAccDescExLDST(MemOp memop, boolean acqrel, boolean tagchecked)">CreateAccDescExLDST</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean acqrel, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.acqsc           = acqrel &amp;&amp; memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.relsc           = acqrel &amp;&amp; memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.exclusive       = TRUE;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescGCS" mylink="shared.functions.memory.CreateAccDescGCS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescGCS()
// ==================
// Access descriptor for memory accesses to the Guarded Control Stack

AccessDescriptor <anchor link="impl-shared.CreateAccDescGCS.2" hover="function: AccessDescriptor CreateAccDescGCS(bits(2) el, MemOp memop)">CreateAccDescGCS</anchor>(bits(2) el, <a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a>);

    accdesc.el              = el;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescGCSSS1" mylink="shared.functions.memory.CreateAccDescGCSSS1" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescGCSSS1()
// =====================
// Access descriptor for memory accesses to the Guarded Control Stack that switch stacks

AccessDescriptor <anchor link="impl-shared.CreateAccDescGCSSS1.1" hover="function: AccessDescriptor CreateAccDescGCSSS1(bits(2) el)">CreateAccDescGCSSS1</anchor>(bits(2) el)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GCS" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GCS</a>);

    accdesc.el              = el;
    accdesc.atomicop        = TRUE;
    accdesc.modop           = <a link="MemAtomicOp_GCSSS1" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_GCSSS1</a>;
    accdesc.read            = TRUE;
    accdesc.write           = TRUE;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescGPR" mylink="shared.functions.memory.CreateAccDescGPR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescGPR()
// ==================
// Access descriptor for general purpose register loads/stores
// without exclusive or ordering semantics

AccessDescriptor <anchor link="impl-shared.CreateAccDescGPR.4" hover="function: AccessDescriptor CreateAccDescGPR(MemOp memop, boolean nontemporal, boolean privileged, boolean tagchecked)">CreateAccDescGPR</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean nontemporal, boolean privileged,
                                  boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.el              = if !privileged then <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> else PSTATE.EL;
    accdesc.nontemporal     = nontemporal;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescGPTW" mylink="shared.functions.memory.CreateAccDescGPTW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescGPTW()
// ===================
// Access descriptor for Granule Protection Table walks

AccessDescriptor <anchor link="impl-shared.CreateAccDescGPTW.1" hover="function: AccessDescriptor CreateAccDescGPTW(AccessDescriptor accdesc_in)">CreateAccDescGPTW</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPTW</a>);

    accdesc.el              = accdesc_in.el;
    accdesc.ss              = accdesc_in.ss;
    accdesc.read            = TRUE;
    accdesc.mpam            = accdesc_in.mpam;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescIC" mylink="shared.functions.memory.CreateAccDescIC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescIC()
// =================
// Access descriptor for instruction cache operations

AccessDescriptor <anchor link="impl-shared.CreateAccDescIC.1" hover="function: AccessDescriptor CreateAccDescIC(CacheRecord cache)">CreateAccDescIC</anchor>(<a link="CacheRecord" file="shared_pseudocode.xml" hover="type CacheRecord is ( AccessType acctype, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, bits(64) regval, FullAddress paddress, bits(64) vaddress, integer set, integer way, integer level, Shareability shareability, boolean translated, boolean is_vmid_valid, bits(16) vmid, boolean is_asid_valid, bits(16) asid, SecurityState security, CachePASpace cpas )">CacheRecord</a> cache)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>);

    accdesc.cacheop         = cache.cacheop;
    accdesc.cachetype       = cache.cachetype;
    accdesc.opscope         = cache.opscope;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescIFetch" mylink="shared.functions.memory.CreateAccDescIFetch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescIFetch()
// =====================
// Access descriptor for instruction fetches

AccessDescriptor <anchor link="impl-shared.CreateAccDescIFetch.0" hover="function: AccessDescriptor CreateAccDescIFetch()">CreateAccDescIFetch</anchor>()
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>);

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescLDAcqPC" mylink="shared.functions.memory.CreateAccDescLDAcqPC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescLDAcqPC()
// ======================
// Access descriptor for general purpose register loads with local ordering semantics

AccessDescriptor <anchor link="impl-shared.CreateAccDescLDAcqPC.1" hover="function: AccessDescriptor CreateAccDescLDAcqPC(boolean tagchecked)">CreateAccDescLDAcqPC</anchor>(boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.acqpc           = TRUE;
    accdesc.read            = TRUE;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescLDGSTG" mylink="shared.functions.memory.CreateAccDescLDGSTG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescLDGSTG()
// =====================
// Access descriptor for tag memory loads/stores

AccessDescriptor <anchor link="impl-shared.CreateAccDescLDGSTG.1" hover="function: AccessDescriptor CreateAccDescLDGSTG(MemOp memop)">CreateAccDescLDGSTG</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.tagaccess       = TRUE;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescLOR" mylink="shared.functions.memory.CreateAccDescLOR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescLOR()
// ==================
// Access descriptor for general purpose register loads/stores with limited ordering semantics

AccessDescriptor <anchor link="impl-shared.CreateAccDescLOR.2" hover="function: AccessDescriptor CreateAccDescLOR(MemOp memop, boolean tagchecked)">CreateAccDescLOR</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.acqsc           = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.relsc           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.limitedordered  = TRUE;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescLS64" mylink="shared.functions.memory.CreateAccDescLS64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescLS64()
// ===================
// Access descriptor for accelerator-supporting memory accesses

AccessDescriptor <anchor link="impl-shared.CreateAccDescLS64.2" hover="function: AccessDescriptor CreateAccDescLS64(MemOp memop, boolean tagchecked)">CreateAccDescLS64</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.ls64            = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescMOPS" mylink="shared.functions.memory.CreateAccDescMOPS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescMOPS()
// ===================
// Access descriptor for data memory copy and set instructions

AccessDescriptor <anchor link="impl-shared.CreateAccDescMOPS.3" hover="function: AccessDescriptor CreateAccDescMOPS(MemOp memop, boolean privileged, boolean nontemporal)">CreateAccDescMOPS</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean privileged, boolean nontemporal)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.el              = if !privileged then <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> else PSTATE.EL;
    accdesc.nontemporal     = nontemporal;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.mops            = TRUE;
    accdesc.tagchecked      = TRUE;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescNV2" mylink="shared.functions.memory.CreateAccDescNV2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescNV2()
// ==================
// Access descriptor nested virtualization memory indirection loads/stores

AccessDescriptor <anchor link="impl-shared.CreateAccDescNV2.1" hover="function: AccessDescriptor CreateAccDescNV2(MemOp memop)">CreateAccDescNV2</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a>);

    accdesc.el              = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    accdesc.ss              = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescRCW" mylink="shared.functions.memory.CreateAccDescRCW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescRCW()
// ==================
// Access descriptor for atomic read-check-write memory accesses

AccessDescriptor <anchor link="impl-shared.CreateAccDescRCW.5" hover="function: AccessDescriptor CreateAccDescRCW(MemAtomicOp modop, boolean soft, boolean acquire, boolean release, boolean tagchecked)">CreateAccDescRCW</anchor>(<a link="MemAtomicOp" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp</a> modop, boolean soft, boolean acquire,
                                  boolean release, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.acqsc           = acquire;
    accdesc.relsc           = release;
    accdesc.rcw             = TRUE;
    accdesc.rcws            = soft;
    accdesc.atomicop        = TRUE;
    accdesc.modop           = modop;
    accdesc.read            = TRUE;
    accdesc.write           = TRUE;
    accdesc.pan             = TRUE;
    accdesc.tagchecked      = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescS1TTW" mylink="shared.functions.memory.CreateAccDescS1TTW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescS1TTW()
// ====================
// Access descriptor for stage 1 translation table walks

AccessDescriptor <anchor link="impl-shared.CreateAccDescS1TTW.3" hover="function: AccessDescriptor CreateAccDescS1TTW(boolean toplevel, VARange varange, AccessDescriptor accdesc_in)">CreateAccDescS1TTW</anchor>(boolean toplevel, <a link="VARange" file="shared_pseudocode.xml" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</a> varange, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>);

    accdesc.el              = accdesc_in.el;
    accdesc.ss              = accdesc_in.ss;
    accdesc.read            = TRUE;
    accdesc.toplevel        = toplevel;
    accdesc.varange         = varange;
    accdesc.mpam            = accdesc_in.mpam;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescS2TTW" mylink="shared.functions.memory.CreateAccDescS2TTW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescS2TTW()
// ====================
// Access descriptor for stage 2 translation table walks

AccessDescriptor <anchor link="impl-shared.CreateAccDescS2TTW.1" hover="function: AccessDescriptor CreateAccDescS2TTW(AccessDescriptor accdesc_in)">CreateAccDescS2TTW</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>);

    accdesc.el              = accdesc_in.el;
    accdesc.ss              = accdesc_in.ss;
    accdesc.read            = TRUE;
    accdesc.mpam            = accdesc_in.mpam;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescSME" mylink="shared.functions.memory.CreateAccDescSME" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescSME()
// ==================
// Access descriptor for SME loads/stores

AccessDescriptor <anchor link="impl-shared.CreateAccDescSME.4" hover="function: AccessDescriptor CreateAccDescSME(MemOp memop, boolean nontemporal, boolean contiguous, boolean tagchecked)">CreateAccDescSME</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean nontemporal, boolean contiguous,
                                  boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_SME" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SME</a>);

    accdesc.nontemporal     = nontemporal;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.contiguous      = contiguous;
    accdesc.streamingsve    = TRUE;
    if boolean IMPLEMENTATION_DEFINED "No tag checking of SME LDR &amp; STR instructions" then
        accdesc.tagchecked  = FALSE;
    else
        accdesc.tagchecked  = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescSPE" mylink="shared.functions.memory.CreateAccDescSPE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescSPE()
// ==================
// Access descriptor for memory accesses by Statistical Profiling unit

AccessDescriptor <anchor link="impl-shared.CreateAccDescSPE.2" hover="function: AccessDescriptor CreateAccDescSPE(SecurityState owning_ss, bits(2) owning_el)">CreateAccDescSPE</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> owning_ss, bits(2) owning_el)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>);

    accdesc.el              = owning_el;
    accdesc.ss              = owning_ss;
    accdesc.write           = TRUE;
    accdesc.mpam            = <a link="impl-shared.GenMPAMatEL.2" file="shared_pseudocode.xml" hover="function: MPAMinfo GenMPAMatEL(AccessType acctype, bits(2) el)">GenMPAMatEL</a>(<a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>, owning_el);

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescSTGMOPS" mylink="shared.functions.memory.CreateAccDescSTGMOPS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescSTGMOPS()
// ======================
// Access descriptor for tag memory set instructions

AccessDescriptor <anchor link="impl-shared.CreateAccDescSTGMOPS.2" hover="function: AccessDescriptor CreateAccDescSTGMOPS(boolean privileged, boolean nontemporal)">CreateAccDescSTGMOPS</anchor>(boolean privileged, boolean nontemporal)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_GPR" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_GPR</a>);

    accdesc.el              = if !privileged then <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> else PSTATE.EL;
    accdesc.nontemporal     = nontemporal;
    accdesc.write           = TRUE;
    accdesc.pan             = TRUE;
    accdesc.mops            = TRUE;
    accdesc.tagaccess       = TRUE;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescSVE" mylink="shared.functions.memory.CreateAccDescSVE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescSVE()
// ==================
// Access descriptor for general SVE loads/stores

AccessDescriptor <anchor link="impl-shared.CreateAccDescSVE.4" hover="function: AccessDescriptor CreateAccDescSVE(MemOp memop, boolean nontemporal, boolean contiguous, boolean tagchecked)">CreateAccDescSVE</anchor>(<a link="MemOp" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</a> memop, boolean nontemporal, boolean contiguous,
                                  boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_SVE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SVE</a>);

    accdesc.nontemporal     = nontemporal;
    accdesc.read            = memop == <a link="MemOp_LOAD" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</a>;
    accdesc.write           = memop == <a link="MemOp_STORE" file="shared_pseudocode.xml" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</a>;
    accdesc.pan             = TRUE;
    accdesc.contiguous      = contiguous;
    accdesc.streamingsve    = <a link="impl-aarch64.InStreamingMode.0" file="shared_pseudocode.xml" hover="function: boolean InStreamingMode()">InStreamingMode</a>();
    if (accdesc.streamingsve &amp;&amp; boolean IMPLEMENTATION_DEFINED
          "No tag checking of SIMD&amp;FP loads and stores in Streaming SVE mode") then
        accdesc.tagchecked  = FALSE;
    else
        accdesc.tagchecked  = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescSVEFF" mylink="shared.functions.memory.CreateAccDescSVEFF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescSVEFF()
// ====================
// Access descriptor for first-fault SVE loads

AccessDescriptor <anchor link="impl-shared.CreateAccDescSVEFF.2" hover="function: AccessDescriptor CreateAccDescSVEFF(boolean contiguous, boolean tagchecked)">CreateAccDescSVEFF</anchor>(boolean contiguous, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_SVE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SVE</a>);

    accdesc.read            = TRUE;
    accdesc.pan             = TRUE;
    accdesc.firstfault      = TRUE;
    accdesc.first           = TRUE;
    accdesc.contiguous      = contiguous;
    accdesc.streamingsve    = <a link="impl-aarch64.InStreamingMode.0" file="shared_pseudocode.xml" hover="function: boolean InStreamingMode()">InStreamingMode</a>();
    if (accdesc.streamingsve &amp;&amp; boolean IMPLEMENTATION_DEFINED
          "No tag checking of SIMD&amp;FP loads and stores in Streaming SVE mode") then
        accdesc.tagchecked  = FALSE;
    else
        accdesc.tagchecked  = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescSVENF" mylink="shared.functions.memory.CreateAccDescSVENF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescSVENF()
// ====================
// Access descriptor for non-fault SVE loads

AccessDescriptor <anchor link="impl-shared.CreateAccDescSVENF.2" hover="function: AccessDescriptor CreateAccDescSVENF(boolean contiguous, boolean tagchecked)">CreateAccDescSVENF</anchor>(boolean contiguous, boolean tagchecked)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_SVE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SVE</a>);

    accdesc.read            = TRUE;
    accdesc.pan             = TRUE;
    accdesc.nonfault        = TRUE;
    accdesc.contiguous      = contiguous;
    accdesc.streamingsve    = <a link="impl-aarch64.InStreamingMode.0" file="shared_pseudocode.xml" hover="function: boolean InStreamingMode()">InStreamingMode</a>();
    if (accdesc.streamingsve &amp;&amp; boolean IMPLEMENTATION_DEFINED
          "No tag checking of SIMD&amp;FP loads and stores in Streaming SVE mode") then
        accdesc.tagchecked  = FALSE;
    else
        accdesc.tagchecked  = tagchecked;
    accdesc.transactional   = <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescTRBE" mylink="shared.functions.memory.CreateAccDescTRBE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescTRBE()
// ===================
// Access descriptor for memory accesses by Trace Buffer Unit

AccessDescriptor <anchor link="impl-shared.CreateAccDescTRBE.2" hover="function: AccessDescriptor CreateAccDescTRBE(SecurityState owning_ss, bits(2) owning_el)">CreateAccDescTRBE</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> owning_ss, bits(2) owning_el)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_TRBE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TRBE</a>);

    accdesc.el              = owning_el;
    accdesc.ss              = owning_ss;
    accdesc.write           = TRUE;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/CreateAccDescTTEUpdate" mylink="shared.functions.memory.CreateAccDescTTEUpdate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAccDescTTEUpdate()
// ========================
// Access descriptor for translation table entry HW update

AccessDescriptor <anchor link="impl-shared.CreateAccDescTTEUpdate.1" hover="function: AccessDescriptor CreateAccDescTTEUpdate(AccessDescriptor accdesc_in)">CreateAccDescTTEUpdate</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc_in)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc = <a link="impl-shared.NewAccDesc.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</a>(<a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>);

    accdesc.el              = accdesc_in.el;
    accdesc.ss              = accdesc_in.ss;
    accdesc.atomicop        = TRUE;
    accdesc.modop           = <a link="MemAtomicOp_CAS" file="shared_pseudocode.xml" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_CAS</a>;
    accdesc.read            = TRUE;
    accdesc.write           = TRUE;
    accdesc.mpam            = accdesc_in.mpam;

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/DataMemoryBarrier" mylink="shared.functions.memory.DataMemoryBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DataMemoryBarrier()
// ===================

<anchor link="impl-shared.DataMemoryBarrier.2" hover="function: DataMemoryBarrier(MBReqDomain domain, MBReqTypes types)">DataMemoryBarrier</anchor>(<a link="MBReqDomain" file="shared_pseudocode.xml" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain</a> domain, <a link="MBReqTypes" file="shared_pseudocode.xml" hover="enumeration MBReqTypes     {MBReqTypes_Reads, MBReqTypes_Writes, MBReqTypes_All}">MBReqTypes</a> types);</pstext>
    </ps>
    <ps name="shared/functions/memory/DataSynchronizationBarrier" mylink="shared.functions.memory.DataSynchronizationBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DataSynchronizationBarrier()
// ============================

<anchor link="impl-shared.DataSynchronizationBarrier.3" hover="function: DataSynchronizationBarrier(MBReqDomain domain, MBReqTypes types, boolean nXS)">DataSynchronizationBarrier</anchor>(<a link="MBReqDomain" file="shared_pseudocode.xml" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain</a> domain, <a link="MBReqTypes" file="shared_pseudocode.xml" hover="enumeration MBReqTypes     {MBReqTypes_Reads, MBReqTypes_Writes, MBReqTypes_All}">MBReqTypes</a> types, boolean nXS);</pstext>
    </ps>
    <ps name="shared/functions/memory/DeviceType" mylink="shared.functions.memory.DeviceType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DeviceType
// ==========
// Extended memory types for Device memory.

enumeration <anchor link="DeviceType" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType</anchor> {<anchor link="DeviceType_GRE" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_GRE</anchor>, <anchor link="DeviceType_nGRE" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGRE</anchor>, <anchor link="DeviceType_nGnRE" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</anchor>, <anchor link="DeviceType_nGnRnE" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/EffectiveMTX" mylink="shared.functions.memory.EffectiveMTX" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveMTX()
// ==============
// Returns the effective MTX in the AArch64 stage 1 translation regime for "el".

bit <anchor link="impl-shared.EffectiveMTX.3" hover="function: bit EffectiveMTX(bits(64) address, boolean is_instr, bits(2) el)">EffectiveMTX</anchor>(bits(64) address, boolean is_instr, bits(2) el)
    bit mtx;
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el);
    regime = <a link="impl-shared.S1TranslationRegime.1" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</a>(el);
    assert(!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(regime));

    if !<a link="impl-shared.HaveMTE4Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE4Ext()">HaveMTE4Ext</a>() || is_instr then
        mtx = '0';
    else
        case regime of
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
                mtx = if address&lt;55&gt; == '1' then TCR_EL1.MTX1 else TCR_EL1.MTX0;
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
                if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(el) then
                    mtx = if address&lt;55&gt; == '1' then TCR_EL2.MTX1 else TCR_EL2.MTX0;
                else
                    mtx = TCR_EL2.MTX;
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
                mtx = TCR_EL3.MTX;

    return mtx;</pstext>
    </ps>
    <ps name="shared/functions/memory/EffectiveTBI" mylink="shared.functions.memory.EffectiveTBI" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveTBI()
// ==============
// Returns the effective TBI in the AArch64 stage 1 translation regime for "el".

bit <anchor link="impl-shared.EffectiveTBI.3" hover="function: bit EffectiveTBI(bits(64) address, boolean IsInstr, bits(2) el)">EffectiveTBI</anchor>(bits(64) address, boolean IsInstr, bits(2) el)
    bit tbi;
    bit tbid;
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el);
    regime = <a link="impl-shared.S1TranslationRegime.1" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</a>(el);
    assert(!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(regime));

    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            tbi = if address&lt;55&gt; == '1' then TCR_EL1.TBI1 else TCR_EL1.TBI0;
            if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>() then
                tbid = if address&lt;55&gt; == '1' then TCR_EL1.TBID1 else TCR_EL1.TBID0;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(el) then
                tbi = if address&lt;55&gt; == '1' then TCR_EL2.TBI1 else TCR_EL2.TBI0;
                if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>() then
                    tbid = if address&lt;55&gt; == '1' then TCR_EL2.TBID1 else TCR_EL2.TBID0;
            else
                tbi = TCR_EL2.TBI;
                if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>() then tbid = TCR_EL2.TBID;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            tbi = TCR_EL3.TBI;
            if <a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>() then tbid = TCR_EL3.TBID;

    return (if tbi == '1' &amp;&amp; (!<a link="impl-aarch64.HavePACExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePACExt()">HavePACExt</a>() || tbid == '0' || !IsInstr) then '1' else '0');</pstext>
    </ps>
    <ps name="shared/functions/memory/EffectiveTCMA" mylink="shared.functions.memory.EffectiveTCMA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveTCMA()
// ===============
// Returns the effective TCMA of a virtual address in the stage 1 translation regime for "el".

bit <anchor link="impl-shared.EffectiveTCMA.2" hover="function: bit EffectiveTCMA(bits(64) address, bits(2) el)">EffectiveTCMA</anchor>(bits(64) address, bits(2) el)
    bit tcma;
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el);
    regime = <a link="impl-shared.S1TranslationRegime.1" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</a>(el);
    assert(!<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(regime));

    case regime of
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            tcma = if address&lt;55&gt; == '1' then TCR_EL1.TCMA1 else TCR_EL1.TCMA0;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(el) then
                tcma = if address&lt;55&gt; == '1' then TCR_EL2.TCMA1 else TCR_EL2.TCMA0;
            else
                tcma = TCR_EL2.TCMA;
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            tcma = TCR_EL3.TCMA;

    return tcma;</pstext>
    </ps>
    <ps name="shared/functions/memory/ErrorState" mylink="shared.functions.memory.ErrorState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ErrorState
// ==========
// The allowed error states that can be returned by memory and used by the PE.

enumeration <anchor link="ErrorState" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</anchor> {<anchor link="ErrorState_UC" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UC</anchor>,            // Uncontainable
                        <anchor link="ErrorState_UEU" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEU</anchor>,           // Unrecoverable state
                        <anchor link="ErrorState_UEO" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UEO</anchor>,           // Restartable state
                        <anchor link="ErrorState_UER" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_UER</anchor>,           // Recoverable state
                        <anchor link="ErrorState_CE" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_CE</anchor>,            // Corrected
                        <anchor link="ErrorState_Uncategorized" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_Uncategorized</anchor>,
                        <anchor link="ErrorState_IMPDEF" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState_IMPDEF</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/Fault" mylink="shared.functions.memory.Fault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Fault
// =====
// Fault types.

enumeration <anchor link="Fault" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</anchor> {<anchor link="Fault_None" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</anchor>,
                   <anchor link="Fault_AccessFlag" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AccessFlag</anchor>,
                   <anchor link="Fault_Alignment" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</anchor>,
                   <anchor link="Fault_Background" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Background</anchor>,
                   <anchor link="Fault_Domain" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Domain</anchor>,
                   <anchor link="Fault_Permission" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</anchor>,
                   <anchor link="Fault_Translation" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Translation</anchor>,
                   <anchor link="Fault_AddressSize" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AddressSize</anchor>,
                   <anchor link="Fault_SyncExternal" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternal</anchor>,
                   <anchor link="Fault_SyncExternalOnWalk" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</anchor>,
                   <anchor link="Fault_SyncParity" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</anchor>,
                   <anchor link="Fault_SyncParityOnWalk" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</anchor>,
                   <anchor link="Fault_GPCFOnWalk" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</anchor>,
                   <anchor link="Fault_GPCFOnOutput" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnOutput</anchor>,
                   <anchor link="Fault_AsyncParity" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</anchor>,
                   <anchor link="Fault_AsyncExternal" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</anchor>,
                   <anchor link="Fault_TagCheck" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TagCheck</anchor>,
                   <anchor link="Fault_Debug" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Debug</anchor>,
                   <anchor link="Fault_TLBConflict" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_TLBConflict</anchor>,
                   <anchor link="Fault_BranchTarget" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_BranchTarget</anchor>,
                   <anchor link="Fault_HWUpdateAccessFlag" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_HWUpdateAccessFlag</anchor>,
                   <anchor link="Fault_Lockdown" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Lockdown</anchor>,
                   <anchor link="Fault_Exclusive" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</anchor>,
                   <anchor link="Fault_ICacheMaint" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_ICacheMaint</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/FaultRecord" mylink="shared.functions.memory.FaultRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FaultRecord
// ===========
// Fields that relate only to Faults.

type <anchor link="FaultRecord" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</anchor> is (
    <a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a>            statuscode,  // Fault Status
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> access,      // Details of the faulting access
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a>      ipaddress,   // Intermediate physical address
    <a link="GPCFRecord" file="shared_pseudocode.xml" hover="type GPCFRecord is ( GPCF gpf, integer level )">GPCFRecord</a>       gpcf,        // Granule Protection Check Fault record
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a>      paddress,    // Physical address
    boolean          gpcfs2walk,  // GPC for a stage 2 translation table walk
    boolean          s2fs1walk,   // Is on a Stage 1 translation table walk
    boolean          write,       // TRUE for a write, FALSE for a read
    boolean          s1tagnotdata,// TRUE for a fault due to tag not accessible at stage 1.
    boolean          tagaccess,   // TRUE for a fault due to NoTagAccess permission.
    integer          level,       // For translation, access flag and Permission faults
    bit              extflag,     // IMPLEMENTATION DEFINED syndrome for External aborts
    boolean          secondstage, // Is a Stage 2 abort
    boolean          assuredonly, // Stage 2 Permission fault due to AssuredOnly attribute
    boolean          toplevel,    // Stage 2 Permission fault due to TopLevel
    boolean          overlay,     // Fault due to overlay permissions
    boolean          dirtybit,    // Fault due to dirty state
    bits(4)          domain,      // Domain number, AArch32 only
    <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a>       merrorstate, // Incoming error state from memory
    bits(4)          debugmoe     // Debug method of entry, from AArch32 only
)</pstext>
    </ps>
    <ps name="shared/functions/memory/FullAddress" mylink="shared.functions.memory.FullAddress" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FullAddress
// ===========
// Physical or Intermediate Physical Address type.
// Although AArch32 only has access to 40 bits of physical or intermediate physical address space,
// the full address type has 56 bits to allow interprocessing with AArch64.
// The maximum physical or intermediate physical address size is IMPLEMENTATION DEFINED,
// but never exceeds 56 bits.

type <anchor link="FullAddress" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</anchor> is (
    <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a>  paspace,
    bits(56) address
)</pstext>
    </ps>
    <ps name="shared/functions/memory/GPCF" mylink="shared.functions.memory.GPCF" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPCF
// ====
// Possible Granule Protection Check Fault reasons

enumeration <anchor link="GPCF" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF</anchor> {
    <anchor link="GPCF_None" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</anchor>,        // No fault
    <anchor link="GPCF_AddressSize" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_AddressSize</anchor>, // GPT address size fault
    <anchor link="GPCF_Walk" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</anchor>,        // GPT walk fault
    <anchor link="GPCF_EABT" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</anchor>,        // Synchronous External abort on GPT fetch
    <anchor link="GPCF_Fail" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</anchor>         // Granule protection fault
};</pstext>
    </ps>
    <ps name="shared/functions/memory/GPCFRecord" mylink="shared.functions.memory.GPCFRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPCFRecord
// ==========
// Full details of a Granule Protection Check Fault

type <anchor link="GPCFRecord" hover="type GPCFRecord is ( GPCF gpf, integer level )">GPCFRecord</anchor> is (
    <a link="GPCF" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF</a>    gpf,
    integer level
)</pstext>
    </ps>
    <ps name="shared/functions/memory/Hint_Prefetch" mylink="shared.functions.memory.Hint_Prefetch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_Prefetch()
// ===============
// Signals the memory system that memory accesses of type HINT to or from the specified address are
// likely in the near future. The memory system may take some action to speed up the memory
// accesses when they do occur, such as pre-loading the specified address into one or more
// caches as indicated by the innermost cache level target (0=L1, 1=L2, etc) and non-temporal hint
// stream. Any or all prefetch hints may be treated as a NOP. A prefetch hint must not cause a
// synchronous abort due to Alignment or Translation faults and the like. Its only effect on
// software-visible state should be on caches and TLBs associated with address, which must be
// accessible by reads, writes or execution, as defined in the translation regime of the current
// Exception level. It is guaranteed not to access Device memory.
// A Prefetch_EXEC hint must not result in an access that could not be performed by a speculative
// instruction fetch, therefore if all associated MMUs are disabled, then it cannot access any
// memory location that cannot be accessed by instruction fetches.

<anchor link="impl-shared.Hint_Prefetch.4" hover="function: Hint_Prefetch(bits(64) address, PrefetchHint hint, integer target, boolean stream)">Hint_Prefetch</anchor>(bits(64) address, <a link="PrefetchHint" file="shared_pseudocode.xml" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">PrefetchHint</a> hint, integer target, boolean stream);</pstext>
    </ps>
    <ps name="shared/functions/memory/Hint_RangePrefetch" mylink="shared.functions.memory.Hint_RangePrefetch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_RangePrefetch()
// ====================
// Signals the memory system that data memory accesses from a specified range
// of addresses are likely to occur in the near future. The memory system can
// respond by taking actions that are expected to speed up the memory accesses
// when they do occur, such as preloading the locations within the specified
// address ranges into one or more caches.

<anchor link="impl-shared.Hint_RangePrefetch.6" hover="function: Hint_RangePrefetch(bits(64) address, integer length, integer stride, integer count, integer reuse, bits(6) operation)">Hint_RangePrefetch</anchor>(bits(64) address, integer length, integer stride,
                   integer count, integer reuse, bits(6) operation);</pstext>
    </ps>
    <ps name="shared/functions/memory/IsDataAccess" mylink="shared.functions.memory.IsDataAccess" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsDataAccess()
// ==============
// Return TRUE if access is to data memory.

boolean <anchor link="impl-shared.IsDataAccess.1" hover="function: boolean IsDataAccess(AccessType acctype)">IsDataAccess</anchor>(<a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype)
    return !(acctype IN {<a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>,
                         <a link="AccessType_TTW" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_TTW</a>,
                         <a link="AccessType_DC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_DC</a>,
                         <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>,
                         <a link="AccessType_AT" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_AT</a>});</pstext>
    </ps>
    <ps name="shared/functions/memory/MBReqDomain" mylink="shared.functions.memory.MBReqDomain" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MBReqDomain
// ===========
// Memory barrier domain.

enumeration <anchor link="MBReqDomain" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain</anchor>    {<anchor link="MBReqDomain_Nonshareable" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain_Nonshareable</anchor>, <anchor link="MBReqDomain_InnerShareable" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain_InnerShareable</anchor>,
                            <anchor link="MBReqDomain_OuterShareable" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain_OuterShareable</anchor>, <anchor link="MBReqDomain_FullSystem" hover="enumeration MBReqDomain    {MBReqDomain_Nonshareable, MBReqDomain_InnerShareable, MBReqDomain_OuterShareable, MBReqDomain_FullSystem}">MBReqDomain_FullSystem</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/MBReqTypes" mylink="shared.functions.memory.MBReqTypes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MBReqTypes
// ==========
// Memory barrier read/write.

enumeration <anchor link="MBReqTypes" hover="enumeration MBReqTypes     {MBReqTypes_Reads, MBReqTypes_Writes, MBReqTypes_All}">MBReqTypes</anchor>     {<anchor link="MBReqTypes_Reads" hover="enumeration MBReqTypes     {MBReqTypes_Reads, MBReqTypes_Writes, MBReqTypes_All}">MBReqTypes_Reads</anchor>, <anchor link="MBReqTypes_Writes" hover="enumeration MBReqTypes     {MBReqTypes_Reads, MBReqTypes_Writes, MBReqTypes_All}">MBReqTypes_Writes</anchor>, <anchor link="MBReqTypes_All" hover="enumeration MBReqTypes     {MBReqTypes_Reads, MBReqTypes_Writes, MBReqTypes_All}">MBReqTypes_All</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/MPAM" mylink="shared.functions.memory.MPAM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MPAM Types
// ==========

type <anchor link="PARTIDtype" hover="type PARTIDtype">PARTIDtype</anchor> = bits(16);

type <anchor link="PMGtype" hover="type PMGtype">PMGtype</anchor> = bits(8);

enumeration <anchor link="PARTIDspaceType" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</anchor> {
    <anchor link="PIdSpace_Secure" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Secure</anchor>,
    <anchor link="PIdSpace_Root" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Root</anchor>,
    <anchor link="PIdSpace_Realm" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Realm</anchor>,
    <anchor link="PIdSpace_NonSecure" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</anchor>
};

type <anchor link="MPAMinfo" hover="type MPAMinfo is ( PARTIDspaceType mpam_sp, PARTIDtype partid, PMGtype pmg )">MPAMinfo</anchor> is (
     <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> mpam_sp,
     <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> partid,
     <a link="PMGtype" file="shared_pseudocode.xml" hover="type PMGtype">PMGtype</a> pmg
)</pstext>
    </ps>
    <ps name="shared/functions/memory/MemAtomicOp" mylink="shared.functions.memory.MemAtomicOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemAtomicOp
// ===========
// Atomic data processing instruction types.

enumeration <anchor link="MemAtomicOp" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp</anchor> {
    <anchor link="MemAtomicOp_GCSSS1" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_GCSSS1</anchor>,
    <anchor link="MemAtomicOp_ADD" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_ADD</anchor>,
    <anchor link="MemAtomicOp_BIC" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_BIC</anchor>,
    <anchor link="MemAtomicOp_EOR" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_EOR</anchor>,
    <anchor link="MemAtomicOp_ORR" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_ORR</anchor>,
    <anchor link="MemAtomicOp_SMAX" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SMAX</anchor>,
    <anchor link="MemAtomicOp_SMIN" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SMIN</anchor>,
    <anchor link="MemAtomicOp_UMAX" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_UMAX</anchor>,
    <anchor link="MemAtomicOp_UMIN" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_UMIN</anchor>,
    <anchor link="MemAtomicOp_SWP" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_SWP</anchor>,
    <anchor link="MemAtomicOp_CAS" hover="enumeration MemAtomicOp { MemAtomicOp_GCSSS1, MemAtomicOp_ADD, MemAtomicOp_BIC, MemAtomicOp_EOR, MemAtomicOp_ORR, MemAtomicOp_SMAX, MemAtomicOp_SMIN, MemAtomicOp_UMAX, MemAtomicOp_UMIN, MemAtomicOp_SWP, MemAtomicOp_CAS }">MemAtomicOp_CAS</anchor>
};

enumeration <anchor link="CacheOp" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp</anchor> {
    <anchor link="CacheOp_Clean" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Clean</anchor>,
    <anchor link="CacheOp_Invalidate" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_Invalidate</anchor>,
    <anchor link="CacheOp_CleanInvalidate" hover="enumeration CacheOp { CacheOp_Clean, CacheOp_Invalidate, CacheOp_CleanInvalidate }">CacheOp_CleanInvalidate</anchor>
};

enumeration <anchor link="CacheOpScope" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope</anchor> {
    <anchor link="CacheOpScope_SetWay" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_SetWay</anchor>,
    <anchor link="CacheOpScope_PoU" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoU</anchor>,
    <anchor link="CacheOpScope_PoC" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoC</anchor>,
    <anchor link="CacheOpScope_PoE" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoE</anchor>,
    <anchor link="CacheOpScope_PoP" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoP</anchor>,
    <anchor link="CacheOpScope_PoDP" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_PoDP</anchor>,
    <anchor link="CacheOpScope_ALLU" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLU</anchor>,
    <anchor link="CacheOpScope_ALLUIS" hover="enumeration CacheOpScope { CacheOpScope_SetWay, CacheOpScope_PoU, CacheOpScope_PoC, CacheOpScope_PoE, CacheOpScope_PoP, CacheOpScope_PoDP, CacheOpScope_ALLU, CacheOpScope_ALLUIS }">CacheOpScope_ALLUIS</anchor>
};

enumeration <anchor link="CacheType" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType</anchor> {
    <anchor link="CacheType_Data" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data</anchor>,
    <anchor link="CacheType_Tag" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Tag</anchor>,
    <anchor link="CacheType_Data_Tag" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Data_Tag</anchor>,
    <anchor link="CacheType_Instruction" hover="enumeration CacheType { CacheType_Data, CacheType_Tag, CacheType_Data_Tag, CacheType_Instruction }">CacheType_Instruction</anchor>
};

enumeration <anchor link="CachePASpace" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CachePASpace</anchor> {
    <anchor link="CPAS_NonSecure" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_NonSecure</anchor>,
    <anchor link="CPAS_Any" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Any</anchor>,               // Applicable only for DC *SW / IC IALLU* in Root state:
                            // match entries from any PA Space
    <anchor link="CPAS_RealmNonSecure" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_RealmNonSecure</anchor>,    // Applicable only for DC *SW / IC IALLU* in Realm state:
                            // match entries from Realm or Non-Secure PAS
    <anchor link="CPAS_Realm" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Realm</anchor>,
    <anchor link="CPAS_Root" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Root</anchor>,
    <anchor link="CPAS_SecureNonSecure" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_SecureNonSecure</anchor>,   // Applicable only for DC *SW / IC IALLU* in Secure state:
                            // match entries from Secure or Non-Secure PAS
    <anchor link="CPAS_Secure" hover="enumeration CachePASpace { CPAS_NonSecure, CPAS_Any,  CPAS_RealmNonSecure,  CPAS_Realm, CPAS_Root, CPAS_SecureNonSecure,  CPAS_Secure }">CPAS_Secure</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/memory/MemAttrHints" mylink="shared.functions.memory.MemAttrHints" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemAttrHints
// ============
// Attributes and hints for Normal memory.

type <anchor link="MemAttrHints" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</anchor> is (
    bits(2) attrs,  // See MemAttr_*, Cacheability attributes
    bits(2) hints,  // See MemHint_*, Allocation hints
    boolean transient
)</pstext>
    </ps>
    <ps name="shared/functions/memory/MemOp" mylink="shared.functions.memory.MemOp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemOp
// =====
// Memory access instruction types.

enumeration <anchor link="MemOp" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp</anchor> {<anchor link="MemOp_LOAD" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_LOAD</anchor>, <anchor link="MemOp_STORE" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_STORE</anchor>, <anchor link="MemOp_PREFETCH" hover="enumeration MemOp {MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH}">MemOp_PREFETCH</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/MemType" mylink="shared.functions.memory.MemType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemType
// =======
// Basic memory types.

enumeration <anchor link="MemType" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType</anchor> {<anchor link="MemType_Normal" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</anchor>, <anchor link="MemType_Device" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/Memory" mylink="shared.functions.memory.Memory" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Memory Tag type
// ===============

enumeration <anchor link="MemTagType" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTagType</anchor> {
    <anchor link="MemTag_Untagged" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</anchor>,
    <anchor link="MemTag_AllocationTagged" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</anchor>,
    <anchor link="MemTag_CanonicallyTagged" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/memory/MemoryAttributes" mylink="shared.functions.memory.MemoryAttributes" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MemoryAttributes
// ================
// Memory attributes descriptor

type <anchor link="MemoryAttributes" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</anchor> is (
    <a link="MemType" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType</a>      memtype,
    <a link="DeviceType" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType</a>   device,       // For Device memory types
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> inner,        // Inner hints and attributes
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> outer,        // Outer hints and attributes
    <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> shareability, // Shareability attribute
    <a link="MemTagType" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTagType</a>   tags,         // MTE tag type for this memory.
    boolean      notagaccess,  // Allocation Tag access permission
    bit          xs            // XS attribute
)</pstext>
    </ps>
    <ps name="shared/functions/memory/NewAccDesc" mylink="shared.functions.memory.NewAccDesc" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NewAccDesc()
// ============
// Create a new AccessDescriptor with initialised fields

AccessDescriptor <anchor link="impl-shared.NewAccDesc.1" hover="function: AccessDescriptor NewAccDesc(AccessType acctype)">NewAccDesc</anchor>(<a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype)
    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc;

    accdesc.acctype         = acctype;
    accdesc.el              = PSTATE.EL;
    accdesc.ss              = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);
    accdesc.acqsc           = FALSE;
    accdesc.acqpc           = FALSE;
    accdesc.relsc           = FALSE;
    accdesc.limitedordered  = FALSE;
    accdesc.exclusive       = FALSE;
    accdesc.rcw             = FALSE;
    accdesc.rcws            = FALSE;
    accdesc.atomicop        = FALSE;
    accdesc.nontemporal     = FALSE;
    accdesc.read            = FALSE;
    accdesc.write           = FALSE;
    accdesc.pan             = FALSE;
    accdesc.nonfault        = FALSE;
    accdesc.firstfault      = FALSE;
    accdesc.first           = FALSE;
    accdesc.contiguous      = FALSE;
    accdesc.streamingsve    = FALSE;
    accdesc.ls64            = FALSE;
    accdesc.mops            = FALSE;
    accdesc.a32lsmd         = FALSE;
    accdesc.tagchecked      = FALSE;
    accdesc.tagaccess       = FALSE;
    accdesc.transactional   = FALSE;
    accdesc.mpam            = <a link="impl-shared.GenMPAMcurEL.1" file="shared_pseudocode.xml" hover="function: MPAMinfo GenMPAMcurEL(AccessType acctype)">GenMPAMcurEL</a>(acctype);

    return accdesc;</pstext>
    </ps>
    <ps name="shared/functions/memory/PASpace" mylink="shared.functions.memory.PASpace" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PASpace
// =======
// Physical address spaces

enumeration <anchor link="PASpace" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</anchor> {
    <anchor link="PAS_NonSecure" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</anchor>,
    <anchor link="PAS_Secure" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</anchor>,
    <anchor link="PAS_Root" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</anchor>,
    <anchor link="PAS_Realm" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/memory/Permissions" mylink="shared.functions.memory.Permissions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Permissions
// ===========
// Access Control bits in translation table descriptors

type <anchor link="Permissions" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</anchor> is (
    bits(2) ap_table,   // Stage 1 hierarchical access permissions
    bit     xn_table,   // Stage 1 hierarchical execute-never for single EL regimes
    bit     pxn_table,  // Stage 1 hierarchical privileged execute-never
    bit     uxn_table,  // Stage 1 hierarchical unprivileged execute-never
    bits(3) ap,         // Stage 1 access permissions
    bit     xn,         // Stage 1 execute-never for single EL regimes
    bit     uxn,        // Stage 1 unprivileged execute-never
    bit     pxn,        // Stage 1 privileged execute-never
    bits(4) ppi,        // Stage 1 privileged indirect permissions
    bits(4) upi,        // Stage 1 unprivileged indirect permissions
    bit     ndirty,     // Stage 1 dirty state for indirect permissions scheme
    bits(4) s2pi,       // Stage 2 indirect permissions
    bit     s2dirty,    // Stage 2 dirty state
    bits(4) po_index,   // Stage 1 overlay permissions index
    bits(4) s2po_index, // Stage 2 overlay permissions index
    bits(2) s2ap,       // Stage 2 access permissions
    bit     s2tag_na,   // Stage 2 tag access
    bit     s2xnx,      // Stage 2 extended execute-never
    bit     s2xn        // Stage 2 execute-never
)</pstext>
    </ps>
    <ps name="shared/functions/memory/PhysMemRead" mylink="shared.functions.memory.PhysMemRead" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysMemRead()
// =============
// Returns the value read from memory, and a status.
// Returned value is UNKNOWN if an External abort occurred while reading the
// memory.
// Otherwise the PhysMemRetStatus statuscode is Fault_None.

(PhysMemRetStatus, bits(8*size)) <anchor link="impl-shared.PhysMemRead.3" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> desc, integer size,
                                             <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc);</pstext>
    </ps>
    <ps name="shared/functions/memory/PhysMemRetStatus" mylink="shared.functions.memory.PhysMemRetStatus" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysMemRetStatus
// ================
// Fields that relate only to return values of PhysMem functions.

type <anchor link="PhysMemRetStatus" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</anchor> is (
    <a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a>       statuscode,     // Fault Status
    bit         extflag,        // IMPLEMENTATION DEFINED syndrome for External aborts
    <a link="ErrorState" file="shared_pseudocode.xml" hover="enumeration ErrorState {ErrorState_UC, ErrorState_UEU, ErrorState_UEO, ErrorState_UER, ErrorState_CE, ErrorState_Uncategorized, ErrorState_IMPDEF}">ErrorState</a>  merrorstate,    // Optional error state returned on a physical memory access
    bits(64)    store64bstatus  // Status of 64B store
)</pstext>
    </ps>
    <ps name="shared/functions/memory/PhysMemWrite" mylink="shared.functions.memory.PhysMemWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysMemWrite()
// ==============
// Writes the value to memory, and returns the status of the write.
// If there is an External abort on the write, the PhysMemRetStatus indicates this.
// Otherwise the statuscode of PhysMemRetStatus is Fault_None.

PhysMemRetStatus <anchor link="impl-shared.PhysMemWrite.4" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> desc, integer size, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                              bits(8*size) value);</pstext>
    </ps>
    <ps name="shared/functions/memory/PrefetchHint" mylink="shared.functions.memory.PrefetchHint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PrefetchHint
// ============
// Prefetch hint types.

enumeration <anchor link="PrefetchHint" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">PrefetchHint</anchor> {<anchor link="Prefetch_READ" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">Prefetch_READ</anchor>, <anchor link="Prefetch_WRITE" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">Prefetch_WRITE</anchor>, <anchor link="Prefetch_EXEC" hover="enumeration PrefetchHint {Prefetch_READ, Prefetch_WRITE, Prefetch_EXEC}">Prefetch_EXEC</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/memory/S1AccessControls" mylink="shared.functions.memory.S1AccessControls" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S1AccessControls
// ================
// Effective access controls defined by stage 1 translation

type <anchor link="S1AccessControls" hover="type S1AccessControls is ( bit r, bit w, bit x, bit gcs, boolean overlay, bit or, bit ow, bit ox, bit wxn )">S1AccessControls</anchor> is (
    bit r,                 // Stage 1 base read permission
    bit w,                 // Stage 1 base write permission
    bit x,                 // Stage 1 base execute permission
    bit gcs,               // Stage 1 GCS permission
    boolean overlay,       // Stage 1 overlay feature enabled
    bit or,                // Stage 1 overlay read permission
    bit ow,                // Stage 1 overlay write permission
    bit ox,                // Stage 1 overlay execute permission
    bit wxn                // Stage 1 write permission implies execute-never
)</pstext>
    </ps>
    <ps name="shared/functions/memory/S2AccessControls" mylink="shared.functions.memory.S2AccessControls" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2AccessControls
// ================
// Effective access controls defined by stage 2 translation

type <anchor link="S2AccessControls" hover="type S2AccessControls is ( bit r, bit w, bit x, bit r_rcw, bit w_rcw, bit r_mmu, bit w_mmu, bit toplevel0, bit toplevel1, boolean overlay, bit or, bit ow, bit ox, bit or_rcw, bit ow_rcw, bit or_mmu, bit ow_mmu, )">S2AccessControls</anchor> is (
    bit r,                 // Stage 2 read permission.
    bit w,                 // Stage 2 write permission.
    bit x,                 // Stage 2 execute permission.
    bit r_rcw,             // Stage 2 Read perms for RCW instruction.
    bit w_rcw,             // Stage 2 Write perms for RCW instruction.
    bit r_mmu,             // Stage 2 Read perms for TTW data.
    bit w_mmu,             // Stage 2 Write perms for TTW data.
    bit toplevel0,         // IPA as top level table for TTBR0_EL1.
    bit toplevel1,         // IPA as top level table for TTBR1_EL1.
    boolean overlay,       // Overlay enable
    bit or,                // Stage 2 overlay read permission.
    bit ow,                // Stage 2 overlay write permission.
    bit ox,                // Stage 2 overlay execute permission.
    bit or_rcw,            // Stage 2 overlay Read perms for RCW instruction.
    bit ow_rcw,            // Stage 2 overlay Write perms for RCW instruction.
    bit or_mmu,            // Stage 2 overlay Read perms for TTW data.
    bit ow_mmu,            // Stage 2 overlay Write perms for TTW data.
)</pstext>
    </ps>
    <ps name="shared/functions/memory/Shareability" mylink="shared.functions.memory.Shareability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Shareability
// ============

enumeration <anchor link="Shareability" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</anchor> {
    <anchor link="Shareability_NSH" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</anchor>,
    <anchor link="Shareability_ISH" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</anchor>,
    <anchor link="Shareability_OSH" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/memory/SpeculativeStoreBypassBarrierToPA" mylink="shared.functions.memory.SpeculativeStoreBypassBarrierToPA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SpeculativeStoreBypassBarrierToPA()
// ===================================

<anchor link="impl-shared.SpeculativeStoreBypassBarrierToPA.0" hover="function: SpeculativeStoreBypassBarrierToPA()">SpeculativeStoreBypassBarrierToPA</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/memory/SpeculativeStoreBypassBarrierToVA" mylink="shared.functions.memory.SpeculativeStoreBypassBarrierToVA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SpeculativeStoreBypassBarrierToVA()
// ===================================

<anchor link="impl-shared.SpeculativeStoreBypassBarrierToVA.0" hover="function: SpeculativeStoreBypassBarrierToVA()">SpeculativeStoreBypassBarrierToVA</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/memory/Tag" mylink="shared.functions.memory.Tag" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="LOG2_TAG_GRANULE" hover="constant integer LOG2_TAG_GRANULE = 4">LOG2_TAG_GRANULE</anchor> = 4;

constant integer <anchor link="TAG_GRANULE" hover="constant integer TAG_GRANULE = 1 &lt;&lt; LOG2_TAG_GRANULE">TAG_GRANULE</anchor> = 1 &lt;&lt; <a link="LOG2_TAG_GRANULE" file="shared_pseudocode.xml" hover="constant integer LOG2_TAG_GRANULE = 4">LOG2_TAG_GRANULE</a>;</pstext>
    </ps>
    <ps name="shared/functions/memory/VARange" mylink="shared.functions.memory.VARange" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VARange
// =======
// Virtual address ranges

enumeration <anchor link="VARange" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange</anchor> {
    <anchor link="VARange_LOWER" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_LOWER</anchor>,
    <anchor link="VARange_UPPER" hover="enumeration VARange { VARange_LOWER, VARange_UPPER }">VARange_UPPER</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/mpam/AltPARTIDspace" mylink="shared.functions.mpam.AltPARTIDspace" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AltPARTIDspace()
// ================
// From the Security state, EL and ALTSP configuration, determine
// whether to primary space or the alt space is selected and which
// PARTID space is the alternative space. Return that alternative
// PARTID space if selected or the primary space if not.

PARTIDspaceType <anchor link="impl-shared.AltPARTIDspace.3" hover="function: PARTIDspaceType AltPARTIDspace(bits(2) el, SecurityState security, PARTIDspaceType primaryPIdSpace)">AltPARTIDspace</anchor>(bits(2) el, <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security,
                                <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> primaryPIdSpace)
    case security of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            assert el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
            return primaryPIdSpace; // there is no ALTSP for Non_secure
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            assert el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
            if primaryPIdSpace == <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a> then
                return primaryPIdSpace;
            return <a link="impl-shared.AltPIdSecure.2" file="shared_pseudocode.xml" hover="function: PARTIDspaceType AltPIdSecure(bits(2) el, PARTIDspaceType primaryPIdSpace)">AltPIdSecure</a>(el, primaryPIdSpace);
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>
            assert el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
            if MPAM3_EL3.ALTSP_EL3 == '1' then
                if MPAM3_EL3.RT_ALTSP_NS == '1' then
                    return <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
                else
                    return <a link="PIdSpace_Secure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Secure</a>;
            else
                return primaryPIdSpace;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            assert el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
            return <a link="impl-shared.AltPIdRealm.2" file="shared_pseudocode.xml" hover="function: PARTIDspaceType AltPIdRealm(bits(2) el, PARTIDspaceType primaryPIdSpace)">AltPIdRealm</a>(el, primaryPIdSpace);
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/functions/mpam/AltPIdRealm" mylink="shared.functions.mpam.AltPIdRealm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AltPIdRealm()
// =============
// Compute PARTID space as either the primary PARTID space or
// alternative PARTID space in the Realm Security state.
// Helper for AltPARTIDspace.

PARTIDspaceType <anchor link="impl-shared.AltPIdRealm.2" hover="function: PARTIDspaceType AltPIdRealm(bits(2) el, PARTIDspaceType primaryPIdSpace)">AltPIdRealm</anchor>(bits(2) el, <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> primaryPIdSpace)
    <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> PIdSpace = primaryPIdSpace;
    case el of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            if <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>) then
                if !<a link="impl-shared.UsePrimarySpaceEL2.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL2()">UsePrimarySpaceEL2</a>() then
                    PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
            elsif !<a link="impl-shared.UsePrimarySpaceEL10.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL10()">UsePrimarySpaceEL10</a>() then
                PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            if !<a link="impl-shared.UsePrimarySpaceEL10.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL10()">UsePrimarySpaceEL10</a>() then
                PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if !<a link="impl-shared.UsePrimarySpaceEL2.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL2()">UsePrimarySpaceEL2</a>() then
                PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return PIdSpace;</pstext>
    </ps>
    <ps name="shared/functions/mpam/AltPIdSecure" mylink="shared.functions.mpam.AltPIdSecure" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AltPIdSecure()
// ==============
// Compute PARTID space as either the primary PARTID space or
// alternative PARTID space in the Secure Security state.
// Helper for AltPARTIDspace.

PARTIDspaceType <anchor link="impl-shared.AltPIdSecure.2" hover="function: PARTIDspaceType AltPIdSecure(bits(2) el, PARTIDspaceType primaryPIdSpace)">AltPIdSecure</anchor>(bits(2) el, <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> primaryPIdSpace)
    <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> PIdSpace = primaryPIdSpace;
    boolean el2en = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();
    case el of
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            if el2en then
                if <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>) then
                    if !<a link="impl-shared.UsePrimarySpaceEL2.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL2()">UsePrimarySpaceEL2</a>() then
                        PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
                elsif !<a link="impl-shared.UsePrimarySpaceEL10.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL10()">UsePrimarySpaceEL10</a>() then
                    PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
            elsif MPAM3_EL3.ALTSP_HEN == '0' &amp;&amp; MPAM3_EL3.ALTSP_HFC == '1' then
                PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            if el2en then
                if !<a link="impl-shared.UsePrimarySpaceEL10.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL10()">UsePrimarySpaceEL10</a>() then
                    PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
            elsif MPAM3_EL3.ALTSP_HEN == '0' &amp;&amp; MPAM3_EL3.ALTSP_HFC == '1' then
                PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if !<a link="impl-shared.UsePrimarySpaceEL2.0" file="shared_pseudocode.xml" hover="function: boolean UsePrimarySpaceEL2()">UsePrimarySpaceEL2</a>() then
                PIdSpace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return PIdSpace;</pstext>
    </ps>
    <ps name="shared/functions/mpam/DefaultMPAMinfo" mylink="shared.functions.mpam.DefaultMPAMinfo" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DefaultMPAMinfo()
// =================
// Returns default MPAM info.  The partidspace argument sets
// the PARTID space of the default MPAM information returned.

MPAMinfo <anchor link="impl-shared.DefaultMPAMinfo.1" hover="function: MPAMinfo DefaultMPAMinfo(PARTIDspaceType partidspace)">DefaultMPAMinfo</anchor>(<a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> partidspace)
    <a link="MPAMinfo" file="shared_pseudocode.xml" hover="type MPAMinfo is ( PARTIDspaceType mpam_sp, PARTIDtype partid, PMGtype pmg )">MPAMinfo</a> DefaultInfo;
    DefaultInfo.mpam_sp = partidspace;
    DefaultInfo.partid  = <a link="DefaultPARTID" file="shared_pseudocode.xml" hover="constant PARTIDtype DefaultPARTID = 0&lt;15:0&gt;">DefaultPARTID</a>;
    DefaultInfo.pmg     = <a link="DefaultPMG" file="shared_pseudocode.xml" hover="constant PMGtype DefaultPMG = 0&lt;7:0&gt;">DefaultPMG</a>;
    return DefaultInfo;</pstext>
    </ps>
    <ps name="shared/functions/mpam/DefaultPARTID" mylink="shared.functions.mpam.DefaultPARTID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant PARTIDtype <anchor link="DefaultPARTID" hover="constant PARTIDtype DefaultPARTID = 0&lt;15:0&gt;">DefaultPARTID</anchor> = 0&lt;15:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/mpam/DefaultPMG" mylink="shared.functions.mpam.DefaultPMG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant PMGtype    <anchor link="DefaultPMG" hover="constant PMGtype DefaultPMG = 0&lt;7:0&gt;">DefaultPMG</anchor> = 0&lt;7:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/mpam/GenMPAMatEL" mylink="shared.functions.mpam.GenMPAMatEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GenMPAMatEL()
// =============
// Returns MPAMinfo for the specified EL.
// May be called if MPAM is not implemented (but in an version that supports
// MPAM), MPAM is disabled, or in AArch32.  In AArch32, convert the mode to
// EL if can and use that to drive MPAM information generation.  If mode
// cannot be converted, MPAM is not implemented, or MPAM is disabled return
// default MPAM information for the current security state.

MPAMinfo <anchor link="impl-shared.GenMPAMatEL.2" hover="function: MPAMinfo GenMPAMatEL(AccessType acctype, bits(2) el)">GenMPAMatEL</anchor>(<a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype, bits(2) el)
    bits(2) mpamEL;
    boolean validEL = FALSE;
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(el);
    boolean InD = FALSE;
    boolean InSM = FALSE;
    <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> pspace = <a link="impl-shared.PARTIDspaceFromSS.1" file="shared_pseudocode.xml" hover="function: PARTIDspaceType PARTIDspaceFromSS(SecurityState security)">PARTIDspaceFromSS</a>(security);
    if pspace == <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a> &amp;&amp; !<a link="impl-shared.MPAMisEnabled.0" file="shared_pseudocode.xml" hover="function: boolean MPAMisEnabled()">MPAMisEnabled</a>() then
        return <a link="impl-shared.DefaultMPAMinfo.1" file="shared_pseudocode.xml" hover="function: MPAMinfo DefaultMPAMinfo(PARTIDspaceType partidspace)">DefaultMPAMinfo</a>(pspace);
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        (validEL, mpamEL) = <a link="impl-shared.ELFromM32.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</a>(PSTATE.M);
    else
        mpamEL = if acctype == <a link="AccessType_NV2" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_NV2</a> then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else el;
        validEL = TRUE;
    case acctype of
        when <a link="AccessType_IFETCH" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IFETCH</a>, <a link="AccessType_IC" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_IC</a>
            InD = TRUE;
        when <a link="AccessType_SME" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SME</a>
            InSM = (boolean IMPLEMENTATION_DEFINED "Shared SMCU" ||
                    boolean IMPLEMENTATION_DEFINED "MPAMSM_EL1 label precedence");
        when <a link="AccessType_ASIMD" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_ASIMD</a>
            InSM = (<a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' &amp;&amp;
                    (boolean IMPLEMENTATION_DEFINED "Shared SMCU" ||
                    boolean IMPLEMENTATION_DEFINED "MPAMSM_EL1 label precedence"));
        when <a link="AccessType_SVE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SVE</a>
            InSM = (<a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() &amp;&amp; PSTATE.SM == '1' &amp;&amp;
                    (boolean IMPLEMENTATION_DEFINED "Shared SMCU" ||
                    boolean IMPLEMENTATION_DEFINED "MPAMSM_EL1 label precedence"));
        otherwise
            // Other access types are DATA accesses
            InD = FALSE;
    if !validEL then
        return <a link="impl-shared.DefaultMPAMinfo.1" file="shared_pseudocode.xml" hover="function: MPAMinfo DefaultMPAMinfo(PARTIDspaceType partidspace)">DefaultMPAMinfo</a>(pspace);
    elsif <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; MPAMIDR_EL1.HAS_ALTSP == '1' then
        // Substitute alternative PARTID space if selected
        pspace = <a link="impl-shared.AltPARTIDspace.3" file="shared_pseudocode.xml" hover="function: PARTIDspaceType AltPARTIDspace(bits(2) el, SecurityState security, PARTIDspaceType primaryPIdSpace)">AltPARTIDspace</a>(mpamEL, security, pspace);
    if <a link="impl-shared.HaveMPAMv0p1Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMPAMv0p1Ext()">HaveMPAMv0p1Ext</a>() &amp;&amp; MPAMIDR_EL1.HAS_FORCE_NS == '1' then
        if MPAM3_EL3.FORCE_NS == '1' &amp;&amp; security == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
            pspace = <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
    if (<a link="impl-shared.HaveMPAMv0p1Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMPAMv0p1Ext()">HaveMPAMv0p1Ext</a>() || <a link="impl-shared.HaveMPAMv1p1Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMPAMv1p1Ext()">HaveMPAMv1p1Ext</a>()) &amp;&amp; MPAMIDR_EL1.HAS_SDEFLT == '1' then
        if MPAM3_EL3.SDEFLT == '1' &amp;&amp; security == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
            return <a link="impl-shared.DefaultMPAMinfo.1" file="shared_pseudocode.xml" hover="function: MPAMinfo DefaultMPAMinfo(PARTIDspaceType partidspace)">DefaultMPAMinfo</a>(pspace);
    if !<a link="impl-shared.MPAMisEnabled.0" file="shared_pseudocode.xml" hover="function: boolean MPAMisEnabled()">MPAMisEnabled</a>() then
        return <a link="impl-shared.DefaultMPAMinfo.1" file="shared_pseudocode.xml" hover="function: MPAMinfo DefaultMPAMinfo(PARTIDspaceType partidspace)">DefaultMPAMinfo</a>(pspace);
    else
        return <a link="impl-shared.genMPAM.4" file="shared_pseudocode.xml" hover="function: MPAMinfo genMPAM(bits(2) el, boolean InD, boolean InSM, PARTIDspaceType pspace)">genMPAM</a>(mpamEL, InD, InSM, pspace);</pstext>
    </ps>
    <ps name="shared/functions/mpam/GenMPAMcurEL" mylink="shared.functions.mpam.GenMPAMcurEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GenMPAMcurEL()
// ==============
// Returns MPAMinfo for the current EL and security state.
// May be called if MPAM is not implemented (but in an version that supports
// MPAM), MPAM is disabled, or in AArch32.  In AArch32, convert the mode to
// EL if can and use that to drive MPAM information generation.  If mode
// cannot be converted, MPAM is not implemented, or MPAM is disabled return
// default MPAM information for the current security state.

MPAMinfo <anchor link="impl-shared.GenMPAMcurEL.1" hover="function: MPAMinfo GenMPAMcurEL(AccessType acctype)">GenMPAMcurEL</anchor>(<a link="AccessType" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType</a> acctype)
    return <a link="impl-shared.GenMPAMatEL.2" file="shared_pseudocode.xml" hover="function: MPAMinfo GenMPAMatEL(AccessType acctype, bits(2) el)">GenMPAMatEL</a>(acctype, PSTATE.EL);</pstext>
    </ps>
    <ps name="shared/functions/mpam/MAP_vPARTID" mylink="shared.functions.mpam.MAP_vPARTID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MAP_vPARTID()
// =============
// Performs conversion of virtual PARTID into physical PARTID
// Contains all of the error checking and implementation
// choices for the conversion.

(PARTIDtype, boolean) <anchor link="impl-shared.MAP_vPARTID.1" hover="function: (PARTIDtype, boolean) MAP_vPARTID(PARTIDtype vpartid)">MAP_vPARTID</anchor>(<a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> vpartid)
    // should not ever be called if EL2 is not implemented
    // or is implemented but not enabled in the current
    // security state.
    <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> ret;
    boolean err;
    integer virt    = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vpartid);
    integer vpmrmax = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(MPAMIDR_EL1.VPMR_MAX);

    // vpartid_max is largest vpartid supported
    integer vpartid_max = (vpmrmax &lt;&lt; 2) + 3;

    // One of many ways to reduce vpartid to value less than vpartid_max.
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(vpartid) &gt; vpartid_max then
        virt = virt MOD (vpartid_max+1);

    // Check for valid mapping entry.
    if MPAMVPMV_EL2&lt;virt&gt; == '1' then
        // vpartid has a valid mapping so access the map.
        ret = <a link="impl-shared.mapvpmw.1" file="shared_pseudocode.xml" hover="function: PARTIDtype mapvpmw(integer vpartid)">mapvpmw</a>(virt);
        err = FALSE;

    // Is the default virtual PARTID valid?
    elsif MPAMVPMV_EL2&lt;0&gt; == '1' then
        // Yes, so use default mapping for vpartid == 0.
        ret = MPAMVPM0_EL2&lt;0 +: 16&gt;;
        err = FALSE;

    // Neither is valid so use default physical PARTID.
    else
        ret = <a link="DefaultPARTID" file="shared_pseudocode.xml" hover="constant PARTIDtype DefaultPARTID = 0&lt;15:0&gt;">DefaultPARTID</a>;
        err = TRUE;

    // Check that the physical PARTID is in-range.
    // This physical PARTID came from a virtual mapping entry.
    integer partid_max = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(MPAMIDR_EL1.PARTID_MAX);
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(ret) &gt; partid_max then
        // Out of range, so return default physical PARTID
        ret = <a link="DefaultPARTID" file="shared_pseudocode.xml" hover="constant PARTIDtype DefaultPARTID = 0&lt;15:0&gt;">DefaultPARTID</a>;
        err = TRUE;
    return (ret, err);</pstext>
    </ps>
    <ps name="shared/functions/mpam/MPAMisEnabled" mylink="shared.functions.mpam.MPAMisEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MPAMisEnabled()
// ===============
// Returns TRUE if MPAMisEnabled.

boolean <anchor link="impl-shared.MPAMisEnabled.0" hover="function: boolean MPAMisEnabled()">MPAMisEnabled</anchor>()
    el = <a link="impl-shared.HighestEL.0" file="shared_pseudocode.xml" hover="function: bits(2) HighestEL()">HighestEL</a>();
    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> return MPAM3_EL3.MPAMEN == '1';
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> return MPAM2_EL2.MPAMEN == '1';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> return MPAM1_EL1.MPAMEN == '1';</pstext>
    </ps>
    <ps name="shared/functions/mpam/MPAMisVirtual" mylink="shared.functions.mpam.MPAMisVirtual" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MPAMisVirtual()
// ===============
// Returns TRUE if MPAM is configured to be virtual at EL.

boolean <anchor link="impl-shared.MPAMisVirtual.1" hover="function: boolean MPAMisVirtual(bits(2) el)">MPAMisVirtual</anchor>(bits(2) el)
    return (MPAMIDR_EL1.HAS_HCR == '1' &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
            ((el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; MPAMHCR_EL2.EL0_VPMEN == '1' &amp;&amp;
               (HCR_EL2.E2H == '0' || HCR_EL2.TGE == '0')) ||
             (el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; MPAMHCR_EL2.EL1_VPMEN == '1')));</pstext>
    </ps>
    <ps name="shared/functions/mpam/PARTIDspaceFromSS" mylink="shared.functions.mpam.PARTIDspaceFromSS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PARTIDspaceFromSS()
// ===================
// Returns the primary PARTID space from the Security State.

PARTIDspaceType <anchor link="impl-shared.PARTIDspaceFromSS.1" hover="function: PARTIDspaceType PARTIDspaceFromSS(SecurityState security)">PARTIDspaceFromSS</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> security)
    case security of
        when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
            return <a link="PIdSpace_NonSecure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_NonSecure</a>;
        when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>
            return <a link="PIdSpace_Root" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Root</a>;
        when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
            return <a link="PIdSpace_Realm" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Realm</a>;
        when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
            return <a link="PIdSpace_Secure" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PIdSpace_Secure</a>;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/functions/mpam/UsePrimarySpaceEL10" mylink="shared.functions.mpam.UsePrimarySpaceEL10" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UsePrimarySpaceEL10()
// =====================
// Checks whether Primary space is configured in the
// MPAM3_EL3 and MPAM2_EL2 ALTSP control bits that affect
// MPAM ALTSP use at EL1 and EL0.

boolean <anchor link="impl-shared.UsePrimarySpaceEL10.0" hover="function: boolean UsePrimarySpaceEL10()">UsePrimarySpaceEL10</anchor>()
    if MPAM3_EL3.ALTSP_HEN == '0' then
        return MPAM3_EL3.ALTSP_HFC == '0';
    return !<a link="impl-shared.MPAMisEnabled.0" file="shared_pseudocode.xml" hover="function: boolean MPAMisEnabled()">MPAMisEnabled</a>() || !<a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() || MPAM2_EL2.ALTSP_HFC == '0';</pstext>
    </ps>
    <ps name="shared/functions/mpam/UsePrimarySpaceEL2" mylink="shared.functions.mpam.UsePrimarySpaceEL2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UsePrimarySpaceEL2()
// ====================
// Checks whether Primary space is configured in the
// MPAM3_EL3 and MPAM2_EL2 ALTSP control bits that affect
// MPAM ALTSP use at EL2.

boolean <anchor link="impl-shared.UsePrimarySpaceEL2.0" hover="function: boolean UsePrimarySpaceEL2()">UsePrimarySpaceEL2</anchor>()
    if MPAM3_EL3.ALTSP_HEN == '0' then
        return MPAM3_EL3.ALTSP_HFC == '0';
    return !<a link="impl-shared.MPAMisEnabled.0" file="shared_pseudocode.xml" hover="function: boolean MPAMisEnabled()">MPAMisEnabled</a>() || MPAM2_EL2.ALTSP_EL2 == '0';</pstext>
    </ps>
    <ps name="shared/functions/mpam/genMPAM" mylink="shared.functions.mpam.genMPAM" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// genMPAM()
// =========
// Returns MPAMinfo for exception level el.
// If InD is TRUE returns MPAM information using PARTID_I and PMG_I fields
// of MPAMel_ELx register and otherwise using PARTID_D and PMG_D fields.
// If InSM is TRUE returns MPAM information using PARTID_D and PMG_D fields
// of MPAMSM_EL1 register.
// Produces a PARTID in PARTID space pspace.

MPAMinfo <anchor link="impl-shared.genMPAM.4" hover="function: MPAMinfo genMPAM(bits(2) el, boolean InD, boolean InSM, PARTIDspaceType pspace)">genMPAM</anchor>(bits(2) el, boolean InD, boolean InSM, <a link="PARTIDspaceType" file="shared_pseudocode.xml" hover="enumeration PARTIDspaceType { PIdSpace_Secure, PIdSpace_Root, PIdSpace_Realm, PIdSpace_NonSecure }">PARTIDspaceType</a> pspace)
    <a link="MPAMinfo" file="shared_pseudocode.xml" hover="type MPAMinfo is ( PARTIDspaceType mpam_sp, PARTIDtype partid, PMGtype pmg )">MPAMinfo</a> returninfo;
    <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> partidel;
    boolean perr;
    // gstplk is guest OS application locked by the EL2 hypervisor to
    // only use EL1 the virtual machine's PARTIDs.
    boolean gstplk = (el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp;
                      MPAMHCR_EL2.GSTAPP_PLK == '1' &amp;&amp;
                      HCR_EL2.TGE == '0');
    bits(2) eff_el = if gstplk then <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> else el;
    (partidel, perr) = <a link="impl-shared.genPARTID.3" file="shared_pseudocode.xml" hover="function: (PARTIDtype, boolean) genPARTID(bits(2) el, boolean InD, boolean InSM)">genPARTID</a>(eff_el, InD, InSM);
    <a link="PMGtype" file="shared_pseudocode.xml" hover="type PMGtype">PMGtype</a> groupel  = <a link="impl-shared.genPMG.4" file="shared_pseudocode.xml" hover="function: PMGtype genPMG(bits(2) el, boolean InD, boolean InSM, boolean partid_err)">genPMG</a>(eff_el, InD, InSM, perr);
    returninfo.mpam_sp = pspace;
    returninfo.partid  = partidel;
    returninfo.pmg     = groupel;
    return returninfo;</pstext>
    </ps>
    <ps name="shared/functions/mpam/genPARTID" mylink="shared.functions.mpam.genPARTID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// genPARTID()
// ===========
// Returns physical PARTID and error boolean for exception level el.
// If InD is TRUE then PARTID is from MPAMel_ELx.PARTID_I and
// otherwise from MPAMel_ELx.PARTID_D.
// If InSM is TRUE then PARTID is from MPAMSM_EL1.PARTID_D.

(PARTIDtype, boolean) <anchor link="impl-shared.genPARTID.3" hover="function: (PARTIDtype, boolean) genPARTID(bits(2) el, boolean InD, boolean InSM)">genPARTID</anchor>(bits(2) el, boolean InD, boolean InSM)
    <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> partidel = <a link="impl-shared.getMPAM_PARTID.3" file="shared_pseudocode.xml" hover="function: PARTIDtype getMPAM_PARTID(bits(2) MPAMn, boolean InD, boolean InSM)">getMPAM_PARTID</a>(el, InD, InSM);
    <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> partid_max = MPAMIDR_EL1.PARTID_MAX;
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(partidel) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(partid_max) then
        return (<a link="DefaultPARTID" file="shared_pseudocode.xml" hover="constant PARTIDtype DefaultPARTID = 0&lt;15:0&gt;">DefaultPARTID</a>, TRUE);
    if <a link="impl-shared.MPAMisVirtual.1" file="shared_pseudocode.xml" hover="function: boolean MPAMisVirtual(bits(2) el)">MPAMisVirtual</a>(el) then
        return <a link="impl-shared.MAP_vPARTID.1" file="shared_pseudocode.xml" hover="function: (PARTIDtype, boolean) MAP_vPARTID(PARTIDtype vpartid)">MAP_vPARTID</a>(partidel);
    else
        return (partidel, FALSE);</pstext>
    </ps>
    <ps name="shared/functions/mpam/genPMG" mylink="shared.functions.mpam.genPMG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// genPMG()
// ========
// Returns PMG for exception level el and I- or D-side (InD).
// If PARTID generation (genPARTID) encountered an error, genPMG() should be
// called with partid_err as TRUE.

PMGtype <anchor link="impl-shared.genPMG.4" hover="function: PMGtype genPMG(bits(2) el, boolean InD, boolean InSM, boolean partid_err)">genPMG</anchor>(bits(2) el, boolean InD, boolean InSM, boolean partid_err)
    integer pmg_max = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(MPAMIDR_EL1.PMG_MAX);
    // It is CONSTRAINED UNPREDICTABLE whether partid_err forces PMG to
    // use the default or if it uses the PMG from getMPAM_PMG.
    if partid_err then
        return <a link="DefaultPMG" file="shared_pseudocode.xml" hover="constant PMGtype DefaultPMG = 0&lt;7:0&gt;">DefaultPMG</a>;
    <a link="PMGtype" file="shared_pseudocode.xml" hover="type PMGtype">PMGtype</a> groupel = <a link="impl-shared.getMPAM_PMG.3" file="shared_pseudocode.xml" hover="function: PMGtype getMPAM_PMG(bits(2) MPAMn, boolean InD, boolean InSM)">getMPAM_PMG</a>(el, InD, InSM);
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(groupel) &lt;= pmg_max then
        return groupel;
    return <a link="DefaultPMG" file="shared_pseudocode.xml" hover="constant PMGtype DefaultPMG = 0&lt;7:0&gt;">DefaultPMG</a>;</pstext>
    </ps>
    <ps name="shared/functions/mpam/getMPAM_PARTID" mylink="shared.functions.mpam.getMPAM_PARTID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// getMPAM_PARTID()
// ================
// Returns a PARTID from one of the MPAMn_ELx or MPAMSM_EL1 registers.
// If InSM is TRUE, the MPAMSM_EL1 register is used. Otherwise,
// MPAMn selects the MPAMn_ELx register used.
// If InD is TRUE, selects the PARTID_I field of that
// register.  Otherwise, selects the PARTID_D field.

PARTIDtype <anchor link="impl-shared.getMPAM_PARTID.3" hover="function: PARTIDtype getMPAM_PARTID(bits(2) MPAMn, boolean InD, boolean InSM)">getMPAM_PARTID</anchor>(bits(2) MPAMn, boolean InD, boolean InSM)
    <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> partid;
    boolean el2avail = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    if InSM then
        partid = MPAMSM_EL1.PARTID_D;
        return partid;

    if InD then
        case MPAMn of
            when '11' partid = MPAM3_EL3.PARTID_I;
            when '10' partid = if el2avail then MPAM2_EL2.PARTID_I else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
            when '01' partid = MPAM1_EL1.PARTID_I;
            when '00' partid = MPAM0_EL1.PARTID_I;
            otherwise partid = <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> UNKNOWN;
    else
        case MPAMn of
            when '11' partid = MPAM3_EL3.PARTID_D;
            when '10' partid = if el2avail then MPAM2_EL2.PARTID_D else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16);
            when '01' partid = MPAM1_EL1.PARTID_D;
            when '00' partid = MPAM0_EL1.PARTID_D;
            otherwise partid = <a link="PARTIDtype" file="shared_pseudocode.xml" hover="type PARTIDtype">PARTIDtype</a> UNKNOWN;
    return partid;</pstext>
    </ps>
    <ps name="shared/functions/mpam/getMPAM_PMG" mylink="shared.functions.mpam.getMPAM_PMG" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// getMPAM_PMG()
// =============
// Returns a PMG from one of the MPAMn_ELx or MPAMSM_EL1 registers.
// If InSM is TRUE, the MPAMSM_EL1 register is used. Otherwise,
// MPAMn selects the MPAMn_ELx register used.
// If InD is TRUE, selects the PMG_I field of that
// register.  Otherwise, selects the PMG_D field.

PMGtype <anchor link="impl-shared.getMPAM_PMG.3" hover="function: PMGtype getMPAM_PMG(bits(2) MPAMn, boolean InD, boolean InSM)">getMPAM_PMG</anchor>(bits(2) MPAMn, boolean InD, boolean InSM)
    <a link="PMGtype" file="shared_pseudocode.xml" hover="type PMGtype">PMGtype</a> pmg;
    boolean el2avail = <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    if InSM then
        pmg = MPAMSM_EL1.PMG_D;
        return pmg;

    if InD then
        case MPAMn of
            when '11' pmg = MPAM3_EL3.PMG_I;
            when '10' pmg = if el2avail then MPAM2_EL2.PMG_I else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
            when '01' pmg = MPAM1_EL1.PMG_I;
            when '00' pmg = MPAM0_EL1.PMG_I;
            otherwise pmg = <a link="PMGtype" file="shared_pseudocode.xml" hover="type PMGtype">PMGtype</a> UNKNOWN;
    else
        case MPAMn of
            when '11' pmg = MPAM3_EL3.PMG_D;
            when '10' pmg = if el2avail then MPAM2_EL2.PMG_D else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8);
            when '01' pmg = MPAM1_EL1.PMG_D;
            when '00' pmg = MPAM0_EL1.PMG_D;
            otherwise pmg = <a link="PMGtype" file="shared_pseudocode.xml" hover="type PMGtype">PMGtype</a> UNKNOWN;
    return pmg;</pstext>
    </ps>
    <ps name="shared/functions/mpam/mapvpmw" mylink="shared.functions.mpam.mapvpmw" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// mapvpmw()
// =========
// Map a virtual PARTID into a physical PARTID using
// the MPAMVPMn_EL2 registers.
// vpartid is now assumed in-range and valid (checked by caller)
// returns physical PARTID from mapping entry.

PARTIDtype <anchor link="impl-shared.mapvpmw.1" hover="function: PARTIDtype mapvpmw(integer vpartid)">mapvpmw</anchor>(integer vpartid)
    bits(64) vpmw;
    integer  wd = vpartid DIV 4;
    case wd of
        when 0 vpmw = MPAMVPM0_EL2;
        when 1 vpmw = MPAMVPM1_EL2;
        when 2 vpmw = MPAMVPM2_EL2;
        when 3 vpmw = MPAMVPM3_EL2;
        when 4 vpmw = MPAMVPM4_EL2;
        when 5 vpmw = MPAMVPM5_EL2;
        when 6 vpmw = MPAMVPM6_EL2;
        when 7 vpmw = MPAMVPM7_EL2;
        otherwise vpmw = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    // vpme_lsb selects LSB of field within register
    integer vpme_lsb = (vpartid MOD 4) * 16;
    return vpmw&lt;vpme_lsb +: 16&gt;;</pstext>
    </ps>
    <ps name="shared/functions/predictionrestrict/ASID" mylink="shared.functions.predictionrestrict.ASID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ASID[]
// ======
// Effective ASID.

bits(16) <anchor link="impl-shared.ASID.read.0" hover="accessor: bits(16) ASID[]">ASID</anchor>[]
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; HCR_EL2.&lt;E2H, TGE&gt; == '11' then
        if TCR_EL2.A1 == '1' then
            return TTBR1_EL2.ASID;
        else
            return TTBR0_EL2.ASID;

    elsif !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        if TCR_EL1.A1 == '1' then
            return TTBR1_EL1.ASID;
        else
            return TTBR0_EL1.ASID;

    else
        if TTBCR.EAE == '0' then
            return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(CONTEXTIDR.ASID, 16);
        else
            if TTBCR.A1 == '1' then
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR1.ASID, 16);
            else
                return <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(TTBR0.ASID, 16);</pstext>
    </ps>
    <ps name="shared/functions/predictionrestrict/ExecutionCntxt" mylink="shared.functions.predictionrestrict.ExecutionCntxt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExecutionCntxt
// ===============
// Context information for prediction restriction operation.

type <anchor link="ExecutionCntxt" hover="type ExecutionCntxt is ( boolean is_vmid_valid, boolean all_vmid, bits(16) vmid, boolean is_asid_valid, boolean all_asid, bits(16) asid, bits(2) target_el, SecurityState security, RestrictType restriction )">ExecutionCntxt</anchor> is (
    boolean          is_vmid_valid, // is vmid valid for current context
    boolean          all_vmid,      // should the operation be applied for all vmids
    bits(16)         vmid,          // if all_vmid = FALSE, vmid to which operation is applied
    boolean          is_asid_valid, // is asid valid for current context
    boolean          all_asid,      // should the operation be applied for all asids
    bits(16)         asid,          // if all_asid = FALSE, ASID to which operation is applied
    bits(2)          target_el,     // target EL at which operation is performed
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a>    security,
    <a link="RestrictType" file="shared_pseudocode.xml" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType</a>     restriction    // type of restriction operation
)</pstext>
    </ps>
    <ps name="shared/functions/predictionrestrict/RESTRICT_PREDICTIONS" mylink="shared.functions.predictionrestrict.RESTRICT_PREDICTIONS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RESTRICT_PREDICTIONS()
// ======================
// Clear all speculated values.

<anchor link="impl-shared.RESTRICT_PREDICTIONS.1" hover="function: RESTRICT_PREDICTIONS(ExecutionCntxt c)">RESTRICT_PREDICTIONS</anchor>(<a link="ExecutionCntxt" file="shared_pseudocode.xml" hover="type ExecutionCntxt is ( boolean is_vmid_valid, boolean all_vmid, bits(16) vmid, boolean is_asid_valid, boolean all_asid, bits(16) asid, bits(2) target_el, SecurityState security, RestrictType restriction )">ExecutionCntxt</a> c)
    IMPLEMENTATION_DEFINED;</pstext>
    </ps>
    <ps name="shared/functions/predictionrestrict/RestrictType" mylink="shared.functions.predictionrestrict.RestrictType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RestrictType
// ============
// Type of restriction on speculation.

enumeration <anchor link="RestrictType" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType</anchor> {
    <anchor link="RestrictType_DataValue" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType_DataValue</anchor>,
    <anchor link="RestrictType_ControlFlow" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType_ControlFlow</anchor>,
    <anchor link="RestrictType_CachePrefetch" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType_CachePrefetch</anchor>,
    <anchor link="RestrictType_Other" hover="enumeration RestrictType { RestrictType_DataValue, RestrictType_ControlFlow, RestrictType_CachePrefetch, RestrictType_Other }">RestrictType_Other</anchor>              // Any other trained speculation mechanisms than those above
};</pstext>
    </ps>
    <ps name="shared/functions/predictionrestrict/TargetSecurityState" mylink="shared.functions.predictionrestrict.TargetSecurityState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TargetSecurityState()
// =====================
// Decode the target security state for the prediction context.

SecurityState <anchor link="impl-shared.TargetSecurityState.2" hover="function: SecurityState TargetSecurityState(bit NS, bit NSE)">TargetSecurityState</anchor>(bit NS, bit NSE)
    curr_ss =  <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);
    if curr_ss == <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> then
        return <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
    elsif curr_ss == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> then
        case NS of
            when '0' return <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
            when '1' return <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
    elsif <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        if curr_ss == <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a> then
            case NSE:NS of
                when '00' return <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
                when '01' return <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
                when '11' return <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>;
                when '10' return <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>;
        elsif curr_ss == <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a> then
            return <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>;</pstext>
    </ps>
    <ps name="shared/functions/registers/BranchTo" mylink="shared.functions.registers.BranchTo" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchTo()
// ==========
// Set program counter to a new address, with a branch type.
// Parameter branch_conditional indicates whether the executed branch has a conditional encoding.
// In AArch64 state the address might include a tag in the top eight bits.

<anchor link="impl-shared.BranchTo.3" hover="function: BranchTo(bits(N) target, BranchType branch_type, boolean branch_conditional)">BranchTo</anchor>(bits(N) target, <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type, boolean branch_conditional)
    <a link="impl-shared.Hint_Branch.1" file="shared_pseudocode.xml" hover="function: Hint_Branch(BranchType hint)">Hint_Branch</a>(branch_type);
    if N == 32 then
        assert <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
        _PC = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(target, 64);
    else
        assert N == 64 &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
        bits(64) target_vaddress = <a link="AArch64.BranchAddr.2" file="shared_pseudocode.xml" hover="function: bits(64) AArch64.BranchAddr(bits(64) vaddress, bits(2) el)">AArch64.BranchAddr</a>(target&lt;63:0&gt;, PSTATE.EL);
        if (<a link="impl-shared.HaveBRBExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBRBExt()">HaveBRBExt</a>() &amp;&amp;
            branch_type IN {<a link="BranchType_DIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</a>, <a link="BranchType_INDIR" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</a>,
                            <a link="BranchType_DIRCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIRCALL</a>, <a link="BranchType_INDCALL" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDCALL</a>,
                            <a link="BranchType_RET" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RET</a>}) then
            <a link="impl-aarch64.BRBEBranch.3" file="shared_pseudocode.xml" hover="function: BRBEBranch(BranchType br_type, boolean cond, bits(64) target_address)">BRBEBranch</a>(branch_type, branch_conditional, target_vaddress);
        boolean branch_taken = TRUE;

        if <a link="impl-shared.HaveStatisticalProfiling.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfiling()">HaveStatisticalProfiling</a>() then
            <a link="impl-aarch64.SPEBranch.4" file="shared_pseudocode.xml" hover="function: SPEBranch(bits(N) target, BranchType branch_type, boolean conditional, boolean taken_flag)">SPEBranch</a>(target, branch_type, branch_conditional, branch_taken);

        _PC = target_vaddress;
    return;</pstext>
    </ps>
    <ps name="shared/functions/registers/BranchToAddr" mylink="shared.functions.registers.BranchToAddr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchToAddr()
// ==============
// Set program counter to a new address, with a branch type.
// In AArch64 state the address does not include a tag in the top eight bits.

<anchor link="impl-shared.BranchToAddr.2" hover="function: BranchToAddr(bits(N) target, BranchType branch_type)">BranchToAddr</anchor>(bits(N) target, <a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branch_type)
    <a link="impl-shared.Hint_Branch.1" file="shared_pseudocode.xml" hover="function: Hint_Branch(BranchType hint)">Hint_Branch</a>(branch_type);
    if N == 32 then
        assert <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
        _PC = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(target, 64);
    else
        assert N == 64 &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
        _PC = target&lt;63:0&gt;;
    return;</pstext>
    </ps>
    <ps name="shared/functions/registers/BranchType" mylink="shared.functions.registers.BranchType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchType
// ==========
// Information associated with a change in control flow.

enumeration <anchor link="BranchType" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</anchor> {
    <anchor link="BranchType_DIRCALL" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIRCALL</anchor>,     // Direct Branch with link
    <anchor link="BranchType_INDCALL" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDCALL</anchor>,     // Indirect Branch with link
    <anchor link="BranchType_ERET" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_ERET</anchor>,        // Exception return (indirect)
    <anchor link="BranchType_DBGEXIT" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DBGEXIT</anchor>,     // Exit from Debug state
    <anchor link="BranchType_RET" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RET</anchor>,         // Indirect branch with function return hint
    <anchor link="BranchType_DIR" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_DIR</anchor>,         // Direct branch
    <anchor link="BranchType_INDIR" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_INDIR</anchor>,       // Indirect branch
    <anchor link="BranchType_EXCEPTION" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_EXCEPTION</anchor>,   // Exception entry
    <anchor link="BranchType_TMFAIL" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_TMFAIL</anchor>,      // Transaction failure
    <anchor link="BranchType_RESET" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_RESET</anchor>,       // Reset
    <anchor link="BranchType_UNKNOWN" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType_UNKNOWN</anchor>};   // Other</pstext>
    </ps>
    <ps name="shared/functions/registers/Hint_Branch" mylink="shared.functions.registers.Hint_Branch" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_Branch()
// =============
// Report the hint passed to BranchTo() and BranchToAddr(), for consideration when processing
// the next instruction.

<anchor link="impl-shared.Hint_Branch.1" hover="function: Hint_Branch(BranchType hint)">Hint_Branch</anchor>(<a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> hint);</pstext>
    </ps>
    <ps name="shared/functions/registers/NextInstrAddr" mylink="shared.functions.registers.NextInstrAddr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NextInstrAddr()
// ===============
// Return address of the sequentially next instruction.

bits(N) <anchor link="impl-shared.NextInstrAddr.1" hover="function: bits(N) NextInstrAddr(integer N)">NextInstrAddr</anchor>(integer N);</pstext>
    </ps>
    <ps name="shared/functions/registers/ResetExternalDebugRegisters" mylink="shared.functions.registers.ResetExternalDebugRegisters" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ResetExternalDebugRegisters()
// =============================
// Reset the External Debug registers in the Core power domain.

<anchor link="impl-shared.ResetExternalDebugRegisters.1" hover="function: ResetExternalDebugRegisters(boolean cold_reset)">ResetExternalDebugRegisters</anchor>(boolean cold_reset);</pstext>
    </ps>
    <ps name="shared/functions/registers/ThisInstrAddr" mylink="shared.functions.registers.ThisInstrAddr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ThisInstrAddr()
// ===============
// Return address of the current instruction.

bits(N) <anchor link="impl-shared.ThisInstrAddr.1" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</anchor>(integer N)
    assert N == 64 || (N == 32 &amp;&amp; <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>());
    return _PC&lt;N-1:0&gt;;</pstext>
    </ps>
    <ps name="shared/functions/registers/_PC" mylink="shared.functions.registers._PC" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(64) _PC;</pstext>
    </ps>
    <ps name="shared/functions/registers/_R" mylink="shared.functions.registers._R" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// _R[] - the general-purpose register file
// ========================================

array bits(64) _R[0..30];</pstext>
    </ps>
    <ps name="shared/functions/sysregisters/SPSR" mylink="shared.functions.sysregisters.SPSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SPSR[] - non-assignment form
// ============================

bits(N) <anchor link="impl-shared.SPSR.read.0" hover="accessor: bits(N) SPSR[]">SPSR</anchor>[]
    bits(N) result;
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        assert N == 32;
        case PSTATE.M of
            when <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>      result = SPSR_fiq&lt;N-1:0&gt;;
            when <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>      result = SPSR_irq&lt;N-1:0&gt;;
            when <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>      result = SPSR_svc&lt;N-1:0&gt;;
            when <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>  result = SPSR_mon&lt;N-1:0&gt;;
            when <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>    result = SPSR_abt&lt;N-1:0&gt;;
            when <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>      result = SPSR_hyp&lt;N-1:0&gt;;
            when <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>    result = SPSR_und&lt;N-1:0&gt;;
            otherwise         <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    else
        assert N == 64;
        case PSTATE.EL of
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>          result = SPSR_EL1&lt;N-1:0&gt;;
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>          result = SPSR_EL2&lt;N-1:0&gt;;
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>          result = SPSR_EL3&lt;N-1:0&gt;;
            otherwise         <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return result;

// SPSR[] - assignment form
// ========================

<anchor link="impl-shared.SPSR.write.0" hover="accessor: SPSR[] = bits(N) value">SPSR</anchor>[] = bits(N) value
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        assert N == 32;
        case PSTATE.M of
            when <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>      SPSR_fiq&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>      SPSR_irq&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>      SPSR_svc&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>  SPSR_mon&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>    SPSR_abt&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>      SPSR_hyp&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>    SPSR_und&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            otherwise         <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    else
        assert N == 64;
        case PSTATE.EL of
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>          SPSR_EL1&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>          SPSR_EL2&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>          SPSR_EL3&lt;N-1:0&gt; = value&lt;N-1:0&gt;;
            otherwise         <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return;</pstext>
    </ps>
    <ps name="shared/functions/system/AArch64.ChkFeat" mylink="shared.functions.system.AArch64.ChkFeat" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AArch64.ChkFeat()
// =================
// Indicates the status of some features

bits(64) <anchor link="AArch64.ChkFeat.1" hover="function: bits(64) AArch64.ChkFeat(bits(64) feat_select)">AArch64.ChkFeat</anchor>(bits(64) feat_select)
    bits(64) feat_en = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
    feat_en[0] = if <a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() &amp;&amp; <a link="impl-aarch64.GCSEnabled.1" file="shared_pseudocode.xml" hover="function: boolean GCSEnabled(bits(2) el)">GCSEnabled</a>(PSTATE.EL) then '1' else '0';
    return feat_select AND NOT(feat_en);</pstext>
    </ps>
    <ps name="shared/functions/system/BranchTargetCheck" mylink="shared.functions.system.BranchTargetCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchTargetCheck()
// ===================
// This function is executed checks if the current instruction is a valid target for a branch
// taken into, or inside, a guarded page. It is executed on every cycle once the current
// instruction has been decoded and the values of InGuardedPage and BTypeCompatible have been
// determined for the current instruction.

<anchor link="impl-shared.BranchTargetCheck.0" hover="function: BranchTargetCheck()">BranchTargetCheck</anchor>()
    assert <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();

    // The branch target check considers two state variables:
    // * InGuardedPage, which is evaluated during instruction fetch.
    // * BTypeCompatible, which is evaluated during instruction decode.
    if InGuardedPage &amp;&amp; PSTATE.BTYPE != '00' &amp;&amp; !BTypeCompatible &amp;&amp; !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() then
        bits(64) pc = <a link="impl-shared.ThisInstrAddr.1" file="shared_pseudocode.xml" hover="function: bits(N) ThisInstrAddr(integer N)">ThisInstrAddr</a>(64);
        <a link="AArch64.BranchTargetException.1" file="shared_pseudocode.xml" hover="function: AArch64.BranchTargetException(bits(52) vaddress)">AArch64.BranchTargetException</a>(pc&lt;51:0&gt;);

    boolean branch_instr = <a link="AArch64.ExecutingBROrBLROrRetInstr.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.ExecutingBROrBLROrRetInstr()">AArch64.ExecutingBROrBLROrRetInstr</a>();
    boolean bti_instr    = <a link="AArch64.ExecutingBTIInstr.0" file="shared_pseudocode.xml" hover="function: boolean AArch64.ExecutingBTIInstr()">AArch64.ExecutingBTIInstr</a>();

    // PSTATE.BTYPE defaults to 00 for instructions that do not explictly set BTYPE.
    if !(branch_instr || bti_instr) then
        BTypeNext = '00';</pstext>
    </ps>
    <ps name="shared/functions/system/ClearEventRegister" mylink="shared.functions.system.ClearEventRegister" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ClearEventRegister()
// ====================
// Clear the Event Register of this PE.

<anchor link="impl-shared.ClearEventRegister.0" hover="function: ClearEventRegister()">ClearEventRegister</anchor>()
    EventRegister = '0';
    return;</pstext>
    </ps>
    <ps name="shared/functions/system/ConditionHolds" mylink="shared.functions.system.ConditionHolds" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConditionHolds()
// ================
// Return TRUE iff COND currently holds

boolean <anchor link="impl-shared.ConditionHolds.1" hover="function: boolean ConditionHolds(bits(4) cond)">ConditionHolds</anchor>(bits(4) cond)
    // Evaluate base condition.
    boolean result;
    case cond&lt;3:1&gt; of
        when '000' result = (PSTATE.Z == '1');                          // EQ or NE
        when '001' result = (PSTATE.C == '1');                          // CS or CC
        when '010' result = (PSTATE.N == '1');                          // MI or PL
        when '011' result = (PSTATE.V == '1');                          // VS or VC
        when '100' result = (PSTATE.C == '1' &amp;&amp; PSTATE.Z == '0');       // HI or LS
        when '101' result = (PSTATE.N == PSTATE.V);                     // GE or LT
        when '110' result = (PSTATE.N == PSTATE.V &amp;&amp; PSTATE.Z == '0');  // GT or LE
        when '111' result = TRUE;                                       // AL

    // Condition flag values in the set '111x' indicate always true
    // Otherwise, invert condition if necessary.
    if cond&lt;0&gt; == '1' &amp;&amp; cond != '1111' then
        result = !result;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/system/ConsumptionOfSpeculativeDataBarrier" mylink="shared.functions.system.ConsumptionOfSpeculativeDataBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConsumptionOfSpeculativeDataBarrier()
// =====================================

<anchor link="impl-shared.ConsumptionOfSpeculativeDataBarrier.0" hover="function: ConsumptionOfSpeculativeDataBarrier()">ConsumptionOfSpeculativeDataBarrier</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/CurrentInstrSet" mylink="shared.functions.system.CurrentInstrSet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentInstrSet()
// =================

InstrSet <anchor link="impl-shared.CurrentInstrSet.0" hover="function: InstrSet CurrentInstrSet()">CurrentInstrSet</anchor>()
    <a link="InstrSet" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet</a> result;
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then
        result = if PSTATE.T == '0' then <a link="InstrSet_A32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</a> else <a link="InstrSet_T32" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</a>;
        // PSTATE.J is RES0. Implementation of T32EE or Jazelle state not permitted.
    else
        result = <a link="InstrSet_A64" file="shared_pseudocode.xml" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A64</a>;
    return result;</pstext>
    </ps>
    <ps name="shared/functions/system/CurrentPL" mylink="shared.functions.system.CurrentPL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentPL()
// ===========

PrivilegeLevel <anchor link="impl-shared.CurrentPL.0" hover="function: PrivilegeLevel CurrentPL()">CurrentPL</anchor>()
    return <a link="impl-shared.PLOfEL.1" file="shared_pseudocode.xml" hover="function: PrivilegeLevel PLOfEL(bits(2) el)">PLOfEL</a>(PSTATE.EL);</pstext>
    </ps>
    <ps name="shared/functions/system/CurrentSecurityState" mylink="shared.functions.system.CurrentSecurityState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CurrentSecurityState()
// ======================
// Returns the effective security state at the exception level based off current settings.

SecurityState <anchor link="impl-shared.CurrentSecurityState.0" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</anchor>()
    return <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(PSTATE.EL);</pstext>
    </ps>
    <ps name="shared/functions/system/DSBAlias" mylink="shared.functions.system.DSBAlias" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DSBAlias
// ========
// Aliases of DSB.

enumeration <anchor link="DSBAlias" hover="enumeration DSBAlias {DSBAlias_SSBB, DSBAlias_PSSBB, DSBAlias_DSB}">DSBAlias</anchor> {<anchor link="DSBAlias_SSBB" hover="enumeration DSBAlias {DSBAlias_SSBB, DSBAlias_PSSBB, DSBAlias_DSB}">DSBAlias_SSBB</anchor>, <anchor link="DSBAlias_PSSBB" hover="enumeration DSBAlias {DSBAlias_SSBB, DSBAlias_PSSBB, DSBAlias_DSB}">DSBAlias_PSSBB</anchor>, <anchor link="DSBAlias_DSB" hover="enumeration DSBAlias {DSBAlias_SSBB, DSBAlias_PSSBB, DSBAlias_DSB}">DSBAlias_DSB</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/system/EL0" mylink="shared.functions.system.EL0" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(2) <anchor link="EL3" hover="constant bits(2) EL3 = '11'">EL3</anchor> = '11';
constant bits(2) <anchor link="EL2" hover="constant bits(2) EL2 = '10'">EL2</anchor> = '10';
constant bits(2) <anchor link="EL1" hover="constant bits(2) EL1 = '01'">EL1</anchor> = '01';
constant bits(2) <anchor link="EL0" hover="constant bits(2) EL0 = '00'">EL0</anchor> = '00';</pstext>
    </ps>
    <ps name="shared/functions/system/EL2Enabled" mylink="shared.functions.system.EL2Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EL2Enabled()
// ============
// Returns TRUE if EL2 is present and executing
// - with the PE in Non-secure state when Non-secure EL2 is implemented, or
// - with the PE in Realm state when Realm EL2 is implemented, or
// - with the PE in Secure state when Secure EL2 is implemented and enabled, or
// - when EL3 is not implemented.

boolean <anchor link="impl-shared.EL2Enabled.0" hover="function: boolean EL2Enabled()">EL2Enabled</anchor>()
    return <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (!<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].NS == '1' || <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>());</pstext>
    </ps>
    <ps name="shared/functions/system/EL3SDDUndef" mylink="shared.functions.system.EL3SDDUndef" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EL3SDDUndef()
// =============
// Returns TRUE if in Debug state and EDSCR.SDD is set.

boolean <anchor link="impl-shared.EL3SDDUndef.0" hover="function: boolean EL3SDDUndef()">EL3SDDUndef</anchor>()
    return <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.SDD == '1';</pstext>
    </ps>
    <ps name="shared/functions/system/EL3SDDUndefPriority" mylink="shared.functions.system.EL3SDDUndefPriority" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EL3SDDUndefPriority()
// =====================
// Returns TRUE if in Debug state, EDSCR.SDD is set, and an EL3 trap by an
// EL3 control register has priority over other traps.
// The IMPLEMENTATION DEFINED priority may be different for each case.

boolean <anchor link="impl-shared.EL3SDDUndefPriority.0" hover="function: boolean EL3SDDUndefPriority()">EL3SDDUndefPriority</anchor>()
    return (<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.SDD == '1' &amp;&amp;
            boolean IMPLEMENTATION_DEFINED "<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> trap priority when SDD == '1'");</pstext>
    </ps>
    <ps name="shared/functions/system/ELFromM32" mylink="shared.functions.system.ELFromM32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELFromM32()
// ===========

(boolean,bits(2)) <anchor link="impl-shared.ELFromM32.1" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</anchor>(bits(5) mode)
    // Convert an AArch32 mode encoding to an Exception level.
    // Returns (valid,EL):
    //   'valid' is TRUE if 'mode&lt;4:0&gt;' encodes a mode that is both valid for this implementation
    //           and the current value of SCR.NS/SCR_EL3.NS.
    //   'EL'    is the Exception level decoded from 'mode'.
    bits(2) el;
    boolean valid = !<a link="impl-aarch32.BadMode.1" file="shared_pseudocode.xml" hover="function: boolean BadMode(bits(5) mode)">BadMode</a>(mode);  // Check for modes that are not valid for this implementation
    bits(2) effective_nse_ns = <a link="impl-shared.EffectiveSCR_EL3_NSE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NSE()">EffectiveSCR_EL3_NSE</a>() : <a link="impl-shared.EffectiveSCR_EL3_NS.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</a>();

    case mode of
        when <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a>
            el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
        when <a link="M32_Hyp" file="shared_pseudocode.xml" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</a>
            el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
        when <a link="M32_FIQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</a>, <a link="M32_IRQ" file="shared_pseudocode.xml" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</a>, <a link="M32_Svc" file="shared_pseudocode.xml" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</a>, <a link="M32_Abort" file="shared_pseudocode.xml" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</a>, <a link="M32_Undef" file="shared_pseudocode.xml" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</a>, <a link="M32_System" file="shared_pseudocode.xml" hover="constant bits(5) M32_System = '11111'">M32_System</a>
            // If EL3 is implemented and using AArch32, then these modes are EL3 modes in Secure
            // state, and EL1 modes in Non-secure state. If EL3 is not implemented or is using
            // AArch64, then these modes are EL1 modes.
            el = (if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() &amp;&amp; SCR.NS == '0' then <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
        when <a link="M32_User" file="shared_pseudocode.xml" hover="constant bits(5) M32_User = '10000'">M32_User</a>
            el = <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>;
        otherwise
            valid = FALSE;           // Passed an illegal mode value

    if valid &amp;&amp; el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].NS == '0' then
        valid = FALSE;               // EL2 only valid in Non-secure state in AArch32

    elsif valid &amp;&amp; <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; effective_nse_ns == '10' then
        valid = FALSE;               // Illegal Exception Return from EL3 if SCR_EL3.&lt;NSE,NS&gt;
                                     // selects a reserved encoding

    if !valid then el = bits(2) UNKNOWN;
    return (valid, el);</pstext>
    </ps>
    <ps name="shared/functions/system/ELFromSPSR" mylink="shared.functions.system.ELFromSPSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELFromSPSR()
// ============

// Convert an SPSR value encoding to an Exception level.
// Returns (valid,EL):
//   'valid' is TRUE if 'spsr&lt;4:0&gt;' encodes a valid mode for the current state.
//   'EL'    is the Exception level decoded from 'spsr'.

(boolean,bits(2)) <anchor link="impl-shared.ELFromSPSR.1" hover="function: (boolean,bits(2)) ELFromSPSR(bits(N) spsr)">ELFromSPSR</anchor>(bits(N) spsr)
    bits(2) el;
    boolean valid;
    bits(2) effective_nse_ns;
    if spsr&lt;4&gt; == '0' then      // AArch64 state
        el = spsr&lt;3:2&gt;;
        effective_nse_ns = <a link="impl-shared.EffectiveSCR_EL3_NSE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NSE()">EffectiveSCR_EL3_NSE</a>() : <a link="impl-shared.EffectiveSCR_EL3_NS.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</a>();
        if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
            valid = FALSE;      // No AArch64 support
        elsif !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el) then
            valid = FALSE;      // Exception level not implemented
        elsif spsr&lt;1&gt; == '1' then
            valid = FALSE;      // M[1] must be 0
        elsif el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; spsr&lt;0&gt; == '1' then
            valid = FALSE;      // for EL0, M[0] must be 0
        elsif <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> &amp;&amp; effective_nse_ns == '10' then
            valid = FALSE;      // Only EL3 valid in Root state
        elsif el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>() &amp;&amp; SCR_EL3.NS == '0' then
            valid = FALSE;      // Unless Secure EL2 is enabled, EL2 valid only in Non-secure state
        else
            valid = TRUE;
    elsif <a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() then    // AArch32 state
        (valid, el) = <a link="impl-shared.ELFromM32.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromM32(bits(5) mode)">ELFromM32</a>(spsr&lt;4:0&gt;);
    else
        valid = FALSE;

    if !valid then el = bits(2) UNKNOWN;
    return (valid,el);</pstext>
    </ps>
    <ps name="shared/functions/system/ELIsInHost" mylink="shared.functions.system.ELIsInHost" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELIsInHost()
// ============

boolean <anchor link="impl-shared.ELIsInHost.1" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</anchor>(bits(2) el)
    if !<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() || <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        return FALSE;
    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            return FALSE;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            return <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.E2H == '1';
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>
            return FALSE;
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
            return <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; HCR_EL2.&lt;E2H,TGE&gt; == '11';
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/functions/system/ELStateUsingAArch32" mylink="shared.functions.system.ELStateUsingAArch32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELStateUsingAArch32()
// =====================

boolean <anchor link="impl-shared.ELStateUsingAArch32.2" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</anchor>(bits(2) el, boolean secure)
    // See ELStateUsingAArch32K() for description. Must only be called in circumstances where
    // result is valid (typically, that means 'el IN {EL1,EL2,EL3}').
    (known, aarch32) = <a link="impl-shared.ELStateUsingAArch32K.2" file="shared_pseudocode.xml" hover="function: (boolean,boolean) ELStateUsingAArch32K(bits(2) el, boolean secure)">ELStateUsingAArch32K</a>(el, secure);
    assert known;
    return aarch32;</pstext>
    </ps>
    <ps name="shared/functions/system/ELStateUsingAArch32K" mylink="shared.functions.system.ELStateUsingAArch32K" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELStateUsingAArch32K()
// ======================

(boolean,boolean) <anchor link="impl-shared.ELStateUsingAArch32K.2" hover="function: (boolean,boolean) ELStateUsingAArch32K(bits(2) el, boolean secure)">ELStateUsingAArch32K</anchor>(bits(2) el, boolean secure)
    // Returns (known, aarch32):
    //   'known'   is FALSE for EL0 if the current Exception level is not EL0 and EL1 is
    //             using AArch64, since it cannot determine the state of EL0; TRUE otherwise.
    //   'aarch32' is TRUE if the specified Exception level is using AArch32; FALSE otherwise.
    if !<a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(el) then
        return (TRUE, FALSE);   // Exception level is using AArch64
    elsif secure &amp;&amp; el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        return (TRUE, FALSE);   // Secure EL2 is using AArch64
    elsif !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        return (TRUE, TRUE);    // Highest Exception level, therefore all levels are using AArch32

    // Remainder of function deals with the interprocessing cases when highest
    // Exception level is using AArch64

    boolean aarch32 = boolean UNKNOWN;
    boolean known = TRUE;

    aarch32_below_el3 = (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; (!secure || !<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() || SCR_EL3.EEL2 == '0') &amp;&amp;
                         SCR_EL3.RW == '0');
    aarch32_at_el1 = (aarch32_below_el3 ||
                      (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (!secure || (<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; SCR_EL3.EEL2 == '1')) &amp;&amp;
                       !(<a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; HCR_EL2.&lt;E2H,TGE&gt; == '11') &amp;&amp;
                       HCR_EL2.RW == '0'));
    if el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !aarch32_at_el1 then       // Only know if EL0 using AArch32 from PSTATE
        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            aarch32 = PSTATE.nRW == '1';       // EL0 controlled by PSTATE
        else
            known = FALSE;                     // EL0 state is UNKNOWN
    else
        aarch32 = (aarch32_below_el3 &amp;&amp; el != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) || (aarch32_at_el1 &amp;&amp; el IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>,<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>});

    if !known then aarch32 = boolean UNKNOWN;
    return (known, aarch32);</pstext>
    </ps>
    <ps name="shared/functions/system/ELUsingAArch32" mylink="shared.functions.system.ELUsingAArch32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELUsingAArch32()
// ================

boolean <anchor link="impl-shared.ELUsingAArch32.1" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</anchor>(bits(2) el)
    return <a link="impl-shared.ELStateUsingAArch32.2" file="shared_pseudocode.xml" hover="function: boolean ELStateUsingAArch32(bits(2) el, boolean secure)">ELStateUsingAArch32</a>(el, <a link="impl-shared.IsSecureBelowEL3.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureBelowEL3()">IsSecureBelowEL3</a>());</pstext>
    </ps>
    <ps name="shared/functions/system/ELUsingAArch32K" mylink="shared.functions.system.ELUsingAArch32K" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ELUsingAArch32K()
// =================

(boolean,boolean) <anchor link="impl-shared.ELUsingAArch32K.1" hover="function: (boolean,boolean) ELUsingAArch32K(bits(2) el)">ELUsingAArch32K</anchor>(bits(2) el)
    return <a link="impl-shared.ELStateUsingAArch32K.2" file="shared_pseudocode.xml" hover="function: (boolean,boolean) ELStateUsingAArch32K(bits(2) el, boolean secure)">ELStateUsingAArch32K</a>(el, <a link="impl-shared.IsSecureBelowEL3.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureBelowEL3()">IsSecureBelowEL3</a>());</pstext>
    </ps>
    <ps name="shared/functions/system/EffectiveEA" mylink="shared.functions.system.EffectiveEA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveEA()
// =============
// Returns effective SCR_EL3.EA value

bit <anchor link="impl-shared.EffectiveEA.0" hover="function: bit EffectiveEA()">EffectiveEA</anchor>()
    if <a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>() &amp;&amp; EDSCR.SDD == '0' then
        return '0';
    else
        return if <a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then SCR_EL3.EA else SCR.EA;</pstext>
    </ps>
    <ps name="shared/functions/system/EffectiveSCR_EL3_NS" mylink="shared.functions.system.EffectiveSCR_EL3_NS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveSCR_EL3_NS()
// =====================
// Return Effective SCR_EL3.NS value.

bit <anchor link="impl-shared.EffectiveSCR_EL3_NS.0" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</anchor>()
    if !<a link="impl-shared.HaveSecureState.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureState()">HaveSecureState</a>() then
        return '1';
    elsif !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        return '0';
    else
        return SCR_EL3.NS;</pstext>
    </ps>
    <ps name="shared/functions/system/EffectiveSCR_EL3_NSE" mylink="shared.functions.system.EffectiveSCR_EL3_NSE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveSCR_EL3_NSE()
// ======================
// Return Effective SCR_EL3.NSE value.

bit <anchor link="impl-shared.EffectiveSCR_EL3_NSE.0" hover="function: bit EffectiveSCR_EL3_NSE()">EffectiveSCR_EL3_NSE</anchor>()
    return if !<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then '0' else SCR_EL3.NSE;</pstext>
    </ps>
    <ps name="shared/functions/system/EffectiveSCR_EL3_RW" mylink="shared.functions.system.EffectiveSCR_EL3_RW" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveSCR_EL3_RW()
// =====================
// Returns effective SCR_EL3.RW value

bit <anchor link="impl-shared.EffectiveSCR_EL3_RW.0" hover="function: bit EffectiveSCR_EL3_RW()">EffectiveSCR_EL3_RW</anchor>()
    if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        return '0';
    if !<a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; !<a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        return '1';
    if <a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then
        if !<a link="impl-shared.HaveAArch32EL.1" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; SCR_EL3.NS == '1' then
            return '1';
        if <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; SCR_EL3.EEL2 == '1' &amp;&amp; SCR_EL3.NS == '0' then
            return '1';
    return SCR_EL3.RW;</pstext>
    </ps>
    <ps name="shared/functions/system/EffectiveTGE" mylink="shared.functions.system.EffectiveTGE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveTGE()
// ==============
// Returns effective TGE value

bit <anchor link="impl-shared.EffectiveTGE.0" hover="function: bit EffectiveTGE()">EffectiveTGE</anchor>()
    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() then
        return if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then HCR.TGE else HCR_EL2.TGE;
    else
        return '0';        // Effective value of TGE is zero</pstext>
    </ps>
    <ps name="shared/functions/system/EndOfInstruction" mylink="shared.functions.system.EndOfInstruction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EndOfInstruction()
// ==================
// Terminate processing of the current instruction.

<anchor link="impl-shared.EndOfInstruction.0" hover="function: EndOfInstruction()">EndOfInstruction</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/EnterLowPowerState" mylink="shared.functions.system.EnterLowPowerState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EnterLowPowerState()
// ====================
// PE enters a low-power state.

<anchor link="impl-shared.EnterLowPowerState.0" hover="function: EnterLowPowerState()">EnterLowPowerState</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/EventRegister" mylink="shared.functions.system.EventRegister" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">bits(1) EventRegister;</pstext>
    </ps>
    <ps name="shared/functions/system/ExceptionalOccurrenceTargetState" mylink="shared.functions.system.ExceptionalOccurrenceTargetState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExceptionalOccurrenceTargetState
// ================================
// Enumeration to represent the target state of an Exceptional Occurrence.
// The Exceptional Occurrence can be either Exception or Debug State entry.

enumeration <anchor link="ExceptionalOccurrenceTargetState" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">ExceptionalOccurrenceTargetState</anchor> {
    <anchor link="AArch32_NonDebugState" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch32_NonDebugState</anchor>,
    <anchor link="AArch64_NonDebugState" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch64_NonDebugState</anchor>,
    <anchor link="DebugState" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">DebugState</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/system/FIQPending" mylink="shared.functions.system.FIQPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FIQPending()
// ============
// Returns a tuple indicating if there is any pending physical FIQ
// and if the pending FIQ has superpriority.

(boolean, boolean) <anchor link="impl-shared.FIQPending.0" hover="function: (boolean, boolean) FIQPending()">FIQPending</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/GetAccumulatedFPExceptions" mylink="shared.functions.system.GetAccumulatedFPExceptions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetAccumulatedFPExceptions()
// ============================
// Returns FP exceptions accumulated by the PE.

bits(8) <anchor link="impl-shared.GetAccumulatedFPExceptions.0" hover="function: bits(8) GetAccumulatedFPExceptions()">GetAccumulatedFPExceptions</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/GetLoadStoreType" mylink="shared.functions.system.GetLoadStoreType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetLoadStoreType()
// ==================
// Returns the Load/Store Type. Used when a Translation fault,
// Access flag fault, or Permission fault generates a Data Abort.

bits(2) <anchor link="impl-shared.GetLoadStoreType.0" hover="function: bits(2) GetLoadStoreType()">GetLoadStoreType</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/GetPSRFromPSTATE" mylink="shared.functions.system.GetPSRFromPSTATE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetPSRFromPSTATE()
// ==================
// Return a PSR value which represents the current PSTATE

bits(N) <anchor link="impl-shared.GetPSRFromPSTATE.2" hover="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N)">GetPSRFromPSTATE</anchor>(<a link="ExceptionalOccurrenceTargetState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">ExceptionalOccurrenceTargetState</a> targetELState, integer N)
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; targetELState == <a link="AArch32_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch32_NonDebugState</a> then
        assert N == 32;
    else
        assert N == 64;

    bits(N) spsr = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N);
    spsr&lt;31:28&gt; = PSTATE.&lt;N,Z,C,V&gt;;
    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() then spsr&lt;22&gt; = PSTATE.PAN;
    spsr&lt;20&gt;    = PSTATE.IL;
    if PSTATE.nRW == '1' then                           // AArch32 state
        spsr&lt;27&gt;    = PSTATE.Q;
        spsr&lt;26:25&gt; = PSTATE.IT&lt;1:0&gt;;
        if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then spsr&lt;23&gt; = PSTATE.SSBS;
        if <a link="impl-shared.HaveDITExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDITExt()">HaveDITExt</a>() then
            if targetELState == <a link="AArch32_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch32_NonDebugState</a> then
                spsr&lt;21&gt; = PSTATE.DIT;
            else                                        // AArch64_NonDebugState or DebugState
                spsr&lt;24&gt; = PSTATE.DIT;
        if targetELState IN {<a link="AArch64_NonDebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">AArch64_NonDebugState</a>, <a link="DebugState" file="shared_pseudocode.xml" hover="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState }">DebugState</a>} then
            spsr&lt;21&gt; = PSTATE.SS;
        spsr&lt;19:16&gt; = PSTATE.GE;
        spsr&lt;15:10&gt; = PSTATE.IT&lt;7:2&gt;;
        spsr&lt;9&gt;     = PSTATE.E;
        spsr&lt;8:6&gt;   = PSTATE.&lt;A,I,F&gt;;                   // No PSTATE.D in AArch32 state
        spsr&lt;5&gt;     = PSTATE.T;
        assert PSTATE.M&lt;4&gt; == PSTATE.nRW;               // bit [4] is the discriminator
        spsr&lt;4:0&gt;   = PSTATE.M;
    else                                                // AArch64 state
        if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() then spsr&lt;25&gt; = PSTATE.TCO;
        if <a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() then spsr&lt;34&gt; = PSTATE.EXLOCK;
        if <a link="impl-shared.HaveDITExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDITExt()">HaveDITExt</a>() then spsr&lt;24&gt; = PSTATE.DIT;
        if <a link="impl-shared.HaveUAOExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveUAOExt()">HaveUAOExt</a>() then spsr&lt;23&gt; = PSTATE.UAO;
        spsr&lt;21&gt;    = PSTATE.SS;
        if <a link="impl-shared.HaveFeatNMI.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatNMI()">HaveFeatNMI</a>() then spsr&lt;13&gt; = PSTATE.ALLINT;
        if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then spsr&lt;12&gt; = PSTATE.SSBS;
        if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then spsr&lt;11:10&gt; = PSTATE.BTYPE;
        spsr&lt;9:6&gt;   = PSTATE.&lt;D,A,I,F&gt;;
        spsr&lt;4&gt;     = PSTATE.nRW;
        spsr&lt;3:2&gt;   = PSTATE.EL;
        spsr&lt;0&gt;     = PSTATE.SP;
    return spsr;</pstext>
    </ps>
    <ps name="shared/functions/system/HasArchVersion" mylink="shared.functions.system.HasArchVersion" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HasArchVersion()
// ================
// Returns TRUE if the implemented architecture includes the extensions defined in the specified
// architecture version.

boolean HasArchVersion(ArchVersion version)
    return Variant(version);</pstext>
    </ps>
    <ps name="shared/functions/system/HaveAArch32" mylink="shared.functions.system.HaveAArch32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAArch32()
// =============
// Return TRUE if AArch32 state is supported at at least EL0.

boolean <anchor link="impl-shared.HaveAArch32.0" hover="function: boolean HaveAArch32()">HaveAArch32</anchor>()
    return boolean IMPLEMENTATION_DEFINED "AArch32 state is supported at at least <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>";</pstext>
    </ps>
    <ps name="shared/functions/system/HaveAArch32EL" mylink="shared.functions.system.HaveAArch32EL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAArch32EL()
// ===============

boolean <anchor link="impl-shared.HaveAArch32EL.1" hover="function: boolean HaveAArch32EL(bits(2) el)">HaveAArch32EL</anchor>(bits(2) el)
    // Return TRUE if Exception level 'el' supports AArch32 in this implementation
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el) then
        return FALSE;                    // The Exception level is not implemented
    elsif !<a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() then
        return FALSE;                    // No Exception level can use AArch32
    elsif !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        return TRUE;                     // All Exception levels are using AArch32
    elsif el == <a link="impl-shared.HighestEL.0" file="shared_pseudocode.xml" hover="function: bits(2) HighestEL()">HighestEL</a>() then
        return FALSE;                    // The highest Exception level is using AArch64
    elsif el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        return TRUE;                     // EL0 must support using AArch32 if any AArch32
    return boolean IMPLEMENTATION_DEFINED;</pstext>
    </ps>
    <ps name="shared/functions/system/HaveAArch64" mylink="shared.functions.system.HaveAArch64" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveAArch64()
// =============
// Return TRUE if the highest Exception level is using AArch64 state.

boolean <anchor link="impl-shared.HaveAArch64.0" hover="function: boolean HaveAArch64()">HaveAArch64</anchor>()
    return boolean IMPLEMENTATION_DEFINED "Highest EL using AArch64";</pstext>
    </ps>
    <ps name="shared/functions/system/HaveEL" mylink="shared.functions.system.HaveEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveEL()
// ========
// Return TRUE if Exception level 'el' is supported

boolean <anchor link="impl-shared.HaveEL.1" hover="function: boolean HaveEL(bits(2) el)">HaveEL</anchor>(bits(2) el)
    if el IN {<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>,<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>} then
        return TRUE;                             // EL1 and EL0 must exist
    return boolean IMPLEMENTATION_DEFINED;</pstext>
    </ps>
    <ps name="shared/functions/system/HaveELUsingSecurityState" mylink="shared.functions.system.HaveELUsingSecurityState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveELUsingSecurityState()
// ==========================
// Returns TRUE if Exception level 'el' with Security state 'secure' is supported,
// FALSE otherwise.

boolean <anchor link="impl-shared.HaveELUsingSecurityState.2" hover="function: boolean HaveELUsingSecurityState(bits(2) el, boolean secure)">HaveELUsingSecurityState</anchor>(bits(2) el, boolean secure)

    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>
            assert secure;
            return <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>
            if secure then
                return <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>();
            else
                return <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        otherwise
            return (<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) ||
                    (secure == boolean IMPLEMENTATION_DEFINED "Secure-only implementation"));</pstext>
    </ps>
    <ps name="shared/functions/system/HaveFP16Ext" mylink="shared.functions.system.HaveFP16Ext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveFP16Ext()
// =============
// Return TRUE if FP16 extension is supported

boolean <anchor link="impl-shared.HaveFP16Ext.0" hover="function: boolean HaveFP16Ext()">HaveFP16Ext</anchor>()
    return IsFeatureImplemented(FEAT_FP16);</pstext>
    </ps>
    <ps name="shared/functions/system/HaveSecureState" mylink="shared.functions.system.HaveSecureState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HaveSecureState()
// =================
// Return TRUE if Secure State is supported.

boolean <anchor link="impl-shared.HaveSecureState.0" hover="function: boolean HaveSecureState()">HaveSecureState</anchor>()
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        return <a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>();
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; !<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then
        return FALSE;
    return TRUE;</pstext>
    </ps>
    <ps name="shared/functions/system/HighestEL" mylink="shared.functions.system.HighestEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HighestEL()
// ===========
// Returns the highest implemented Exception level.

bits(2) <anchor link="impl-shared.HighestEL.0" hover="function: bits(2) HighestEL()">HighestEL</anchor>()
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        return <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
        return <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        return <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;</pstext>
    </ps>
    <ps name="shared/functions/system/Hint_CLRBHB" mylink="shared.functions.system.Hint_CLRBHB" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_CLRBHB()
// =============
// Provides a hint to clear the branch history for the current context.

<anchor link="impl-shared.Hint_CLRBHB.0" hover="function: Hint_CLRBHB()">Hint_CLRBHB</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/Hint_DGH" mylink="shared.functions.system.Hint_DGH" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_DGH()
// ==========
// Provides a hint to close any gathering occurring within the micro-architecture.

<anchor link="impl-shared.Hint_DGH.0" hover="function: Hint_DGH()">Hint_DGH</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/Hint_WFE" mylink="shared.functions.system.Hint_WFE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_WFE()
// ==========
// Provides a hint indicating that the PE can enter a low-power state
// and remain there until a wakeup event occurs or, for WFET,  a local
// timeout event is generated when the virtual timer value equals or
// exceeds the supplied threshold value.

<anchor link="impl-shared.Hint_WFE.2" hover="function: Hint_WFE(integer localtimeout, WFxType wfxtype)">Hint_WFE</anchor>(integer localtimeout, <a link="WFxType" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType</a> wfxtype)
    if <a link="impl-shared.IsEventRegisterSet.0" file="shared_pseudocode.xml" hover="function: boolean IsEventRegisterSet()">IsEventRegisterSet</a>() then
        <a link="impl-shared.ClearEventRegister.0" file="shared_pseudocode.xml" hover="function: ClearEventRegister()">ClearEventRegister</a>();
    elsif <a link="impl-shared.HaveFeatWFxT.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatWFxT()">HaveFeatWFxT</a>() &amp;&amp; <a link="impl-shared.LocalTimeoutEvent.1" file="shared_pseudocode.xml" hover="function: boolean LocalTimeoutEvent(integer localtimeout)">LocalTimeoutEvent</a>(localtimeout) then
        // No further operation if the local timeout has expired.
        <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    else
        bits(2) target_el;
        trap = FALSE;
        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            // Check for traps described by the OS which may be EL1 or EL2.
            if <a link="impl-shared.HaveTWEDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTWEDExt()">HaveTWEDExt</a>() then
                sctlr     = <a link="impl-aarch64.SCTLR.read.0" file="shared_pseudocode.xml" hover="accessor: SCTLRType SCTLR[]">SCTLR</a>[];
                trap      = sctlr.nTWE == '0';
                target_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
            else
                <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, wfxtype);
        if !trap &amp;&amp; PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            // Check for traps described by the Hypervisor.
            if <a link="impl-shared.HaveTWEDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTWEDExt()">HaveTWEDExt</a>() then
                trap      = HCR_EL2.TWE == '1';
                target_el = <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
            else
                <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, wfxtype);

        if !trap &amp;&amp; <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            // Check for traps described by the Secure Monitor.
            if <a link="impl-shared.HaveTWEDExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTWEDExt()">HaveTWEDExt</a>() then
                trap      = SCR_EL3.TWE == '1';
                target_el = <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
            else
                <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, wfxtype);

        if trap &amp;&amp; PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            // Determine if trap delay is enabled and delay amount
            (delay_enabled, delay) = <a link="impl-aarch64.WFETrapDelay.1" file="shared_pseudocode.xml" hover="function: (boolean, integer) WFETrapDelay(bits(2) target_el)">WFETrapDelay</a>(target_el);
            if !<a link="impl-aarch64.WaitForEventUntilDelay.2" file="shared_pseudocode.xml" hover="function: boolean WaitForEventUntilDelay(boolean delay_enabled, integer delay)">WaitForEventUntilDelay</a>(delay_enabled, delay) then
                // Event did not arrive before delay expired so trap WFE
                <a link="AArch64.WFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.WFxTrap(WFxType wfxtype, bits(2) target_el)">AArch64.WFxTrap</a>(wfxtype, target_el);
        else
            <a link="impl-shared.WaitForEvent.1" file="shared_pseudocode.xml" hover="function: WaitForEvent(integer localtimeout)">WaitForEvent</a>(localtimeout);</pstext>
    </ps>
    <ps name="shared/functions/system/Hint_WFI" mylink="shared.functions.system.Hint_WFI" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_WFI()
// ==========
// Provides a hint indicating that the PE can enter a low-power state and
// remain there until a wakeup event occurs or, for WFIT, a local timeout
// event is generated when the virtual timer value equals or exceeds the
// supplied threshold value.

<anchor link="impl-shared.Hint_WFI.2" hover="function: Hint_WFI(integer localtimeout, WFxType wfxtype)">Hint_WFI</anchor>(integer localtimeout, <a link="WFxType" file="shared_pseudocode.xml" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType</a> wfxtype)
    if <a link="impl-shared.HaveTME.0" file="shared_pseudocode.xml" hover="function: boolean HaveTME()">HaveTME</a>() &amp;&amp; TSTATE.depth &gt; 0 then
        <a link="impl-aarch64.FailTransaction.2" file="shared_pseudocode.xml" hover="function: FailTransaction(TMFailure cause, boolean retry)">FailTransaction</a>(<a link="TMFailure_ERR" file="shared_pseudocode.xml" hover="enumeration TMFailure { TMFailure_CNCL, TMFailure_DBG, TMFailure_ERR, TMFailure_NEST, TMFailure_SIZE, TMFailure_MEM, TMFailure_TRIVIAL, TMFailure_IMP }">TMFailure_ERR</a>, FALSE);

    if <a link="impl-shared.InterruptPending.0" file="shared_pseudocode.xml" hover="function: boolean InterruptPending()">InterruptPending</a>() || (<a link="impl-shared.HaveFeatWFxT.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatWFxT()">HaveFeatWFxT</a>() &amp;&amp; <a link="impl-shared.LocalTimeoutEvent.1" file="shared_pseudocode.xml" hover="function: boolean LocalTimeoutEvent(integer localtimeout)">LocalTimeoutEvent</a>(localtimeout)) then
        // No further operation if an interrupt is pending or the local timeout has expired.
        <a link="impl-shared.EndOfInstruction.0" file="shared_pseudocode.xml" hover="function: EndOfInstruction()">EndOfInstruction</a>();
    else
        if PSTATE.EL == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
            // Check for traps described by the OS.
            <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>, wfxtype);
        if PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; !<a link="impl-shared.IsInHost.0" file="shared_pseudocode.xml" hover="function: boolean IsInHost()">IsInHost</a>() then
            // Check for traps described by the Hypervisor.
            <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>, wfxtype);
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; PSTATE.EL != <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
            // Check for traps described by the Secure Monitor.
            <a link="AArch64.CheckForWFxTrap.2" file="shared_pseudocode.xml" hover="function: AArch64.CheckForWFxTrap(bits(2) target_el, WFxType wfxtype)">AArch64.CheckForWFxTrap</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>, wfxtype);
        <a link="impl-shared.WaitForInterrupt.1" file="shared_pseudocode.xml" hover="function: WaitForInterrupt(integer localtimeout)">WaitForInterrupt</a>(localtimeout);</pstext>
    </ps>
    <ps name="shared/functions/system/Hint_Yield" mylink="shared.functions.system.Hint_Yield" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Hint_Yield()
// ============
// Provides a hint that the task performed by a thread is of low
// importance so that it could yield to improve overall performance.

<anchor link="impl-shared.Hint_Yield.0" hover="function: Hint_Yield()">Hint_Yield</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/IRQPending" mylink="shared.functions.system.IRQPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IRQPending()
// ============
// Returns a tuple indicating if there is any pending physical IRQ
// and if the pending IRQ has superpriority.

(boolean, boolean) <anchor link="impl-shared.IRQPending.0" hover="function: (boolean, boolean) IRQPending()">IRQPending</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/IllegalExceptionReturn" mylink="shared.functions.system.IllegalExceptionReturn" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IllegalExceptionReturn()
// ========================

boolean <anchor link="impl-shared.IllegalExceptionReturn.1" hover="function: boolean IllegalExceptionReturn(bits(N) spsr)">IllegalExceptionReturn</anchor>(bits(N) spsr)

    // Check for illegal return:
    //   * To an unimplemented Exception level.
    //   * To EL2 in Secure state, when SecureEL2 is not enabled.
    //   * To EL0 using AArch64 state, with SPSR.M[0]==1.
    //   * To AArch64 state with SPSR.M[1]==1.
    //   * To AArch32 state with an illegal value of SPSR.M.
    (valid, target) = <a link="impl-shared.ELFromSPSR.1" file="shared_pseudocode.xml" hover="function: (boolean,bits(2)) ELFromSPSR(bits(N) spsr)">ELFromSPSR</a>(spsr);
    if !valid then return TRUE;

    // Check for return to higher Exception level
    if <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(target) &gt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(PSTATE.EL) then return TRUE;

    spsr_mode_is_aarch32 = (spsr&lt;4&gt; == '1');

    // Check for illegal return:
    //   * To EL1, EL2 or EL3 with register width specified in the SPSR different from the
    //     Execution state used in the Exception level being returned to, as determined by
    //     the SCR_EL3.RW or HCR_EL2.RW bits, or as configured from reset.
    //   * To EL0 using AArch64 state when EL1 is using AArch32 state as determined by the
    //     SCR_EL3.RW or HCR_EL2.RW bits or as configured from reset.
    //   * To AArch64 state from AArch32 state (should be caught by above)
    (known, target_el_is_aarch32) = <a link="impl-shared.ELUsingAArch32K.1" file="shared_pseudocode.xml" hover="function: (boolean,boolean) ELUsingAArch32K(bits(2) el)">ELUsingAArch32K</a>(target);
    assert known || (target == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> &amp;&amp; !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>));
    if known &amp;&amp; spsr_mode_is_aarch32 != target_el_is_aarch32 then return TRUE;

    // Check for illegal return from AArch32 to AArch64
    if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; !spsr_mode_is_aarch32 then return TRUE;

    // Check for illegal return to EL1 when HCR.TGE is set and when either of
    // * SecureEL2 is enabled.
    // * SecureEL2 is not enabled and EL1 is in Non-secure state.
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; target == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> &amp;&amp; HCR_EL2.TGE == '1' then
        if (!<a link="impl-shared.IsSecureBelowEL3.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureBelowEL3()">IsSecureBelowEL3</a>() || <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>()) then return TRUE;

    if (<a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() &amp;&amp; PSTATE.EXLOCK == '0' &amp;&amp; PSTATE.EL == target &amp;&amp;
        <a link="impl-aarch64.GetCurrentEXLOCKEN.0" file="shared_pseudocode.xml" hover="function: boolean GetCurrentEXLOCKEN()">GetCurrentEXLOCKEN</a>() &amp;&amp; !<a link="impl-shared.Halted.0" file="shared_pseudocode.xml" hover="function: boolean Halted()">Halted</a>()) then
        return TRUE;

    return FALSE;</pstext>
    </ps>
    <ps name="shared/functions/system/InstrSet" mylink="shared.functions.system.InstrSet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InstrSet
// ========

enumeration <anchor link="InstrSet" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet</anchor> {<anchor link="InstrSet_A64" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A64</anchor>, <anchor link="InstrSet_A32" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_A32</anchor>, <anchor link="InstrSet_T32" hover="enumeration InstrSet {InstrSet_A64, InstrSet_A32, InstrSet_T32}">InstrSet_T32</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/system/InstructionSynchronizationBarrier" mylink="shared.functions.system.InstructionSynchronizationBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InstructionSynchronizationBarrier()
// ===================================
<anchor link="impl-shared.InstructionSynchronizationBarrier.0" hover="function: InstructionSynchronizationBarrier()">InstructionSynchronizationBarrier</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/InterruptPending" mylink="shared.functions.system.InterruptPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// InterruptPending()
// ==================
// Returns TRUE if there are any pending physical or virtual
// interrupts, and FALSE otherwise.

boolean <anchor link="impl-shared.InterruptPending.0" hover="function: boolean InterruptPending()">InterruptPending</anchor>()
    boolean pending_virtual_interrupt = FALSE;
    (irq_pending, -) = <a link="impl-shared.IRQPending.0" file="shared_pseudocode.xml" hover="function: (boolean, boolean) IRQPending()">IRQPending</a>();
    (fiq_pending, -) = <a link="impl-shared.FIQPending.0" file="shared_pseudocode.xml" hover="function: (boolean, boolean) FIQPending()">FIQPending</a>();
    boolean pending_physical_interrupt = (irq_pending || fiq_pending ||
                                          <a link="impl-shared.IsPhysicalSErrorPending.0" file="shared_pseudocode.xml" hover="function: boolean IsPhysicalSErrorPending()">IsPhysicalSErrorPending</a>());

    if <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>() &amp;&amp; PSTATE.EL IN {<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>, <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>} &amp;&amp; HCR_EL2.TGE == '0' then
        boolean virq_pending = HCR_EL2.IMO == '1' &amp;&amp; (<a link="impl-shared.VirtualIRQPending.0" file="shared_pseudocode.xml" hover="function: boolean VirtualIRQPending()">VirtualIRQPending</a>() || HCR_EL2.VI == '1') ;
        boolean vfiq_pending = HCR_EL2.FMO == '1' &amp;&amp; (<a link="impl-shared.VirtualFIQPending.0" file="shared_pseudocode.xml" hover="function: boolean VirtualFIQPending()">VirtualFIQPending</a>() || HCR_EL2.VF == '1');
        boolean vsei_pending = HCR_EL2.AMO == '1' &amp;&amp; (<a link="impl-shared.IsVirtualSErrorPending.0" file="shared_pseudocode.xml" hover="function: boolean IsVirtualSErrorPending()">IsVirtualSErrorPending</a>() ||
                                                      HCR_EL2.VSE == '1');
        pending_virtual_interrupt = vsei_pending || virq_pending || vfiq_pending;

    return pending_physical_interrupt || pending_virtual_interrupt;</pstext>
    </ps>
    <ps name="shared/functions/system/IsASEInstruction" mylink="shared.functions.system.IsASEInstruction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsASEInstruction()
// ==================
// Returns TRUE if the current instruction is an ASIMD or SVE vector instruction.

boolean <anchor link="impl-shared.IsASEInstruction.0" hover="function: boolean IsASEInstruction()">IsASEInstruction</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/IsCMOWControlledInstruction" mylink="shared.functions.system.IsCMOWControlledInstruction" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsCMOWControlledInstruction()
// =============================
// When using AArch64, returns TRUE if the current instruction is one of IC IVAU,
// DC CIVAC, DC CIGDVAC, or DC CIGVAC.
// When using AArch32, returns TRUE if the current instruction is ICIMVAU or DCCIMVAC.

boolean <anchor link="impl-shared.IsCMOWControlledInstruction.0" hover="function: boolean IsCMOWControlledInstruction()">IsCMOWControlledInstruction</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/IsCurrentSecurityState" mylink="shared.functions.system.IsCurrentSecurityState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsCurrentSecurityState()
// ========================
// Returns TRUE if the current Security state matches
// the given Security state, and FALSE otherwise.

boolean <anchor link="impl-shared.IsCurrentSecurityState.1" hover="function: boolean IsCurrentSecurityState(SecurityState ss)">IsCurrentSecurityState</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss)
    return <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == ss;</pstext>
    </ps>
    <ps name="shared/functions/system/IsEventRegisterSet" mylink="shared.functions.system.IsEventRegisterSet" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsEventRegisterSet()
// ====================
// Return TRUE if the Event Register of this PE is set, and FALSE if it is clear.

boolean <anchor link="impl-shared.IsEventRegisterSet.0" hover="function: boolean IsEventRegisterSet()">IsEventRegisterSet</anchor>()
    return EventRegister == '1';</pstext>
    </ps>
    <ps name="shared/functions/system/IsHighestEL" mylink="shared.functions.system.IsHighestEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsHighestEL()
// =============
// Returns TRUE if given exception level is the highest exception level implemented

boolean <anchor link="impl-shared.IsHighestEL.1" hover="function: boolean IsHighestEL(bits(2) el)">IsHighestEL</anchor>(bits(2) el)
    return <a link="impl-shared.HighestEL.0" file="shared_pseudocode.xml" hover="function: bits(2) HighestEL()">HighestEL</a>() == el;</pstext>
    </ps>
    <ps name="shared/functions/system/IsInHost" mylink="shared.functions.system.IsInHost" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsInHost()
// ==========

boolean <anchor link="impl-shared.IsInHost.0" hover="function: boolean IsInHost()">IsInHost</anchor>()
    return <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(PSTATE.EL);</pstext>
    </ps>
    <ps name="shared/functions/system/IsSecure" mylink="shared.functions.system.IsSecure" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSecure()
// ==========
// Returns TRUE if current Exception level is in Secure state.

boolean <anchor link="impl-shared.IsSecure.0" hover="function: boolean IsSecure()">IsSecure</anchor>()
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; PSTATE.EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        return TRUE;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() &amp;&amp; PSTATE.M == <a link="M32_Monitor" file="shared_pseudocode.xml" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</a> then
        return TRUE;
    return <a link="impl-shared.IsSecureBelowEL3.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureBelowEL3()">IsSecureBelowEL3</a>();</pstext>
    </ps>
    <ps name="shared/functions/system/IsSecureBelowEL3" mylink="shared.functions.system.IsSecureBelowEL3" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSecureBelowEL3()
// ==================
// Return TRUE if an Exception level below EL3 is in Secure state
// or would be following an exception return to that level.
//
// Differs from IsSecure in that it ignores the current EL or Mode
// in considering security state.
// That is, if at AArch64 EL3 or in AArch32 Monitor mode, whether an
// exception return would pass to Secure or Non-secure state.

boolean <anchor link="impl-shared.IsSecureBelowEL3.0" hover="function: boolean IsSecureBelowEL3()">IsSecureBelowEL3</anchor>()
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        return <a link="impl-shared.SCR_GEN.read.0" file="shared_pseudocode.xml" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</a>[].NS == '0';
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (!<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() || !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>()) then
        // If Secure EL2 is not an architecture option then we must be Non-secure.
        return FALSE;
    else
        // TRUE if processor is Secure or FALSE if Non-secure.
        return boolean IMPLEMENTATION_DEFINED "Secure-only implementation";</pstext>
    </ps>
    <ps name="shared/functions/system/IsSecureEL2Enabled" mylink="shared.functions.system.IsSecureEL2Enabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsSecureEL2Enabled()
// ====================
// Returns TRUE if Secure EL2 is enabled, FALSE otherwise.

boolean <anchor link="impl-shared.IsSecureEL2Enabled.0" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</anchor>()
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.EEL2 == '1' then
                return TRUE;
            else
                return FALSE;
        else
            return <a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>();
    else
        return FALSE;</pstext>
    </ps>
    <ps name="shared/functions/system/LocalTimeoutEvent" mylink="shared.functions.system.LocalTimeoutEvent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// LocalTimeoutEvent()
// ===================
// Returns TRUE if CNTVCT_EL0 equals or exceeds the localtimeout value.

boolean <anchor link="impl-shared.LocalTimeoutEvent.1" hover="function: boolean LocalTimeoutEvent(integer localtimeout)">LocalTimeoutEvent</anchor>(integer localtimeout);</pstext>
    </ps>
    <ps name="shared/functions/system/Mode_Bits" mylink="shared.functions.system.Mode_Bits" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(5) <anchor link="M32_User" hover="constant bits(5) M32_User = '10000'">M32_User</anchor>    = '10000';
constant bits(5) <anchor link="M32_FIQ" hover="constant bits(5) M32_FIQ = '10001'">M32_FIQ</anchor>     = '10001';
constant bits(5) <anchor link="M32_IRQ" hover="constant bits(5) M32_IRQ = '10010'">M32_IRQ</anchor>     = '10010';
constant bits(5) <anchor link="M32_Svc" hover="constant bits(5) M32_Svc = '10011'">M32_Svc</anchor>     = '10011';
constant bits(5) <anchor link="M32_Monitor" hover="constant bits(5) M32_Monitor = '10110'">M32_Monitor</anchor> = '10110';
constant bits(5) <anchor link="M32_Abort" hover="constant bits(5) M32_Abort = '10111'">M32_Abort</anchor>   = '10111';
constant bits(5) <anchor link="M32_Hyp" hover="constant bits(5) M32_Hyp = '11010'">M32_Hyp</anchor>     = '11010';
constant bits(5) <anchor link="M32_Undef" hover="constant bits(5) M32_Undef = '11011'">M32_Undef</anchor>   = '11011';
constant bits(5) <anchor link="M32_System" hover="constant bits(5) M32_System = '11111'">M32_System</anchor>  = '11111';</pstext>
    </ps>
    <ps name="shared/functions/system/NonSecureOnlyImplementation" mylink="shared.functions.system.NonSecureOnlyImplementation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NonSecureOnlyImplementation()
// =============================
// Returns TRUE if the security state is always Non-secure for this implementation.

boolean <anchor link="impl-shared.NonSecureOnlyImplementation.0" hover="function: boolean NonSecureOnlyImplementation()">NonSecureOnlyImplementation</anchor>()
    return boolean IMPLEMENTATION_DEFINED "Non-secure only implementation";</pstext>
    </ps>
    <ps name="shared/functions/system/PLOfEL" mylink="shared.functions.system.PLOfEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PLOfEL()
// ========

PrivilegeLevel <anchor link="impl-shared.PLOfEL.1" hover="function: PrivilegeLevel PLOfEL(bits(2) el)">PLOfEL</anchor>(bits(2) el)
    case el of
        when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  return if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then <a link="PL1" file="shared_pseudocode.xml" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL1</a> else <a link="PL3" file="shared_pseudocode.xml" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL3</a>;
        when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  return <a link="PL2" file="shared_pseudocode.xml" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL2</a>;
        when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  return <a link="PL1" file="shared_pseudocode.xml" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL1</a>;
        when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>  return <a link="PL0" file="shared_pseudocode.xml" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL0</a>;</pstext>
    </ps>
    <ps name="shared/functions/system/PSTATE" mylink="shared.functions.system.PSTATE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions"><a link="ProcState" file="shared_pseudocode.xml" hover="type ProcState is ( bits (1) N, bits (1) Z, bits (1) C, bits (1) V, bits (1) D, bits (1) A, bits (1) I, bits (1) F, bits (1) EXLOCK, bits (1) PAN, bits (1) UAO, bits (1) DIT, bits (1) TCO, bits (1) PM, bits (1) PPEND, bits (2) BTYPE, bits (1) ZA, bits (1) SM, bits (1) ALLINT, bits (1) SS, bits (1) IL, bits (2) EL, bits (1) nRW, bits (1) SP, bits (1) Q, bits (4) GE, bits (1) SSBS, bits (8) IT, bits (1) J, bits (1) T, bits (1) E, bits (5) M )">ProcState</a> PSTATE;</pstext>
    </ps>
    <ps name="shared/functions/system/PhysicalCountInt" mylink="shared.functions.system.PhysicalCountInt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysicalCountInt()
// ==================
// Returns the integral part of physical count value of the System counter.

bits(64) <anchor link="impl-shared.PhysicalCountInt.0" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</anchor>()
    return PhysicalCount&lt;87:24&gt;;</pstext>
    </ps>
    <ps name="shared/functions/system/PrivilegeLevel" mylink="shared.functions.system.PrivilegeLevel" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PrivilegeLevel
// ==============
// Privilege Level abstraction.

enumeration <anchor link="PrivilegeLevel" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PrivilegeLevel</anchor> {<anchor link="PL3" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL3</anchor>, <anchor link="PL2" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL2</anchor>, <anchor link="PL1" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL1</anchor>, <anchor link="PL0" hover="enumeration PrivilegeLevel {PL3, PL2, PL1, PL0}">PL0</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/system/ProcState" mylink="shared.functions.system.ProcState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ProcState
// =========
// Armv8 processor state bits.
// There is no significance to the field order.

type <anchor link="ProcState" hover="type ProcState is ( bits (1) N, bits (1) Z, bits (1) C, bits (1) V, bits (1) D, bits (1) A, bits (1) I, bits (1) F, bits (1) EXLOCK, bits (1) PAN, bits (1) UAO, bits (1) DIT, bits (1) TCO, bits (1) PM, bits (1) PPEND, bits (2) BTYPE, bits (1) ZA, bits (1) SM, bits (1) ALLINT, bits (1) SS, bits (1) IL, bits (2) EL, bits (1) nRW, bits (1) SP, bits (1) Q, bits (4) GE, bits (1) SSBS, bits (8) IT, bits (1) J, bits (1) T, bits (1) E, bits (5) M )">ProcState</anchor> is (
    bits (1) N,        // Negative condition flag
    bits (1) Z,        // Zero condition flag
    bits (1) C,        // Carry condition flag
    bits (1) V,        // Overflow condition flag
    bits (1) D,        // Debug mask bit                     [AArch64 only]
    bits (1) A,        // SError interrupt mask bit
    bits (1) I,        // IRQ mask bit
    bits (1) F,        // FIQ mask bit
    bits (1) EXLOCK,   // Lock exception return state
    bits (1) PAN,      // Privileged Access Never Bit        [v8.1]
    bits (1) UAO,      // User Access Override               [v8.2]
    bits (1) DIT,      // Data Independent Timing            [v8.4]
    bits (1) TCO,      // Tag Check Override                 [v8.5, AArch64 only]
    bits (1) PM,       // PMU exception Mask
    bits (1) PPEND,     // synchronous PMU exception to be observed
    bits (2) BTYPE,    // Branch Type                        [v8.5]
    bits (1) ZA,       // Accumulation array enabled         [SME]
    bits (1) SM,       // Streaming SVE mode enabled         [SME]
    bits (1) ALLINT,   // Interrupt mask bit
    bits (1) SS,       // Software step bit
    bits (1) IL,       // Illegal Execution state bit
    bits (2) EL,       // Exception level
    bits (1) nRW,      // Execution state: 0=AArch64, 1=AArch32
    bits (1) SP,       // Stack pointer select: 0=SP0, 1=SPx [AArch64 only]
    bits (1) Q,        // Cumulative saturation flag         [AArch32 only]
    bits (4) GE,       // Greater than or Equal flags        [AArch32 only]
    bits (1) SSBS,     // Speculative Store Bypass Safe
    bits (8) IT,       // If-then bits, RES0 in CPSR         [AArch32 only]
    bits (1) J,        // J bit, RES0                        [AArch32 only, RES0 in SPSR and CPSR]
    bits (1) T,        // T32 bit, RES0 in CPSR              [AArch32 only]
    bits (1) E,        // Endianness bit                     [AArch32 only]
    bits (5) M         // Mode field                         [AArch32 only]
)</pstext>
    </ps>
    <ps name="shared/functions/system/RestoredITBits" mylink="shared.functions.system.RestoredITBits" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RestoredITBits()
// ================
// Get the value of PSTATE.IT to be restored on this exception return.

bits(8) <anchor link="impl-shared.RestoredITBits.1" hover="function: bits(8) RestoredITBits(bits(N) spsr)">RestoredITBits</anchor>(bits(N) spsr)
    it = spsr&lt;15:10,26:25&gt;;

    // When PSTATE.IL is set, it is CONSTRAINED UNPREDICTABLE whether the IT bits are each set
    // to zero or copied from the SPSR.
    if PSTATE.IL == '1' then
        if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ILZEROIT" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ILZEROIT</a>) then return '00000000';
        else return it;

    // The IT bits are forced to zero when they are set to a reserved value.
    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(it&lt;7:4&gt;) &amp;&amp; <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(it&lt;3:0&gt;) then
        return '00000000';

    // The IT bits are forced to zero when returning to A32 state, or when returning to an EL
    // with the ITD bit set to 1, and the IT bits are describing a multi-instruction block.
    itd = if PSTATE.EL == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then HSCTLR.ITD else SCTLR.ITD;
    if (spsr&lt;5&gt; == '0' &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(it)) || (itd == '1' &amp;&amp; !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(it&lt;2:0&gt;)) then
        return '00000000';
    else
        return it;</pstext>
    </ps>
    <ps name="shared/functions/system/SCRType" mylink="shared.functions.system.SCRType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">type <anchor link="SCRType" hover="type SCRType">SCRType</anchor>;</pstext>
    </ps>
    <ps name="shared/functions/system/SCR_GEN" mylink="shared.functions.system.SCR_GEN" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SCR_GEN[]
// =========

SCRType <anchor link="impl-shared.SCR_GEN.read.0" hover="accessor: SCRType SCR_GEN[]">SCR_GEN</anchor>[]
    // AArch32 secure &amp; AArch64 EL3 registers are not architecturally mapped
    assert <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
    bits(64) r;
    if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        r = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(SCR, 64);
    else
        r = SCR_EL3;
    return r;</pstext>
    </ps>
    <ps name="shared/functions/system/SecureOnlyImplementation" mylink="shared.functions.system.SecureOnlyImplementation" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SecureOnlyImplementation()
// ==========================
// Returns TRUE if the security state is always Secure for this implementation.

boolean <anchor link="impl-shared.SecureOnlyImplementation.0" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</anchor>()
    return boolean IMPLEMENTATION_DEFINED "Secure-only implementation";</pstext>
    </ps>
    <ps name="shared/functions/system/SecurityState" mylink="shared.functions.system.SecurityState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SecurityState
// =============
// The Security state of an execution context

enumeration <anchor link="SecurityState" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</anchor> {
    <anchor link="SS_NonSecure" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</anchor>,
    <anchor link="SS_Root" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</anchor>,
    <anchor link="SS_Realm" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</anchor>,
    <anchor link="SS_Secure" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/system/SecurityStateAtEL" mylink="shared.functions.system.SecurityStateAtEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SecurityStateAtEL()
// ===================
// Returns the effective security state at the exception level based off current settings.

SecurityState <anchor link="impl-shared.SecurityStateAtEL.1" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</anchor>(bits(2) EL)
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        if EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then return <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>;
        effective_nse_ns = SCR_EL3.NSE : <a link="impl-shared.EffectiveSCR_EL3_NS.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</a>();
        case effective_nse_ns of
            when '00' if <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then return <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>; else <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
            when '01' return <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
            when '11' return <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>;
            otherwise        <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        if <a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>() then
            return <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
        else
            return <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
    elsif EL == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        return <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
    else
        // For EL2 call only when EL2 is enabled in current security state
        assert(EL != <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> || <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>());
        if !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            return if SCR_EL3.NS == '1' then <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> else <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
        else
            return if SCR.NS == '1' then <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> else <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;</pstext>
    </ps>
    <ps name="shared/functions/system/SendEvent" mylink="shared.functions.system.SendEvent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SendEvent()
// ===========
// Signal an event to all PEs in a multiprocessor system to set their Event Registers.
// When a PE executes the SEV instruction, it causes this function to be executed.

<anchor link="impl-shared.SendEvent.0" hover="function: SendEvent()">SendEvent</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/SendEventLocal" mylink="shared.functions.system.SendEventLocal" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SendEventLocal()
// ================
// Set the local Event Register of this PE.
// When a PE executes the SEVL instruction, it causes this function to be executed.

<anchor link="impl-shared.SendEventLocal.0" hover="function: SendEventLocal()">SendEventLocal</anchor>()
    EventRegister = '1';
    return;</pstext>
    </ps>
    <ps name="shared/functions/system/SetAccumulatedFPExceptions" mylink="shared.functions.system.SetAccumulatedFPExceptions" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetAccumulatedFPExceptions()
// ============================
// Stores FP Exceptions accumulated by the PE.

<anchor link="impl-shared.SetAccumulatedFPExceptions.1" hover="function: SetAccumulatedFPExceptions(bits(8) accumulated_exceptions)">SetAccumulatedFPExceptions</anchor>(bits(8) accumulated_exceptions);</pstext>
    </ps>
    <ps name="shared/functions/system/SetPSTATEFromPSR" mylink="shared.functions.system.SetPSTATEFromPSR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SetPSTATEFromPSR()
// ==================

<anchor link="impl-shared.SetPSTATEFromPSR.1" hover="function: SetPSTATEFromPSR(bits(N) spsr)">SetPSTATEFromPSR</anchor>(bits(N) spsr)
    boolean illegal_psr_state = <a link="impl-shared.IllegalExceptionReturn.1" file="shared_pseudocode.xml" hover="function: boolean IllegalExceptionReturn(bits(N) spsr)">IllegalExceptionReturn</a>(spsr);
    <a link="impl-shared.SetPSTATEFromPSR.2" file="shared_pseudocode.xml" hover="function: SetPSTATEFromPSR(bits(N) spsr_in, boolean illegal_psr_state)">SetPSTATEFromPSR</a>(spsr, illegal_psr_state);

// SetPSTATEFromPSR()
// ==================
// Set PSTATE based on a PSR value

<anchor link="impl-shared.SetPSTATEFromPSR.2" hover="function: SetPSTATEFromPSR(bits(N) spsr_in, boolean illegal_psr_state)">SetPSTATEFromPSR</anchor>(bits(N) spsr_in, boolean illegal_psr_state)
    bits(N) spsr = spsr_in;
    boolean from_aarch64 = !<a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>();
    PSTATE.SS = <a link="impl-shared.DebugExceptionReturnSS.1" file="shared_pseudocode.xml" hover="function: bit DebugExceptionReturnSS(bits(N) spsr)">DebugExceptionReturnSS</a>(spsr);

    ShouldAdvanceSS = FALSE;
    if illegal_psr_state then
        PSTATE.IL = '1';
        if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = bit UNKNOWN;
        if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then PSTATE.BTYPE = bits(2) UNKNOWN;
        if <a link="impl-shared.HaveUAOExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveUAOExt()">HaveUAOExt</a>() then PSTATE.UAO = bit UNKNOWN;
        if <a link="impl-shared.HaveDITExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDITExt()">HaveDITExt</a>() then PSTATE.DIT = bit UNKNOWN;
        if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() then PSTATE.TCO = bit UNKNOWN;
    else
        // State that is reinstated only on a legal exception return
        PSTATE.IL = spsr&lt;20&gt;;
        if spsr&lt;4&gt; == '1' then                    // AArch32 state
            <a link="AArch32.WriteMode.1" file="shared_pseudocode.xml" hover="function: AArch32.WriteMode(bits(5) mode)">AArch32.WriteMode</a>(spsr&lt;4:0&gt;);         // Sets PSTATE.EL correctly
            if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = spsr&lt;23&gt;;
        else                                      // AArch64 state
            PSTATE.nRW = '0';
            PSTATE.EL  = spsr&lt;3:2&gt;;
            PSTATE.SP  = spsr&lt;0&gt;;
            if <a link="impl-shared.HaveBTIExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveBTIExt()">HaveBTIExt</a>() then PSTATE.BTYPE = spsr&lt;11:10&gt;;
            if <a link="impl-shared.HaveSSBSExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveSSBSExt()">HaveSSBSExt</a>() then PSTATE.SSBS = spsr&lt;12&gt;;
            if <a link="impl-shared.HaveUAOExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveUAOExt()">HaveUAOExt</a>() then PSTATE.UAO = spsr&lt;23&gt;;
            if <a link="impl-shared.HaveDITExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDITExt()">HaveDITExt</a>() then PSTATE.DIT = spsr&lt;24&gt;;
            if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() then PSTATE.TCO = spsr&lt;25&gt;;
            if <a link="impl-shared.HaveGCS.0" file="shared_pseudocode.xml" hover="function: boolean HaveGCS()">HaveGCS</a>() then PSTATE.EXLOCK = spsr&lt;34&gt;;

    // If PSTATE.IL is set, it is CONSTRAINED UNPREDICTABLE whether the T bit is set to zero or
    // copied from SPSR.
    if PSTATE.IL == '1' &amp;&amp; PSTATE.nRW == '1' then
        if <a link="impl-shared.ConstrainUnpredictableBool.1" file="shared_pseudocode.xml" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</a>(<a link="Unpredictable_ILZEROT" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ILZEROT</a>) then spsr&lt;5&gt; = '0';

    // State that is reinstated regardless of illegal exception return
    PSTATE.&lt;N,Z,C,V&gt; = spsr&lt;31:28&gt;;
    if <a link="impl-shared.HavePANExt.0" file="shared_pseudocode.xml" hover="function: boolean HavePANExt()">HavePANExt</a>() then PSTATE.PAN = spsr&lt;22&gt;;
    if PSTATE.nRW == '1' then                     // AArch32 state
        PSTATE.Q         = spsr&lt;27&gt;;
        PSTATE.IT        = <a link="impl-shared.RestoredITBits.1" file="shared_pseudocode.xml" hover="function: bits(8) RestoredITBits(bits(N) spsr)">RestoredITBits</a>(spsr);
        ShouldAdvanceIT  = FALSE;
        if <a link="impl-shared.HaveDITExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveDITExt()">HaveDITExt</a>() then
            PSTATE.DIT = (if (<a link="impl-shared.Restarting.0" file="shared_pseudocode.xml" hover="function: boolean Restarting()">Restarting</a>() || from_aarch64) then spsr&lt;24&gt; else spsr&lt;21&gt;);
        PSTATE.GE        = spsr&lt;19:16&gt;;
        PSTATE.E         = spsr&lt;9&gt;;
        PSTATE.&lt;A,I,F&gt;   = spsr&lt;8:6&gt;;             // No PSTATE.D in AArch32 state
        PSTATE.T         = spsr&lt;5&gt;;               // PSTATE.J is RES0
    else                                          // AArch64 state
        if <a link="impl-shared.HaveFeatNMI.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatNMI()">HaveFeatNMI</a>() then PSTATE.ALLINT = spsr&lt;13&gt;;
        PSTATE.&lt;D,A,I,F&gt; = spsr&lt;9:6&gt;;             // No PSTATE.&lt;Q,IT,GE,E,T&gt; in AArch64 state
    return;</pstext>
    </ps>
    <ps name="shared/functions/system/ShouldAdvanceIT" mylink="shared.functions.system.ShouldAdvanceIT" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">boolean ShouldAdvanceIT;</pstext>
    </ps>
    <ps name="shared/functions/system/ShouldAdvanceSS" mylink="shared.functions.system.ShouldAdvanceSS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">boolean ShouldAdvanceSS;</pstext>
    </ps>
    <ps name="shared/functions/system/SpeculationBarrier" mylink="shared.functions.system.SpeculationBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SpeculationBarrier()
// ====================

<anchor link="impl-shared.SpeculationBarrier.0" hover="function: SpeculationBarrier()">SpeculationBarrier</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/SynchronizeContext" mylink="shared.functions.system.SynchronizeContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SynchronizeContext()
// ====================

<anchor link="impl-shared.SynchronizeContext.0" hover="function: SynchronizeContext()">SynchronizeContext</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/SynchronizeErrors" mylink="shared.functions.system.SynchronizeErrors" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SynchronizeErrors()
// ===================
// Implements the error synchronization event.

<anchor link="impl-shared.SynchronizeErrors.0" hover="function: SynchronizeErrors()">SynchronizeErrors</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/TakeUnmaskedPhysicalSErrorInterrupts" mylink="shared.functions.system.TakeUnmaskedPhysicalSErrorInterrupts" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TakeUnmaskedPhysicalSErrorInterrupts()
// ======================================
// Take any pending unmasked physical SError interrupt.

<anchor link="impl-shared.TakeUnmaskedPhysicalSErrorInterrupts.1" hover="function: TakeUnmaskedPhysicalSErrorInterrupts(boolean iesb_req)">TakeUnmaskedPhysicalSErrorInterrupts</anchor>(boolean iesb_req);</pstext>
    </ps>
    <ps name="shared/functions/system/TakeUnmaskedSErrorInterrupts" mylink="shared.functions.system.TakeUnmaskedSErrorInterrupts" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TakeUnmaskedSErrorInterrupts()
// ==============================
// Take any pending unmasked physical SError interrupt or unmasked virtual SError
// interrupt.

<anchor link="impl-shared.TakeUnmaskedSErrorInterrupts.0" hover="function: TakeUnmaskedSErrorInterrupts()">TakeUnmaskedSErrorInterrupts</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/ThisInstr" mylink="shared.functions.system.ThisInstr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ThisInstr()
// ===========

bits(32) <anchor link="impl-shared.ThisInstr.0" hover="function: bits(32) ThisInstr()">ThisInstr</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/ThisInstrLength" mylink="shared.functions.system.ThisInstrLength" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ThisInstrLength()
// =================

integer <anchor link="impl-shared.ThisInstrLength.0" hover="function: integer ThisInstrLength()">ThisInstrLength</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/Unreachable" mylink="shared.functions.system.Unreachable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Unreachable()
// =============

<anchor link="impl-shared.Unreachable.0" hover="function: Unreachable()">Unreachable</anchor>()
    assert FALSE;</pstext>
    </ps>
    <ps name="shared/functions/system/UsingAArch32" mylink="shared.functions.system.UsingAArch32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UsingAArch32()
// ==============
// Return TRUE if the current Exception level is using AArch32, FALSE if using AArch64.

boolean <anchor link="impl-shared.UsingAArch32.0" hover="function: boolean UsingAArch32()">UsingAArch32</anchor>()
    boolean aarch32 = (PSTATE.nRW == '1');
    if !<a link="impl-shared.HaveAArch32.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch32()">HaveAArch32</a>() then assert !aarch32;
    if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then assert aarch32;
    return aarch32;</pstext>
    </ps>
    <ps name="shared/functions/system/ValidSecurityStateAtEL" mylink="shared.functions.system.ValidSecurityStateAtEL" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ValidSecurityStateAtEL()
// ========================
// Returns TRUE if the current settings and architecture choices for this
// implementation permit a valid Security state at the indicated EL.

boolean <anchor link="impl-shared.ValidSecurityStateAtEL.1" hover="function: boolean ValidSecurityStateAtEL(bits(2) el)">ValidSecurityStateAtEL</anchor>(bits(2) el)
    if !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(el) then
        return FALSE;

    if el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        return TRUE;

    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        bits(2) effective_nse_ns = SCR_EL3.NSE : <a link="impl-shared.EffectiveSCR_EL3_NS.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_NS()">EffectiveSCR_EL3_NS</a>();
        if effective_nse_ns == '10' then
            return FALSE;

    if el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        return <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();

    return TRUE;</pstext>
    </ps>
    <ps name="shared/functions/system/VirtualFIQPending" mylink="shared.functions.system.VirtualFIQPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VirtualFIQPending()
// ===================
// Returns TRUE if there is any pending virtual FIQ.

boolean <anchor link="impl-shared.VirtualFIQPending.0" hover="function: boolean VirtualFIQPending()">VirtualFIQPending</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/VirtualIRQPending" mylink="shared.functions.system.VirtualIRQPending" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// VirtualIRQPending()
// ===================
// Returns TRUE if there is any pending virtual IRQ.

boolean <anchor link="impl-shared.VirtualIRQPending.0" hover="function: boolean VirtualIRQPending()">VirtualIRQPending</anchor>();</pstext>
    </ps>
    <ps name="shared/functions/system/WFxType" mylink="shared.functions.system.WFxType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// WFxType
// =======
// WFx instruction types.

enumeration <anchor link="WFxType" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType</anchor> {<anchor link="WFxType_WFE" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFE</anchor>, <anchor link="WFxType_WFI" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFI</anchor>, <anchor link="WFxType_WFET" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFET</anchor>, <anchor link="WFxType_WFIT" hover="enumeration WFxType {WFxType_WFE, WFxType_WFI, WFxType_WFET, WFxType_WFIT}">WFxType_WFIT</anchor>};</pstext>
    </ps>
    <ps name="shared/functions/system/WaitForEvent" mylink="shared.functions.system.WaitForEvent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// WaitForEvent()
// ==============
// PE optionally suspends execution until one of the following occurs:
// - A WFE wakeup event.
// - A reset.
// - The implementation chooses to resume execution.
// - A Wait for Event with Timeout (WFET) is executing, and a local timeout event occurs
// It is IMPLEMENTATION DEFINED whether restarting execution after the period of
// suspension causes the Event Register to be cleared.

<anchor link="impl-shared.WaitForEvent.1" hover="function: WaitForEvent(integer localtimeout)">WaitForEvent</anchor>(integer localtimeout)
    if !(<a link="impl-shared.IsEventRegisterSet.0" file="shared_pseudocode.xml" hover="function: boolean IsEventRegisterSet()">IsEventRegisterSet</a>() || (<a link="impl-shared.HaveFeatWFxT.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatWFxT()">HaveFeatWFxT</a>() &amp;&amp; <a link="impl-shared.LocalTimeoutEvent.1" file="shared_pseudocode.xml" hover="function: boolean LocalTimeoutEvent(integer localtimeout)">LocalTimeoutEvent</a>(localtimeout))) then
        <a link="impl-shared.EnterLowPowerState.0" file="shared_pseudocode.xml" hover="function: EnterLowPowerState()">EnterLowPowerState</a>();
    return;</pstext>
    </ps>
    <ps name="shared/functions/system/WaitForInterrupt" mylink="shared.functions.system.WaitForInterrupt" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// WaitForInterrupt()
// ==================
// PE optionally suspends execution until one of the following occurs:
// - A WFI wakeup event.
// - A reset.
// - The implementation chooses to resume execution.
// - A Wait for Interrupt with Timeout (WFIT) is executing, and a local timeout event occurs.

<anchor link="impl-shared.WaitForInterrupt.1" hover="function: WaitForInterrupt(integer localtimeout)">WaitForInterrupt</anchor>(integer localtimeout)
    if !(<a link="impl-shared.HaveFeatWFxT.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatWFxT()">HaveFeatWFxT</a>() &amp;&amp; <a link="impl-shared.LocalTimeoutEvent.1" file="shared_pseudocode.xml" hover="function: boolean LocalTimeoutEvent(integer localtimeout)">LocalTimeoutEvent</a>(localtimeout)) then
        <a link="impl-shared.EnterLowPowerState.0" file="shared_pseudocode.xml" hover="function: EnterLowPowerState()">EnterLowPowerState</a>();
    return;</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/ConstrainUnpredictable" mylink="shared.functions.unpredictable.ConstrainUnpredictable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConstrainUnpredictable()
// ========================
// Return the appropriate Constraint result to control the caller's behavior.
// The return value is IMPLEMENTATION DEFINED within a permitted list for each
// UNPREDICTABLE case.
// (The permitted list is determined by an assert or case statement at the call site.)

Constraint <anchor link="impl-shared.ConstrainUnpredictable.1" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</anchor>(<a link="Unpredictable" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable</a> which);</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/ConstrainUnpredictableBits" mylink="shared.functions.unpredictable.ConstrainUnpredictableBits" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConstrainUnpredictableBits()
// ============================

// This is a variant of ConstrainUnpredictable for when the result can be Constraint_UNKNOWN.
// If the result is Constraint_UNKNOWN then the function also returns UNKNOWN value, but that
// value is always an allocated value; that is, one for which the behavior is not itself
// CONSTRAINED.

(Constraint,bits(width)) <anchor link="impl-shared.ConstrainUnpredictableBits.2" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</anchor>(<a link="Unpredictable" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable</a> which, integer width);</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/ConstrainUnpredictableBool" mylink="shared.functions.unpredictable.ConstrainUnpredictableBool" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConstrainUnpredictableBool()
// ============================
// This is a variant of the ConstrainUnpredictable function where the result is either
// Constraint_TRUE or Constraint_FALSE.

boolean <anchor link="impl-shared.ConstrainUnpredictableBool.1" hover="function: boolean ConstrainUnpredictableBool(Unpredictable which)">ConstrainUnpredictableBool</anchor>(<a link="Unpredictable" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable</a> which);</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/ConstrainUnpredictableInteger" mylink="shared.functions.unpredictable.ConstrainUnpredictableInteger" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConstrainUnpredictableInteger()
// ===============================
// This is a variant of ConstrainUnpredictable for when the result can be Constraint_UNKNOWN.
// If the result is Constraint_UNKNOWN then the function also returns an UNKNOWN
// value in the range low to high, inclusive.

(Constraint,integer) <anchor link="impl-shared.ConstrainUnpredictableInteger.3" hover="function: (Constraint,integer) ConstrainUnpredictableInteger(integer low, integer high, Unpredictable which)">ConstrainUnpredictableInteger</anchor>(integer low, integer high,
                                                   <a link="Unpredictable" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable</a> which);</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/ConstrainUnpredictableProcedure" mylink="shared.functions.unpredictable.ConstrainUnpredictableProcedure" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ConstrainUnpredictableProcedure()
// =================================
// This is a variant of ConstrainUnpredictable that implements a Constrained
// Unpredictable behavior for a given Unpredictable situation.
// The behavior is within permitted behaviors for a given Unpredictable situation,
// these are documented in the textual part of the architecture specification.
//
// This function is expected to be refined in an IMPLEMENTATION DEFINED manner.
// The details of possible outcomes may not be present in the code and must be interpreted
// for each use with respect to the CONSTRAINED UNPREDICTABLE specifications
// for the specific area.

<anchor link="impl-shared.ConstrainUnpredictableProcedure.1" hover="function: ConstrainUnpredictableProcedure(Unpredictable which)">ConstrainUnpredictableProcedure</anchor>(<a link="Unpredictable" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable</a> which);</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/Constraint" mylink="shared.functions.unpredictable.Constraint" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Constraint
// ==========
// List of Constrained Unpredictable behaviors.

enumeration <anchor link="Constraint" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint</anchor>    {// General
                           <anchor link="Constraint_NONE" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NONE</anchor>,              // Instruction executes with
                                                         // no change or side-effect
                                                         // to its described behavior
                           <anchor link="Constraint_UNKNOWN" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNKNOWN</anchor>,           // Destination register
                                                         // has UNKNOWN value
                           <anchor link="Constraint_UNDEF" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNDEF</anchor>,             // Instruction is UNDEFINED
                           <anchor link="Constraint_UNDEFEL0" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNDEFEL0</anchor>,          // Instruction is UNDEFINED at EL0 only
                           <anchor link="Constraint_NOP" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NOP</anchor>,               // Instruction executes as NOP
                           <anchor link="Constraint_TRUE" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_TRUE</anchor>,
                           <anchor link="Constraint_FALSE" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FALSE</anchor>,
                           <anchor link="Constraint_DISABLED" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_DISABLED</anchor>,
                           <anchor link="Constraint_UNCOND" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_UNCOND</anchor>,            // Instruction executes unconditionally
                           <anchor link="Constraint_COND" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_COND</anchor>,              // Instruction executes conditionally
                           <anchor link="Constraint_ADDITIONAL_DECODE" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_ADDITIONAL_DECODE</anchor>, // Instruction executes
                                                         // with additional decode
                           // Load-store
                           <anchor link="Constraint_WBSUPPRESS" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_WBSUPPRESS</anchor>,
                           <anchor link="Constraint_FAULT" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FAULT</anchor>,
                           <anchor link="Constraint_LIMITED_ATOMICITY" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_LIMITED_ATOMICITY</anchor>, // Accesses are not
                                                         // single-copy atomic
                                                         // above the byte level
                           <anchor link="Constraint_NVNV1_00" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NVNV1_00</anchor>,
                           <anchor link="Constraint_NVNV1_01" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NVNV1_01</anchor>,
                           <anchor link="Constraint_NVNV1_11" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NVNV1_11</anchor>,
                           <anchor link="Constraint_EL1TIMESTAMP" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_EL1TIMESTAMP</anchor>,      // Constrain to Virtual Timestamp
                           <anchor link="Constraint_EL2TIMESTAMP" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_EL2TIMESTAMP</anchor>,      // Constrain to Virtual Timestamp
                           <anchor link="Constraint_OSH" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_OSH</anchor>,               // Constrain to Outer Shareable
                           <anchor link="Constraint_ISH" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_ISH</anchor>,               // Constrain to Inner Shareable
                           <anchor link="Constraint_NSH" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NSH</anchor>,               // Constrain to Nonshareable

                           <anchor link="Constraint_NC" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NC</anchor>,                // Constrain to Noncacheable
                           <anchor link="Constraint_WT" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_WT</anchor>,                // Constrain to Writethrough
                           <anchor link="Constraint_WB" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_WB</anchor>,                // Constrain to Writeback

                           // IPA too large
                           <anchor link="Constraint_FORCE" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FORCE</anchor>, <anchor link="Constraint_FORCENOSLCHECK" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_FORCENOSLCHECK</anchor>,
                           // An unallocated System register value maps onto an allocated value
                           <anchor link="Constraint_MAPTOALLOCATED" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_MAPTOALLOCATED</anchor>,
                           // PMSCR_PCT reserved values select Virtual timestamp
                           <anchor link="Constraint_PMSCR_PCT_VIRT" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_PMSCR_PCT_VIRT</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/unpredictable/Unpredictable" mylink="shared.functions.unpredictable.Unpredictable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Unpredictable
// =============
// List of Constrained Unpredictable situations.

enumeration <anchor link="Unpredictable" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable</anchor> {
                           // VMSR on MVFR
                           <anchor link="Unpredictable_VMSR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_VMSR</anchor>,
                           // Writeback/transfer register overlap (load)
                           <anchor link="Unpredictable_WBOVERLAPLD" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WBOVERLAPLD</anchor>,
                           // Writeback/transfer register overlap (store)
                           <anchor link="Unpredictable_WBOVERLAPST" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WBOVERLAPST</anchor>,
                           // Load Pair transfer register overlap
                           <anchor link="Unpredictable_LDPOVERLAP" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_LDPOVERLAP</anchor>,
                           // Store-exclusive base/status register overlap
                           <anchor link="Unpredictable_BASEOVERLAP" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BASEOVERLAP</anchor>,
                           // Store-exclusive data/status register overlap
                           <anchor link="Unpredictable_DATAOVERLAP" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DATAOVERLAP</anchor>,
                           // Load-store alignment checks
                           <anchor link="Unpredictable_DEVPAGE2" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVPAGE2</anchor>,
                           // Instruction fetch from Device memory
                           <anchor link="Unpredictable_INSTRDEVICE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_INSTRDEVICE</anchor>,
                           // Reserved CPACR value
                           <anchor link="Unpredictable_RESCPACR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESCPACR</anchor>,
                           // Reserved MAIR value
                           <anchor link="Unpredictable_RESMAIR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESMAIR</anchor>,
                           // Effect of SCTLR_ELx.C on Tagged attribute
                           <anchor link="Unpredictable_S1CTAGGED" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_S1CTAGGED</anchor>,
                           // Reserved Stage 2 MemAttr value
                           <anchor link="Unpredictable_S2RESMEMATTR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_S2RESMEMATTR</anchor>,
                           // Reserved TEX:C:B value
                           <anchor link="Unpredictable_RESTEXCB" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTEXCB</anchor>,
                           // Reserved PRRR value
                           <anchor link="Unpredictable_RESPRRR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESPRRR</anchor>,
                           // Reserved DACR field
                           <anchor link="Unpredictable_RESDACR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESDACR</anchor>,
                           // Reserved VTCR.S value
                           <anchor link="Unpredictable_RESVTCRS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESVTCRS</anchor>,
                           // Reserved TCR.TnSZ value
                           <anchor link="Unpredictable_RESTnSZ" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTnSZ</anchor>,
                           // Reserved SCTLR_ELx.TCF value
                           <anchor link="Unpredictable_RESTCF" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTCF</anchor>,
                           // Tag stored to Device memory
                           <anchor link="Unpredictable_DEVICETAGSTORE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DEVICETAGSTORE</anchor>,
                           // Out-of-range TCR.TnSZ value
                           <anchor link="Unpredictable_OORTnSZ" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_OORTnSZ</anchor>,
                           // IPA size exceeds PA size
                           <anchor link="Unpredictable_LARGEIPA" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_LARGEIPA</anchor>,
                           // Syndrome for a known-passing conditional A32 instruction
                           <anchor link="Unpredictable_ESRCONDPASS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ESRCONDPASS</anchor>,
                           // Illegal State exception: zero PSTATE.IT
                           <anchor link="Unpredictable_ILZEROIT" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ILZEROIT</anchor>,
                           // Illegal State exception: zero PSTATE.T
                           <anchor link="Unpredictable_ILZEROT" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ILZEROT</anchor>,
                           // Debug: prioritization of Vector Catch
                           <anchor link="Unpredictable_BPVECTORCATCHPRI" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPVECTORCATCHPRI</anchor>,
                           // Debug Vector Catch: match on 2nd halfword
                           <anchor link="Unpredictable_VCMATCHHALF" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_VCMATCHHALF</anchor>,
                           // Debug Vector Catch: match on Data Abort
                           // or Prefetch abort
                           <anchor link="Unpredictable_VCMATCHDAPA" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_VCMATCHDAPA</anchor>,
                           // Debug watchpoints: non-zero MASK and non-ones BAS
                           <anchor link="Unpredictable_WPMASKANDBAS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPMASKANDBAS</anchor>,
                           // Debug watchpoints: non-contiguous BAS
                           <anchor link="Unpredictable_WPBASCONTIGUOUS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPBASCONTIGUOUS</anchor>,
                           // Debug watchpoints: reserved MASK
                           <anchor link="Unpredictable_RESWPMASK" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESWPMASK</anchor>,
                           // Debug watchpoints: non-zero MASKed bits of address
                           <anchor link="Unpredictable_WPMASKEDBITS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WPMASKEDBITS</anchor>,
                           // Debug breakpoints and watchpoints: reserved control bits
                           <anchor link="Unpredictable_RESBPWPCTRL" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESBPWPCTRL</anchor>,
                           // Debug breakpoints: not implemented
                           <anchor link="Unpredictable_BPNOTIMPL" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPNOTIMPL</anchor>,
                           // Debug breakpoints: reserved type
                           <anchor link="Unpredictable_RESBPTYPE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESBPTYPE</anchor>,
                           // Debug breakpoints: not-context-aware breakpoint
                           <anchor link="Unpredictable_BPNOTCTXCMP" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPNOTCTXCMP</anchor>,
                           // Debug breakpoints: match on 2nd halfword of instruction
                           <anchor link="Unpredictable_BPMATCHHALF" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMATCHHALF</anchor>,
                           // Debug breakpoints: mismatch on 2nd halfword of instruction
                           <anchor link="Unpredictable_BPMISMATCHHALF" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BPMISMATCHHALF</anchor>,
                           // Debug: restart to a misaligned AArch32 PC value
                           <anchor link="Unpredictable_RESTARTALIGNPC" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTARTALIGNPC</anchor>,
                           // Debug: restart to a not-zero-extended AArch32 PC value
                           <anchor link="Unpredictable_RESTARTZEROUPPERPC" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTARTZEROUPPERPC</anchor>,
                           // Zero top 32 bits of X registers in AArch32 state
                           <anchor link="Unpredictable_ZEROUPPER" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ZEROUPPER</anchor>,
                           // Zero top 32 bits of PC on illegal return to
                           // AArch32 state
                           <anchor link="Unpredictable_ERETZEROUPPERPC" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ERETZEROUPPERPC</anchor>,
                           // Force address to be aligned when interworking
                           // branch to A32 state
                           <anchor link="Unpredictable_A32FORCEALIGNPC" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_A32FORCEALIGNPC</anchor>,
                           // SMC disabled
                           <anchor link="Unpredictable_SMD" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SMD</anchor>,
                           // FF speculation
                           <anchor link="Unpredictable_NONFAULT" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_NONFAULT</anchor>,
                           // Zero top bits of Z registers in EL change
                           <anchor link="Unpredictable_SVEZEROUPPER" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVEZEROUPPER</anchor>,
                           // Load mem data in NF loads
                           <anchor link="Unpredictable_SVELDNFDATA" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVELDNFDATA</anchor>,
                           // Write zeros in NF loads
                           <anchor link="Unpredictable_SVELDNFZERO" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SVELDNFZERO</anchor>,
                           // SP alignment fault when predicate is all zero
                           <anchor link="Unpredictable_CHECKSPNONEACTIVE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_CHECKSPNONEACTIVE</anchor>,
                           // Zero top bits of ZA registers in EL change
                           <anchor link="Unpredictable_SMEZEROUPPER" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_SMEZEROUPPER</anchor>,
                           // HCR_EL2.&lt;NV,NV1&gt; == '01'
                           <anchor link="Unpredictable_NVNV1" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_NVNV1</anchor>,
                           // Reserved shareability encoding
                           <anchor link="Unpredictable_Shareability" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_Shareability</anchor>,
                           // Access Flag Update by HW
                           <anchor link="Unpredictable_AFUPDATE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_AFUPDATE</anchor>,
                           // Dirty Bit State Update by HW
                           <anchor link="Unpredictable_DBUPDATE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DBUPDATE</anchor>,
                           // Consider SCTLR[].IESB in Debug state
                           <anchor link="Unpredictable_IESBinDebug" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_IESBinDebug</anchor>,
                           // Bad settings for PMSFCR_EL1/PMSEVFR_EL1/PMSLATFR_EL1
                           <anchor link="Unpredictable_BADPMSFCR" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BADPMSFCR</anchor>,
                           // Zero saved BType value in SPSR_ELx/DPSR_EL0
                           <anchor link="Unpredictable_ZEROBTYPE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ZEROBTYPE</anchor>,
                           // Timestamp constrained to virtual or physical
                           <anchor link="Unpredictable_EL2TIMESTAMP" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_EL2TIMESTAMP</anchor>,
                           <anchor link="Unpredictable_EL1TIMESTAMP" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_EL1TIMESTAMP</anchor>,
                            // Reserved MDCR_EL3.&lt;NSTBE,NSTB&gt; or MDCR_EL3.&lt;NSPBE,NSPB&gt; value
                            <anchor link="Unpredictable_RESERVEDNSxB" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESERVEDNSxB</anchor>,
                           // WFET or WFIT instruction in Debug state
                           <anchor link="Unpredictable_WFxTDEBUG" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_WFxTDEBUG</anchor>,
                           // Address does not support LS64 instructions
                           <anchor link="Unpredictable_LS64UNSUPPORTED" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_LS64UNSUPPORTED</anchor>,
                           // Misaligned exclusives, atomics, acquire/release
                           // to region that is not Normal Cacheable WB
                           <anchor link="Unpredictable_MISALIGNEDATOMIC" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_MISALIGNEDATOMIC</anchor>,
                           // Clearing DCC/ITR sticky flags when instruction is in flight
                           <anchor link="Unpredictable_CLEARERRITEZERO" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_CLEARERRITEZERO</anchor>,
                           // ALUEXCEPTIONRETURN when in user/system mode in
                           // A32 instructions
                           <anchor link="Unpredictable_ALUEXCEPTIONRETURN" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_ALUEXCEPTIONRETURN</anchor>,
                           // Trap to register in debug state are ignored
                           <anchor link="Unpredictable_IGNORETRAPINDEBUG" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_IGNORETRAPINDEBUG</anchor>,
                           // Compare DBGBVR.RESS for BP/WP
                           <anchor link="Unpredictable_DBGxVR_RESS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_DBGxVR_RESS</anchor>,
                           // Inaccessible event counter
                           <anchor link="Unpredictable_PMUEVENTCOUNTER" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_PMUEVENTCOUNTER</anchor>,
                           // Reserved PMSCR.PCT behavior.
                           <anchor link="Unpredictable_PMSCR_PCT" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_PMSCR_PCT</anchor>,
                           // MDCR_EL2.HPMN or HDCR.HPMN is larger than PMCR.N or
                           // FEAT_HPMN0 is not implemented and HPMN is 0.
                           <anchor link="Unpredictable_CounterReservedForEL2" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_CounterReservedForEL2</anchor>,
                           // Generate BRB_FILTRATE event on BRB injection
                           <anchor link="Unpredictable_BRBFILTRATE" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_BRBFILTRATE</anchor>,
                          // Operands for CPY*/SET* instructions overlap or
                          // use 0b11111 as a register specifier
                          <anchor link="Unpredictable_MOPSOVERLAP31" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_MOPSOVERLAP31</anchor>,
                          // Store-only Tag checking on a failed Atomic Compare and Swap
                          <anchor link="Unpredictable_STOREONLYTAGCHECKEDCAS" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_STOREONLYTAGCHECKEDCAS</anchor>,
                           // Reserved PMEVTYPER&lt;n&gt;_EL0.TC value
                           <anchor link="Unpredictable_RESTC" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESTC</anchor>
};</pstext>
    </ps>
    <ps name="shared/functions/vector/AdvSIMDExpandImm" mylink="shared.functions.vector.AdvSIMDExpandImm" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AdvSIMDExpandImm()
// ==================

bits(64) <anchor link="impl-shared.AdvSIMDExpandImm.3" hover="function: bits(64) AdvSIMDExpandImm(bit op, bits(4) cmode, bits(8) imm8)">AdvSIMDExpandImm</anchor>(bit op, bits(4) cmode, bits(8) imm8)
    bits(64) imm64;
    case cmode&lt;3:1&gt; of
        when '000'
            imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24):imm8, 2);
        when '001'
            imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16):imm8:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8), 2);
        when '010'
            imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8):imm8:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16), 2);
        when '011'
            imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24), 2);
        when '100'
            imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8):imm8, 4);
        when '101'
            imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8), 4);
        when '110'
            if cmode&lt;0&gt; == '0' then
                imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(16):imm8:<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(8), 2);
            else
                imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(8):imm8:<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(16), 2);
        when '111'
            if cmode&lt;0&gt; == '0' &amp;&amp; op == '0' then
                imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8, 8);
            if cmode&lt;0&gt; == '0' &amp;&amp; op == '1' then
                imm8a = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;7&gt;, 8); imm8b = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;6&gt;, 8);
                imm8c = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;5&gt;, 8); imm8d = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;4&gt;, 8);
                imm8e = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;3&gt;, 8); imm8f = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;2&gt;, 8);
                imm8g = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;1&gt;, 8); imm8h = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;0&gt;, 8);
                imm64 = imm8a:imm8b:imm8c:imm8d:imm8e:imm8f:imm8g:imm8h;
            if cmode&lt;0&gt; == '1' &amp;&amp; op == '0' then
                imm32 = imm8&lt;7&gt;:NOT(imm8&lt;6&gt;):<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;6&gt;,5):imm8&lt;5:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(19);
                imm64 = <a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm32, 2);
            if cmode&lt;0&gt; == '1' &amp;&amp; op == '1' then
                if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then ReservedEncoding();
                imm64 = imm8&lt;7&gt;:NOT(imm8&lt;6&gt;):<a link="impl-shared.Replicate.2" file="shared_pseudocode.xml" hover="function: bits(M*N) Replicate(bits(M) x, integer N)">Replicate</a>(imm8&lt;6&gt;,8):imm8&lt;5:0&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(48);

    return imm64;</pstext>
    </ps>
    <ps name="shared/functions/vector/MatMulAdd" mylink="shared.functions.vector.MatMulAdd" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// MatMulAdd()
// ===========
//
// Signed or unsigned 8-bit integer matrix multiply and add to 32-bit integer matrix
// result[2, 2] = addend[2, 2] + (op1[2, 8] * op2[8, 2])

bits(N) <anchor link="impl-shared.MatMulAdd.5" hover="function: bits(N) MatMulAdd(bits(N) addend, bits(N) op1, bits(N) op2, boolean op1_unsigned, boolean op2_unsigned)">MatMulAdd</anchor>(bits(N) addend, bits(N) op1, bits(N) op2, boolean op1_unsigned,
                  boolean op2_unsigned)
    assert N == 128;

    bits(N)  result;
    bits(32) sum;
    integer  prod;

    for i = 0 to 1
        for j = 0 to 1
            sum = <a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[addend, 2*i + j, 32];
            for k = 0 to 7
                prod = (<a link="impl-shared.Int.2" file="shared_pseudocode.xml" hover="function: integer Int(bits(N) x, boolean unsigned)">Int</a>(<a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op1, 8*i + k, 8], op1_unsigned) *
                        <a link="impl-shared.Int.2" file="shared_pseudocode.xml" hover="function: integer Int(bits(N) x, boolean unsigned)">Int</a>(<a link="impl-shared.Elem.read.3" file="shared_pseudocode.xml" hover="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[op2, 8*j + k, 8], op2_unsigned));
                sum  = sum + prod;
            <a link="impl-shared.Elem.write.3" file="shared_pseudocode.xml" hover="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, 2*i + j, 32] = sum;

    return result;</pstext>
    </ps>
    <ps name="shared/functions/vector/PolynomialMult" mylink="shared.functions.vector.PolynomialMult" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PolynomialMult()
// ================

bits(M+N) <anchor link="impl-shared.PolynomialMult.2" hover="function: bits(M+N) PolynomialMult(bits(M) op1, bits(N) op2)">PolynomialMult</anchor>(bits(M) op1, bits(N) op2)
    result = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(M+N);
    extended_op2 = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(op2, M+N);
    for i=0 to M-1
        if op1&lt;i&gt; == '1' then
            result = result EOR <a link="impl-shared.LSL.2" file="shared_pseudocode.xml" hover="function: bits(N) LSL(bits(N) x, integer shift)">LSL</a>(extended_op2, i);
    return result;</pstext>
    </ps>
    <ps name="shared/functions/vector/SatQ" mylink="shared.functions.vector.SatQ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SatQ()
// ======

(bits(N), boolean) <anchor link="impl-shared.SatQ.3" hover="function: (bits(N), boolean) SatQ(integer i, integer N, boolean unsigned)">SatQ</anchor>(integer i, integer N, boolean unsigned)
    (result, sat) = if unsigned then <a link="impl-shared.UnsignedSatQ.2" file="shared_pseudocode.xml" hover="function: (bits(N), boolean) UnsignedSatQ(integer i, integer N)">UnsignedSatQ</a>(i, N) else <a link="impl-shared.SignedSatQ.2" file="shared_pseudocode.xml" hover="function: (bits(N), boolean) SignedSatQ(integer i, integer N)">SignedSatQ</a>(i, N);
    return (result, sat);</pstext>
    </ps>
    <ps name="shared/functions/vector/SignedSatQ" mylink="shared.functions.vector.SignedSatQ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SignedSatQ()
// ============

(bits(N), boolean) <anchor link="impl-shared.SignedSatQ.2" hover="function: (bits(N), boolean) SignedSatQ(integer i, integer N)">SignedSatQ</anchor>(integer i, integer N)
    integer result;
    boolean saturated;
    if i &gt; 2^(N-1) - 1 then
        result = 2^(N-1) - 1;  saturated = TRUE;
    elsif i &lt; -(2^(N-1)) then
        result = -(2^(N-1));  saturated = TRUE;
    else
        result = i;  saturated = FALSE;
    return (result&lt;N-1:0&gt;, saturated);</pstext>
    </ps>
    <ps name="shared/functions/vector/UnsignedRSqrtEstimate" mylink="shared.functions.vector.UnsignedRSqrtEstimate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UnsignedRSqrtEstimate()
// =======================

bits(N) <anchor link="impl-shared.UnsignedRSqrtEstimate.1" hover="function: bits(N) UnsignedRSqrtEstimate(bits(N) operand)">UnsignedRSqrtEstimate</anchor>(bits(N) operand)
    assert N == 32;
    bits(N) result;
    if operand&lt;N-1:N-2&gt; == '00' then  // Operands &lt;= 0x3FFFFFFF produce 0xFFFFFFFF
        result = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(N);
    else
        // input is in the range 0x40000000 .. 0xffffffff representing [0.25 .. 1.0)
        // estimate is in the range 256 .. 511 representing [1.0 .. 2.0)
        increasedprecision = FALSE;
        estimate = <a link="impl-shared.RecipSqrtEstimate.2" file="shared_pseudocode.xml" hover="function: integer RecipSqrtEstimate(integer a_in, boolean increasedprecision)">RecipSqrtEstimate</a>(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;31:23&gt;), increasedprecision);
        // result is in the range 0x80000000 .. 0xff800000 representing [1.0 .. 2.0)
        result = estimate&lt;8:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N-9);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/vector/UnsignedRecipEstimate" mylink="shared.functions.vector.UnsignedRecipEstimate" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UnsignedRecipEstimate()
// =======================

bits(N) <anchor link="impl-shared.UnsignedRecipEstimate.1" hover="function: bits(N) UnsignedRecipEstimate(bits(N) operand)">UnsignedRecipEstimate</anchor>(bits(N) operand)
    assert N == 32;
    bits(N) result;
    if operand&lt;N-1&gt; == '0' then  // Operands &lt;= 0x7FFFFFFF produce 0xFFFFFFFF
        result = <a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(N);
    else
        // input is in the range 0x80000000 .. 0xffffffff representing [0.5 .. 1.0)

        // estimate is in the range 256 to 511 representing [1.0 .. 2.0)
        increasedprecision = FALSE;
        estimate = <a link="impl-shared.RecipEstimate.2" file="shared_pseudocode.xml" hover="function: integer RecipEstimate(integer a_in, boolean increasedprecision)">RecipEstimate</a>(<a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(operand&lt;31:23&gt;), increasedprecision);

        // result is in the range 0x80000000 .. 0xff800000 representing [1.0 .. 2.0)
        result = estimate&lt;8:0&gt; : <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(N-9);

    return result;</pstext>
    </ps>
    <ps name="shared/functions/vector/UnsignedSatQ" mylink="shared.functions.vector.UnsignedSatQ" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UnsignedSatQ()
// ==============

(bits(N), boolean) <anchor link="impl-shared.UnsignedSatQ.2" hover="function: (bits(N), boolean) UnsignedSatQ(integer i, integer N)">UnsignedSatQ</anchor>(integer i, integer N)
    integer result;
    boolean saturated;
    if i &gt; 2^N - 1 then
        result = 2^N - 1;  saturated = TRUE;
    elsif i &lt; 0 then
        result = 0;  saturated = TRUE;
    else
        result = i;  saturated = FALSE;
    return (result&lt;N-1:0&gt;, saturated);</pstext>
    </ps>
    <ps name="shared/trace/Common/DebugMemWrite" mylink="shared.trace.Common.DebugMemWrite" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugMemWrite()
// ===============
// Write data to memory one byte at a time. Starting at the passed virtual address.
// Used by SPE.

(PhysMemRetStatus, AddressDescriptor) <anchor link="impl-shared.DebugMemWrite.4" hover="function: (PhysMemRetStatus, AddressDescriptor) DebugMemWrite(bits(64) vaddress, AccessDescriptor accdesc, boolean aligned, bits(8) data)">DebugMemWrite</anchor>(bits(64) vaddress, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc,
                                                    boolean aligned, bits(8) data)

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus = <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> UNKNOWN;

    // Translate virtual address
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc;
    integer size = 1;
    addrdesc = <a link="AArch64.TranslateAddress.4" file="shared_pseudocode.xml" hover="function: AddressDescriptor AArch64.TranslateAddress(bits(64) va, AccessDescriptor accdesc, boolean aligned, integer size)">AArch64.TranslateAddress</a>(vaddress, accdesc, aligned, size);

    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(addrdesc) then
        return (memstatus, addrdesc);

    memstatus = <a link="impl-shared.PhysMemWrite.4" file="shared_pseudocode.xml" hover="function: PhysMemRetStatus PhysMemWrite(AddressDescriptor desc, integer size, AccessDescriptor accdesc, bits(8*size) value)">PhysMemWrite</a>(addrdesc, 1, accdesc, data);

    return (memstatus, addrdesc);</pstext>
    </ps>
    <ps name="shared/trace/Common/DebugWriteExternalAbort" mylink="shared.trace.Common.DebugWriteExternalAbort" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugWriteExternalAbort()
// =========================
// Populate the syndrome register for an External abort caused by a call of DebugMemWrite().

<anchor link="impl-shared.DebugWriteExternalAbort.3" hover="function: DebugWriteExternalAbort(PhysMemRetStatus memstatus, AddressDescriptor addrdesc, bits(64) start_vaddr)">DebugWriteExternalAbort</anchor>(<a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc,
                        bits(64) start_vaddr)

    boolean iswrite = TRUE;

    boolean handle_as_SError = FALSE;
    boolean async_external_abort = FALSE;
    bits(64) syndrome;
    case addrdesc.fault.access.acctype of
        when <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>
            handle_as_SError = boolean IMPLEMENTATION_DEFINED "SPE SyncExternal as SError";
            async_external_abort = boolean IMPLEMENTATION_DEFINED "SPE async External abort";
            syndrome = PMBSR_EL1&lt;63:0&gt;;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    boolean ttw_abort;
    ttw_abort = addrdesc.fault.statuscode IN {<a link="Fault_SyncExternalOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncExternalOnWalk</a>,
                                              <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>};
    <a link="Fault" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault</a> statuscode = if ttw_abort then addrdesc.fault.statuscode else memstatus.statuscode;
    bit extflag = if ttw_abort then addrdesc.fault.extflag else memstatus.extflag;
    if (statuscode IN {<a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>, <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>} || handle_as_SError) then
        // ASYNC Fault -&gt; SError or SYNC Fault handled as SError
        <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = <a link="impl-shared.NoFault.0" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault()">NoFault</a>();
        boolean parity = statuscode IN {<a link="Fault_SyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParity</a>, <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a>,
                                        <a link="Fault_SyncParityOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_SyncParityOnWalk</a>};
        fault.statuscode = if parity then <a link="Fault_AsyncParity" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncParity</a> else <a link="Fault_AsyncExternal" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_AsyncExternal</a>;
        if <a link="impl-shared.HaveRASExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveRASExt()">HaveRASExt</a>() then
            fault.merrorstate = memstatus.merrorstate;
        fault.extflag = extflag;
        fault.access.acctype = addrdesc.fault.access.acctype;
        <a link="impl-shared.PendSErrorInterrupt.1" file="shared_pseudocode.xml" hover="function: PendSErrorInterrupt(FaultRecord fault)">PendSErrorInterrupt</a>(fault);
    else
        // SYNC Fault, not handled by SError
        // Generate Buffer Management Event
        // EA bit
        syndrome&lt;18&gt; = '1';

        // DL bit for SPE
        if addrdesc.fault.access.acctype == <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a> &amp;&amp; (async_external_abort ||
            (start_vaddr != addrdesc.vaddress)) then
            syndrome&lt;19&gt; = '1';

        // Do not change following values if previous Buffer Management Event
        // has not been handled.
        // S bit
        if <a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(syndrome&lt;17&gt;) then
            syndrome&lt;17&gt; = '1';

            // EC bits
            bits(6) ec;
            if (<a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; addrdesc.fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> &amp;&amp;
                addrdesc.fault.gpcf.gpf != <a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a>) then
                ec = '011110';
            else
                ec = if addrdesc.fault.secondstage then '100101' else '100100';
            syndrome&lt;31:26&gt; = ec;

            // MSS bits
            if async_external_abort then
                syndrome&lt;15:0&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(10) : '010001';
            else
                syndrome&lt;15:0&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(10) : <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(statuscode, addrdesc.fault.level);

        case addrdesc.fault.access.acctype of
            when <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>
                PMBSR_EL1&lt;63:0&gt; = syndrome;
            otherwise
                <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/trace/Common/DebugWriteFault" mylink="shared.trace.Common.DebugWriteFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DebugWriteFault()
// =================
// Populate the syndrome register for a Translation fault caused by a call of DebugMemWrite().

<anchor link="impl-shared.DebugWriteFault.2" hover="function: DebugWriteFault(bits(64) vaddress, FaultRecord fault)">DebugWriteFault</anchor>(bits(64) vaddress, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    bits(64) syndrome;
    case fault.access.acctype of
        when <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>
            syndrome = PMBSR_EL1&lt;63:0&gt;;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    // MSS
    syndrome&lt;15:0&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(10) : <a link="impl-shared.EncodeLDFSC.2" file="shared_pseudocode.xml" hover="function: bits(6) EncodeLDFSC(Fault statuscode, integer level)">EncodeLDFSC</a>(fault.statuscode, fault.level);

    // MSS2
    syndrome&lt;55:32&gt; = <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(24);

    // EC bits
    bits(6) ec;
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() &amp;&amp; fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> &amp;&amp; fault.gpcf.gpf != <a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a> then
        ec = '011110';
    else
        ec = if fault.secondstage then '100101' else '100100';
    syndrome&lt;31:26&gt; = ec;

    // S bit
    syndrome&lt;17&gt; = '1';

    if fault.statuscode == <a link="Fault_Permission" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Permission</a> then
        // assuredonly bit
        syndrome&lt;39&gt; = if fault.assuredonly then '1' else '0';
        // overlay bit
        syndrome&lt;38&gt; = if fault.overlay then '1' else '0';
        // dirtybit
        syndrome&lt;37&gt; = if fault.dirtybit then '1' else '0';

    case fault.access.acctype of
        when <a link="AccessType_SPE" file="shared_pseudocode.xml" hover="enumeration AccessType { AccessType_IFETCH, AccessType_GPR, AccessType_ASIMD, AccessType_SVE, AccessType_SME, AccessType_IC, AccessType_DC, AccessType_DCZero, AccessType_AT, AccessType_NV2, AccessType_SPE, AccessType_GCS, AccessType_TRBE, AccessType_GPTW, AccessType_TTW }">AccessType_SPE</a>
            PMBSR_EL1&lt;63:0&gt; = syndrome;
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    // Buffer Write Pointer already points to the address that generated the fault.
    // Writing to memory never started so no data loss. DL is unchanged.

    return;</pstext>
    </ps>
    <ps name="shared/trace/Common/GetTimestamp" mylink="shared.trace.Common.GetTimestamp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GetTimestamp()
// ==============
// Returns the Timestamp depending on the type

bits(64) <anchor link="impl-shared.GetTimestamp.1" hover="function: bits(64) GetTimestamp(TimeStamp timeStampType)">GetTimestamp</anchor>(<a link="TimeStamp" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp</a> timeStampType)
    case timeStampType of
        when <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>
            return <a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>();
        when <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>
            return <a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>() - CNTVOFF_EL2;
        when <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>
            bits(64) physoff = if <a link="impl-shared.PhysicalOffsetIsValid.0" file="shared_pseudocode.xml" hover="function: boolean PhysicalOffsetIsValid()">PhysicalOffsetIsValid</a>() then CNTPOFF_EL2 else <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
            return <a link="impl-shared.PhysicalCountInt.0" file="shared_pseudocode.xml" hover="function: bits(64) PhysicalCountInt()">PhysicalCountInt</a>() - physoff;
        when <a link="TimeStamp_None" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_None</a>
            return <a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(64);
        when <a link="TimeStamp_CoreSight" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_CoreSight</a>
            return bits(64) IMPLEMENTATION_DEFINED "CoreSight timestamp";
        otherwise
            <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/trace/Common/PhysicalOffsetIsValid" mylink="shared.trace.Common.PhysicalOffsetIsValid" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PhysicalOffsetIsValid()
// =======================
// Returns whether the Physical offset for the timestamp is valid

boolean <anchor link="impl-shared.PhysicalOffsetIsValid.0" hover="function: boolean PhysicalOffsetIsValid()">PhysicalOffsetIsValid</anchor>()
    if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then
        return FALSE;
    elsif !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) || !<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() then
        return FALSE;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.NS == '1' &amp;&amp; <a link="impl-shared.EffectiveSCR_EL3_RW.0" file="shared_pseudocode.xml" hover="function: bit EffectiveSCR_EL3_RW()">EffectiveSCR_EL3_RW</a>() == '0' then
        return FALSE;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR_EL3.ECVEn == '0' then
        return FALSE;
    elsif CNTHCTL_EL2.ECV == '0' then
        return FALSE;
    else
        return TRUE;</pstext>
    </ps>
    <ps name="shared/trace/TraceBranch/BranchNotTaken" mylink="shared.trace.TraceBranch.BranchNotTaken" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// BranchNotTaken()
// ================
// Called when a branch is not taken.

<anchor link="impl-shared.BranchNotTaken.2" hover="function: BranchNotTaken(BranchType branchtype, boolean branch_conditional)">BranchNotTaken</anchor>(<a link="BranchType" file="shared_pseudocode.xml" hover="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN}">BranchType</a> branchtype, boolean branch_conditional)
    boolean branchtaken = FALSE;
    if <a link="impl-shared.HaveStatisticalProfiling.0" file="shared_pseudocode.xml" hover="function: boolean HaveStatisticalProfiling()">HaveStatisticalProfiling</a>() then
        <a link="impl-aarch64.SPEBranch.4" file="shared_pseudocode.xml" hover="function: SPEBranch(bits(N) target, BranchType branch_type, boolean conditional, boolean taken_flag)">SPEBranch</a>(bits(64) UNKNOWN, branchtype, branch_conditional, branchtaken);
    return;</pstext>
    </ps>
    <ps name="shared/trace/TraceBuffer/TraceBufferEnabled" mylink="shared.trace.TraceBuffer.TraceBufferEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceBufferEnabled()
// ====================

boolean <anchor link="impl-shared.TraceBufferEnabled.0" hover="function: boolean TraceBufferEnabled()">TraceBufferEnabled</anchor>()
    if !<a link="impl-shared.HaveTraceBufferExtension.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceBufferExtension()">HaveTraceBufferExtension</a>() || TRBLIMITR_EL1.E == '0' then
        return FALSE;
    if !<a link="impl-shared.SelfHostedTraceEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</a>() then
        return FALSE;
    (-, el) = <a link="impl-shared.TraceBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) TraceBufferOwner()">TraceBufferOwner</a>();
    return !<a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el);</pstext>
    </ps>
    <ps name="shared/trace/TraceBuffer/TraceBufferOwner" mylink="shared.trace.TraceBuffer.TraceBufferOwner" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceBufferOwner()
// ==================
// Return the owning Security state and Exception level. Must only be called
// when SelfHostedTraceEnabled() is TRUE.

(SecurityState, bits(2)) <anchor link="impl-shared.TraceBufferOwner.0" hover="function: (SecurityState, bits(2)) TraceBufferOwner()">TraceBufferOwner</anchor>()
    assert <a link="impl-shared.HaveTraceBufferExtension.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceBufferExtension()">HaveTraceBufferExtension</a>() &amp;&amp; <a link="impl-shared.SelfHostedTraceEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</a>();

    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> owning_ss;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        bits(3) state_bits;
        if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
            state_bits = MDCR_EL3.&lt;NSTBE,NSTB&gt;;
            if (state_bits IN {'10x'} ||
                (!<a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() &amp;&amp; state_bits IN {'00x'})) then
                // Reserved value
                (-, state_bits) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESERVEDNSxB" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESERVEDNSxB</a>, 3);
        else
            state_bits = '0' : MDCR_EL3.NSTB;

        case state_bits of
            when '00x' owning_ss = <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>;
            when '01x' owning_ss = <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
            when '11x' owning_ss = <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>;
    else
        owning_ss = if <a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>() then <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> else <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>;
    bits(2) owning_el;
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) &amp;&amp; (owning_ss != <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> || <a link="impl-shared.IsSecureEL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean IsSecureEL2Enabled()">IsSecureEL2Enabled</a>()) then
        owning_el = if MDCR_EL2.E2TB == '00' then <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> else <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    else
        owning_el = <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;
    return (owning_ss, owning_el);</pstext>
    </ps>
    <ps name="shared/trace/TraceBuffer/TraceBufferRunning" mylink="shared.trace.TraceBuffer.TraceBufferRunning" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceBufferRunning()
// ====================

boolean <anchor link="impl-shared.TraceBufferRunning.0" hover="function: boolean TraceBufferRunning()">TraceBufferRunning</anchor>()
    return <a link="impl-shared.TraceBufferEnabled.0" file="shared_pseudocode.xml" hover="function: boolean TraceBufferEnabled()">TraceBufferEnabled</a>() &amp;&amp; TRBSR_EL1.S == '0';</pstext>
    </ps>
    <ps name="shared/trace/TraceInstrumentationAllowed/TraceInstrumentationAllowed" mylink="shared.trace.TraceInstrumentationAllowed.TraceInstrumentationAllowed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceInstrumentationAllowed()
// =============================
// Returns TRUE if Instrumentation Trace is allowed
// in the given Exception level and Security state.

boolean <anchor link="impl-shared.TraceInstrumentationAllowed.2" hover="function: boolean TraceInstrumentationAllowed(SecurityState ss, bits(2) el)">TraceInstrumentationAllowed</anchor>(<a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss, bits(2) el)
    if !IsFeatureImplemented(FEAT_ITE) then return FALSE;
    if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(el) then return FALSE;

    if <a link="impl-shared.TraceAllowed.1" file="shared_pseudocode.xml" hover="function: boolean TraceAllowed(bits(2) el)">TraceAllowed</a>(el) then
        bit ite_bit;
        case el of
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> ite_bit = '0';
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> ite_bit = TRCITECR_EL2.E2E;
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> ite_bit = TRCITECR_EL1.E1E;
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
                if <a link="impl-shared.EffectiveTGE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveTGE()">EffectiveTGE</a>() == '1' then
                    ite_bit = TRCITECR_EL2.E0HE;
                else
                    ite_bit = TRCITECR_EL1.E0E;

        if <a link="impl-shared.SelfHostedTraceEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</a>() then
            return ite_bit == '1';
        else
            bit el_bit;
            bit ss_bit;
            case el of
                when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> el_bit = TRCITEEDCR.E0;
                when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> el_bit = TRCITEEDCR.E1;
                when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> el_bit = TRCITEEDCR.E2;
                when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> el_bit = TRCITEEDCR.E3;
            case ss of
                when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>     ss_bit = TRCITEEDCR.RL;
                when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>    ss_bit = TRCITEEDCR.S;
                when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a> ss_bit = TRCITEEDCR.NS;
                otherwise ss_bit = '1';

            boolean ed_allowed = ss_bit == '1' &amp;&amp; el_bit == '1';

            if TRCCONFIGR.ITO == '1' then
                return ed_allowed;
            else
                return ed_allowed &amp;&amp; ite_bit == '1';
    else
        return FALSE;</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/EffectiveE0HTRE" mylink="shared.trace.selfhosted.EffectiveE0HTRE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveE0HTRE()
// =================
// Returns effective E0HTRE value

bit <anchor link="impl-shared.EffectiveE0HTRE.0" hover="function: bit EffectiveE0HTRE()">EffectiveE0HTRE</anchor>()
    return if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then HTRFCR.E0HTRE else TRFCR_EL2.E0HTRE;</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/EffectiveE0TRE" mylink="shared.trace.selfhosted.EffectiveE0TRE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveE0TRE()
// ================
// Returns effective E0TRE value

bit <anchor link="impl-shared.EffectiveE0TRE.0" hover="function: bit EffectiveE0TRE()">EffectiveE0TRE</anchor>()
    return if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>) then TRFCR.E0TRE else TRFCR_EL1.E0TRE;</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/EffectiveE1TRE" mylink="shared.trace.selfhosted.EffectiveE1TRE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveE1TRE()
// ================
// Returns effective E1TRE value

bit <anchor link="impl-shared.EffectiveE1TRE.0" hover="function: bit EffectiveE1TRE()">EffectiveE1TRE</anchor>()
    return if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then TRFCR.E1TRE else TRFCR_EL1.E1TRE;</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/EffectiveE2TRE" mylink="shared.trace.selfhosted.EffectiveE2TRE" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveE2TRE()
// ================
// Returns effective E2TRE value

bit <anchor link="impl-shared.EffectiveE2TRE.0" hover="function: bit EffectiveE2TRE()">EffectiveE2TRE</anchor>()
    return if <a link="impl-shared.UsingAArch32.0" file="shared_pseudocode.xml" hover="function: boolean UsingAArch32()">UsingAArch32</a>() then HTRFCR.E2TRE else TRFCR_EL2.E2TRE;</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/SelfHostedTraceEnabled" mylink="shared.trace.selfhosted.SelfHostedTraceEnabled" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SelfHostedTraceEnabled()
// ========================
// Returns TRUE if Self-hosted Trace is enabled.

boolean <anchor link="impl-shared.SelfHostedTraceEnabled.0" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</anchor>()
    bit secure_trace_enable = '0';
    if !(<a link="impl-shared.HaveTraceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceExt()">HaveTraceExt</a>() &amp;&amp; <a link="impl-shared.HaveSelfHostedTrace.0" file="shared_pseudocode.xml" hover="function: boolean HaveSelfHostedTrace()">HaveSelfHostedTrace</a>()) then return FALSE;
    if EDSCR.TFO == '0' then return TRUE;
    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        secure_trace_enable = if <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>() then MDCR_EL3.STE else '0';
        return ((secure_trace_enable == '1' &amp;&amp; !<a link="impl-shared.ExternalSecureNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureNoninvasiveDebugEnabled()">ExternalSecureNoninvasiveDebugEnabled</a>()) ||
                (MDCR_EL3.RLTE == '1' &amp;&amp; !<a link="impl-shared.ExternalRealmNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalRealmNoninvasiveDebugEnabled()">ExternalRealmNoninvasiveDebugEnabled</a>()));
    if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
        secure_trace_enable = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SDCR.STE else MDCR_EL3.STE;
    else
        secure_trace_enable = if <a link="impl-shared.SecureOnlyImplementation.0" file="shared_pseudocode.xml" hover="function: boolean SecureOnlyImplementation()">SecureOnlyImplementation</a>() then '1' else '0';

    if secure_trace_enable == '1' &amp;&amp; !<a link="impl-shared.ExternalSecureNoninvasiveDebugEnabled.0" file="shared_pseudocode.xml" hover="function: boolean ExternalSecureNoninvasiveDebugEnabled()">ExternalSecureNoninvasiveDebugEnabled</a>() then
        return TRUE;

    return FALSE;</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/TraceAllowed" mylink="shared.trace.selfhosted.TraceAllowed" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceAllowed()
// ==============
// Returns TRUE if Self-hosted Trace is allowed in the given Exception level.

boolean <anchor link="impl-shared.TraceAllowed.1" hover="function: boolean TraceAllowed(bits(2) el)">TraceAllowed</anchor>(bits(2) el)
    if !<a link="impl-shared.HaveTraceExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceExt()">HaveTraceExt</a>() then return FALSE;
    if <a link="impl-shared.SelfHostedTraceEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</a>() then
        boolean trace_allowed;
        ss = <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(el);
        // Detect scenarios where tracing in this Security state is never allowed.
        case ss of
            when <a link="SS_NonSecure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_NonSecure</a>
                trace_allowed = TRUE;
            when <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>
                bit trace_bit;
                if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
                    trace_bit = if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then SDCR.STE else MDCR_EL3.STE;
                else
                    trace_bit = '1';
                trace_allowed = trace_bit == '1';
            when <a link="SS_Realm" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Realm</a>
                trace_allowed = MDCR_EL3.RLTE == '1';
            when <a link="SS_Root" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Root</a>
                trace_allowed = FALSE;

        // Tracing is prohibited if the trace buffer owning security state is not the
        // current Security state or the owning Exception level is a lower Exception level.
        if <a link="impl-shared.HaveTraceBufferExtension.0" file="shared_pseudocode.xml" hover="function: boolean HaveTraceBufferExtension()">HaveTraceBufferExtension</a>() &amp;&amp; <a link="impl-shared.TraceBufferEnabled.0" file="shared_pseudocode.xml" hover="function: boolean TraceBufferEnabled()">TraceBufferEnabled</a>() then
            (owning_ss, owning_el) = <a link="impl-shared.TraceBufferOwner.0" file="shared_pseudocode.xml" hover="function: (SecurityState, bits(2)) TraceBufferOwner()">TraceBufferOwner</a>();
            if (ss != owning_ss || <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(owning_el) &lt; <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(el) ||
                (<a link="impl-shared.EffectiveTGE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveTGE()">EffectiveTGE</a>() == '1' &amp;&amp; owning_el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>)) then
                trace_allowed = FALSE;

        bit TRE_bit;
        case el of
            when <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>  TRE_bit = if !<a link="impl-shared.HaveAArch64.0" file="shared_pseudocode.xml" hover="function: boolean HaveAArch64()">HaveAArch64</a>() then TRFCR.E1TRE else '0';
            when <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>  TRE_bit = <a link="impl-shared.EffectiveE2TRE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveE2TRE()">EffectiveE2TRE</a>();
            when <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>  TRE_bit = <a link="impl-shared.EffectiveE1TRE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveE1TRE()">EffectiveE1TRE</a>();
            when <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>
                if <a link="impl-shared.EffectiveTGE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveTGE()">EffectiveTGE</a>() == '1' then
                    TRE_bit = <a link="impl-shared.EffectiveE0HTRE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveE0HTRE()">EffectiveE0HTRE</a>();
                else
                    TRE_bit = <a link="impl-shared.EffectiveE0TRE.0" file="shared_pseudocode.xml" hover="function: bit EffectiveE0TRE()">EffectiveE0TRE</a>();

        return trace_allowed &amp;&amp; TRE_bit == '1';
    else
        return <a link="impl-shared.ExternalNoninvasiveDebugAllowed.1" file="shared_pseudocode.xml" hover="function: boolean ExternalNoninvasiveDebugAllowed(bits(2) el)">ExternalNoninvasiveDebugAllowed</a>(el);</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/TraceContextIDR2" mylink="shared.trace.selfhosted.TraceContextIDR2" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceContextIDR2()
// ==================

boolean <anchor link="impl-shared.TraceContextIDR2.0" hover="function: boolean TraceContextIDR2()">TraceContextIDR2</anchor>()
    if !<a link="impl-shared.TraceAllowed.1" file="shared_pseudocode.xml" hover="function: boolean TraceAllowed(bits(2) el)">TraceAllowed</a>(PSTATE.EL)|| !<a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then return FALSE;
    return (!<a link="impl-shared.SelfHostedTraceEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</a>() || TRFCR_EL2.CX == '1');</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/TraceSynchronizationBarrier" mylink="shared.trace.selfhosted.TraceSynchronizationBarrier" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceSynchronizationBarrier()
// =============================
// Memory barrier instruction that preserves the relative order of memory accesses to System
// registers due to trace operations and other memory accesses to the same registers

<anchor link="impl-shared.TraceSynchronizationBarrier.0" hover="function: TraceSynchronizationBarrier()">TraceSynchronizationBarrier</anchor>();</pstext>
    </ps>
    <ps name="shared/trace/selfhosted/TraceTimeStamp" mylink="shared.trace.selfhosted.TraceTimeStamp" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TraceTimeStamp()
// ================

TimeStamp <anchor link="impl-shared.TraceTimeStamp.0" hover="function: TimeStamp TraceTimeStamp()">TraceTimeStamp</anchor>()
    if <a link="impl-shared.SelfHostedTraceEnabled.0" file="shared_pseudocode.xml" hover="function: boolean SelfHostedTraceEnabled()">SelfHostedTraceEnabled</a>() then
        if <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then
            TS_el2 = TRFCR_EL2.TS;
            if !<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() &amp;&amp; TS_el2 == '10' then
                // Reserved value
                (-, TS_el2) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_EL2TIMESTAMP" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_EL2TIMESTAMP</a>, 2);

            case TS_el2 of
                when '00'
                    // Falls out to check TRFCR_EL1.TS
                when '01'
                    return <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
                when '10'
                    assert <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>();  // Otherwise ConstrainUnpredictableBits removes this case
                    return <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>;
                when '11'
                    return <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>;

        TS_el1 = TRFCR_EL1.TS;
        if TS_el1 == '00' || (!<a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>() &amp;&amp; TS_el1 == '10') then
            // Reserved value
            (-, TS_el1) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_EL1TIMESTAMP" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_EL1TIMESTAMP</a>, 2);

        case TS_el1 of
            when '01'
                return <a link="TimeStamp_Virtual" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Virtual</a>;
            when '10'
                assert <a link="impl-shared.HaveECVExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveECVExt()">HaveECVExt</a>();
                return <a link="TimeStamp_OffsetPhysical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_OffsetPhysical</a>;
            when '11'
                return <a link="TimeStamp_Physical" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_Physical</a>;
            otherwise
                <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();         // ConstrainUnpredictableBits removes this case
    else
        return <a link="TimeStamp_CoreSight" file="shared_pseudocode.xml" hover="enumeration TimeStamp { TimeStamp_None, TimeStamp_CoreSight, TimeStamp_Physical, TimeStamp_OffsetPhysical, TimeStamp_Virtual  }">TimeStamp_CoreSight</a>;</pstext>
    </ps>
    <ps name="shared/trace/system/IsTraceCorePowered" mylink="shared.trace.system.IsTraceCorePowered" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// IsTraceCorePowered()
// ====================
// Returns TRUE if the Trace Core Power Domain is powered up

boolean <anchor link="impl-shared.IsTraceCorePowered.0" hover="function: boolean IsTraceCorePowered()">IsTraceCorePowered</anchor>();</pstext>
    </ps>
    <ps name="shared/translation/at" mylink="shared.translation.at" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">enumeration <anchor link="TranslationStage" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage</anchor> {
    <anchor link="TranslationStage_1" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_1</anchor>,
    <anchor link="TranslationStage_12" hover="enumeration TranslationStage { TranslationStage_1, TranslationStage_12 }">TranslationStage_12</anchor>
};

enumeration <anchor link="ATAccess" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess</anchor> {
    <anchor link="ATAccess_Read" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_Read</anchor>,
    <anchor link="ATAccess_Write" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_Write</anchor>,
    <anchor link="ATAccess_ReadPAN" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_ReadPAN</anchor>,
    <anchor link="ATAccess_WritePAN" hover="enumeration ATAccess { ATAccess_Read, ATAccess_Write, ATAccess_ReadPAN, ATAccess_WritePAN }">ATAccess_WritePAN</anchor>
};</pstext>
    </ps>
    <ps name="shared/translation/at/EncodePARAttrs" mylink="shared.translation.at.EncodePARAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EncodePARAttrs()
// ================
// Convert orthogonal attributes and hints to 64-bit PAR ATTR field.

bits(8) <anchor link="impl-shared.EncodePARAttrs.1" hover="function: bits(8) EncodePARAttrs(MemoryAttributes memattrs)">EncodePARAttrs</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    bits(8) result;

    if <a link="impl-shared.HaveMTEExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEExt()">HaveMTEExt</a>() &amp;&amp; memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        if <a link="impl-shared.HaveMTEPermExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEPermExt()">HaveMTEPermExt</a>() &amp;&amp; memattrs.notagaccess then
            result&lt;7:0&gt; = '11100000';
        else
            result&lt;7:0&gt; = '11110000';
        return result;

    if memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
        result&lt;7:4&gt; = '0000';
        case memattrs.device of
            when <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a> result&lt;3:0&gt; = '0000';
            when <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a>  result&lt;3:0&gt; = '0100';
            when <a link="DeviceType_nGRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGRE</a>   result&lt;3:0&gt; = '1000';
            when <a link="DeviceType_GRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_GRE</a>    result&lt;3:0&gt; = '1100';
            otherwise              <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
        result&lt;0&gt; = NOT memattrs.xs;
    else
        if memattrs.xs == '0' then
            if (memattrs.outer.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> &amp;&amp; memattrs.inner.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> &amp;&amp;
                    !memattrs.outer.transient &amp;&amp; memattrs.outer.hints == <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>) then
                return '10100000';
            elsif memattrs.outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp; memattrs.inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
                return '01000000';

        if memattrs.outer.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> then
            result&lt;7:6&gt; = if memattrs.outer.transient then '00' else '10';
            result&lt;5:4&gt; = memattrs.outer.hints;
        elsif memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> then
            result&lt;7:6&gt; = if memattrs.outer.transient then '01' else '11';
            result&lt;5:4&gt; = memattrs.outer.hints;
        else // MemAttr_NC
            result&lt;7:4&gt; = '0100';

        if memattrs.inner.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> then
            result&lt;3:2&gt; = if memattrs.inner.transient then '00' else '10';
            result&lt;1:0&gt; = memattrs.inner.hints;
        elsif memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> then
            result&lt;3:2&gt; = if memattrs.inner.transient then '01' else '11';
            result&lt;1:0&gt; = memattrs.inner.hints;
        else // MemAttr_NC
            result&lt;3:0&gt; = '0100';

    return result;</pstext>
    </ps>
    <ps name="shared/translation/at/PAREncodeShareability" mylink="shared.translation.at.PAREncodeShareability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PAREncodeShareability()
// =======================
// Derive 64-bit PAR SH field.

bits(2) <anchor link="impl-shared.PAREncodeShareability.1" hover="function: bits(2) PAREncodeShareability(MemoryAttributes memattrs)">PAREncodeShareability</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if (memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> ||
            (memattrs.inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp;
             memattrs.outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>)) then
        // Force Outer-Shareable on Device and Normal Non-Cacheable memory
        return '10';

    case memattrs.shareability of
        when <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a> return '00';
        when <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a> return '11';
        when <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> return '10';</pstext>
    </ps>
    <ps name="shared/translation/at/ReportedPARAttrs" mylink="shared.translation.at.ReportedPARAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportedPARAttrs()
// ==================
// The value returned in this field can be the resulting attribute, as determined by any permitted
// implementation choices and any applicable configuration bits, instead of the value that appears
// in the translation table descriptor.

bits(8) <anchor link="impl-shared.ReportedPARAttrs.1" hover="function: bits(8) ReportedPARAttrs(bits(8) parattrs)">ReportedPARAttrs</anchor>(bits(8) parattrs);</pstext>
    </ps>
    <ps name="shared/translation/at/ReportedPARShareability" mylink="shared.translation.at.ReportedPARShareability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ReportedPARShareability()
// =========================
// The value returned in SH field can be the resulting attribute, as determined by any
// permitted implementation choices and any applicable configuration bits, instead of
// the value that appears in the translation table descriptor.

bits(2) <anchor link="impl-shared.ReportedPARShareability.1" hover="function: bits(2) ReportedPARShareability(bits(2) sh)">ReportedPARShareability</anchor>(bits(2) sh);</pstext>
    </ps>
    <ps name="shared/translation/attrs/DecodeDevice" mylink="shared.translation.attrs.DecodeDevice" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeDevice()
// ==============
// Decode output Device type

DeviceType <anchor link="impl-shared.DecodeDevice.1" hover="function: DeviceType DecodeDevice(bits(2) device)">DecodeDevice</anchor>(bits(2) device)
    case device of
        when '00'   return <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a>;
        when '01'   return <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a>;
        when '10'   return <a link="DeviceType_nGRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGRE</a>;
        when '11'   return <a link="DeviceType_GRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_GRE</a>;</pstext>
    </ps>
    <ps name="shared/translation/attrs/DecodeLDFAttr" mylink="shared.translation.attrs.DecodeLDFAttr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeLDFAttr()
// ===============
// Decode memory attributes using LDF (Long Descriptor Format) mapping

MemAttrHints <anchor link="impl-shared.DecodeLDFAttr.1" hover="function: MemAttrHints DecodeLDFAttr(bits(4) attr)">DecodeLDFAttr</anchor>(bits(4) attr)
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> ldfattr;

    if    attr IN {'x0xx'} then ldfattr.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>; // Write-through
    elsif attr == '0100' then ldfattr.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;   // Non-cacheable
    elsif attr IN {'x1xx'} then ldfattr.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>; // Write-back
    else                      <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    // Allocation hints are applicable only to cacheable memory.
    if ldfattr.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
        case attr&lt;1:0&gt; of
            when '00' ldfattr.hints = <a link="MemHint_No" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_No = '00'">MemHint_No</a>;  // No allocation hints
            when '01' ldfattr.hints = <a link="MemHint_WA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_WA = '01'">MemHint_WA</a>;  // Write-allocate
            when '10' ldfattr.hints = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;  // Read-allocate
            when '11' ldfattr.hints = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>; // Read/Write allocate

    // The Transient hint applies only to cacheable memory with some allocation hints.
    if ldfattr.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp; ldfattr.hints != <a link="MemHint_No" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_No = '00'">MemHint_No</a> then
        ldfattr.transient = attr&lt;3&gt; == '0';

    return ldfattr;</pstext>
    </ps>
    <ps name="shared/translation/attrs/DecodeSDFAttr" mylink="shared.translation.attrs.DecodeSDFAttr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeSDFAttr()
// ===============
// Decode memory attributes using SDF (Short Descriptor Format) mapping

MemAttrHints <anchor link="impl-shared.DecodeSDFAttr.1" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</anchor>(bits(2) rgn)
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> sdfattr;

    case rgn of
        when '00'                   // Non-cacheable (no allocate)
            sdfattr.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
        when '01'                   // Write-back, Read and Write allocate
            sdfattr.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            sdfattr.hints = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
        when '10'                   // Write-through, Read allocate
            sdfattr.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            sdfattr.hints = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
        when '11'                   // Write-back, Read allocate
            sdfattr.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            sdfattr.hints = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;

    sdfattr.transient = FALSE;

    return sdfattr;</pstext>
    </ps>
    <ps name="shared/translation/attrs/DecodeShareability" mylink="shared.translation.attrs.DecodeShareability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeShareability()
// ====================
// Decode shareability of target memory region

Shareability <anchor link="impl-shared.DecodeShareability.1" hover="function: Shareability DecodeShareability(bits(2) sh)">DecodeShareability</anchor>(bits(2) sh)
    case sh of
        when '10' return <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
        when '11' return <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a>;
        when '00' return <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;
        otherwise
            case <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_Shareability" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_Shareability</a>) of
                when <a link="Constraint_OSH" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_OSH</a> return <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
                when <a link="Constraint_ISH" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_ISH</a> return <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a>;
                when <a link="Constraint_NSH" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NSH</a> return <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;</pstext>
    </ps>
    <ps name="shared/translation/attrs/EffectiveShareability" mylink="shared.translation.attrs.EffectiveShareability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// EffectiveShareability()
// =======================
// Force Outer Shareability on Device and Normal iNCoNC memory

Shareability <anchor link="impl-shared.EffectiveShareability.1" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    if (memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> ||
            (memattrs.inner.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> &amp;&amp;
             memattrs.outer.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>)) then
        return <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
    else
        return memattrs.shareability;</pstext>
    </ps>
    <ps name="shared/translation/attrs/NormalNCMemAttr" mylink="shared.translation.attrs.NormalNCMemAttr" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NormalNCMemAttr()
// =================
// Normal Non-cacheable memory attributes

MemoryAttributes <anchor link="impl-shared.NormalNCMemAttr.0" hover="function: MemoryAttributes NormalNCMemAttr()">NormalNCMemAttr</anchor>()
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> non_cacheable;
    non_cacheable.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> nc_memattrs;
    nc_memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
    nc_memattrs.outer        = non_cacheable;
    nc_memattrs.inner        = non_cacheable;
    nc_memattrs.shareability = <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
    nc_memattrs.tags         = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
    nc_memattrs.notagaccess  = FALSE;

    return nc_memattrs;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S1ConstrainUnpredictableRESMAIR" mylink="shared.translation.attrs.S1ConstrainUnpredictableRESMAIR" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S1ConstrainUnpredictableRESMAIR()
// =================================
// Determine whether a reserved value occupies MAIR_ELx.AttrN

boolean <anchor link="impl-shared.S1ConstrainUnpredictableRESMAIR.2" hover="function: boolean S1ConstrainUnpredictableRESMAIR(bits(8) attr, boolean s1aarch64)">S1ConstrainUnpredictableRESMAIR</anchor>(bits(8) attr, boolean s1aarch64)
    case attr of
        when '0000xx01' return !(s1aarch64 &amp;&amp; <a link="impl-shared.HaveFeatXS.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatXS()">HaveFeatXS</a>());
        when '0000xxxx' return attr&lt;1:0&gt; != '00';
        when '01000000' return !(s1aarch64 &amp;&amp; <a link="impl-shared.HaveFeatXS.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatXS()">HaveFeatXS</a>());
        when '10100000' return !(s1aarch64 &amp;&amp; <a link="impl-shared.HaveFeatXS.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatXS()">HaveFeatXS</a>());
        when '11110000' return !(s1aarch64 &amp;&amp; <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>());
        when 'xxxx0000' return TRUE;
        otherwise       return FALSE;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S1DecodeMemAttrs" mylink="shared.translation.attrs.S1DecodeMemAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S1DecodeMemAttrs()
// ==================
// Decode MAIR-format memory attributes assigned in stage 1

<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> S1DecodeMemAttrs(bits(8) attr_in, bits(2) sh, boolean s1aarch64,
                                  S1TTWParams walkparams)
    bits(8) attr = attr_in;
    if <a link="impl-shared.S1ConstrainUnpredictableRESMAIR.2" file="shared_pseudocode.xml" hover="function: boolean S1ConstrainUnpredictableRESMAIR(bits(8) attr, boolean s1aarch64)">S1ConstrainUnpredictableRESMAIR</a>(attr, s1aarch64) then
        (-, attr) = <a link="impl-shared.ConstrainUnpredictableBits.2" file="shared_pseudocode.xml" hover="function: (Constraint,bits(width)) ConstrainUnpredictableBits(Unpredictable which, integer width)">ConstrainUnpredictableBits</a>(<a link="Unpredictable_RESMAIR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_RESMAIR</a>, 8);

    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;
    case attr of
        when '0000xxxx' // Device memory
            memattrs.memtype = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
            memattrs.device  = <a link="impl-shared.DecodeDevice.1" file="shared_pseudocode.xml" hover="function: DeviceType DecodeDevice(bits(2) device)">DecodeDevice</a>(attr&lt;3:2&gt;);
            memattrs.xs      = if s1aarch64 then NOT attr&lt;0&gt; else '1';
        when '01000000'
            assert s1aarch64 &amp;&amp; <a link="impl-shared.HaveFeatXS.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatXS()">HaveFeatXS</a>();
            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.outer.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
            memattrs.inner.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
            memattrs.xs          = '0';

        when '10100000'
            assert s1aarch64 &amp;&amp; <a link="impl-shared.HaveFeatXS.0" file="shared_pseudocode.xml" hover="function: boolean HaveFeatXS()">HaveFeatXS</a>();
            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.outer.attrs     = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            memattrs.outer.hints     = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.outer.transient = FALSE;
            memattrs.inner.attrs     = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
            memattrs.inner.hints     = <a link="MemHint_RA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RA = '10'">MemHint_RA</a>;
            memattrs.inner.transient = FALSE;
            memattrs.xs              = '0';
        when '11110000' // Tagged memory
            assert s1aarch64 &amp;&amp; <a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>();
            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.outer.attrs     = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            memattrs.outer.hints     = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
            memattrs.outer.transient = FALSE;
            memattrs.inner.attrs     = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;
            memattrs.inner.hints     = <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>;
            memattrs.inner.transient = FALSE;
            memattrs.xs              = '0';
        otherwise
            memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.outer   = <a link="impl-shared.DecodeLDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeLDFAttr(bits(4) attr)">DecodeLDFAttr</a>(attr&lt;7:4&gt;);
            memattrs.inner   = <a link="impl-shared.DecodeLDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeLDFAttr(bits(4) attr)">DecodeLDFAttr</a>(attr&lt;3:0&gt;);

            if (memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
                    memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>) then
                memattrs.xs = '0';
            else
                memattrs.xs = '1';

    if s1aarch64 &amp;&amp; attr IN {'11110000'} then
        memattrs.tags = <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>;
    elsif s1aarch64 &amp;&amp; walkparams.mtx == '1' then
        memattrs.tags = <a link="MemTag_CanonicallyTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_CanonicallyTagged</a>;
    else
        memattrs.tags = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;

    memattrs.notagaccess = FALSE;

    memattrs.shareability = <a link="impl-shared.DecodeShareability.1" file="shared_pseudocode.xml" hover="function: Shareability DecodeShareability(bits(2) sh)">DecodeShareability</a>(sh);

    return memattrs;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2CombineS1AttrHints" mylink="shared.translation.attrs.S2CombineS1AttrHints" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2CombineS1AttrHints()
// ======================
// Determine resultant Normal memory cacheability and allocation hints from
// combining stage 1 Normal memory attributes and stage 2 cacheability attributes.

MemAttrHints <anchor link="impl-shared.S2CombineS1AttrHints.2" hover="function: MemAttrHints S2CombineS1AttrHints(MemAttrHints s1_attrhints, MemAttrHints s2_attrhints)">S2CombineS1AttrHints</anchor>(<a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> s1_attrhints, <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> s2_attrhints)
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> attrhints;

    if s1_attrhints.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> || s2_attrhints.attrs == <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
        attrhints.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
    elsif s1_attrhints.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> || s2_attrhints.attrs == <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a> then
        attrhints.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
    else
        attrhints.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;

    // Stage 2 does not assign any allocation hints
    // Instead, they are inherited from stage 1
    if attrhints.attrs != <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a> then
        attrhints.hints     = s1_attrhints.hints;
        attrhints.transient = s1_attrhints.transient;

    return attrhints;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2CombineS1Device" mylink="shared.translation.attrs.S2CombineS1Device" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2CombineS1Device()
// ===================
// Determine resultant Device type from combining output memory attributes
// in stage 1 and Device attributes in stage 2

DeviceType <anchor link="impl-shared.S2CombineS1Device.2" hover="function: DeviceType S2CombineS1Device(DeviceType s1_device, DeviceType s2_device)">S2CombineS1Device</anchor>(<a link="DeviceType" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType</a> s1_device, <a link="DeviceType" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType</a> s2_device)
    if s1_device == <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a> || s2_device == <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a> then
        return <a link="DeviceType_nGnRnE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRnE</a>;
    elsif s1_device == <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a> || s2_device == <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a> then
        return <a link="DeviceType_nGnRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGnRE</a>;
    elsif s1_device == <a link="DeviceType_nGRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGRE</a> || s2_device == <a link="DeviceType_nGRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGRE</a> then
        return <a link="DeviceType_nGRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_nGRE</a>;
    else
        return <a link="DeviceType_GRE" file="shared_pseudocode.xml" hover="enumeration DeviceType {DeviceType_GRE, DeviceType_nGRE, DeviceType_nGnRE, DeviceType_nGnRnE}">DeviceType_GRE</a>;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2CombineS1MemAttrs" mylink="shared.translation.attrs.S2CombineS1MemAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2CombineS1MemAttrs()
// =====================
// Combine stage 2 with stage 1 memory attributes

MemoryAttributes <anchor link="impl-shared.S2CombineS1MemAttrs.3" hover="function: MemoryAttributes S2CombineS1MemAttrs(MemoryAttributes s1_memattrs, MemoryAttributes s2_memattrs, boolean s2aarch64)">S2CombineS1MemAttrs</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> s1_memattrs, <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> s2_memattrs,
                                     boolean s2aarch64)
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;

    if s1_memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> &amp;&amp; s2_memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then
        memattrs.memtype = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
        memattrs.device  = <a link="impl-shared.S2CombineS1Device.2" file="shared_pseudocode.xml" hover="function: DeviceType S2CombineS1Device(DeviceType s1_device, DeviceType s2_device)">S2CombineS1Device</a>(s1_memattrs.device, s2_memattrs.device);
    elsif s1_memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then    // S2 Normal, S1 Device
        memattrs = s1_memattrs;
    elsif s2_memattrs.memtype == <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a> then    // S2 Device, S1 Normal
        memattrs = s2_memattrs;
    else                                                // S2 Normal, S1 Normal
        memattrs.memtype = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
        memattrs.inner   = <a link="impl-shared.S2CombineS1AttrHints.2" file="shared_pseudocode.xml" hover="function: MemAttrHints S2CombineS1AttrHints(MemAttrHints s1_attrhints, MemAttrHints s2_attrhints)">S2CombineS1AttrHints</a>(s1_memattrs.inner, s2_memattrs.inner);
        memattrs.outer   = <a link="impl-shared.S2CombineS1AttrHints.2" file="shared_pseudocode.xml" hover="function: MemAttrHints S2CombineS1AttrHints(MemAttrHints s1_attrhints, MemAttrHints s2_attrhints)">S2CombineS1AttrHints</a>(s1_memattrs.outer, s2_memattrs.outer);

    memattrs.tags = <a link="impl-shared.S2MemTagType.2" file="shared_pseudocode.xml" hover="function: MemTagType S2MemTagType(MemoryAttributes s2_memattrs, MemTagType s1_tagtype)">S2MemTagType</a>(memattrs, s1_memattrs.tags);

    if !<a link="impl-shared.HaveMTEPermExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEPermExt()">HaveMTEPermExt</a>() then
        memattrs.notagaccess = FALSE;
    else
        memattrs.notagaccess = (s2_memattrs.notagaccess &amp;&amp;
                               s1_memattrs.tags == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>);
    memattrs.shareability = <a link="impl-shared.S2CombineS1Shareability.2" file="shared_pseudocode.xml" hover="function: Shareability S2CombineS1Shareability(Shareability s1_shareability, Shareability s2_shareability)">S2CombineS1Shareability</a>(s1_memattrs.shareability,
                                                    s2_memattrs.shareability);

    if (memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a> &amp;&amp;
            memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
            memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>) then
        memattrs.xs = '0';
    elsif s2aarch64 then
        memattrs.xs = s2_memattrs.xs AND s1_memattrs.xs;
    else
        memattrs.xs = s1_memattrs.xs;

    memattrs.shareability = <a link="impl-shared.EffectiveShareability.1" file="shared_pseudocode.xml" hover="function: Shareability EffectiveShareability(MemoryAttributes memattrs)">EffectiveShareability</a>(memattrs);
    return memattrs;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2CombineS1Shareability" mylink="shared.translation.attrs.S2CombineS1Shareability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2CombineS1Shareability()
// =========================
// Combine stage 2 shareability with stage 1

Shareability <anchor link="impl-shared.S2CombineS1Shareability.2" hover="function: Shareability S2CombineS1Shareability(Shareability s1_shareability, Shareability s2_shareability)">S2CombineS1Shareability</anchor>(<a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> s1_shareability,
                                     <a link="Shareability" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability</a> s2_shareability)

    if (s1_shareability == <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a> ||
            s2_shareability == <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>) then
        return <a link="Shareability_OSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_OSH</a>;
    elsif (s1_shareability == <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a> ||
            s2_shareability == <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a>) then
        return <a link="Shareability_ISH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_ISH</a>;
    else
        return <a link="Shareability_NSH" file="shared_pseudocode.xml" hover="enumeration Shareability { Shareability_NSH, Shareability_ISH, Shareability_OSH }">Shareability_NSH</a>;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2DecodeCacheability" mylink="shared.translation.attrs.S2DecodeCacheability" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2DecodeCacheability()
// ======================
// Determine the stage 2 cacheability for Normal memory

MemAttrHints <anchor link="impl-shared.S2DecodeCacheability.1" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</anchor>(bits(2) attr)
    <a link="MemAttrHints" file="shared_pseudocode.xml" hover="type MemAttrHints is ( bits(2) attrs, bits(2) hints, boolean transient )">MemAttrHints</a> s2attr;

    case attr of
        when '01' s2attr.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;  // Non-cacheable
        when '10' s2attr.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;  // Write-through
        when '11' s2attr.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;  // Write-back
        otherwise // Constrained unpredictable
            case <a link="impl-shared.ConstrainUnpredictable.1" file="shared_pseudocode.xml" hover="function: Constraint ConstrainUnpredictable(Unpredictable which)">ConstrainUnpredictable</a>(<a link="Unpredictable_S2RESMEMATTR" file="shared_pseudocode.xml" hover="enumeration Unpredictable {  Unpredictable_VMSR,  Unpredictable_WBOVERLAPLD,  Unpredictable_WBOVERLAPST,  Unpredictable_LDPOVERLAP,  Unpredictable_BASEOVERLAP,  Unpredictable_DATAOVERLAP,  Unpredictable_DEVPAGE2,  Unpredictable_INSTRDEVICE,  Unpredictable_RESCPACR,  Unpredictable_RESMAIR,  Unpredictable_S1CTAGGED,  Unpredictable_S2RESMEMATTR,  Unpredictable_RESTEXCB,  Unpredictable_RESPRRR,  Unpredictable_RESDACR,  Unpredictable_RESVTCRS,  Unpredictable_RESTnSZ,  Unpredictable_RESTCF,  Unpredictable_DEVICETAGSTORE,  Unpredictable_OORTnSZ,  Unpredictable_LARGEIPA,  Unpredictable_ESRCONDPASS,  Unpredictable_ILZEROIT,  Unpredictable_ILZEROT,  Unpredictable_BPVECTORCATCHPRI,  Unpredictable_VCMATCHHALF,   Unpredictable_VCMATCHDAPA,  Unpredictable_WPMASKANDBAS,  Unpredictable_WPBASCONTIGUOUS,  Unpredictable_RESWPMASK,  Unpredictable_WPMASKEDBITS,  Unpredictable_RESBPWPCTRL,  Unpredictable_BPNOTIMPL,  Unpredictable_RESBPTYPE,  Unpredictable_BPNOTCTXCMP,  Unpredictable_BPMATCHHALF,  Unpredictable_BPMISMATCHHALF,  Unpredictable_RESTARTALIGNPC,  Unpredictable_RESTARTZEROUPPERPC,  Unpredictable_ZEROUPPER,   Unpredictable_ERETZEROUPPERPC,   Unpredictable_A32FORCEALIGNPC,  Unpredictable_SMD,  Unpredictable_NONFAULT,  Unpredictable_SVEZEROUPPER,  Unpredictable_SVELDNFDATA,  Unpredictable_SVELDNFZERO,  Unpredictable_CHECKSPNONEACTIVE,  Unpredictable_SMEZEROUPPER,  Unpredictable_NVNV1,  Unpredictable_Shareability,  Unpredictable_AFUPDATE,  Unpredictable_DBUPDATE,  Unpredictable_IESBinDebug,  Unpredictable_BADPMSFCR,  Unpredictable_ZEROBTYPE,  Unpredictable_EL2TIMESTAMP, Unpredictable_EL1TIMESTAMP,  Unpredictable_RESERVEDNSxB,  Unpredictable_WFxTDEBUG,  Unpredictable_LS64UNSUPPORTED,   Unpredictable_MISALIGNEDATOMIC,  Unpredictable_CLEARERRITEZERO,   Unpredictable_ALUEXCEPTIONRETURN,  Unpredictable_IGNORETRAPINDEBUG,  Unpredictable_DBGxVR_RESS,  Unpredictable_PMUEVENTCOUNTER,  Unpredictable_PMSCR_PCT,   Unpredictable_CounterReservedForEL2,  Unpredictable_BRBFILTRATE,   Unpredictable_MOPSOVERLAP31,  Unpredictable_STOREONLYTAGCHECKEDCAS,  Unpredictable_RESTC }">Unpredictable_S2RESMEMATTR</a>) of
                when <a link="Constraint_NC" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_NC</a> s2attr.attrs = <a link="MemAttr_NC" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_NC = '00'">MemAttr_NC</a>;
                when <a link="Constraint_WT" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_WT</a> s2attr.attrs = <a link="MemAttr_WT" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WT = '10'">MemAttr_WT</a>;
                when <a link="Constraint_WB" file="shared_pseudocode.xml" hover="enumeration Constraint    { Constraint_NONE,   Constraint_UNKNOWN,  Constraint_UNDEF, Constraint_UNDEFEL0, Constraint_NOP, Constraint_TRUE, Constraint_FALSE, Constraint_DISABLED, Constraint_UNCOND, Constraint_COND, Constraint_ADDITIONAL_DECODE,   Constraint_WBSUPPRESS, Constraint_FAULT, Constraint_LIMITED_ATOMICITY,   Constraint_NVNV1_00, Constraint_NVNV1_01, Constraint_NVNV1_11, Constraint_EL1TIMESTAMP, Constraint_EL2TIMESTAMP, Constraint_OSH, Constraint_ISH, Constraint_NSH,  Constraint_NC, Constraint_WT, Constraint_WB,   Constraint_FORCE, Constraint_FORCENOSLCHECK,  Constraint_MAPTOALLOCATED,  Constraint_PMSCR_PCT_VIRT }">Constraint_WB</a> s2attr.attrs = <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>;

    // Stage 2 does not assign hints or the transient property
    // They are inherited from stage 1 if the result of the combination allows it
    s2attr.hints     = bits(2) UNKNOWN;
    s2attr.transient = boolean UNKNOWN;

    return s2attr;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2DecodeMemAttrs" mylink="shared.translation.attrs.S2DecodeMemAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2DecodeMemAttrs()
// ==================
// Decode stage 2 memory attributes

MemoryAttributes <anchor link="impl-shared.S2DecodeMemAttrs.3" hover="function: MemoryAttributes S2DecodeMemAttrs(bits(4) attr, bits(2) sh, boolean s2aarch64)">S2DecodeMemAttrs</anchor>(bits(4) attr, bits(2) sh, boolean s2aarch64)
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs;

    case attr of
        when '00xx' // Device memory
            memattrs.memtype      = <a link="MemType_Device" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Device</a>;
            memattrs.device       = <a link="impl-shared.DecodeDevice.1" file="shared_pseudocode.xml" hover="function: DeviceType DecodeDevice(bits(2) device)">DecodeDevice</a>(attr&lt;1:0&gt;);
        when '0100' // Normal, Inner+Outer WB cacheable NoTagAccess memory
            if s2aarch64 &amp;&amp; <a link="impl-shared.HaveMTEPermExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEPermExt()">HaveMTEPermExt</a>() then
                memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
                memattrs.outer        = <a link="impl-shared.S2DecodeCacheability.1" file="shared_pseudocode.xml" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</a>('11'); // Write-back
                memattrs.inner        = <a link="impl-shared.S2DecodeCacheability.1" file="shared_pseudocode.xml" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</a>('11'); // Write-back
            else
                memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
                memattrs.outer        = <a link="impl-shared.S2DecodeCacheability.1" file="shared_pseudocode.xml" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</a>(attr&lt;3:2&gt;);
                memattrs.inner        = <a link="impl-shared.S2DecodeCacheability.1" file="shared_pseudocode.xml" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</a>(attr&lt;1:0&gt;);
        otherwise   // Normal memory
            memattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
            memattrs.outer        = <a link="impl-shared.S2DecodeCacheability.1" file="shared_pseudocode.xml" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</a>(attr&lt;3:2&gt;);
            memattrs.inner        = <a link="impl-shared.S2DecodeCacheability.1" file="shared_pseudocode.xml" hover="function: MemAttrHints S2DecodeCacheability(bits(2) attr)">S2DecodeCacheability</a>(attr&lt;1:0&gt;);

    memattrs.shareability = <a link="impl-shared.DecodeShareability.1" file="shared_pseudocode.xml" hover="function: Shareability DecodeShareability(bits(2) sh)">DecodeShareability</a>(sh);

    if s2aarch64 &amp;&amp; <a link="impl-shared.HaveMTEPermExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTEPermExt()">HaveMTEPermExt</a>() then
        memattrs.notagaccess = attr == '0100';
    else
        memattrs.notagaccess = FALSE;

    return memattrs;</pstext>
    </ps>
    <ps name="shared/translation/attrs/S2MemTagType" mylink="shared.translation.attrs.S2MemTagType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2MemTagType()
// ==============
// Determine whether the combined output memory attributes of stage 1 and
// stage 2 indicate tagged memory

MemTagType <anchor link="impl-shared.S2MemTagType.2" hover="function: MemTagType S2MemTagType(MemoryAttributes s2_memattrs, MemTagType s1_tagtype)">S2MemTagType</anchor>(<a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> s2_memattrs, <a link="MemTagType" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTagType</a> s1_tagtype)

    if !<a link="impl-shared.HaveMTE2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveMTE2Ext()">HaveMTE2Ext</a>() then
        return <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;

    if ((s1_tagtype == <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>)  &amp;&amp;
        (s2_memattrs.memtype == <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>)  &amp;&amp;
        (s2_memattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>)  &amp;&amp;
        (s2_memattrs.inner.hints == <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>) &amp;&amp;
        (!s2_memattrs.inner.transient)           &amp;&amp;
        (s2_memattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>)  &amp;&amp;
        (s2_memattrs.outer.hints == <a link="MemHint_RWA" file="shared_pseudocode.xml" hover="constant bits(2) MemHint_RWA = '11'">MemHint_RWA</a>) &amp;&amp;
        (!s2_memattrs.outer.transient)) then
        return <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a>;

    // Return what stage 1 asked for if we can, otherwise Untagged.
    if s1_tagtype != <a link="MemTag_AllocationTagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_AllocationTagged</a> then
        return s1_tagtype;

    return <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;</pstext>
    </ps>
    <ps name="shared/translation/attrs/WalkMemAttrs" mylink="shared.translation.attrs.WalkMemAttrs" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// WalkMemAttrs()
// ==============
// Retrieve memory attributes of translation table walk

MemoryAttributes <anchor link="impl-shared.WalkMemAttrs.3" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</anchor>(bits(2) sh, bits(2) irgn, bits(2) orgn)
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> walkmemattrs;

    walkmemattrs.memtype      = <a link="MemType_Normal" file="shared_pseudocode.xml" hover="enumeration MemType {MemType_Normal, MemType_Device}">MemType_Normal</a>;
    walkmemattrs.shareability = <a link="impl-shared.DecodeShareability.1" file="shared_pseudocode.xml" hover="function: Shareability DecodeShareability(bits(2) sh)">DecodeShareability</a>(sh);
    walkmemattrs.inner        = <a link="impl-shared.DecodeSDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</a>(irgn);
    walkmemattrs.outer        = <a link="impl-shared.DecodeSDFAttr.1" file="shared_pseudocode.xml" hover="function: MemAttrHints DecodeSDFAttr(bits(2) rgn)">DecodeSDFAttr</a>(orgn);
    walkmemattrs.tags         = <a link="MemTag_Untagged" file="shared_pseudocode.xml" hover="enumeration MemTagType { MemTag_Untagged, MemTag_AllocationTagged, MemTag_CanonicallyTagged }">MemTag_Untagged</a>;
    if (walkmemattrs.inner.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a> &amp;&amp;
            walkmemattrs.outer.attrs == <a link="MemAttr_WB" file="shared_pseudocode.xml" hover="constant bits(2) MemAttr_WB = '11'">MemAttr_WB</a>) then
        walkmemattrs.xs = '0';
    else
        walkmemattrs.xs = '1';
    walkmemattrs.notagaccess = FALSE;

    return walkmemattrs;</pstext>
    </ps>
    <ps name="shared/translation/faults/AlignmentFault" mylink="shared.translation.faults.AlignmentFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AlignmentFault()
// ================
// Return a fault record indicating an Alignment fault not due to memory type has occured
// for a specific access

FaultRecord <anchor link="impl-shared.AlignmentFault.1" hover="function: FaultRecord AlignmentFault(AccessDescriptor accdesc)">AlignmentFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault;

    fault.statuscode  = <a link="Fault_Alignment" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Alignment</a>;
    fault.access      = accdesc;
    fault.secondstage = FALSE;
    fault.s2fs1walk   = FALSE;
    fault.write       = !accdesc.read &amp;&amp; accdesc.write;
    fault.gpcfs2walk  = FALSE;
    fault.gpcf        = <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();

    return fault;</pstext>
    </ps>
    <ps name="shared/translation/faults/ExclusiveFault" mylink="shared.translation.faults.ExclusiveFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ExclusiveFault()
// ================
// Return a fault record indicating an Exclusive fault for a specific access

FaultRecord <anchor link="impl-shared.ExclusiveFault.1" hover="function: FaultRecord ExclusiveFault(AccessDescriptor accdesc)">ExclusiveFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault;

    fault.statuscode  = <a link="Fault_Exclusive" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_Exclusive</a>;
    fault.access      = accdesc;
    fault.secondstage = FALSE;
    fault.s2fs1walk   = FALSE;
    fault.write       = !accdesc.read &amp;&amp; accdesc.write;
    fault.gpcfs2walk  = FALSE;
    fault.gpcf        = <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();

    return fault;</pstext>
    </ps>
    <ps name="shared/translation/faults/NoFault" mylink="shared.translation.faults.NoFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// NoFault()
// =========
// Return a clear fault record indicating no faults have occured

FaultRecord <anchor link="impl-shared.NoFault.0" hover="function: FaultRecord NoFault()">NoFault</anchor>()
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault;

    fault.statuscode  = <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;
    fault.access      = <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> UNKNOWN;
    fault.secondstage = FALSE;
    fault.s2fs1walk   = FALSE;
    fault.dirtybit    = FALSE;
    fault.overlay     = FALSE;
    fault.toplevel    = FALSE;
    fault.assuredonly = FALSE;
    fault.s1tagnotdata = FALSE;
    fault.tagaccess   = FALSE;
    fault.gpcfs2walk  = FALSE;
    fault.gpcf        = <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();

    return fault;

// NoFault()
// =========
// Return a clear fault record indicating no faults have occured for a specific access

FaultRecord <anchor link="impl-shared.NoFault.1" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</anchor>(<a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault;

    fault.statuscode  = <a link="Fault_None" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_None</a>;
    fault.access      = accdesc;
    fault.secondstage = FALSE;
    fault.s2fs1walk   = FALSE;
    fault.dirtybit    = FALSE;
    fault.overlay     = FALSE;
    fault.toplevel    = FALSE;
    fault.assuredonly = FALSE;
    fault.s1tagnotdata = FALSE;
    fault.tagaccess   = FALSE;
    fault.write       = !accdesc.read &amp;&amp; accdesc.write;
    fault.gpcfs2walk  = FALSE;
    fault.gpcf        = <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();

    return fault;</pstext>
    </ps>
    <ps name="shared/translation/gpc/AbovePPS" mylink="shared.translation.gpc.AbovePPS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// AbovePPS()
// ==========
// Returns TRUE if an address exceeds the range configured in GPCCR_EL3.PPS.

boolean <anchor link="impl-shared.AbovePPS.1" hover="function: boolean AbovePPS(bits(56) address)">AbovePPS</anchor>(bits(56) address)
    pps = <a link="impl-shared.DecodePPS.0" file="shared_pseudocode.xml" hover="function: integer DecodePPS()">DecodePPS</a>();
    if pps &gt;= 56 then
        return FALSE;

    return !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(address&lt;55:pps&gt;);</pstext>
    </ps>
    <ps name="shared/translation/gpc/DecodeGPTBlock" mylink="shared.translation.gpc.DecodeGPTBlock" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeGPTBlock()
// ================
// Validate and decode a GPT Block descriptor

(GPCF, GPTEntry) <anchor link="impl-shared.DecodeGPTBlock.2" hover="function: (GPCF, GPTEntry) DecodeGPTBlock(PGSe pgs, bits(64) entry)">DecodeGPTBlock</anchor>(<a link="PGSe" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGSe</a> pgs, bits(64) entry)
    assert entry&lt;3:0&gt; == <a link="GPT_Block" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Block = '0001'">GPT_Block</a>;
    <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> result;

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(entry&lt;63:8&gt;) then
        return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    if !<a link="impl-shared.GPIValid.1" file="shared_pseudocode.xml" hover="function: boolean GPIValid(bits(4) gpi)">GPIValid</a>(entry&lt;7:4&gt;) then
        return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    result.gpi   = entry&lt;7:4&gt;;
    result.level = 0;

    // GPT information from a level 0 GPT Block descriptor is permitted
    // to be cached in a TLB as though the Block is a contiguous region
    // of granules each of the size configured in GPCCR_EL3.PGS.
    case pgs of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  result.size = <a link="GPTRange_4KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_4KB = 12">GPTRange_4KB</a>;
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> result.size = <a link="GPTRange_16KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_16KB = 14">GPTRange_16KB</a>;
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> result.size = <a link="GPTRange_64KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_64KB = 16">GPTRange_64KB</a>;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    result.contig_size = <a link="impl-shared.GPTL0Size.0" file="shared_pseudocode.xml" hover="function: integer GPTL0Size()">GPTL0Size</a>();

    return (<a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a>, result);</pstext>
    </ps>
    <ps name="shared/translation/gpc/DecodeGPTContiguous" mylink="shared.translation.gpc.DecodeGPTContiguous" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeGPTContiguous()
// =====================
// Validate and decode a GPT Contiguous descriptor

(GPCF, GPTEntry) <anchor link="impl-shared.DecodeGPTContiguous.2" hover="function: (GPCF, GPTEntry) DecodeGPTContiguous(PGSe pgs, bits(64) entry)">DecodeGPTContiguous</anchor>(<a link="PGSe" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGSe</a> pgs, bits(64) entry)
    assert entry&lt;3:0&gt; == <a link="GPT_Contig" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Contig = '0001'">GPT_Contig</a>;
    <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> result;

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(entry&lt;63:10&gt;) then
        return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, result);

    result.gpi = entry&lt;7:4&gt;;
    if !<a link="impl-shared.GPIValid.1" file="shared_pseudocode.xml" hover="function: boolean GPIValid(bits(4) gpi)">GPIValid</a>(result.gpi) then
        return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, result);

    case pgs of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  result.size = <a link="GPTRange_4KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_4KB = 12">GPTRange_4KB</a>;
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> result.size = <a link="GPTRange_16KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_16KB = 14">GPTRange_16KB</a>;
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> result.size = <a link="GPTRange_64KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_64KB = 16">GPTRange_64KB</a>;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    case entry&lt;9:8&gt; of
        when '01' result.contig_size = <a link="GPTRange_2MB" file="shared_pseudocode.xml" hover="constant integer GPTRange_2MB = 21">GPTRange_2MB</a>;
        when '10' result.contig_size = <a link="GPTRange_32MB" file="shared_pseudocode.xml" hover="constant integer GPTRange_32MB = 25">GPTRange_32MB</a>;
        when '11' result.contig_size = <a link="GPTRange_512MB" file="shared_pseudocode.xml" hover="constant integer GPTRange_512MB = 29">GPTRange_512MB</a>;
        otherwise return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    result.level = 1;

    return (<a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a>, result);</pstext>
    </ps>
    <ps name="shared/translation/gpc/DecodeGPTGranules" mylink="shared.translation.gpc.DecodeGPTGranules" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeGPTGranules()
// ===================
// Validate and decode a GPT Granules descriptor

(GPCF, GPTEntry) <anchor link="impl-shared.DecodeGPTGranules.3" hover="function: (GPCF, GPTEntry) DecodeGPTGranules(PGSe pgs, integer index, bits(64) entry)">DecodeGPTGranules</anchor>(<a link="PGSe" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGSe</a> pgs, integer index, bits(64) entry)
    <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> result;

    for i = 0 to 15
        if !<a link="impl-shared.GPIValid.1" file="shared_pseudocode.xml" hover="function: boolean GPIValid(bits(4) gpi)">GPIValid</a>(entry&lt;i*4 +:4&gt;) then
            return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, result);

    result.gpi = entry&lt;index*4 +:4&gt;;

    case pgs of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  result.size = <a link="GPTRange_4KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_4KB = 12">GPTRange_4KB</a>;
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> result.size = <a link="GPTRange_16KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_16KB = 14">GPTRange_16KB</a>;
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> result.size = <a link="GPTRange_64KB" file="shared_pseudocode.xml" hover="constant integer GPTRange_64KB = 16">GPTRange_64KB</a>;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    result.contig_size = result.size; // No contiguity
    result.level = 1;

    return (<a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a>, result);</pstext>
    </ps>
    <ps name="shared/translation/gpc/DecodeGPTTable" mylink="shared.translation.gpc.DecodeGPTTable" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodeGPTTable()
// ================
// Validate and decode a GPT Table descriptor

(GPCF, GPTTable) <anchor link="impl-shared.DecodeGPTTable.2" hover="function: (GPCF, GPTTable) DecodeGPTTable(PGSe pgs, bits(64) entry)">DecodeGPTTable</anchor>(<a link="PGSe" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGSe</a> pgs, bits(64) entry)
    assert entry&lt;3:0&gt; == <a link="GPT_Table" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Table = '0011'">GPT_Table</a>;
    <a link="GPTTable" file="shared_pseudocode.xml" hover="type GPTTable is ( bits(56) address )">GPTTable</a> result;

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(entry&lt;63:52,11:4&gt;) then
        return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, <a link="GPTTable" file="shared_pseudocode.xml" hover="type GPTTable is ( bits(56) address )">GPTTable</a> UNKNOWN);

    l0sz = <a link="impl-shared.GPTL0Size.0" file="shared_pseudocode.xml" hover="function: integer GPTL0Size()">GPTL0Size</a>();
    integer p;
    case pgs of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  p = 12;
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> p = 14;
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> p = 16;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    if !<a link="impl-shared.IsZero.1" file="shared_pseudocode.xml" hover="function: boolean IsZero(bits(N) x)">IsZero</a>(entry&lt;(l0sz-p)-2:12&gt;) then
        return (<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, <a link="GPTTable" file="shared_pseudocode.xml" hover="type GPTTable is ( bits(56) address )">GPTTable</a> UNKNOWN);

    case pgs of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  result.address = entry&lt;55:17&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(17);
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> result.address = entry&lt;55:15&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(15);
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> result.address = entry&lt;55:13&gt;:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(13);
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();

    // The address must be within the range covered by the GPT
    if <a link="impl-shared.AbovePPS.1" file="shared_pseudocode.xml" hover="function: boolean AbovePPS(bits(56) address)">AbovePPS</a>(result.address) then
        return (<a link="GPCF_AddressSize" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_AddressSize</a>, <a link="GPTTable" file="shared_pseudocode.xml" hover="type GPTTable is ( bits(56) address )">GPTTable</a> UNKNOWN);

    return (<a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a>, result);</pstext>
    </ps>
    <ps name="shared/translation/gpc/DecodePGS" mylink="shared.translation.gpc.DecodePGS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodePGS()
// ===========

PGSe <anchor link="impl-shared.DecodePGS.1" hover="function: PGSe DecodePGS(bits(2) pgs)">DecodePGS</anchor>(bits(2) pgs)
    case pgs of
        when '00' return <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>;
        when '10' return <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a>;
        when '01' return <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a>;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/translation/gpc/DecodePPS" mylink="shared.translation.gpc.DecodePPS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodePPS()
// ===========
// Size of region protected by the GPT, in bits.

integer <anchor link="impl-shared.DecodePPS.0" hover="function: integer DecodePPS()">DecodePPS</anchor>()
    case GPCCR_EL3.PPS of
        when '000' return 32;
        when '001' return 36;
        when '010' return 40;
        when '011' return 42;
        when '100' return 44;
        when '101' return 48;
        when '110' return 52;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPCFault" mylink="shared.translation.gpc.GPCFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPCFault()
// ==========
// Constructs and returns a GPCF

GPCFRecord <anchor link="impl-shared.GPCFault.2" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</anchor>(<a link="GPCF" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF</a> gpf, integer level)
    <a link="GPCFRecord" file="shared_pseudocode.xml" hover="type GPCFRecord is ( GPCF gpf, integer level )">GPCFRecord</a> fault;
    fault.gpf   = gpf;
    fault.level = level;
    return fault;</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPCNoFault" mylink="shared.translation.gpc.GPCNoFault" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPCNoFault()
// ============
// Returns the default properties of a GPCF that does not represent a fault

GPCFRecord <anchor link="impl-shared.GPCNoFault.0" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</anchor>()
    <a link="GPCFRecord" file="shared_pseudocode.xml" hover="type GPCFRecord is ( GPCF gpf, integer level )">GPCFRecord</a> result;
    result.gpf = <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a>;
    return result;</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPCRegistersConsistent" mylink="shared.translation.gpc.GPCRegistersConsistent" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPCRegistersConsistent()
// ========================
// Returns whether the GPT registers are configured correctly.
// This returns false if any fields select a Reserved value.

boolean <anchor link="impl-shared.GPCRegistersConsistent.0" hover="function: boolean GPCRegistersConsistent()">GPCRegistersConsistent</anchor>()

    // Check for Reserved register values
    if GPCCR_EL3.PPS == '111' || <a link="impl-shared.DecodePPS.0" file="shared_pseudocode.xml" hover="function: integer DecodePPS()">DecodePPS</a>() &gt; <a link="AArch64.PAMax.0" file="shared_pseudocode.xml" hover="function: integer AArch64.PAMax()">AArch64.PAMax</a>() then
        return FALSE;
    if GPCCR_EL3.PGS == '11' then
        return FALSE;
    if GPCCR_EL3.SH == '01' then
        return FALSE;

    // Inner and Outer Non-cacheable requires Outer Shareable
    if GPCCR_EL3.&lt;ORGN, IRGN&gt; == '0000' &amp;&amp; GPCCR_EL3.SH != '10' then
        return FALSE;

    return TRUE;</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPICheck" mylink="shared.translation.gpc.GPICheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPICheck()
// ==========
// Returns whether an access to a given physical address space is permitted
// given the configured GPI value.
// paspace: Physical address space of the access
// gpi: Value read from GPT for the access

boolean <anchor link="impl-shared.GPICheck.2" hover="function: boolean GPICheck(PASpace paspace, bits(4) gpi)">GPICheck</anchor>(<a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a> paspace, bits(4) gpi)

    case gpi of
        when <a link="GPT_NoAccess" file="shared_pseudocode.xml" hover="constant bits(4) GPT_NoAccess = '0000'">GPT_NoAccess</a>  return FALSE;
        when <a link="GPT_Secure" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Secure = '1000'">GPT_Secure</a>    assert <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>();return paspace == <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when <a link="GPT_NonSecure" file="shared_pseudocode.xml" hover="constant bits(4) GPT_NonSecure = '1001'">GPT_NonSecure</a> return paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when <a link="GPT_Root" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Root = '1010'">GPT_Root</a>      return paspace == <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>;
        when <a link="GPT_Realm" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Realm = '1011'">GPT_Realm</a>     return paspace == <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;
        when <a link="GPT_Any" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Any = '1111'">GPT_Any</a>       return TRUE;
        otherwise          <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPIIndex" mylink="shared.translation.gpc.GPIIndex" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPIIndex()
// ==========

integer <anchor link="impl-shared.GPIIndex.1" hover="function: integer GPIIndex(bits(56) pa)">GPIIndex</anchor>(bits(56) pa)
    case <a link="impl-shared.DecodePGS.1" file="shared_pseudocode.xml" hover="function: PGSe DecodePGS(bits(2) pgs)">DecodePGS</a>(GPCCR_EL3.PGS) of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;15:12&gt;);
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;17:14&gt;);
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;19:16&gt;);
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPIValid" mylink="shared.translation.gpc.GPIValid" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPIValid()
// ==========
// Returns whether a given value is a valid encoding for a GPI value

boolean <anchor link="impl-shared.GPIValid.1" hover="function: boolean GPIValid(bits(4) gpi)">GPIValid</anchor>(bits(4) gpi)
    if gpi == <a link="GPT_Secure" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Secure = '1000'">GPT_Secure</a> then
        return <a link="impl-shared.HaveSecureEL2Ext.0" file="shared_pseudocode.xml" hover="function: boolean HaveSecureEL2Ext()">HaveSecureEL2Ext</a>();

    return gpi IN {<a link="GPT_NoAccess" file="shared_pseudocode.xml" hover="constant bits(4) GPT_NoAccess = '0000'">GPT_NoAccess</a>,
                   <a link="GPT_NonSecure" file="shared_pseudocode.xml" hover="constant bits(4) GPT_NonSecure = '1001'">GPT_NonSecure</a>,
                   <a link="GPT_Root" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Root = '1010'">GPT_Root</a>,
                   <a link="GPT_Realm" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Realm = '1011'">GPT_Realm</a>,
                   <a link="GPT_Any" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Any = '1111'">GPT_Any</a>};</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPTL0Size" mylink="shared.translation.gpc.GPTL0Size" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPTL0Size()
// ===========
// Returns number of bits covered by a level 0 GPT entry

integer <anchor link="impl-shared.GPTL0Size.0" hover="function: integer GPTL0Size()">GPTL0Size</anchor>()
    case GPCCR_EL3.L0GPTSZ of
        when '0000' return <a link="GPTRange_1GB" file="shared_pseudocode.xml" hover="constant integer GPTRange_1GB = 30">GPTRange_1GB</a>;
        when '0100' return <a link="GPTRange_16GB" file="shared_pseudocode.xml" hover="constant integer GPTRange_16GB = 34">GPTRange_16GB</a>;
        when '0110' return <a link="GPTRange_64GB" file="shared_pseudocode.xml" hover="constant integer GPTRange_64GB = 36">GPTRange_64GB</a>;
        when '1001' return <a link="GPTRange_512GB" file="shared_pseudocode.xml" hover="constant integer GPTRange_512GB = 39">GPTRange_512GB</a>;
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();
    return 30;</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPTLevel0Index" mylink="shared.translation.gpc.GPTLevel0Index" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPTLevel0Index()
// ================
// Compute the level 0 index based on input PA.

integer <anchor link="impl-shared.GPTLevel0Index.1" hover="function: integer GPTLevel0Index(bits(56) pa)">GPTLevel0Index</anchor>(bits(56) pa)
    // Input address and index bounds
    pps = <a link="impl-shared.DecodePPS.0" file="shared_pseudocode.xml" hover="function: integer DecodePPS()">DecodePPS</a>();
    l0sz = <a link="impl-shared.GPTL0Size.0" file="shared_pseudocode.xml" hover="function: integer GPTL0Size()">GPTL0Size</a>();
    if pps &lt;= l0sz then
        return 0;

    return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;pps-1:l0sz&gt;);</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPTLevel1Index" mylink="shared.translation.gpc.GPTLevel1Index" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPTLevel1Index()
// ================
// Compute the level 1 index based on input PA.

integer <anchor link="impl-shared.GPTLevel1Index.1" hover="function: integer GPTLevel1Index(bits(56) pa)">GPTLevel1Index</anchor>(bits(56) pa)
    // Input address and index bounds
    l0sz = <a link="impl-shared.GPTL0Size.0" file="shared_pseudocode.xml" hover="function: integer GPTL0Size()">GPTL0Size</a>();
    case <a link="impl-shared.DecodePGS.1" file="shared_pseudocode.xml" hover="function: PGSe DecodePGS(bits(2) pgs)">DecodePGS</a>(GPCCR_EL3.PGS) of
        when <a link="PGS_4KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</a>  return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;l0sz-1:16&gt;);
        when <a link="PGS_16KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</a> return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;l0sz-1:18&gt;);
        when <a link="PGS_64KB" file="shared_pseudocode.xml" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</a> return <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(pa&lt;l0sz-1:20&gt;);
        otherwise <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/translation/gpc/GPTWalk" mylink="shared.translation.gpc.GPTWalk" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GPTWalk()
// =========
// Get the GPT entry for a given physical address, pa

(GPCFRecord, GPTEntry) <anchor link="impl-shared.GPTWalk.2" hover="function: (GPCFRecord, GPTEntry) GPTWalk(bits(56) pa, AccessDescriptor accdesc)">GPTWalk</anchor>(bits(56) pa, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    // GPT base address
    bits(56) base;
    pgs = <a link="impl-shared.DecodePGS.1" file="shared_pseudocode.xml" hover="function: PGSe DecodePGS(bits(2) pgs)">DecodePGS</a>(GPCCR_EL3.PGS);

    // The level 0 GPT base address is aligned to the greater of:
    // * the size of the level 0 GPT, determined by GPCCR_EL3.{PPS, L0GPTSZ}.
    // * 4KB
    base = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(GPTBR_EL3.BADDR:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 56);
    pps = <a link="impl-shared.DecodePPS.0" file="shared_pseudocode.xml" hover="function: integer DecodePPS()">DecodePPS</a>();
    l0sz = <a link="impl-shared.GPTL0Size.0" file="shared_pseudocode.xml" hover="function: integer GPTL0Size()">GPTL0Size</a>();
    integer alignment = <a link="impl-shared.Max.2" file="shared_pseudocode.xml" hover="function: integer Max(integer a, integer b)">Max</a>((pps - l0sz) + 3, 12);
    base = base AND NOT <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(<a link="impl-shared.Ones.1" file="shared_pseudocode.xml" hover="function: bits(N) Ones(integer N)">Ones</a>(alignment), 56);

    <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> gptaccdesc = <a link="impl-shared.CreateAccDescGPTW.1" file="shared_pseudocode.xml" hover="function: AccessDescriptor CreateAccDescGPTW(AccessDescriptor accdesc_in)">CreateAccDescGPTW</a>(accdesc);

    // Access attributes and address for GPT fetches
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> gptaddrdesc;
    gptaddrdesc.memattrs = <a link="impl-shared.WalkMemAttrs.3" file="shared_pseudocode.xml" hover="function: MemoryAttributes WalkMemAttrs(bits(2) sh, bits(2) irgn, bits(2) orgn)">WalkMemAttrs</a>(GPCCR_EL3.SH, GPCCR_EL3.ORGN, GPCCR_EL3.IRGN);
    gptaddrdesc.fault    = <a link="impl-shared.NoFault.1" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault(AccessDescriptor accdesc)">NoFault</a>(gptaccdesc);

    // Address of level 0 GPT entry
    gptaddrdesc.paddress.paspace = <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>;
    gptaddrdesc.paddress.address = base + <a link="impl-shared.GPTLevel0Index.1" file="shared_pseudocode.xml" hover="function: integer GPTLevel0Index(bits(56) pa)">GPTLevel0Index</a>(pa) * 8;

    // Fetch L0GPT entry
    bits(64) level_0_entry;
    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, level_0_entry) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(gptaddrdesc, 8, gptaccdesc);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        return (<a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_EABT" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</a>, 0), <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> result;
    <a link="GPTTable" file="shared_pseudocode.xml" hover="type GPTTable is ( bits(56) address )">GPTTable</a> table;
    <a link="GPCF" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF</a> gpf;
    case level_0_entry&lt;3:0&gt; of
        when <a link="GPT_Block" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Block = '0001'">GPT_Block</a>
            // Decode the GPI value and return that
            (gpf, result) = <a link="impl-shared.DecodeGPTBlock.2" file="shared_pseudocode.xml" hover="function: (GPCF, GPTEntry) DecodeGPTBlock(PGSe pgs, bits(64) entry)">DecodeGPTBlock</a>(pgs, level_0_entry);
            result.pa = pa;
            return (<a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(gpf, 0), result);
        when <a link="GPT_Table" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Table = '0011'">GPT_Table</a>
            // Decode the table entry and continue walking
            (gpf, table) = <a link="impl-shared.DecodeGPTTable.2" file="shared_pseudocode.xml" hover="function: (GPCF, GPTTable) DecodeGPTTable(PGSe pgs, bits(64) entry)">DecodeGPTTable</a>(pgs, level_0_entry);
            if gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
                return (<a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(gpf, 0), <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);
        otherwise
            // GPF - invalid encoding
            return (<a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, 0), <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    // Must be a GPT Table entry
    assert level_0_entry&lt;3:0&gt; == <a link="GPT_Table" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Table = '0011'">GPT_Table</a>;

    // Address of level 1 GPT entry
    offset = <a link="impl-shared.GPTLevel1Index.1" file="shared_pseudocode.xml" hover="function: integer GPTLevel1Index(bits(56) pa)">GPTLevel1Index</a>(pa) * 8;
    gptaddrdesc.paddress.address = table.address + offset;

    // Fetch L1GPT entry
    bits(64) level_1_entry;
    (memstatus, level_1_entry) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(gptaddrdesc, 8, gptaccdesc);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        return (<a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_EABT" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_EABT</a>, 1), <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    case level_1_entry&lt;3:0&gt; of
        when <a link="GPT_Contig" file="shared_pseudocode.xml" hover="constant bits(4) GPT_Contig = '0001'">GPT_Contig</a>
            (gpf, result) = <a link="impl-shared.DecodeGPTContiguous.2" file="shared_pseudocode.xml" hover="function: (GPCF, GPTEntry) DecodeGPTContiguous(PGSe pgs, bits(64) entry)">DecodeGPTContiguous</a>(pgs, level_1_entry);
        otherwise
            gpi_index = <a link="impl-shared.GPIIndex.1" file="shared_pseudocode.xml" hover="function: integer GPIIndex(bits(56) pa)">GPIIndex</a>(pa);
            (gpf, result) = <a link="impl-shared.DecodeGPTGranules.3" file="shared_pseudocode.xml" hover="function: (GPCF, GPTEntry) DecodeGPTGranules(PGSe pgs, integer index, bits(64) entry)">DecodeGPTGranules</a>(pgs, gpi_index, level_1_entry);

    if gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
        return (<a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(gpf, 1), <a link="GPTEntry" file="shared_pseudocode.xml" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</a> UNKNOWN);

    result.pa = pa;
    return (<a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>(), result);</pstext>
    </ps>
    <ps name="shared/translation/gpc/GranuleProtectionCheck" mylink="shared.translation.gpc.GranuleProtectionCheck" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// GranuleProtectionCheck()
// ========================
// Returns whether a given access is permitted, according to the
// granule protection check.
// addrdesc and accdesc describe the access to be checked.

GPCFRecord <anchor link="impl-shared.GranuleProtectionCheck.2" hover="function: GPCFRecord GranuleProtectionCheck(AddressDescriptor addrdesc, AccessDescriptor accdesc)">GranuleProtectionCheck</anchor>(<a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc, <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> accdesc)

    assert <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>();
    // The address to be checked
    address = addrdesc.paddress;

    // Bypass mode - all accesses pass
    if GPCCR_EL3.GPC == '0' then
        return <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();

    // Configuration consistency check
    if !<a link="impl-shared.GPCRegistersConsistent.0" file="shared_pseudocode.xml" hover="function: boolean GPCRegistersConsistent()">GPCRegistersConsistent</a>() then
        return <a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_Walk" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Walk</a>, 0);

    // Input address size check
    if <a link="impl-shared.AbovePPS.1" file="shared_pseudocode.xml" hover="function: boolean AbovePPS(bits(56) address)">AbovePPS</a>(address.address) then
        if address.paspace == <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a> then
            return <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();
        else
            return <a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a>, 0);

    // GPT base address size check
    bits(56) gpt_base = <a link="impl-shared.ZeroExtend.2" file="shared_pseudocode.xml" hover="function: bits(N) ZeroExtend(bits(M) x, integer N)">ZeroExtend</a>(GPTBR_EL3.BADDR:<a link="impl-shared.Zeros.1" file="shared_pseudocode.xml" hover="function: bits(N) Zeros(integer N)">Zeros</a>(12), 56);
    if <a link="impl-shared.AbovePPS.1" file="shared_pseudocode.xml" hover="function: boolean AbovePPS(bits(56) address)">AbovePPS</a>(gpt_base) then
        return <a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_AddressSize" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_AddressSize</a>, 0);

    // GPT lookup
    (gpcf, gpt_entry) = <a link="impl-shared.GPTWalk.2" file="shared_pseudocode.xml" hover="function: (GPCFRecord, GPTEntry) GPTWalk(bits(56) pa, AccessDescriptor accdesc)">GPTWalk</a>(address.address, accdesc);
    if gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
        return gpcf;

    // Check input physical address space against GPI
    permitted = <a link="impl-shared.GPICheck.2" file="shared_pseudocode.xml" hover="function: boolean GPICheck(PASpace paspace, bits(4) gpi)">GPICheck</a>(address.paspace, gpt_entry.gpi);

    if !permitted then
        gpcf = <a link="impl-shared.GPCFault.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCFault(GPCF gpf, integer level)">GPCFault</a>(<a link="GPCF_Fail" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_Fail</a>, gpt_entry.level);
        return gpcf;

    // Check passed

    return <a link="impl-shared.GPCNoFault.0" file="shared_pseudocode.xml" hover="function: GPCFRecord GPCNoFault()">GPCNoFault</a>();</pstext>
    </ps>
    <ps name="shared/translation/gpc/PGS" mylink="shared.translation.gpc.PGS" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// PGS
// ===
// Physical granule size

enumeration <anchor link="PGSe" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGSe</anchor> {
    <anchor link="PGS_4KB" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_4KB</anchor>,
    <anchor link="PGS_16KB" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_16KB</anchor>,
    <anchor link="PGS_64KB" hover="enumeration PGSe { PGS_4KB, PGS_16KB, PGS_64KB }">PGS_64KB</anchor>
};</pstext>
    </ps>
    <ps name="shared/translation/gpc/Table" mylink="shared.translation.gpc.Table" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(4) <anchor link="GPT_NoAccess" hover="constant bits(4) GPT_NoAccess = '0000'">GPT_NoAccess</anchor>  = '0000';
constant bits(4) <anchor link="GPT_Table" hover="constant bits(4) GPT_Table = '0011'">GPT_Table</anchor>     = '0011';
constant bits(4) <anchor link="GPT_Block" hover="constant bits(4) GPT_Block = '0001'">GPT_Block</anchor>     = '0001';
constant bits(4) <anchor link="GPT_Contig" hover="constant bits(4) GPT_Contig = '0001'">GPT_Contig</anchor>    = '0001';
constant bits(4) <anchor link="GPT_Secure" hover="constant bits(4) GPT_Secure = '1000'">GPT_Secure</anchor>    = '1000';
constant bits(4) <anchor link="GPT_NonSecure" hover="constant bits(4) GPT_NonSecure = '1001'">GPT_NonSecure</anchor> = '1001';
constant bits(4) <anchor link="GPT_Root" hover="constant bits(4) GPT_Root = '1010'">GPT_Root</anchor>      = '1010';
constant bits(4) <anchor link="GPT_Realm" hover="constant bits(4) GPT_Realm = '1011'">GPT_Realm</anchor>     = '1011';
constant bits(4) <anchor link="GPT_Any" hover="constant bits(4) GPT_Any = '1111'">GPT_Any</anchor>       = '1111';
constant integer <anchor link="GPTRange_4KB" hover="constant integer GPTRange_4KB = 12">GPTRange_4KB</anchor>   = 12;
constant integer <anchor link="GPTRange_16KB" hover="constant integer GPTRange_16KB = 14">GPTRange_16KB</anchor>  = 14;
constant integer <anchor link="GPTRange_64KB" hover="constant integer GPTRange_64KB = 16">GPTRange_64KB</anchor>  = 16;
constant integer <anchor link="GPTRange_2MB" hover="constant integer GPTRange_2MB = 21">GPTRange_2MB</anchor>   = 21;
constant integer <anchor link="GPTRange_32MB" hover="constant integer GPTRange_32MB = 25">GPTRange_32MB</anchor>  = 25;
constant integer <anchor link="GPTRange_512MB" hover="constant integer GPTRange_512MB = 29">GPTRange_512MB</anchor> = 29;
constant integer <anchor link="GPTRange_1GB" hover="constant integer GPTRange_1GB = 30">GPTRange_1GB</anchor>   = 30;
constant integer <anchor link="GPTRange_16GB" hover="constant integer GPTRange_16GB = 34">GPTRange_16GB</anchor>  = 34;
constant integer <anchor link="GPTRange_64GB" hover="constant integer GPTRange_64GB = 36">GPTRange_64GB</anchor>  = 36;
constant integer <anchor link="GPTRange_512GB" hover="constant integer GPTRange_512GB = 39">GPTRange_512GB</anchor> = 39;

type <anchor link="GPTTable" hover="type GPTTable is ( bits(56) address )">GPTTable</anchor> is (
    bits(56) address        // Base address of next table
)

type <anchor link="GPTEntry" hover="type GPTEntry is ( bits(4) gpi, integer size, integer contig_size, integer level, bits(56) pa )">GPTEntry</anchor> is (
    bits(4)  gpi,           // GPI value for this region
    integer  size,          // Region size
    integer  contig_size,   // Contiguous region size
    integer  level,         // Level of GPT lookup
    bits(56) pa             // PA uniquely identifying the GPT entry
)</pstext>
    </ps>
    <ps name="shared/translation/translation/S1TranslationRegime" mylink="shared.translation.translation.S1TranslationRegime" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S1TranslationRegime()
// =====================
// Stage 1 translation regime for the given Exception level

bits(2) <anchor link="impl-shared.S1TranslationRegime.1" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</anchor>(bits(2) el)
    if el != <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        return el;
    elsif <a link="impl-shared.HaveEL.1" file="shared_pseudocode.xml" hover="function: boolean HaveEL(bits(2) el)">HaveEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) &amp;&amp; SCR.NS == '0' then
        return <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>;
    elsif <a link="impl-shared.HaveVirtHostExt.0" file="shared_pseudocode.xml" hover="function: boolean HaveVirtHostExt()">HaveVirtHostExt</a>() &amp;&amp; <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(el) then
        return <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>;
    else
        return <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>;

// S1TranslationRegime()
// =====================
// Returns the Exception level controlling the current Stage 1 translation regime. For the most
// part this is unused in code because the System register accessors (SCTLR[], etc.) implicitly
// return the correct value.

bits(2) <anchor link="impl-shared.S1TranslationRegime.0" hover="function: bits(2) S1TranslationRegime()">S1TranslationRegime</anchor>()
    return <a link="impl-shared.S1TranslationRegime.1" file="shared_pseudocode.xml" hover="function: bits(2) S1TranslationRegime(bits(2) el)">S1TranslationRegime</a>(PSTATE.EL);</pstext>
    </ps>
    <ps name="shared/translation/vmsa/AddressDescriptor" mylink="shared.translation.vmsa.AddressDescriptor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant integer <anchor link="FINAL_LEVEL" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</anchor> = 3;

// AddressDescriptor
// =================
// Descriptor used to access the underlying memory array.

type <anchor link="AddressDescriptor" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</anchor> is (
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a>      fault,      // fault.statuscode indicates whether the address is valid
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs,
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a>      paddress,
    boolean          s1assured,  // Stage 1 Assured Translation Property
    boolean          s2fs1mro,   // Stage 2 MRO permission for Satge 1
    bits(16)         mecid,      // FEAT_MEC: Memory Encryption Context ID
    bits(64)         vaddress
)</pstext>
    </ps>
    <ps name="shared/translation/vmsa/ContiguousSize" mylink="shared.translation.vmsa.ContiguousSize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// ContiguousSize()
// ================
// Return the number of entries log 2 marking a contiguous output range

integer <anchor link="impl-shared.ContiguousSize.3" hover="function: integer ContiguousSize(bit d128, TGx tgx, integer level)">ContiguousSize</anchor>(bit d128, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer level)
    if d128 == '1' then
        return 4;
    else
        case tgx of
            when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>
                assert level != 0;
                return 4;
            when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a>
                assert level IN {2, 3};
                return if level == 2 then 5 else 7;
            when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a>
                assert level != 1;
                return 5;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/CreateAddressDescriptor" mylink="shared.translation.vmsa.CreateAddressDescriptor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateAddressDescriptor()
// =========================
// Set internal members for address descriptor type to valid values

AddressDescriptor <anchor link="impl-shared.CreateAddressDescriptor.3" hover="function: AddressDescriptor CreateAddressDescriptor(bits(64) va, FullAddress pa, MemoryAttributes memattrs)">CreateAddressDescriptor</anchor>(bits(64) va, <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> pa,
                                          <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a> memattrs)
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc;

    addrdesc.paddress = pa;
    addrdesc.vaddress = va;
    addrdesc.memattrs = memattrs;
    addrdesc.fault    = <a link="impl-shared.NoFault.0" file="shared_pseudocode.xml" hover="function: FaultRecord NoFault()">NoFault</a>();
    addrdesc.s1assured = FALSE;

    return addrdesc;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/CreateFaultyAddressDescriptor" mylink="shared.translation.vmsa.CreateFaultyAddressDescriptor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// CreateFaultyAddressDescriptor()
// ===============================
// Set internal members for address descriptor type with values indicating error

AddressDescriptor <anchor link="impl-shared.CreateFaultyAddressDescriptor.2" hover="function: AddressDescriptor CreateFaultyAddressDescriptor(bits(64) va, FaultRecord fault)">CreateFaultyAddressDescriptor</anchor>(bits(64) va, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault)
    <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> addrdesc;

    addrdesc.vaddress = va;
    addrdesc.fault    = fault;

    return addrdesc;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/DecodePASpace" mylink="shared.translation.vmsa.DecodePASpace" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DecodePASpace()
// ===============
// Decode the target PA Space

PASpace <anchor link="impl-shared.DecodePASpace.2" hover="function: PASpace DecodePASpace (bit nse, bit ns)">DecodePASpace</anchor> (bit nse, bit ns)
    case nse:ns of
        when '00'   return <a link="PAS_Secure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Secure</a>;
        when '01'   return <a link="PAS_NonSecure" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_NonSecure</a>;
        when '10'   return <a link="PAS_Root" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Root</a>;
        when '11'   return <a link="PAS_Realm" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PAS_Realm</a>;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/DescriptorType" mylink="shared.translation.vmsa.DescriptorType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// DescriptorType
// ==============
// Translation table descriptor formats

enumeration <anchor link="DescriptorType" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType</anchor> {
    <anchor link="DescriptorType_Table" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Table</anchor>,
    <anchor link="DescriptorType_Leaf" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Leaf</anchor>,
    <anchor link="DescriptorType_Invalid" hover="enumeration DescriptorType { DescriptorType_Table, DescriptorType_Leaf, DescriptorType_Invalid }">DescriptorType_Invalid</anchor>
};</pstext>
    </ps>
    <ps name="shared/translation/vmsa/Domains" mylink="shared.translation.vmsa.Domains" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">constant bits(2) <anchor link="Domain_NoAccess" hover="constant bits(2) Domain_NoAccess = '00'">Domain_NoAccess</anchor> = '00';
constant bits(2) <anchor link="Domain_Client" hover="constant bits(2) Domain_Client = '01'">Domain_Client</anchor>   = '01';
constant bits(2) <anchor link="Domain_Manager" hover="constant bits(2) Domain_Manager = '11'">Domain_Manager</anchor>  = '11';</pstext>
    </ps>
    <ps name="shared/translation/vmsa/FetchDescriptor" mylink="shared.translation.vmsa.FetchDescriptor" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// FetchDescriptor()
// =================
// Fetch a translation table descriptor

(FaultRecord, bits(N)) <anchor link="impl-shared.FetchDescriptor.5" hover="function: (FaultRecord, bits(N)) FetchDescriptor(bit ee, AddressDescriptor walkaddress, AccessDescriptor walkaccess, FaultRecord fault_in, integer N)">FetchDescriptor</anchor>(bit ee, <a link="AddressDescriptor" file="shared_pseudocode.xml" hover="type AddressDescriptor is ( FaultRecord fault, MemoryAttributes memattrs, FullAddress paddress, boolean s1assured, boolean s2fs1mro, bits(16) mecid, bits(64) vaddress )">AddressDescriptor</a> walkaddress,
                                       <a link="AccessDescriptor" file="shared_pseudocode.xml" hover="type AccessDescriptor is ( AccessType acctype, bits(2) el, SecurityState ss, boolean acqsc, boolean acqpc, boolean relsc, boolean limitedordered, boolean exclusive, boolean atomicop, MemAtomicOp modop, boolean nontemporal, boolean read, boolean write, CacheOp cacheop, CacheOpScope opscope, CacheType cachetype, boolean pan, boolean transactional, boolean nonfault, boolean firstfault, boolean first, boolean contiguous, boolean streamingsve, boolean ls64, boolean mops, boolean rcw, boolean rcws, boolean toplevel, VARange varange, boolean a32lsmd, boolean tagchecked, boolean tagaccess, MPAMinfo mpam )">AccessDescriptor</a> walkaccess, <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault_in,
                                       integer N)
    // 32-bit descriptors for AArch32 Short-descriptor format
    // 64-bit descriptors for AArch64 or AArch32 Long-descriptor format
    // 128-bit descriptors for AArch64 when FEAT_D128 is set and {V}TCR_ELx.d128 is set
    assert N == 32 || N == 64 || N == 128;
    bits(N) descriptor;
    <a link="FaultRecord" file="shared_pseudocode.xml" hover="type FaultRecord is ( Fault statuscode, AccessDescriptor access, FullAddress ipaddress, GPCFRecord gpcf, FullAddress paddress, boolean gpcfs2walk, boolean s2fs1walk, boolean write, boolean s1tagnotdata, boolean tagaccess, integer level, bit extflag, boolean secondstage, boolean assuredonly, boolean toplevel, boolean overlay, boolean dirtybit, bits(4) domain, ErrorState merrorstate, bits(4) debugmoe )">FaultRecord</a> fault = fault_in;

    if <a link="impl-shared.HaveRME.0" file="shared_pseudocode.xml" hover="function: boolean HaveRME()">HaveRME</a>() then
        fault.gpcf = <a link="impl-shared.GranuleProtectionCheck.2" file="shared_pseudocode.xml" hover="function: GPCFRecord GranuleProtectionCheck(AddressDescriptor addrdesc, AccessDescriptor accdesc)">GranuleProtectionCheck</a>(walkaddress, walkaccess);
        if fault.gpcf.gpf != <a link="GPCF_None" file="shared_pseudocode.xml" hover="enumeration GPCF { GPCF_None, GPCF_AddressSize, GPCF_Walk, GPCF_EABT, GPCF_Fail }">GPCF_None</a> then
            fault.statuscode = <a link="Fault_GPCFOnWalk" file="shared_pseudocode.xml" hover="enumeration Fault {Fault_None, Fault_AccessFlag, Fault_Alignment, Fault_Background, Fault_Domain, Fault_Permission, Fault_Translation, Fault_AddressSize, Fault_SyncExternal, Fault_SyncExternalOnWalk, Fault_SyncParity, Fault_SyncParityOnWalk, Fault_GPCFOnWalk, Fault_GPCFOnOutput, Fault_AsyncParity, Fault_AsyncExternal, Fault_TagCheck, Fault_Debug, Fault_TLBConflict, Fault_BranchTarget, Fault_HWUpdateAccessFlag, Fault_Lockdown, Fault_Exclusive, Fault_ICacheMaint}">Fault_GPCFOnWalk</a>;
            fault.paddress   = walkaddress.paddress;
            fault.gpcfs2walk = fault.secondstage;
            return (fault, bits(N) UNKNOWN);

    <a link="PhysMemRetStatus" file="shared_pseudocode.xml" hover="type PhysMemRetStatus is ( Fault statuscode, bit extflag, ErrorState merrorstate, bits(64) store64bstatus )">PhysMemRetStatus</a> memstatus;
    (memstatus, descriptor) = <a link="impl-shared.PhysMemRead.3" file="shared_pseudocode.xml" hover="function: (PhysMemRetStatus, bits(8*size)) PhysMemRead(AddressDescriptor desc, integer size, AccessDescriptor accdesc)">PhysMemRead</a>(walkaddress, N DIV 8, walkaccess);
    if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(memstatus) then
        boolean iswrite = FALSE;
        fault = <a link="impl-shared.HandleExternalTTWAbort.6" file="shared_pseudocode.xml" hover="function: FaultRecord HandleExternalTTWAbort(PhysMemRetStatus memretstatus, boolean iswrite, AddressDescriptor memaddrdesc, AccessDescriptor accdesc, integer size, FaultRecord input_fault)">HandleExternalTTWAbort</a>(memstatus, iswrite, walkaddress,
                                       walkaccess, N DIV 8, fault);
        if <a link="impl-shared.IsFault.1" file="shared_pseudocode.xml" hover="function: boolean IsFault(AddressDescriptor addrdesc)">IsFault</a>(fault.statuscode) then
            return (fault, bits(N) UNKNOWN);

    if ee == '1' then
        descriptor = <a link="impl-shared.BigEndianReverse.1" file="shared_pseudocode.xml" hover="function: bits(width) BigEndianReverse (bits(width) value)">BigEndianReverse</a>(descriptor);

    return (fault, descriptor);</pstext>
    </ps>
    <ps name="shared/translation/vmsa/HasUnprivileged" mylink="shared.translation.vmsa.HasUnprivileged" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// HasUnprivileged()
// =================
// Returns whether a translation regime serves EL0 as well as a higher EL

boolean <anchor link="impl-shared.HasUnprivileged.1" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    return (regime IN {
        <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>,
        <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a>,
        <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>
    });</pstext>
    </ps>
    <ps name="shared/translation/vmsa/Regime" mylink="shared.translation.vmsa.Regime" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// Regime
// ======
// Translation regimes

enumeration <anchor link="Regime" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</anchor> {
    <anchor link="Regime_EL3" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</anchor>,            // EL3
    <anchor link="Regime_EL30" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</anchor>,           // EL3&amp;0 (PL1&amp;0 when EL3 is AArch32)
    <anchor link="Regime_EL2" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</anchor>,            // EL2
    <anchor link="Regime_EL20" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</anchor>,           // EL2&amp;0
    <anchor link="Regime_EL10" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</anchor>            // EL1&amp;0
};</pstext>
    </ps>
    <ps name="shared/translation/vmsa/RegimeUsingAArch32" mylink="shared.translation.vmsa.RegimeUsingAArch32" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// RegimeUsingAArch32()
// ====================
// Determine if the EL controlling the regime executes in AArch32 state

boolean <anchor link="impl-shared.RegimeUsingAArch32.1" hover="function: boolean RegimeUsingAArch32(Regime regime)">RegimeUsingAArch32</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> return <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> return TRUE;
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> return FALSE;
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>  return <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>  return FALSE;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/S1TTWParams" mylink="shared.translation.vmsa.S1TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S1TTWParams
// ===========
// Register fields corresponding to stage 1 translation
// For A32-VMSA, if noted, they correspond to A32-LPAE (Long descriptor format)

type S1TTWParams is (
// A64-VMSA exclusive parameters
    bit         ha,         // TCR_ELx.HA
    bit         hd,         // TCR_ELx.HD
    bit         tbi,        // TCR_ELx.TBI{x}
    bit         tbid,       // TCR_ELx.TBID{x}
    bit         nfd,        // TCR_EL1.NFDx or TCR_EL2.NFDx when HCR_EL2.E2H == '1'
    bit         e0pd,       // TCR_EL1.E0PDx or TCR_EL2.E0PDx when HCR_EL2.E2H == '1'
    bit         d128,       // TCR_ELx.D128
    bit         aie,         // (TCR2_ELx/TCR_EL3).AIE
    MAIRType    mair2,       // MAIR2_ELx
    bit         ds,         // TCR_ELx.DS
    bits(3)     ps,         // TCR_ELx.{I}PS
    bits(6)     txsz,       // TCR_ELx.TxSZ
    bit         epan,       // SCTLR_EL1.EPAN or SCTLR_EL2.EPAN when HCR_EL2.E2H == '1'
    bit         dct,        // HCR_EL2.DCT
    bit         nv1,        // HCR_EL2.NV1
    bit         cmow,       // SCTLR_EL1.CMOW or SCTLR_EL2.CMOW when HCR_EL2.E2H == '1'
    bit         pnch,       // TCR{2}_ELx.PnCH
    bit         disch,      // TCR{2}_ELx.DisCH
    bit         haft,       // TCR{2}_ELx.HAFT
    bit         mtx,        // TCR_ELx.MTX{y}
    bits(2)     skl,        // TCR_ELx.SKL
    bit         pie,        // TCR2_ELx.PIE or TCR_EL3.PIE
    S1PIRType   pir,        // PIR_ELx
    S1PIRType   pire0,      // PIRE0_EL1 or PIRE0_EL2 when HCR_EL2.E2H == '1'
    bit         emec,       // SCTLR2_EL2.EMEC or SCTLR2_EL3.EMEC
    bit         amec,       // TCR2_EL2.AMEC0 or TCR2_EL2.AMEC1 when HCR_EL2.E2H == '1'

// A32-VMSA exclusive parameters
    bits(3)     t0sz,       // TTBCR.T0SZ
    bits(3)     t1sz,       // TTBCR.T1SZ
    bit         uwxn,       // SCTLR.UWXN

// Parameters common to both A64-VMSA &amp; A32-VMSA (A64/A32)
    <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a>         tgx,        // TCR_ELx.TGx      / Always TGx_4KB
    bits(2)     irgn,       // TCR_ELx.IRGNx    / TTBCR.IRGNx or HTCR.IRGN0
    bits(2)     orgn,       // TCR_ELx.ORGNx    / TTBCR.ORGNx or HTCR.ORGN0
    bits(2)     sh,         // TCR_ELx.SHx      / TTBCR.SHx or HTCR.SH0
    bit         hpd,        // TCR_ELx.HPD{x}   / TTBCR2.HPDx or HTCR.HPD
    bit         ee,         // SCTLR_ELx.EE     / SCTLR.EE or HSCTLR.EE
    bit         wxn,        // SCTLR_ELx.WXN    / SCTLR.WXN or HSCTLR.WXN
    bit         ntlsmd,     // SCTLR_ELx.nTLSMD / SCTLR.nTLSMD or HSCTLR.nTLSMD
    bit         dc,         // HCR_EL2.DC       / HCR.DC
    bit         sif,        // SCR_EL3.SIF      / SCR.SIF
    MAIRType    mair        // MAIR_ELx         / MAIR1:MAIR0 or HMAIR1:HMAIR0
)</pstext>
    </ps>
    <ps name="shared/translation/vmsa/S2TTWParams" mylink="shared.translation.vmsa.S2TTWParams" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// S2TTWParams
// ===========
// Register fields corresponding to stage 2 translation.

type S2TTWParams is (
// A64-VMSA exclusive parameters
    bit         ha,         // VTCR_EL2.HA
    bit         hd,         // VTCR_EL2.HD
    bit         sl2,        // V{S}TCR_EL2.SL2
    bit         ds,         // VTCR_EL2.DS
    bit         d128,       // VTCR_ELx.D128
    bit         sw,         // VSTCR_EL2.SW
    bit         nsw,        // VTCR_EL2.NSW
    bit         sa,         // VSTCR_EL2.SA
    bit         nsa,        // VTCR_EL2.NSA
    bits(3)     ps,         // VTCR_EL2.PS
    bits(6)     txsz,       // V{S}TCR_EL2.T0SZ
    bit         fwb,        // HCR_EL2.PTW
    bit         cmow,       // HCRX_EL2.CMOW
    bits(2)     skl,        // VTCR_EL2.SKL
    bit         s2pie,      // VTCR_EL2.S2PIE
    S2PIRType   s2pir,      // S2PIR_EL2
    bit         tl0,        // VTCR_EL2.TL0
    bit         tl1,        // VTCR_EL2.TL1
    bit         assuredonly,// VTCR_EL2.AssuredOnly
    bit         haft,       // VTCR_EL2.HAFT
    bit         emec,       // SCTLR2_EL2.EMEC

// A32-VMSA exclusive parameters
    bit         s,          // VTCR.S
    bits(4)     t0sz,       // VTCR.T0SZ

// Parameters common to both A64-VMSA &amp; A32-VMSA if implemented (A64/A32)
    <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a>         tgx,        // V{S}TCR_EL2.TG0  / Always TGx_4KB
    bits(2)     sl0,        // V{S}TCR_EL2.SL0  / VTCR.SL0
    bits(2)     irgn,       // VTCR_EL2.IRGN0   / VTCR.IRGN0
    bits(2)     orgn,       // VTCR_EL2.ORGN0   / VTCR.ORGN0
    bits(2)     sh,         // VTCR_EL2.SH0     / VTCR.SH0
    bit         ee,         // SCTLR_EL2.EE     / HSCTLR.EE
    bit         ptw,        // HCR_EL2.PTW      / HCR.PTW
    bit         vm          // HCR_EL2.VM       / HCR.VM
)</pstext>
    </ps>
    <ps name="shared/translation/vmsa/SDFType" mylink="shared.translation.vmsa.SDFType" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SDFType
// =======
// Short-descriptor format type

enumeration <anchor link="SDFType" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</anchor> {
    <anchor link="SDFType_Table" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Table</anchor>,
    <anchor link="SDFType_Invalid" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Invalid</anchor>,
    <anchor link="SDFType_Supersection" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Supersection</anchor>,
    <anchor link="SDFType_Section" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_Section</anchor>,
    <anchor link="SDFType_LargePage" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_LargePage</anchor>,
    <anchor link="SDFType_SmallPage" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType_SmallPage</anchor>
};</pstext>
    </ps>
    <ps name="shared/translation/vmsa/SecurityStateForRegime" mylink="shared.translation.vmsa.SecurityStateForRegime" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// SecurityStateForRegime()
// ========================
// Return the Security State of the given translation regime

SecurityState <anchor link="impl-shared.SecurityStateForRegime.1" hover="function: SecurityState SecurityStateForRegime(Regime regime)">SecurityStateForRegime</anchor>(<a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a> regime)
    case regime of
        when <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>     return <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>);
        when <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a>    return <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a>; // A32 EL3 is always Secure
        when <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>     return <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>    return <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>);
        when <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>    return <a link="impl-shared.SecurityStateAtEL.1" file="shared_pseudocode.xml" hover="function: SecurityState SecurityStateAtEL(bits(2) EL)">SecurityStateAtEL</a>(<a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a>);</pstext>
    </ps>
    <ps name="shared/translation/vmsa/StageOA" mylink="shared.translation.vmsa.StageOA" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// StageOA()
// =========
// Given the final walk state (a page or block descriptor), map the untranslated
// input address bits to the output address

FullAddress <anchor link="impl-shared.StageOA.4" hover="function: FullAddress StageOA(bits(64) ia, bit d128, TGx tgx, TTWState walkstate)">StageOA</anchor>(bits(64) ia, bit d128, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a> walkstate)
    // Output Address
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a> oa;
    integer csize;

    tsize = <a link="impl-shared.TranslationSize.3" file="shared_pseudocode.xml" hover="function: integer TranslationSize(bit d128, TGx tgx, integer level)">TranslationSize</a>(d128, tgx, walkstate.level);
    if walkstate.contiguous == '1' then
        csize = <a link="impl-shared.ContiguousSize.3" file="shared_pseudocode.xml" hover="function: integer ContiguousSize(bit d128, TGx tgx, integer level)">ContiguousSize</a>(d128, tgx, walkstate.level);
    else
        csize = 0;

    ia_msb = tsize + csize;
    oa.paspace = walkstate.baseaddress.paspace;
    oa.address = walkstate.baseaddress.address&lt;55:ia_msb&gt;:ia&lt;ia_msb-1:0&gt;;

    return oa;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TGx" mylink="shared.translation.vmsa.TGx" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TGx
// ===
// Translation granules sizes

enumeration <anchor link="TGx" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</anchor> {
    <anchor link="TGx_4KB" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</anchor>,
    <anchor link="TGx_16KB" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</anchor>,
    <anchor link="TGx_64KB" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</anchor>
};</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TGxGranuleBits" mylink="shared.translation.vmsa.TGxGranuleBits" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TGxGranuleBits()
// ================
// Retrieve the address size, in bits, of a granule

integer <anchor link="impl-shared.TGxGranuleBits.1" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</anchor>(<a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx)
    case tgx of
        when <a link="TGx_4KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_4KB</a>  return 12;
        when <a link="TGx_16KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_16KB</a> return 14;
        when <a link="TGx_64KB" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx_64KB</a> return 16;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TLBContext" mylink="shared.translation.vmsa.TLBContext" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBContext
// ==========
// Translation context compared on TLB lookups and invalidations, promoting a TLB hit on match

type <anchor link="TLBContext" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</anchor> is (
    <a link="SecurityState" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SecurityState</a> ss,
    <a link="Regime" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime</a>        regime,
    bits(16)      vmid,
    bits(16)      asid,
    bit           nG,
    <a link="PASpace" file="shared_pseudocode.xml" hover="enumeration PASpace { PAS_NonSecure, PAS_Secure, PAS_Root, PAS_Realm }">PASpace</a>       ipaspace, // Used in stage 2 lookups &amp; invalidations only
    boolean       includes_s1,
    boolean       includes_s2,
    boolean       includes_gpt,
    bits(64)      ia,       // Input Address
    <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a>           tg,
    bit           cnp,
    integer       level,    // Assist TLBI level hints (FEAT_TTL)
    boolean       isd128,
    bit           xs        // XS attribute (FEAT_XS)
)</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TLBRecord" mylink="shared.translation.vmsa.TLBRecord" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TLBRecord
// =========
// Translation output as a TLB payload

type <anchor link="TLBRecord" hover="type TLBRecord is ( TLBContext context, TTWState walkstate, integer blocksize, integer contigsize, bits(128) s1descriptor, bits(128) s2descriptor )">TLBRecord</anchor> is (
    <a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a>  context,
    <a link="TTWState" file="shared_pseudocode.xml" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</a>    walkstate,
    integer     blocksize,    // Number of bits directly mapped from IA to OA
    integer     contigsize,   // Number of entries log 2 marking a contiguous output range
    bits(128)   s1descriptor, // Stage 1 leaf descriptor in memory (valid if the TLB caches stage 1)
    bits(128)   s2descriptor  // Stage 2 leaf descriptor in memory (valid if the TLB caches stage 2)
)</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TTWState" mylink="shared.translation.vmsa.TTWState" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TTWState
// ========
// Translation table walk state

type <anchor link="TTWState" hover="type TTWState is ( boolean istable, integer level, FullAddress baseaddress, bit contiguous, boolean s1assured, bit s2assuredonly, bit disch, bit nG, bit guardedpage, SDFType sdftype, bits(4) domain, MemoryAttributes memattrs, Permissions permissions )">TTWState</anchor> is (
    boolean             istable,
    integer             level,
    <a link="FullAddress" file="shared_pseudocode.xml" hover="type FullAddress is ( PASpace paspace, bits(56) address )">FullAddress</a>         baseaddress,
    bit                 contiguous,
    boolean             s1assured,      // Stage 1 Assured Translation Property
    bit                 s2assuredonly,  // Stage 2 AssuredOnly attribute
    bit                 disch,          // Stage 1 Disable Contiguous Hint
    bit                 nG,
    bit                 guardedpage,
    <a link="SDFType" file="shared_pseudocode.xml" hover="enumeration SDFType { SDFType_Table, SDFType_Invalid, SDFType_Supersection, SDFType_Section, SDFType_LargePage, SDFType_SmallPage }">SDFType</a>             sdftype,    // AArch32 Short-descriptor format walk only
    bits(4)             domain,     // AArch32 Short-descriptor format walk only
    <a link="MemoryAttributes" file="shared_pseudocode.xml" hover="type MemoryAttributes is ( MemType memtype, DeviceType device, MemAttrHints inner, MemAttrHints outer, Shareability shareability, MemTagType tags, boolean notagaccess, bit xs )">MemoryAttributes</a>    memattrs,
    <a link="Permissions" file="shared_pseudocode.xml" hover="type Permissions is ( bits(2) ap_table, bit xn_table, bit pxn_table, bit uxn_table, bits(3) ap, bit xn, bit uxn, bit pxn, bits(4) ppi, bits(4) upi, bit ndirty, bits(4) s2pi, bit s2dirty, bits(4) po_index, bits(4) s2po_index, bits(2) s2ap, bit s2tag_na, bit s2xnx, bit s2xn )">Permissions</a>         permissions
)</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TranslationRegime" mylink="shared.translation.vmsa.TranslationRegime" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TranslationRegime()
// ===================
// Select the translation regime given the target EL and PE state

Regime <anchor link="impl-shared.TranslationRegime.1" hover="function: Regime TranslationRegime(bits(2) el)">TranslationRegime</anchor>(bits(2) el)
    if el == <a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a> then
        return if <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a> else <a link="Regime_EL3" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL3</a>;
    elsif el == <a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a> then
        return if <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL2" file="shared_pseudocode.xml" hover="constant bits(2) EL2 = '10'">EL2</a>) then <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a> else <a link="Regime_EL2" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL2</a>;
    elsif el == <a link="EL1" file="shared_pseudocode.xml" hover="constant bits(2) EL1 = '01'">EL1</a> then
        return <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
    elsif el == <a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a> then
        if <a link="impl-shared.CurrentSecurityState.0" file="shared_pseudocode.xml" hover="function: SecurityState CurrentSecurityState()">CurrentSecurityState</a>() == <a link="SS_Secure" file="shared_pseudocode.xml" hover="enumeration SecurityState { SS_NonSecure, SS_Root, SS_Realm, SS_Secure }">SS_Secure</a> &amp;&amp; <a link="impl-shared.ELUsingAArch32.1" file="shared_pseudocode.xml" hover="function: boolean ELUsingAArch32(bits(2) el)">ELUsingAArch32</a>(<a link="EL3" file="shared_pseudocode.xml" hover="constant bits(2) EL3 = '11'">EL3</a>) then
            return <a link="Regime_EL30" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL30</a>;
        elsif <a link="impl-shared.ELIsInHost.1" file="shared_pseudocode.xml" hover="function: boolean ELIsInHost(bits(2) el)">ELIsInHost</a>(<a link="EL0" file="shared_pseudocode.xml" hover="constant bits(2) EL0 = '00'">EL0</a>) then
            return <a link="Regime_EL20" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL20</a>;
        else
            return <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a>;
    else
        <a link="impl-shared.Unreachable.0" file="shared_pseudocode.xml" hover="function: Unreachable()">Unreachable</a>();</pstext>
    </ps>
    <ps name="shared/translation/vmsa/TranslationSize" mylink="shared.translation.vmsa.TranslationSize" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// TranslationSize()
// =================
// Compute the number of bits directly mapped from the input address
// to the output address

integer <anchor link="impl-shared.TranslationSize.3" hover="function: integer TranslationSize(bit d128, TGx tgx, integer level)">TranslationSize</anchor>(bit d128, <a link="TGx" file="shared_pseudocode.xml" hover="enumeration TGx { TGx_4KB, TGx_16KB, TGx_64KB }">TGx</a> tgx, integer level)
    granulebits = <a link="impl-shared.TGxGranuleBits.1" file="shared_pseudocode.xml" hover="function: integer TGxGranuleBits(TGx tgx)">TGxGranuleBits</a>(tgx);
    descsizelog2 = if d128 == '1' then 4 else 3;
    blockbits   = (<a link="FINAL_LEVEL" file="shared_pseudocode.xml" hover="constant integer FINAL_LEVEL = 3">FINAL_LEVEL</a> - level) * (granulebits - descsizelog2);

    return granulebits + blockbits;</pstext>
    </ps>
    <ps name="shared/translation/vmsa/UseASID" mylink="shared.translation.vmsa.UseASID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UseASID()
// =========
// Determine whether the translation context for the access requires ASID or is a global entry

boolean <anchor link="impl-shared.UseASID.1" hover="function: boolean UseASID(TLBContext access)">UseASID</anchor>(<a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> access)
    return <a link="impl-shared.HasUnprivileged.1" file="shared_pseudocode.xml" hover="function: boolean HasUnprivileged(Regime regime)">HasUnprivileged</a>(access.regime);</pstext>
    </ps>
    <ps name="shared/translation/vmsa/UseVMID" mylink="shared.translation.vmsa.UseVMID" enclabels="" sections="1" secttype="Library">
      <pstext mayhavelinks="1" section="Functions" rep_section="functions">// UseVMID()
// =========
// Determine whether the translation context for the access requires VMID to match a TLB entry

boolean <anchor link="impl-shared.UseVMID.1" hover="function: boolean UseVMID(TLBContext access)">UseVMID</anchor>(<a link="TLBContext" file="shared_pseudocode.xml" hover="type TLBContext is ( SecurityState ss, Regime regime, bits(16) vmid, bits(16) asid, bit nG, PASpace ipaspace, boolean includes_s1, boolean includes_s2, boolean includes_gpt, bits(64) ia, TGx tg, bit cnp, integer level, boolean isd128, bit xs )">TLBContext</a> access)
    return access.regime == <a link="Regime_EL10" file="shared_pseudocode.xml" hover="enumeration Regime { Regime_EL3, Regime_EL30, Regime_EL2, Regime_EL20, Regime_EL10 }">Regime_EL10</a> &amp;&amp; <a link="impl-shared.EL2Enabled.0" file="shared_pseudocode.xml" hover="function: boolean EL2Enabled()">EL2Enabled</a>();</pstext>
    </ps>
  </ps_section>
</instructionsection>
