Issue 144869
Summary SystemZ `esrl` instruction doesn't disassemble `%r0`
Labels new issue
Assignees
Reporter Rot127
    The SystemZ disassembler doesn't decode `%r0` registers if they are part of an address.

```
echo "0xc6,0x00,0x00,0x00,0x00,0x05" | llvm-mc --disassemble --triple=s390x --show-encoding
	.text
	exrl	0, 0xa                          # encoding: [0xc6,0x00,A,A,A,A]
                                        #   fixup A - offset: 2, value: 12, kind: FK_390_PC32D
```

It should be `exrl	%r0, 0xa`.

It does work the other way around though:

```
echo "exrl %r0, 0xa" | llvm-mc --assemble --triple=s390x --show-encoding
	.text
.Ltmp0:
	exrl	%r0, .Ltmp0+10                  # encoding: [0xc6,0x00,A,A,A,A]
                                        # fixup A - offset: 2, value: (.Ltmp0+10)+2, kind: FK_390_PC32DBL
```

This might due to https://github.com/llvm/llvm-project/issues/44437.

Debugging shows that it happens due to these lines:

https://github.com/llvm/llvm-project/blob/1c35fe4e6b2596d153da82b23d04a3779fb12730/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp#L87-L89

The given register table in `Regs` contains a the valid register id of `r0`, but here it ignores it.

It possibly was supposed to be?
```diff
 {
 assert(RegNo < Size && "Invalid register");
-       if (IsAddr && RegNo == 0) {
+       if (IsAddr && Regs[RegNo] == 0) {
                RegNo = SystemZ::NoRegister;
        } else {
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to