Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[MC][Thumb2] .w suffix rejected for certain ldr and str operands #49633

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR50664
Status NEW
Importance P enhancement
Reported by Ryan Prichard (rprichard@google.com)
Reported on 2021-06-10 17:09:28 -0700
Last modified on 2021-06-11 10:11:10 -0700
Version trunk
Hardware PC Linux
CC kristof.beyls@arm.com, llvm-bugs@lists.llvm.org, ndesaulniers@google.com, smithp352@googlemail.com, Ties.Stuij@arm.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
LLVM can assemble this Thumb2 code (clang --target=armv7a-linux-gnueabi):

    .syntax unified
    .thumb
    ldr.w r0, [r1, #0xf00]

But not this:

    .syntax unified
    .thumb
    ldr.w r0, [r1, #-2]

test.S:3:15: error: invalid operand for instruction
    ldr.w r0, [r1, #-2]
              ^

It will assemble if I remove the ".w" suffix. The disassembly is then:

00000000 <.text>:
   0:   f851 0c02   ldr.w   r0, [r1, #-2]

... which indicates a wide instruction.

Maybe the fix for bug #49118 was incomplete?

There are some similar instructions that, IIRC, use the same encoding, and have
the same problem. They're wide instructions that can only be assembled if the
".w" suffix is omitted:

    ldr.w r0, [r1, #2]!
    ldr.w r0, [r1], #2
    ldr.w r0, [r1, #-0]
Quuxplusone commented 3 years ago
> ldr.w r0, [r1, #2]!
> ldr.w r0, [r1], #2
> ldr.w r0, [r1, #-0]

Actually it looks like a current version of LLVM can handle the first two of
these. Only the last one is a problem, and that's basically the same as "ldr.w
r0, [r1, #-2]".