[PATCH] D21809: [SystemZ] Add support for .insn and .word/.short/.long/.quad directives

Marcin Koƛcielnicki via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 14:46:04 PDT 2016


koriakin added a comment.

In http://reviews.llvm.org/D21809#470546, @zhanjunl wrote:

> From my understanding, gas only supports some of the possible s390 instruction formats when using ".insn". For example, the "ri" format in the insn directive corresponds to the RI-a format, which uses an immediate field and not a relative-immediate field. Therefore, for the .insn directive specifically:
>
> ri = RI-a
>  rie = RIE-d
>  ril = RIL-a


I was refering to RIE, RIL, RSI with my comments about pc-relative operands, not RI. Here goes (gas):

  nopr %r7      
  .insn rie, 0xec0000000044, 1, 2, label
  nopr %r7
  label:



  Disassembly of section .text:
  
  0000000000000000 <label-0xa>:
     0:   07 07                   nopr    %r7
     2:   ec 12 00 04 00 44       brxhg   %r1,%r2,a <label>
     8:   07 07                   nopr    %r7
  
  000000000000000a <label>:
     a:   07 07                   nopr    %r7

So this is definitely supported.

> I tried assembling a sample .insn directive with gas:

> 

>           .text

>           .globl  main

>           .type   main, at function

>   main:

>           lghi    %r2, 0

>   #       brct %r2,.label

>           .insn ri,0xa7060000,%r2,.label

>   .label:

>           br      %r14

>   .Lfunc_end0:

>           .size   main, .Lfunc_end0-main

> 

> 

> gas will assemble the above code with no errors, but when I do an objdump of the object file, I see:

> 

>   temp.o:     file format elf64-s390

>   

>   

>   Disassembly of section .text:

>   

>   0000000000000000 <main>:

>      0:   a7 29 00 00             lghi    %r2,0

>      4:   a7 26 00 00             brct    %r2,4 <main+0x4>

>   

>   0000000000000008 <.label>:

>      8:   07 fe                   br      %r14

>      a:   07 07                   nopr    %r7

> 

> 

> So it looks like it was able to get the correct instruction mnemonic, but it silently fails when trying to encode the label into the instruction. This was my understanding when supporting the .insn, and so I didn't expect to have to do any fixups. Unless I'm mistaken?


Again, this is RI, which gas considers to be RI-a, which is not PC-relative.  Also, please disassemble your code with objdump -dr:

  Disassembly of section .text:
  
  0000000000000000 <main>:
     0:   a7 29 00 00             lghi    %r2,0
     4:   a7 26 00 00             brct    %r2,4 <main+0x4>
                          6: R_390_16     .text+0x8
  
  0000000000000008 <.label>:
     8:   07 fe                   br      %r14
     a:   07 07                   nopr    %r7

Here goes the fixup.


http://reviews.llvm.org/D21809





More information about the llvm-commits mailing list