question on assembler for systemz backend

What assembler are people using with the SystemZ backend?

I am trying to assemble the output of the SystemZ backend with the GNU binutils assembler (build with --target=s390x-linux). I get errors when assembling instructions with literals that are negatives. For example, the test case test/CodeGen/SystemZ/01-RetImm.ll gives errors:

$ s390x-as 01-RetImm.s
01-RetImm.s: Assembler messages:
01-RetImm.s:16: Error: operand out of range (0xffffffffffffffff is not between 0x0000000000000000 and 0x000000000000ffff)
01-RetImm.s:61: Error: operand out of range (0xffffffffffffffff is not between 0x0000000000000000 and 0x00000000ffffffff)

line 16 is:
  llill %r2, -1 <<< why -1

which was generated from:
define i64 @foo2() {
entry:
     ret i64 65535
}

Why are negative literals being generated.

regards,
bagel

Hello

I am trying to assemble the output of the SystemZ backend with the GNU
binutils assembler (build with --target=s390x-linux). I get errors when
assembling instructions with literals that are negatives. For example,
the test case test/CodeGen/SystemZ/01-RetImm.ll gives errors:

There are different instruction sets for z/System. Basically, you have
to provide proper -march / -mcpu to assembler, otherwise the very old
ISA is assumed.
I don't recall offhand, but you need to provide either z990 or z9-109,
because LLVM assumes that long displacements and ext imm stuff is
available (this is rather fair assumption).

   llill   %r2, \-1                 &lt;&lt;&lt; why \-1

Because it sets lowest (ll) 16 bit word of 64 bits.

Why are negative literals being generated.

Because of z/Systems ISA :slight_smile:

Hi Anton,

Hello

I am trying to assemble the output of the SystemZ backend with the GNU
binutils assembler (build with --target=s390x-linux). I get errors when
assembling instructions with literals that are negatives. For example,
the test case test/CodeGen/SystemZ/01-RetImm.ll gives errors:

There are different instruction sets for z/System. Basically, you have
to provide proper -march / -mcpu to assembler, otherwise the very old
ISA is assumed.
I don't recall offhand, but you need to provide either z990 or z9-109,
because LLVM assumes that long displacements and ext imm stuff is
available (this is rather fair assumption).

I have tried:
   s390x-as -m64 -march=z900
   s390x-as -m64 -march=z990
   s390x-as -m64 -march=z9-109
All give the same error messages. This is with binutils-2.20.51.

        llill %r2, -1<<< why -1

Because it sets lowest (ll) 16 bit word of 64 bits.

The way I read the gas code for s390, "llill" expects the second operand to be unsigned, and the parsed expression is cast to unsigned before the range check. This does not appear to be -march dependent.

Why are negative literals being generated.

Because of z/Systems ISA :slight_smile:

I'd still like to know if anyone has sucessfully assembled SystemZ generated assembly language with a binutils assembler, and if so, how.

regards,
bagel

I'd still like to know if anyone has sucessfully assembled SystemZ generated
assembly language with a binutils assembler, and if so, how.

Almost all testsuite passed ~ 1.5 years ago (with clang + gas). I
doubt anyone tried to assembler anything else after that time.

Lots of things have changed in 1.5 years with respect to assembly output, so I guess it got broken.

I'll file a bug report, but it appears that no one uses this backend, so I suspect it won't get fixed very soon. Too bad, it is possible to run SystemZ code via the simulator "hercules". I had hoped to do some testing that way.

regards,
bagel

I'll file a bug report, but it appears that no one uses this backend, so I
suspect it won't get fixed very soon. Too bad, it is possible to run SystemZ
code via the simulator "hercules". I had hoped to do some testing that way.

As far as I remember, hercules was extremely slow to run code on :slight_smile: