Bug 31919 - AArch64 gas test case "gas/aarch64/brbe-brb-inst" fails on s390x
Summary: AArch64 gas test case "gas/aarch64/brbe-brb-inst" 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-06-21 15:27 UTC by Jens Remus
Modified: 2024-06-25 15:52 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-06-21 15:27:43 UTC
The AArch64 GNU Assembler test case "gas/aarch64/brbe-brb-inst" 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
...
regexp_diff match failure
regexp "^.*:    d509729e        brb     iall    // unpredictable encoding \(Rt!=31\): #30$"
line   "   4:   d509729e        brb     iall    // unpredictable encoding (Rt!=31): #128849018880"
regexp_diff match failure
regexp "^.*:    d50972be        brb     inj     // unpredictable encoding \(Rt!=31\): #30$"
line   "   c:   d50972be        brb     inj     // unpredictable encoding (Rt!=31): #128849018880"
FAIL: gas/aarch64/brbe-brb-inst

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

This resolves the assembler test case "gas/aarch64/brbe-brb-inst" 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.

I will send a patch.
Comment 1 Sourceware Commits 2024-06-25 15:27:50 UTC
The master branch has been updated by Jens Remus <jremus@sourceware.org>:

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

commit 64daf9abd9c805770727ade9c8197f5e07b28324
Author: Jens Remus <jremus@linux.ibm.com>
Date:   Tue Jun 25 17:25:55 2024 +0200

    aarch64: Treat operand Rt_IN_SYS_ALIASES as register number (PR 31919)
    
    The AArch64 instruction table (aarch64-tbl.h) defines the operand
    Rt_IN_SYS_ALIASES as register number. During assembly it is correctly
    encoded as register number (reg.regno) in parse_operands. During
    disassembly it is first correctly decoded as register number (reg.regno)
    in aarch64_ext_regno called by aarch64_extract_operand, but then
    erroneously treated as immediate value (imm.value) in
    aarch64_print_operand.
    
    This resolves the assembler test case "gas/aarch64/brbe-brb-inst" 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/31919
            * aarch64-opc.c: Treat operand Rt_IN_SYS_ALIASES as register
            number.
    
    Bug: https://sourceware.org/PR31919
    Fixes: 72476aca8f58 ("aarch64: add Branch Record Buffer extension instructions")
    Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Comment 2 Jens Remus 2024-06-25 15:52:31 UTC
Commited fix approved by Alan to mainline.