[PATCH] D109657: [SystemZ] Accept plain register name where an address is expected.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 19 04:07:58 PDT 2021


jonpa updated this revision to Diff 373449.
jonpa added a comment.

> I believe %reg should be treated equivalently to 0(%reg) for any type of address, including those with length or vector index, so this should be fine. However, it would be good to validate that behavior against GAS, and also add a few test cases for instructions with those address types.

For addresses with a Length field, it seems GAS does require the full address with the explicit displacement as well:

          xc      0(32,%r2), 0(%r2)
          xc      0(32,%r2), %r2
  #       xc      (32,%r2), %r2    # not accepted by GAS
  #       xc      32,%r2, %r2      # not accepted by GAS

The same is also the case with a vector index:

           vsceg   %v0, 0(%v1, %r3), 1
  #        vsceg   %v0, (%v1, %r3), 1  # not accepted by GAS
  #        vsceg   %v0, %v1, %r3, 1    # not accepted by GAS

So I did not see any changes I could make for the patch, but I nevertheless added an extra test for the second (plain) address of an XC.

> An interesting twist is that you have to use the full name (%rX); if you were to use just the register number (1-15), it would be considered a displacement instead of a register ...

Hmmm... to my surprise it now seems that GAS is treating a plain register name as an offset:

  lg      %r0, 0(%r1)
  lg      %r0, %r1
  lg      %r0, 1



> as ; objdump =>
=================

  Disassembly of section .text:
  
  0000000000000000 <.text>:
     0:	e3 00 10 00 00 04 	lg	%r0,0(%r1)
     6:	e3 00 00 01 00 04 	lg	%r0,1
     c:	e3 00 00 01 00 04 	lg	%r0,1

With this patch though as we agreed:

  llvm-mc --show-encoding
  	.text
  	lg	%r0, 0(%r1)                     # encoding: [0xe3,0x00,0x10,0x00,0x00,0x04]
  	lg	%r0, 0(%r1)                     # encoding: [0xe3,0x00,0x10,0x00,0x00,0x04]
  	lg	%r0, 1                          # encoding: [0xe3,0x00,0x00,0x01,0x00,0x04]

Mayebe this was fixed recently in GAS?

as --version
GNU assembler version 2.32-30.2ibm.fc31
Copyright (C) 2019 Free Software Foundation, Inc.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109657/new/

https://reviews.llvm.org/D109657

Files:
  llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
  llvm/test/MC/SystemZ/insn-good.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109657.373449.patch
Type: text/x-patch
Size: 4304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210919/d6b375c0/attachment.bin>


More information about the llvm-commits mailing list