configure: Fix detection of SME

Older versions of Clang (Xcode 14, llvm.org Clang 13 and 14)
do support and recognize SME, but when enabled through
".arch_extension sme" it fails to transitively enable support
for Streaming SVE; this was fixed in [1].

This issue results in those versions currently detecting support
for SME, but later failing to build cpu_sme.s with errors like
"error: instruction requires: sve or sme" or "error: instruction
requires: streaming-sve or sve", on the "cntb x0" instruction.

Extend the check for this instruction set extension, to test
with two instructions, both specifically a SME instruction
(smstart) and an instruction that is available in Streaming SVE
mode (cntb).

For the configure check, add an extra parameter to
check_archext_insn for an optional second instruction to check.

It would be tempting to just pass both instructions through
the same parameter, as "smstart; cntb x0". However, Darwin
targets use a different token (%%) for starting a new
instruction on the same line - those targets interpret ";"
as the start of a comment. Due to that, such a check would
entirely ignore the second instruction on Darwin targets.

To avoid dealing with the variability in passing multiple
instructions on one line, just pass the optional second
instruction on a separate line.

[1] ff3f3a54e2
This commit is contained in:
Martin Storsjö
2025-12-11 15:32:54 +02:00
parent 04df80f973
commit 6258e61c4d

6
configure vendored
View File

@@ -1207,8 +1207,9 @@ check_archext_insn(){
log check_archext_insn "$@"
feature="$1"
instr="$2"
instr2="$3"
# Check if the assembly is accepted in inline assembly.
check_inline_asm ${feature}_inline "\"$instr\""
check_inline_asm ${feature}_inline "\"$instr \n\t $instr2\""
# We don't check if the instruction is supported out of the box by the
# external assembler (we don't try to set ${feature}_external) as we don't
# need to use these instructions in non-runtime detected codepaths.
@@ -1230,6 +1231,7 @@ EOF
$arch_directive
$arch_extension_directive
$instr
$instr2
EOF
}
@@ -6454,7 +6456,7 @@ if enabled aarch64; then
enabled i8mm && check_archext_insn i8mm 'usdot v0.4s, v0.16b, v0.16b'
enabled sve && check_archext_insn sve 'whilelt p0.s, x0, x1'
enabled sve2 && check_archext_insn sve2 'sqrdmulh z0.s, z0.s, z0.s'
enabled sme && check_archext_insn sme 'smstop'
enabled sme && check_archext_insn sme 'smstart' 'cntb x0'
# Disable the main feature (e.g. HAVE_NEON) if neither inline nor external
# assembly support the feature out of the box. Skip this for the features