llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.88k stars 11.93k forks source link

Arm thumb assembler doesn't recognise 'rsbs' instruction #55215

Open esky-software opened 2 years ago

esky-software commented 2 years ago

When using clang (LLVM 14.0.0) to process assembler for armv6-m, the instruction 'rsbs Rn, #0' is not recognised, and the equivalent instruction 'negs Rn,Rn' must be used instead.

llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-arm

efriedma-quic commented 2 years ago

The syntax rsbs Rn, Rn, #0 works. I guess rsbs Rn, #0 should be treated as an alias.

DavidSpickett commented 2 years ago

To back that up from the manual "ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition". Assembler syntax is:

RSB{S}{<c>}{<q>} {<Rd>,} <Rn>, #<const>

Meaning <Rd> is optional and takes the value of Rn if not given. From the description of neg:

Assembler syntax
NEG{<c>}{<q>} <Rd>, <Rm>
This is equivalent to:
RSBS{<c>}{<q>} <Rd>, <Rm>, #0

So it should work. We allow the alias for thumb2 (armv7-m) but not armv6-m so it exists in some form already.

https://godbolt.org/z/eThcvcdch (current main does the same)