Shared pseudocode from the offline Arm documentation snapshot. Part 16 of 36.
Library pseudocode for aarch64/functions/sve/CheckOriginalSVEEnabled
// CheckOriginalSVEEnabled // ========================= // Checks for traps on SVE instructions and instructions that access SVE System // registers.func CheckOriginalSVEEnabled begin assert IsFeatureImplemented(FEAT_SVE); var disabled : boolean;
if (HaveEL(EL3) && (CPTR_EL3().EZ == '0' || CPTR_EL3().TFP == '1') && EL3SDDUndefPriority()) then Undefined();end;// Check if access disabled in CPACR_EL1if PSTATE.EL IN {EL0, EL1} && () then // Check SVE at EL0/EL1 case CPACR_EL1().ZEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0; when '11' => disabled = FALSE; end; if disabled then SVEAccessTrap(EL1); end; // Check SIMD&FP at EL0/EL1 case CPACR_EL1().FPEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0; when '11' => disabled = FALSE; end; if disabled then AArch64_AdvSIMDFPAccessTrap(EL1); end;end;// Check if access disabled in CPTR_EL2if PSTATE.EL IN {EL0, EL1, EL2} && EL2Enabled() then if ELIsInHost(EL2) then // Check SVE at EL2 case CPTR_EL2().ZEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0 && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then SVEAccessTrap(EL2); end; // Check SIMD&FP at EL2 case CPTR_EL2().FPEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0 && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then AArch64_AdvSIMDFPAccessTrap(EL2); end; else if CPTR_EL2().TZ == '1' then SVEAccessTrap(EL2); end; if CPTR_EL2().TFP == '1' then AArch64_AdvSIMDFPAccessTrap(EL2); end; end;end;// Check if access disabled in CPTR_EL3if HaveEL(EL3) then if CPTR_EL3().EZ == '0' then if EL3SDDUndef() then Undefined(); end; SVEAccessTrap(EL3); end; if CPTR_EL3().TFP == '1' then if EL3SDDUndef() then Undefined(); end; AArch64_AdvSIMDFPAccessTrap(EL3); end;end;
end;
Library pseudocode for aarch64/functions/sve/CheckSMEAccess
// CheckSMEAccess // ================ // Check that access to SME System registers is enabled.func CheckSMEAccess begin var disabled : boolean;
if HaveEL(EL3) && CPTR_EL3().ESM == '0' && EL3SDDUndefPriority() then Undefined();end;// Check if access disabled in CPACR_EL1if PSTATE.EL IN {EL0, EL1} && () then // Check SME at EL0/EL1 case CPACR_EL1().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = EffectivelyAtEL0NotInHost(); when '11' => disabled = FALSE; end; if disabled then SMEAccessTrap(SMEExceptionType_AccessTrap, EL1); end;end;if PSTATE.EL IN {EL0, EL1, EL2} && EL2Enabled() then if ELIsInHost(EL2) then // Check SME at EL2 case CPTR_EL2().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = EffectivelyAtEL0InHost(); when '11' => disabled = FALSE; end; if disabled then SMEAccessTrap(SMEExceptionType_AccessTrap, EL2); end; else if CPTR_EL2().TSM == '1' then SMEAccessTrap(SMEExceptionType_AccessTrap, EL2); end; end;end;// Check if access disabled in CPTR_EL3if HaveEL(EL3) then if CPTR_EL3().ESM == '0' then if EL3SDDUndef() then Undefined(); end; SMEAccessTrap(SMEExceptionType_AccessTrap, EL3); end;end;
end;
Library pseudocode for aarch64/functions/sve/CheckSMEAndZAEnabled
// CheckSMEAndZAEnabled // ======================func CheckSMEAndZAEnabled begin CheckSMEEnabled();
if PSTATE.ZA == '0' then SMEAccessTrap(SMEExceptionType_InactiveZA, PSTATE.EL);end;
end;
Library pseudocode for aarch64/functions/sve/CheckSMEEnabled
// CheckSMEEnabled // =================func CheckSMEEnabled begin var disabled : boolean;
if HaveEL(EL3) && CPTR_EL3().[ESM,TFP] != '10' && EL3SDDUndefPriority() then Undefined();end;// Check if access disabled in CPACR_EL1if PSTATE.EL IN {EL0, EL1} && () then // Check SME at EL0/EL1 case CPACR_EL1().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0; when '11' => disabled = FALSE; end; if disabled then SMEAccessTrap(SMEExceptionType_AccessTrap, EL1); end; // Check SIMD&FP at EL0/EL1 case CPACR_EL1().FPEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0; when '11' => disabled = FALSE; end; if disabled then AArch64_AdvSIMDFPAccessTrap(EL1); end;end;if PSTATE.EL IN {EL0, EL1, EL2} && EL2Enabled() then if ELIsInHost(EL2) then // Check SME at EL2 case CPTR_EL2().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0 && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then SMEAccessTrap(SMEExceptionType_AccessTrap, EL2); end; // Check SIMD&FP at EL2 case CPTR_EL2().FPEN of when 'x0' => disabled = TRUE; when '01' => disabled = PSTATE.EL == EL0 && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then AArch64_AdvSIMDFPAccessTrap(EL2); end; else if CPTR_EL2().TSM == '1' then SMEAccessTrap(SMEExceptionType_AccessTrap, EL2); end; if CPTR_EL2().TFP == '1' then AArch64_AdvSIMDFPAccessTrap(EL2); end; end;end;// Check if access disabled in CPTR_EL3if HaveEL(EL3) then if CPTR_EL3().ESM == '0' then if EL3SDDUndef() then Undefined(); end; SMEAccessTrap(SMEExceptionType_AccessTrap, EL3); end; if CPTR_EL3().TFP == '1' then if EL3SDDUndef() then Undefined(); end; AArch64_AdvSIMDFPAccessTrap(EL3); end;end;
end;
Library pseudocode for aarch64/functions/sve/CheckSMEZT0Enabled
// CheckSMEZT0Enabled // ==================== // Checks for ZT0 enabled.func CheckSMEZT0Enabled begin if HaveEL(EL3) && SMCR_EL3().EZT0 == '0' && EL3SDDUndefPriority() then Undefined(); end;
// Check if ZA and ZT0 are inactive in PSTATEif PSTATE.ZA == '0' then SMEAccessTrap(SMEExceptionType_InactiveZA, PSTATE.EL);end;// Check if EL0/EL1 accesses to ZT0 are disabled in SMCR_EL1if PSTATE.EL IN {EL0, EL1} && () then if SMCR_EL1().EZT0 == '0' then SMEAccessTrap(SMEExceptionType_InaccessibleZT0, EL1); end;end;// Check if EL0/EL1/EL2 accesses to ZT0 are disabled in SMCR_EL2if PSTATE.EL IN {EL0, EL1, EL2} && EL2Enabled() then if SMCR_EL2().EZT0 == '0' then SMEAccessTrap(SMEExceptionType_InaccessibleZT0, EL2); end;end;// Check if all accesses to ZT0 are disabled in SMCR_EL3if HaveEL(EL3) then if SMCR_EL3().EZT0 == '0' then if EL3SDDUndef() then Undefined(); end; SMEAccessTrap(SMEExceptionType_InaccessibleZT0, EL3); end;end;
end;
Library pseudocode for aarch64/functions/sve/CheckSVEEnabled
// CheckSVEEnabled // ================= // Checks for traps on SVE instructions and instructions that // access SVE System registers.
func CheckSVEEnabled begin if IsFeatureImplemented(FEAT_SME) && PSTATE.SM == '1' then CheckSMEEnabled(); elsif IsFeatureImplemented(FEAT_SME) && !IsFeatureImplemented(FEAT_SVE) then CheckStreamingSVEEnabled(); else CheckOriginalSVEEnabled(); end; end;
Library pseudocode for aarch64/functions/sve/CheckStreamingSVEAndZAEnabled
// CheckStreamingSVEAndZAEnabled // ===============================func CheckStreamingSVEAndZAEnabled begin CheckStreamingSVEEnabled();
if PSTATE.ZA == '0' then SMEAccessTrap(SMEExceptionType_InactiveZA, PSTATE.EL);end;
end;
Library pseudocode for aarch64/functions/sve/CheckStreamingSVEEnabled
// CheckStreamingSVEEnabled // ==========================func CheckStreamingSVEEnabled begin CheckSMEEnabled();
if PSTATE.SM == '0' then SMEAccessTrap(SMEExceptionType_NotStreaming, PSTATE.EL);end;
end;
Library pseudocode for aarch64/functions/sve/CmpOp
// CmpOp // =====
type CmpOp of enumeration { Cmp_EQ, Cmp_NE, Cmp_GE, Cmp_GT, Cmp_LT, Cmp_LE, Cmp_UN };
Library pseudocode for aarch64/functions/sve/CurrentNSVL
// CurrentNSVL // =========== // Non-Streaming VLreadonly func CurrentNSVL() => VecLen begin var vl : integer;
if PSTATE.EL == EL1 || (PSTATE.EL == EL0 && ()) then vl = UInt(ZCR_EL1().LEN);end;if PSTATE.EL == EL2 || (PSTATE.EL == EL0 && IsInHost()) then vl = UInt(ZCR_EL2().LEN);elsif PSTATE.EL IN {EL0, EL1} && EL2Enabled() then vl = Min(vl, UInt(ZCR_EL2().LEN));end;if PSTATE.EL == EL3 then vl = UInt(ZCR_EL3().LEN);elsif HaveEL(EL3) then vl = Min(vl, UInt(ZCR_EL3().LEN));end;return ImplementedSVEVectorLength((vl + 1) * 128);
end;
Library pseudocode for aarch64/functions/sve/CurrentSVL
// CurrentSVL // ========== // Streaming SVLreadonly func CurrentSVL() => VecLen begin var vl : integer;
if PSTATE.EL == EL1 || (PSTATE.EL == EL0 && ()) then vl = UInt(SMCR_EL1().LEN);end;if PSTATE.EL == EL2 || (PSTATE.EL == EL0 && IsInHost()) then vl = UInt(SMCR_EL2().LEN);elsif PSTATE.EL IN {EL0, EL1} && EL2Enabled() then vl = Min(vl, UInt(SMCR_EL2().LEN));end;if PSTATE.EL == EL3 then vl = UInt(SMCR_EL3().LEN);elsif HaveEL(EL3) then vl = Min(vl, UInt(SMCR_EL3().LEN));end;return ImplementedSMEVectorLength((vl + 1) * 128);
end;
Library pseudocode for aarch64/functions/sve/CurrentVL
// CurrentVL // =========
readonly func CurrentVL() => VecLen begin return (if IsFeatureImplemented(FEAT_SME) && PSTATE.SM == '1' then CurrentSVL else CurrentNSVL()); end;
Library pseudocode for aarch64/functions/sve/DecodePredCount
// DecodePredCount // =================
func DecodePredCount(bitpattern : bits(5), esize : integer) => integer begin let elements : integer = CurrentVL() DIV esize; var numElem : integer; case bitpattern of when '00000' => numElem = FloorPow2(elements); when '00001' => numElem = if elements >= 1 then 1 else 0; when '00010' => numElem = if elements >= 2 then 2 else 0; when '00011' => numElem = if elements >= 3 then 3 else 0; when '00100' => numElem = if elements >= 4 then 4 else 0; when '00101' => numElem = if elements >= 5 then 5 else 0; when '00110' => numElem = if elements >= 6 then 6 else 0; when '00111' => numElem = if elements >= 7 then 7 else 0; when '01000' => numElem = if elements >= 8 then 8 else 0; when '01001' => numElem = if elements >= 16 then 16 else 0; when '01010' => numElem = if elements >= 32 then 32 else 0; when '01011' => numElem = if elements >= 64 then 64 else 0; when '01100' => numElem = if elements >= 128 then 128 else 0; when '01101' => numElem = if elements >= 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; end; return numElem; end;
Library pseudocode for aarch64/functions/sve/ElemFFR
// ElemFFR - accessor // ==================
accessor ElemFFR(e : integer, esize : ESize) <=> value : bit begin getter return PredicateElement{MAX_PL}(_FFR, e, esize); end; setter let psize : integer{} = esize DIV 8; _FFR[e*:psize] = ZeroExtend{psize}(value); end; end;
Library pseudocode for aarch64/functions/sve/FFR
// FFR - accessor // ==============accessor FFR{width}() <=> value : bits(width) begin getter assert width == CurrentVL() DIV 8; return _FFR[width-1:0]; end;
setter assert width == CurrentVL() DIV 8; if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then _FFR = ZeroExtend{MAX_PL}(value); else _FFR[width-1:0] = value; end;end;
end;
Library pseudocode for aarch64/functions/sve/FPCompareNE
// FPCompareNE // =============func FPCompareNE{N}(op1 : bits(N), op2 : bits(N), fpcr : FPCR_Type) => boolean begin assert N IN {16,32,64}; var result : boolean; let (type1,sign1,value1) : (FPType, bit, real) = FPUnpack{N}(op1, fpcr); let (type2,sign2,value2) : (FPType, bit, real) = FPUnpack{N}(op2, fpcr); let op1_nan : boolean = type1 IN {FPType_SNaN, FPType_QNaN}; let op2_nan : boolean = type2 IN {FPType_SNaN, FPType_QNaN};
if op1_nan || op2_nan then result = TRUE; if type1 == FPType_SNaN || type2 == FPType_SNaN then FPProcessException(FPExc_InvalidOp, fpcr); end;else // All non-NaN cases can be evaluated on the values produced by FPUnpack result = (value1 != value2); FPProcessDenorms(type1, type2, N, fpcr);end;return result;
end;
Library pseudocode for aarch64/functions/sve/FPCompareUN
// FPCompareUN // =============func FPCompareUN{N}(op1 : bits(N), op2 : bits(N), fpcr : FPCR_Type) => boolean begin assert N IN {16,32,64}; let (type1,sign1,value1) : (FPType, bit, real) = FPUnpack{N}(op1, fpcr); let (type2,sign2,value2) : (FPType, bit, real) = FPUnpack{N}(op2, fpcr);
if type1 == FPType_SNaN || type2 == FPType_SNaN then FPProcessException(FPExc_InvalidOp, fpcr);end;let result : boolean = (type1 IN {FPType_SNaN, FPType_QNaN} || type2 IN {FPType_SNaN, FPType_QNaN});if !result then FPProcessDenorms(type1, type2, N, fpcr);end;return result;
end;
Library pseudocode for aarch64/functions/sve/FPConvertSVE
// FPConvertSVE // ==============func FPConvertSVE{M, N}(op : bits(N), fpcr_in : FPCR_Type, rounding : FPRounding) => bits(M) begin var fpcr : FPCR_Type = fpcr_in; fpcr.AHP = '0'; return FPConvert{M, N}(op, fpcr, rounding); end;
// FPConvertSVE // ==============
func FPConvertSVE{M, N}(op : bits(N), fpcr_in : FPCR_Type) => bits(M) begin var fpcr : FPCR_Type = fpcr_in; fpcr.AHP = '0'; return FPConvert{M, N}(op, fpcr, FPRoundingMode(fpcr)); end;
Library pseudocode for aarch64/functions/sve/FPExpA
// FPExpA // ========func FPExpA{N}(op : bits(N)) => bits(N) begin assert N IN {16,32,64}; var result : bits(N); var coeff : bits(N); let idx : integer = if N == 16 then UInt(op[4:0]) else UInt(op[5:0]); coeff = FPExpCoefficient{N}(idx); if N == 16 then result[15:0] = '0'::op[9:5]::coeff[9:0]; elsif N == 32 then result[31:0] = '0'::op[13:6]::coeff[22:0]; else // N == 64 result[63:0] = '0'::op[16:6]::coeff[51:0]; end;
return result;
end;
Library pseudocode for aarch64/functions/sve/FPExpCoefficient
// FPExpCoefficient // ==================func FPExpCoefficient{N}(index : integer) => bits(N) begin assert N IN {16,32,64}; var result : integer;
if N == 16 then case index of when 0 => result = 0x000; when 1 => result = 0x016; when 2 => result = 0x02d; when 3 => result = 0x045; when 4 => result = 0x05d; when 5 => result = 0x075; when 6 => result = 0x08e; when 7 => result = 0x0a8; when 8 => result = 0x0c2; when 9 => result = 0x0dc; when 10 => result = 0x0f8; when 11 => result = 0x114; when 12 => result = 0x130; when 13 => result = 0x14d; when 14 => result = 0x16b; when 15 => result = 0x189; when 16 => result = 0x1a8; when 17 => result = 0x1c8; when 18 => result = 0x1e8; when 19 => result = 0x209; when 20 => result = 0x22b; when 21 => result = 0x24e; when 22 => result = 0x271; when 23 => result = 0x295; when 24 => result = 0x2ba; when 25 => result = 0x2e0; when 26 => result = 0x306; when 27 => result = 0x32e; when 28 => result = 0x356; when 29 => result = 0x37f; when 30 => result = 0x3a9; when 31 => result = 0x3d4; end;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; end;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; end;end;return result[N-1:0];
end;
Library pseudocode for aarch64/functions/sve/FPLogB
// FPLogB // ========func FPLogB{N}(op : bits(N), fpcr : FPCR_Type) => bits(N) begin assert N IN {16,32,64}; var result : integer; var (fptype,sign,value) : (FPType, bit, real) = FPUnpack{N}(op, fpcr);
if fptype == FPType_SNaN || fptype == FPType_QNaN || fptype == FPType_Zero then FPProcessException(FPExc_InvalidOp, fpcr); result = -(2^(N-1)); // MinInt, 100..00elsif fptype == FPType_Infinity then result = 2^(N-1) - 1; // MaxInt, 011..11else // FPUnpack has already scaled a subnormal input value = Abs(value); (value, result) = NormalizeReal(value); FPProcessDenorm(fptype, N, fpcr);end;return result[N-1:0];
end;
Library pseudocode for aarch64/functions/sve/FPOne
// FPOne // =======
func FPOne{N}(sign : bit) => bits(N) begin assert N IN {16,32,64}; let E : integer{} = (if N == 16 then 5 else (if N == 32 then 8 else 11)); let F : integer{} = N - (E + 1); let exp : bits(E) = '0'::Ones{E-1}; let frac : bits(F) = Zeros{}; return sign :: exp :: frac; end;
Library pseudocode for aarch64/functions/sve/FPPointFive
// FPPointFive // =============
func FPPointFive{N}(sign : bit) => bits(N) begin assert N IN {16,32,64}; let E : integer{} = (if N == 16 then 5 else (if N == 32 then 8 else 11)); let F : integer{} = N - (E + 1); let exp : bits(E) = '0'::Ones{E-2}::'0'; let frac : bits(F) = Zeros{}; return sign :: exp :: frac; end;
Library pseudocode for aarch64/functions/sve/FPReducePredicated
// FPReducePredicated // ==================== func FPReducePredicated{esize, N, M}(op : ReduceOp, input : bits(N), mask : bits(M), identity : bits(esize), fpcr : FPCR_Type) => bits(esize) begin assert(N == M * 8); assert IsPow2(N); var operand : bits(N); let elements : integer = N DIV esize;for e = 0 to elements-1 do if e * esize < N && ActivePredicateElement{M}(mask, e, esize) then operand[e*:esize] = input[e*:esize]; else operand[e*:esize] = identity; end;end;return FPReduce{esize, N}(op, operand, fpcr);
end;
Library pseudocode for aarch64/functions/sve/FPTrigMAdd
// FPTrigMAdd // ============func FPTrigMAdd{N}(x_in : integer, op1 : bits(N), op2_in : bits(N), fpcr : FPCR_Type) => bits(N) begin assert N IN {16,32,64}; var coeff : bits(N); var op2 : bits(N) = op2_in; var x : integer = x_in; assert x >= 0; assert x < 8;
if op2[N-1] == '1' then x = x + 8;end;coeff = FPTrigMAddCoefficient{N}(x);// Safer to use EffectiveFPCR() in case the input fpcr argument// is modified as opposed to actual value of FPCRop2 = FPAbs{N}(op2, EffectiveFPCR());let result : bits(N) = FPMulAdd{}(coeff, op1, op2, fpcr);return result;
end;
Library pseudocode for aarch64/functions/sve/FPTrigMAddCoefficient
// FPTrigMAddCoefficient // =======================func FPTrigMAddCoefficient{N}(index : integer) => bits(N) begin assert N IN {16,32,64}; var result : integer;
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; end;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; end;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; end;end;return result[N-1:0];
end;
Library pseudocode for aarch64/functions/sve/FPTrigSMul
// FPTrigSMul // ============func FPTrigSMul{N}(op1 : bits(N), op2 : bits(N), fpcr : FPCR_Type) => bits(N) begin assert N IN {16,32,64}; var result : bits(N) = FPMul{}(op1, op1, fpcr); let fpexc = FALSE; let (fptype, sign, value) : (FPType, bit, real) = FPUnpack{N}(result, fpcr, fpexc);
if ! fptype IN {FPType_QNaN, FPType_SNaN} then result[N-1] = op2[0];end;return result;
end;
Library pseudocode for aarch64/functions/sve/FPTrigSSel
// FPTrigSSel // ============func FPTrigSSel{N}(op1 : bits(N), op2 : bits(N)) => bits(N) begin assert N IN {16,32,64}; var result : bits(N);
if op2[0] == '1' then result = FPOne{N}(op2[1]);elsif op2[1] == '1' then result = FPNeg{N}(op1, EffectiveFPCR());else result = op1;end;return result;
end;
Library pseudocode for aarch64/functions/sve/FirstActive
// FirstActive // =============
func FirstActive{N}(mask : bits(N), x : bits(N), esize : integer) => bit begin let elements : integer = N DIV (esize DIV 8); for e = 0 to elements-1 do if ActivePredicateElement{N}(mask, e, esize) then return PredicateElement{N}(x, e, esize); end; end; return '0'; end;
Library pseudocode for aarch64/functions/sve/HaveSVE2FP8DOT2
// HaveSVE2FP8DOT2 // ================= // Returns TRUE if SVE2 FP8 dot product to half-precision instructions // are implemented, FALSE otherwise.
func HaveSVE2FP8DOT2() => boolean begin return ((IsFeatureImplemented(FEAT_SVE2) && IsFeatureImplemented(FEAT_FP8DOT2)) || IsFeatureImplemented(FEAT_SSVE_FP8DOT2)); end;
Library pseudocode for aarch64/functions/sve/HaveSVE2FP8DOT4
// HaveSVE2FP8DOT4 // ================= // Returns TRUE if SVE2 FP8 dot product to single-precision instructions // are implemented, FALSE otherwise.
func HaveSVE2FP8DOT4() => boolean begin return ((IsFeatureImplemented(FEAT_SVE2) && IsFeatureImplemented(FEAT_FP8DOT4)) || IsFeatureImplemented(FEAT_SSVE_FP8DOT4)); end;
Library pseudocode for aarch64/functions/sve/HaveSVE2FP8FMA
// HaveSVE2FP8FMA // ================ // Returns TRUE if SVE2 FP8 multiply-accumulate to half-precision and single-precision // instructions are implemented, FALSE otherwise.
func HaveSVE2FP8FMA() => boolean begin return ((IsFeatureImplemented(FEAT_SVE2) && IsFeatureImplemented(FEAT_FP8FMA)) || IsFeatureImplemented(FEAT_SSVE_FP8FMA)); end;
Library pseudocode for aarch64/functions/sve/ImplementedSMEVectorLength
// ImplementedSMEVectorLength // ============================ // Reduce SVE/SME vector length to a supported value (power of two)readonly func ImplementedSMEVectorLength(nbits_in : integer) => VecLen begin let maxbits : VecLen = MaxImplementedSVL(); assert 128 <= maxbits && maxbits <= 2048 && IsPow2(maxbits); var nbits : integer = Min(nbits_in, maxbits); assert 128 <= nbits && nbits <= 2048 && AlignDownSize(nbits, 128) == nbits;
// Search for a supported power-of-two VL less than or equal to nbitswhile nbits > 128 && !SupportedPowerTwoSVL(nbits) looplimit 7 do nbits = nbits - 128;end;// Return the smallest supported power-of-two VLwhile nbits < maxbits && !SupportedPowerTwoSVL(nbits) looplimit 7 do nbits = nbits * 2;end;return nbits as VecLen;
end;
Library pseudocode for aarch64/functions/sve/ImplementedSVEVectorLength
// ImplementedSVEVectorLength // ============================ // Reduce SVE vector length to a supported value (power of two)readonly func ImplementedSVEVectorLength(nbits_in : integer) => VecLen begin let maxbits : integer = MaxImplementedVL(); assert 128 <= maxbits && maxbits <= 2048 && IsPow2(maxbits); var nbits : integer = Min(nbits_in, maxbits); assert 128 <= nbits && nbits <= 2048 && AlignDownSize(nbits, 128) == nbits;
while !IsPow2(nbits) looplimit 7 do nbits = nbits - 128;end;return nbits as VecLen;
end;
Library pseudocode for aarch64/functions/sve/InStreamingMode
// InStreamingMode // =================
func InStreamingMode() => boolean begin return IsFeatureImplemented(FEAT_SME) && PSTATE.SM == '1'; end;
Library pseudocode for aarch64/functions/sve/IsFPEnabled
// 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.
func IsFPEnabled(el : bits(2)) => boolean begin if ELUsingAArch32(el) then return AArch32_IsFPEnabled(el); else return AArch64_IsFPEnabled(el); end; end;
Library pseudocode for aarch64/functions/sve/IsFullA64Enabled
// IsFullA64Enabled // ================== // Returns TRUE if full A64 is enabled in Streaming mode and FALSE otherwise.func IsFullA64Enabled() => boolean begin if !IsFeatureImplemented(FEAT_SME_FA64) then return FALSE; end;
// Check if full A64 disabled in SMCR_EL1if PSTATE.EL IN {EL0, EL1} && () then // Check full A64 at EL0/EL1 if SMCR_EL1().FA64 == '0' then return FALSE; end;end;// Check if full A64 disabled in SMCR_EL2if PSTATE.EL IN {EL0, EL1, EL2} && EL2Enabled() then if SMCR_EL2().FA64 == '0' then return FALSE; end;end;// Check if full A64 disabled in SMCR_EL3if HaveEL(EL3) then if SMCR_EL3().FA64 == '0' then return FALSE; end;end;return TRUE;
end;
Library pseudocode for aarch64/functions/sve/IsOriginalSVEEnabled
// IsOriginalSVEEnabled // ====================== // Returns TRUE if access to SVE functionality is enabled at the target // exception level and FALSE otherwise.func IsOriginalSVEEnabled(el : bits(2)) => boolean begin var disabled : boolean; if ELUsingAArch32(el) then return FALSE; end;
// Check if access disabled in CPACR_EL1if el IN {EL0, EL1} && () then // Check SVE at EL0/EL1 case CPACR_EL1().ZEN of when 'x0' => disabled = TRUE; when '01' => disabled = el == EL0; when '11' => disabled = FALSE; end; if disabled then return FALSE; end;end;// Check if access disabled in CPTR_EL2if el IN {EL0, EL1, EL2} && EL2Enabled() then if ELIsInHost(EL2) then case CPTR_EL2().ZEN of when 'x0' => disabled = TRUE; when '01' => disabled = el == EL0 && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then return FALSE; end; else if CPTR_EL2().TZ == '1' then return FALSE; end; end;end;// Check if access disabled in CPTR_EL3if HaveEL(EL3) then if CPTR_EL3().EZ == '0' then return FALSE; end;end;return TRUE;
end;
Library pseudocode for aarch64/functions/sve/IsSMEEnabled
// IsSMEEnabled // ============== // Returns TRUE if access to SME functionality is enabled at the target // exception level and FALSE otherwise.func IsSMEEnabled(el : bits(2)) => boolean begin var disabled : boolean; if ELUsingAArch32(el) then return FALSE; end;
// Check if access disabled in CPACR_EL1if el IN {EL0, EL1} && () then // Check SME at EL0/EL1 case CPACR_EL1().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = el == EL0; when '11' => disabled = FALSE; end; if disabled then return FALSE; end;end;// Check if access disabled in CPTR_EL2if el IN {EL0, EL1, EL2} && EL2Enabled() then if ELIsInHost(EL2) then case CPTR_EL2().SMEN of when 'x0' => disabled = TRUE; when '01' => disabled = el == EL0 && HCR_EL2().TGE == '1'; when '11' => disabled = FALSE; end; if disabled then return FALSE; end; else if CPTR_EL2().TSM == '1' then return FALSE; end; end;end;// Check if access disabled in CPTR_EL3if HaveEL(EL3) then if CPTR_EL3().ESM == '0' then return FALSE; end;end;return TRUE;
end;
Library pseudocode for aarch64/functions/sve/IsSVEEnabled
// IsSVEEnabled // ============== // Returns TRUE if access to SVE registers is enabled at the target exception // level and FALSE otherwise.
func IsSVEEnabled(el : bits(2)) => boolean begin if IsFeatureImplemented(FEAT_SME) && PSTATE.SM == '1' then return IsSMEEnabled(el); elsif IsFeatureImplemented(FEAT_SVE) then return IsOriginalSVEEnabled(el); else return FALSE; end; end;
Library pseudocode for aarch64/functions/sve/LastActive
// LastActive // ============
func LastActive{N}(mask : bits(N), x : bits(N), esize : integer) => bit begin let elements : integer = N DIV (esize DIV 8); for e = elements-1 downto 0 do if ActivePredicateElement{N}(mask, e, esize) then return PredicateElement{N}(x, e, esize); end; end; return '0'; end;
Library pseudocode for aarch64/functions/sve/LastActiveElement
// LastActiveElement // ===================
func LastActiveElement{N}(mask : bits(N), esize : integer) => integer begin let elements : integer = N DIV (esize DIV 8); for e = elements-1 downto 0 do if ActivePredicateElement{N}(mask, e, esize) then return e; end; end; return -1; end;
Library pseudocode for aarch64/functions/sve/MaxImplementedAnyVL
// MaxImplementedAnyVL // =====================
readonly func MaxImplementedAnyVL() => integer begin if IsFeatureImplemented(FEAT_SME) && IsFeatureImplemented(FEAT_SVE) then return Max(MaxImplementedVL(), MaxImplementedSVL()); end; if IsFeatureImplemented(FEAT_SME) then return MaxImplementedSVL(); end; return MaxImplementedVL(); end;
Library pseudocode for aarch64/functions/sve/MaxImplementedSVL
// MaxImplementedSVL // ===================
readonly func MaxImplementedSVL() => VecLen begin return ImpDefInt("Max implemented SVL") as VecLen; end;
Library pseudocode for aarch64/functions/sve/MaxImplementedVL
// MaxImplementedVL // ==================readonly func MaxImplementedVL() => integer begin let max_vl : integer = ImpDefInt("Max implemented VL"); if IsFeatureImplemented(FEAT_SME_FA64) then let max_svl : integer = ImpDefInt("Max implemented SVL"); return Max(max_vl, max_svl); end;
return max_vl;
end;
Library pseudocode for aarch64/functions/sve/MaybeZeroSVEUppers
// MaybeZeroSVEUppers // ====================func MaybeZeroSVEUppers(target_el : bits(2)) begin var lower_enabled : boolean;
if UInt(target_el) <= UInt(PSTATE.EL) || (target_el) then return;end;if target_el == EL3 then if EL2Enabled() then lower_enabled = IsFPEnabled(EL2); else lower_enabled = IsFPEnabled(EL1); end;elsif target_el == EL2 then assert EL2Enabled() && (EL2); if HCR_EL2().TGE == '0' then lower_enabled = IsFPEnabled(EL1); else lower_enabled = IsFPEnabled(EL0); end;else assert target_el == EL1 && (EL1); lower_enabled = IsFPEnabled(EL0);end;if lower_enabled then let VL : integer{} = if IsSVEEnabled(PSTATE.EL) then CurrentVL() else 128; let PL : integer{} = VL DIV 8; for n = 0 to 31 do if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then _Z[[n]] = ZeroExtend{MAX_VL}(_Z[[n]][VL-1:0]); end; end; for n = 0 to 15 do if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then _P[[n]] = ZeroExtend{MAX_PL}(_P[[n]][PL-1:0]); end; end; if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then _FFR = ZeroExtend{MAX_PL}(_FFR[PL-1:0]); end; if IsFeatureImplemented(FEAT_SME) && PSTATE.ZA == '1' then let SVL : integer{} = CurrentSVL(); let accessiblevecs : integer = SVL DIV 8; let allvecs : integer = MaxImplementedSVL() DIV 8; for n = 0 to accessiblevecs - 1 do if ConstrainUnpredictableBool(Unpredictable_SMEZEROUPPER) then _ZA[[n]] = ZeroExtend{MAX_VL}(_ZA[[n]][SVL-1:0]); end; end; for n = accessiblevecs to allvecs - 1 do if ConstrainUnpredictableBool(Unpredictable_SMEZEROUPPER) then _ZA[[n]] = Zeros{MAX_VL}; end; end; end;end;
end;
Library pseudocode for aarch64/functions/sve/MemNF
// MemNF // =====func MemNF{size : integer{8, 16, 32, 64, 128}}(address : bits(64), accdesc : AccessDescriptor ) => (bits(size), boolean) begin let bytes : integer{} = size DIV 8; var value : bits(size); var bad : boolean;
var aligned : boolean = IsAlignedSize{64}(address, bytes);if !aligned && AArch64_UnalignedAccessFaults(accdesc, address, bytes) then return (ARBITRARY : bits(size), TRUE);end;let atomic : boolean = (aligned || (IsFeatureImplemented(FEAT_LSE2) && AllInSCAGranule(address, bytes)));if !atomic then (value[7:0], bad) = MemSingleNF{8}(address, accdesc, aligned); if bad then return (ARBITRARY : bits(size), TRUE); end; // For subsequent bytes, if they cross to a new translation page which assigns // Device memory type, it is CONSTRAINED UNPREDICTABLE whether an unaligned access // will generate an Alignment Fault. if !aligned then let c : Constraint = ConstrainUnpredictable(Unpredictable_DEVPAGE2); assert c IN {Constraint_FAULT, Constraint_NONE}; if c == Constraint_NONE then aligned = TRUE; end; end; for i = 1 to bytes-1 do (value[i*:8], bad) = MemSingleNF{8}(address+i, accdesc, aligned); if bad then return (ARBITRARY : bits(size), TRUE); end; end;else (value, bad) = MemSingleNF{size}(address, accdesc, aligned); if bad then return (ARBITRARY : bits(size), TRUE); end;end;if BigEndian(accdesc.acctype) then value = BigEndianReverse{size}(value);end;return (value, FALSE);
end;
Library pseudocode for aarch64/functions/sve/MemSingleNF
// MemSingleNF // ===========func MemSingleNF{size : integer{8, 16, 32, 64, 128}}(address : bits(64), accdesc_in : AccessDescriptor, aligned : boolean) => (bits(size), boolean) begin assert accdesc_in.acctype == AccessType_SVE; assert accdesc_in.nonfault || (accdesc_in.firstfault && !accdesc_in.first);
let bytes : integer{} = size DIV 8;var value : bits(size);var memaddrdesc : AddressDescriptor;var memstatus : PhysMemRetStatus;var accdesc : AccessDescriptor = accdesc_in;var fault : FaultRecord = NoFault(accdesc, address);// Implementation may suppress NF load for any reasonif ConstrainUnpredictableBool(Unpredictable_NONFAULT) then return (ARBITRARY : bits(size), TRUE);end;// If the instruction encoding permits tag checking, confer with system register configuration// which may override this.if accdesc.tagchecked then accdesc.tagchecked = AArch64_AccessIsTagChecked(address, accdesc);end;// MMU or MPUmemaddrdesc = AArch64_TranslateAddress(address, accdesc, aligned, bytes);// Non-fault and first-fault loads from non-Conventional Device memory must not be performed// externally. For Conventional memory, it is IMPLEMENTATION DEFINED.if memaddrdesc.memattrs.memtype == MemType_Device then if ((memaddrdesc) || ImpDefBool("SVE NF/FF load from Device Conventional memory is suppressed")) then return (ARBITRARY : bits(size), TRUE); end;end;// Check for aborts or debug exceptionsif IsFault(memaddrdesc) then return (ARBITRARY : bits(size), TRUE);end;if accdesc.tagchecked then let ltag : bits(4) = AArch64_LogicalAddressTag(address); let readcheck : boolean = TRUE; fault = AArch64_CheckTag(memaddrdesc, accdesc, readcheck, bytes, ltag); if fault.statuscode != Fault_None then return (ARBITRARY : bits(size), TRUE); end;end;(memstatus, value) = PhysMemRead{size}(memaddrdesc, accdesc);if IsFault(memstatus) then let iswrite : boolean = FALSE; if IsExternalAbortTakenSynchronously(memstatus, iswrite, memaddrdesc, bytes, accdesc) then return (ARBITRARY : bits(size), TRUE); end; fault.merrorstate = memstatus.merrorstate; fault.extflag = memstatus.extflag; fault.statuscode = memstatus.statuscode; PendSErrorInterrupt(fault);end;return (value, FALSE);
end;
Library pseudocode for aarch64/functions/sve/NoneActive
// NoneActive // ============
func NoneActive{N}(mask : bits(N), x : bits(N), esize : integer) => bit begin let elements : integer = N DIV (esize DIV 8); for e = 0 to elements-1 do if ActivePredicateElement{N}(mask, e, esize) && ActivePredicateElement{N}(x, e, esize) then return '0'; end; end; return '1'; end;
Library pseudocode for aarch64/functions/sve/P
// P - accessor // ============accessor P{width}(n : integer) <=> value : bits(width) begin getter assert n >= 0 && n <= 31; assert width == CurrentVL() DIV 8; return _P[[n]][width-1:0]; end;
setter assert n >= 0 && n <= 31; assert width == CurrentVL() DIV 8; if ConstrainUnpredictableBool(Unpredictable_SVEZEROUPPER) then _P[[n]] = ZeroExtend{MAX_PL}(value); else _P[[n]][width-1:0] = value; end;end;
end;
Library pseudocode for aarch64/functions/sve/PredLen
// PredLen // =======
type PredLen of integer{16, 32, 64, 128, 256};
Library pseudocode for aarch64/functions/sve/PredTest
// PredTest // ==========
func PredTest{N}(mask : bits(N), result : bits(N), esize : integer) => bits(4) begin let n : bit = FirstActive{N}(mask, result, esize); let z : bit = NoneActive{N}(mask, result, esize); let c : bit = NOT LastActive{N}(mask, result, esize); let v : bit = '0'; return n::z::c::v; end;
Library pseudocode for aarch64/functions/sve/PredicateElement
// PredicateElement // ================== // Returns the predicate bit
func PredicateElement{N}(pred : bits(N), e : integer, esize : integer) => bit begin assert esize IN {8, 16, 32, 64, 128}; let n : integer = e * (esize DIV 8); assert n >= 0 && n < N; return pred[n]; end;
Library pseudocode for aarch64/functions/sve/ResetSMEState
// ResetSMEState // ===============
func ResetSMEState(newenable : bit) begin let vectors : integer = MAX_VL DIV 8; if newenable == '1' then for n = 0 to vectors - 1 do _ZA[[n]] = Zeros{MAX_VL}; end; if IsFeatureImplemented(FEAT_SME2) then _ZT0 = Zeros{ZT0_LEN}; end; else for n = 0 to vectors - 1 do _ZA[[n]] = ARBITRARY : bits(MAX_VL); end; if IsFeatureImplemented(FEAT_SME2) then _ZT0 = ARBITRARY : bits(ZT0_LEN); end; end; end;
Library pseudocode for aarch64/functions/sve/ResetSVERegisters
// ResetSVERegisters // ===================
func ResetSVERegisters begin for n = 0 to 31 do _Z[[n]] = ARBITRARY : bits(MAX_VL); end; for n = 0 to 15 do _P[[n]] = ARBITRARY : bits(MAX_PL); end; _FFR = ARBITRARY : bits(MAX_PL); end;
Library pseudocode for aarch64/functions/sve/ResetSVEState
// ResetSVEState // ===============
func ResetSVEState begin for n = 0 to 31 do _Z[[n]] = Zeros{MAX_VL}; end; for n = 0 to 15 do _P[[n]] = Zeros{MAX_PL}; end; _FFR = Zeros{MAX_PL}; FPSR() = ZeroExtend{64}(0x0800009f[31:0]); FPMR() = Zeros{64}; end;
Library pseudocode for aarch64/functions/sve/SMEAccessTrap
// SMEAccessTrap // =============== // Trapped access to SME registers due to CPACR_EL1, CPTR_EL2, or CPTR_EL3.func SMEAccessTrap(etype : SMEExceptionType, target_el_in : bits(2)) begin var target_el : bits(2) = target_el_in; assert UInt(target_el) >= UInt(PSTATE.EL); if target_el == EL0 then target_el = EL1; end; let route_to_el2 : boolean = (PSTATE.EL == EL0 && target_el == EL1 && EL2Enabled() && HCR_EL2().TGE == '1');
var except : ExceptionRecord = ExceptionSyndrome(Exception_SMEAccessTrap);let preferred_exception_return : bits(64) = ThisInstrAddr{}();let vect_offset : integer = 0x0;case etype of when SMEExceptionType_AccessTrap => except.syndrome.iss[2:0] = '000'; when SMEExceptionType_Streaming => except.syndrome.iss[2:0] = '001'; when SMEExceptionType_NotStreaming => except.syndrome.iss[2:0] = '010'; when SMEExceptionType_InactiveZA => except.syndrome.iss[2:0] = '011'; when SMEExceptionType_InaccessibleZT0 => except.syndrome.iss[2:0] = '100';end;if route_to_el2 then AArch64_TakeException(EL2, except, preferred_exception_return, vect_offset);else AArch64_TakeException(target_el, except, preferred_exception_return, vect_offset);end;
end;
Library pseudocode for aarch64/functions/sve/SMEExceptionType
// SMEExceptionType// ================type SMEExceptionType of enumeration { SMEExceptionType_AccessTrap, // SME functionality trapped or disabled SMEExceptionType_Streaming, // Illegal instruction in Streaming SVE mode SMEExceptionType_NotStreaming, // Illegal instruction not in Streaming SVE mode SMEExceptionType_InactiveZA, // Illegal instruction when ZA is inactive SMEExceptionType_InaccessibleZT0, // Access to ZT0 is disabled};
Library pseudocode for aarch64/functions/sve/SVCR
// SVCR // ====accessor SVCR() <=> value : SVCR_Type begin // Returns PSTATE.[ZA, SM] getter let value : SVCR_Type = Zeros{62} :: PSTATE.ZA :: PSTATE.SM; return value; end;
// Sets PSTATE.[ZA, SM]setter SetPSTATE_SM(value[0]); SetPSTATE_ZA(value[1]); return;end;
end;
Library pseudocode for aarch64/functions/sve/SVEAccessTrap
// SVEAccessTrap // =============== // Trapped access to SVE registers due to CPACR_EL1, CPTR_EL2, or CPTR_EL3.func SVEAccessTrap(target_el : bits(2)) begin assert UInt(target_el) >= UInt(PSTATE.EL) && target_el != EL0 && HaveEL(target_el); let route_to_el2 : boolean = target_el == EL1 && EL2Enabled() && HCR_EL2().TGE == '1';
let except : ExceptionRecord = ExceptionSyndrome(Exception_SVEAccessTrap);let preferred_exception_return : bits(64) = ThisInstrAddr{}();let vect_offset : integer{} = 0x0;if route_to_el2 then AArch64_TakeException(EL2, except, preferred_exception_return, vect_offset);else AArch64_TakeException(target_el, except, preferred_exception_return, vect_offset);end;
end;
Library pseudocode for aarch64/functions/sve/SVEMoveMaskPreferred
// 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<-DUPM alias.
func SVEMoveMaskPreferred(imm13 : bits(13)) => boolean
begin
var imm : bits(64);
(imm, -) = DecodeBitMasks{64}(imm13[12], imm13[5:0], imm13[11:6], TRUE);
// Check for 8 bit immediatesif !IsZero(imm[7:0]) then // Check for 'ffffffffffffffxy' or '00000000000000xy' if IsZero(imm[63:7]) || IsOnes(imm[63:7]) then return FALSE; end; // Check for 'ffffffxyffffffxy' or '000000xy000000xy' if imm[63:32] == imm[31:0] && (IsZero(imm[31:7]) || IsOnes(imm[31:7])) then return FALSE; end; // Check for 'ffxyffxyffxyffxy' or '00xy00xy00xy00xy' if (imm[63:32] == imm[31:0] && imm[31:16] == imm[15:0] && (IsZero(imm[15:7]) || IsOnes(imm[15:7]))) then return FALSE; end; // Check for 'xyxyxyxyxyxyxyxy' if imm[63:32] == imm[31:0] && imm[31:16] == imm[15:0] && (imm[15:8] == imm[7:0]) then return FALSE; end;// Check for 16 bit immediateselse // Check for 'ffffffffffffxy00' or '000000000000xy00' if IsZero(imm[63:15]) || IsOnes(imm[63:15]) then return FALSE; end; // Check for 'ffffxy00ffffxy00' or '0000xy000000xy00' if imm[63:32] == imm[31:0] && (IsZero(imm[31:15]) || IsOnes(imm[31:15])) then</code></pre>