Bug 31561 - AArch64 gas test case "SME extension (ZERO)" fails on s390x
Summary: AArch64 gas test case "SME extension (ZERO)" fails on s390x
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.43 (HEAD)
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-26 16:39 UTC by Jens Remus
Modified: 2024-04-18 11:06 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Remus 2024-03-26 16:39:17 UTC
The AArch64 GNU Assembler test case "SME extension (ZERO)" fails in a GNU Binutils build for target "aarch64-linux-gnu" on s390x as follows:


Target is aarch64-unknown-linux-gnu
Host   is s390x-ibm-linux-gnu
...
../as-new  -march=armv8-a+sme  -o tmpdir/sme-4.o /home/jremus/binutils/gas/testsuite/gas/aarch64/sme-4.s
Executing on host: sh -c {../as-new  -march=armv8-a+sme  -o tmpdir/sme-4.o /home/jremus/binutils/gas/testsuite/gas/aarch64/sme-4.s 2>&1}  /dev/null dump.tmp (timeout = 300)
spawn [open ...]
/home/jremus/binutils/build-gcc-aarch64/gas/testsuite/../../binutils/objdump  -dr tmpdir/sme-4.o > tmpdir/dump.out
Executing on host: sh -c {/home/jremus/binutils/build-gcc-aarch64/gas/testsuite/../../binutils/objdump  -dr tmpdir/sme-4.o > tmpdir/dump.out 2>dump.tmp}  /dev/null  (timeout = 300)
spawn [open ...]
regexp_diff match failure
regexp "^   4:  c00800ff        zero    {za}$"
line   "   4:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^   8:  c00800ff        zero    {za}$"
line   "   8:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^   c:  c00800ff        zero    {za}$"
line   "   c:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^  10:  c00800ff        zero    {za}$"
line   "  10:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^  14:  c00800ff        zero    {za}$"
line   "  14:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^  18:  c0080001        zero    {za0\.d}$"
line   "  18:   c0080001        zero    {}"
regexp_diff match failure
regexp "^  1c:  c0080002        zero    {za1\.d}$"
line   "  1c:   c0080002        zero    {}"
regexp_diff match failure
regexp "^  20:  c0080004        zero    {za2\.d}$"
line   "  20:   c0080004        zero    {}"
regexp_diff match failure
regexp "^  24:  c0080008        zero    {za3\.d}$"
line   "  24:   c0080008        zero    {}"
regexp_diff match failure
regexp "^  28:  c0080010        zero    {za4\.d}$"
line   "  28:   c0080010        zero    {}"
regexp_diff match failure
regexp "^  2c:  c0080020        zero    {za5\.d}$"
line   "  2c:   c0080020        zero    {}"
regexp_diff match failure
regexp "^  30:  c0080040        zero    {za6\.d}$"
line   "  30:   c0080040        zero    {}"
regexp_diff match failure
regexp "^  34:  c0080080        zero    {za7\.d}$"
line   "  34:   c0080080        zero    {}"
regexp_diff match failure
regexp "^  38:  c0080001        zero    {za0\.d}$"
line   "  38:   c0080001        zero    {}"
regexp_diff match failure
regexp "^  3c:  c0080003        zero    {za0\.d, za1\.d}$"
line   "  3c:   c0080003        zero    {}"
regexp_diff match failure
regexp "^  40:  c0080007        zero    {za0\.d, za1\.d, za2\.d}$"
line   "  40:   c0080007        zero    {}"
regexp_diff match failure
regexp "^  44:  c008000f        zero    {za0\.d, za1\.d, za2\.d, za3\.d}$"
line   "  44:   c008000f        zero    {}"
regexp_diff match failure
regexp "^  48:  c008001f        zero    {za0\.s, za1\.d, za2\.d, za3\.d}$"
line   "  48:   c008001f        zero    {}"
regexp_diff match failure
regexp "^  4c:  c008003f        zero    {za0\.s, za1\.s, za2\.d, za3\.d}$"
line   "  4c:   c008003f        zero    {}"
regexp_diff match failure
regexp "^  50:  c008007f        zero    {za0\.h, za1\.s, za3\.d}$"
line   "  50:   c008007f        zero    {}"
regexp_diff match failure
regexp "^  54:  c00800ff        zero    {za}$"
line   "  54:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^  58:  c0080080        zero    {za7\.d}$"
line   "  58:   c0080080        zero    {}"
regexp_diff match failure
regexp "^  5c:  c00800c0        zero    {za6\.d, za7\.d}$"
line   "  5c:   c00800c0        zero    {}"
regexp_diff match failure
regexp "^  60:  c00800e0        zero    {za5\.d, za6\.d, za7\.d}$"
line   "  60:   c00800e0        zero    {}"
regexp_diff match failure
regexp "^  64:  c00800f0        zero    {za4\.d, za5\.d, za6\.d, za7\.d}$"
line   "  64:   c00800f0        zero    {}"
regexp_diff match failure
regexp "^  68:  c00800f8        zero    {za3\.s, za4\.d, za5\.d, za6\.d}$"
line   "  68:   c00800f8        zero    {}"
regexp_diff match failure
regexp "^  6c:  c00800fc        zero    {za2\.s, za3\.s, za4\.d, za5\.d}$"
line   "  6c:   c00800fc        zero    {}"
regexp_diff match failure
regexp "^  70:  c00800fe        zero    {za1\.h, za2\.s, za4\.d}$"
line   "  70:   c00800fe        zero    {}"
regexp_diff match failure
regexp "^  74:  c00800ff        zero    {za}$"
line   "  74:   c00800ff        zero    {}"
regexp_diff match failure
regexp "^  78:  c00800fe        zero    {za1\.h, za2\.s, za4\.d}$"
line   "  78:   c00800fe        zero    {}"
regexp_diff match failure
regexp "^  7c:  c00800fd        zero    {za0\.h, za3\.s, za5\.d}$"
line   "  7c:   c00800fd        zero    {}"
regexp_diff match failure
regexp "^  80:  c00800fb        zero    {za1\.h, za0\.s, za6\.d}$"
line   "  80:   c00800fb        zero    {}"
regexp_diff match failure
regexp "^  84:  c00800f7        zero    {za0\.h, za1\.s, za7\.d}$"
line   "  84:   c00800f7        zero    {}"
regexp_diff match failure
regexp "^  88:  c00800ef        zero    {za1\.h, za2\.s, za0\.d}$"
line   "  88:   c00800ef        zero    {}"
regexp_diff match failure
regexp "^  8c:  c00800df        zero    {za0\.h, za3\.s, za1\.d}$"
line   "  8c:   c00800df        zero    {}"
regexp_diff match failure
regexp "^  90:  c00800bf        zero    {za1\.h, za0\.s, za2\.d}$"
line   "  90:   c00800bf        zero    {}"
regexp_diff match failure
regexp "^  94:  c008007f        zero    {za0\.h, za1\.s, za3\.d}$"
line   "  94:   c008007f        zero    {}"
regexp_diff match failure
regexp "^  98:  c0080055        zero    {za0\.h}$"
line   "  98:   c0080055        zero    {}"
regexp_diff match failure
regexp "^  9c:  c00800aa        zero    {za1\.h}$"
line   "  9c:   c00800aa        zero    {}"
regexp_diff match failure
regexp "^  a0:  c0080011        zero    {za0\.s}$"
line   "  a0:   c0080011        zero    {}"
regexp_diff match failure
regexp "^  a4:  c0080022        zero    {za1\.s}$"
line   "  a4:   c0080022        zero    {}"
regexp_diff match failure
regexp "^  a8:  c0080044        zero    {za2\.s}$"
line   "  a8:   c0080044        zero    {}"
regexp_diff match failure
regexp "^  ac:  c0080088        zero    {za3\.s}$"
line   "  ac:   c0080088        zero    {}"
regexp_diff match failure
regexp "^  b0:  c0080055        zero    {za0\.h}$"
line   "  b0:   c0080055        zero    {}"
regexp_diff match failure
regexp "^  b4:  c0080055        zero    {za0\.h}$"
line   "  b4:   c0080055        zero    {}"
regexp_diff match failure
regexp "^  b8:  c0080055        zero    {za0\.h}$"
line   "  b8:   c0080055        zero    {}"
regexp_diff match failure
regexp "^  bc:  c00800aa        zero    {za1\.h}$"
line   "  bc:   c00800aa        zero    {}"
regexp_diff match failure
regexp "^  c0:  c00800aa        zero    {za1\.h}$"
line   "  c0:   c00800aa        zero    {}"
regexp_diff match failure
regexp "^  c4:  c00800aa        zero    {za1\.h}$"
line   "  c4:   c00800aa        zero    {}"
regexp_diff match failure
regexp "^  c8:  c0080011        zero    {za0\.s}$"
line   "  c8:   c0080011        zero    {}"
regexp_diff match failure
regexp "^  cc:  c0080022        zero    {za1\.s}$"
line   "  cc:   c0080022        zero    {}"
regexp_diff match failure
regexp "^  d0:  c0080044        zero    {za2\.s}$"
line   "  d0:   c0080044        zero    {}"
regexp_diff match failure
regexp "^  d4:  c0080088        zero    {za3\.s}$"
line   "  d4:   c0080088        zero    {}"
regexp_diff match failure
regexp "^  d8:  c00800d5        zero    {za0.h, za7.d}$"
line   "  d8:   c00800d5        zero    {}"
regexp_diff match failure
regexp "^  dc:  c00800ab        zero    {za1.h, za0.d}$"
line   "  dc:   c00800ab        zero    {}"
regexp_diff match failure
regexp "^  e0:  c0080015        zero    {za0.s, za2.d}$"
line   "  e0:   c0080015        zero    {}"
regexp_diff match failure
regexp "^  e4:  c008002a        zero    {za1.s, za3.d}$"
line   "  e4:   c008002a        zero    {}"
regexp_diff match failure
regexp "^  e8:  c0080054        zero    {za2.s, za4.d}$"
line   "  e8:   c0080054        zero    {}"
regexp_diff match failure
regexp "^  ec:  c00800a8        zero    {za3.s, za5.d}$"
line   "  ec:   c00800a8        zero    {}"
regexp_diff match failure
regexp "^  f0:  c00800d5        zero    {za0.h, za7.d}$"
line   "  f0:   c00800d5        zero    {}"
regexp_diff match failure
regexp "^  f4:  c0080015        zero    {za0.s, za2.d}$"
line   "  f4:   c0080015        zero    {}"
FAIL: SME extension (ZERO)


The AArch64 instruction table (aarch64-tbl.h) defines the operand "SME list of ZA tiles" (SME_list_of_64bit_tiles) as immediate.
During assembly it is correctly encoded as immediate value (imm.value) in parse_operands.
During disassembly it is first correctly decoded as immediate value (imm.value) in aarch64_ext_imm called by aarch64_extract_operand, but then erroneously treated as register number (reg.regno) in aarch64_print_operand.

On AArch64 - being little-endian - the struct aarch64_opnd_info union fields reg.regno and imm.value share their least-significant bits. On s390 - being big-endian - they do not.

I will send a patch.
Comment 1 Sourceware Commits 2024-04-09 15:22:18 UTC
The master branch has been updated by Jens Remus <jremus@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6f3cf71845e68409724aef1cfef3b5a44beecf53

commit 6f3cf71845e68409724aef1cfef3b5a44beecf53
Author: Jens Remus <jremus@linux.ibm.com>
Date:   Tue Apr 9 17:21:53 2024 +0200

    aarch64: Treat operand "SME list of ZA tiles" as immediate (PR 31561)
    
    The AArch64 instruction table (aarch64-tbl.h) defines the operand
    "SME list of ZA tiles" (SME_list_of_64bit_tiles) as immediate. During
    assembly it is correctly encoded as immediate value (imm.value) in
    parse_operands. During disassembly it is first correctly decoded as
    immediate value (imm.value) in aarch64_ext_imm called by
    aarch64_extract_operand, but then erroneously treated as register
    number (reg.regno) in aarch64_print_operand.
    
    This resolves the assembler test case "SME extension (ZERO)" to
    erroneously fail on s390. On AArch64 - being little-endian - the struct
    aarch64_opnd_info union fields reg.regno and imm.value share their
    least-significant bits. On s390 - being big-endian - they do not.
    
    opcodes/
            PR binutils/31561
            * aarch64-opc.c: Treat operand "SME list of ZA tiles" as
            immediate.
    
    Bug: https://sourceware.org/PR31561
    Signed-off-by: Jens Remus <jremus@linux.ibm.com>
    Acked-by: Nick Clifton <nickc@redhat.com>
Comment 2 Jens Remus 2024-04-18 11:06:59 UTC
Commited fix approved by Nick to mainline.