llvm / llvm-project

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

Arm thumb assembler doesn't allow expression in 'adr' instruction #55218

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 'adr Rn,, expr' is only accepted if expr is a label. An expression is not accepted. However if expr is a .equ it is accepted, even if the .equ is defined by an exression

e.g. Not accepted: adr Rn, lbl+4

e,g, Accepted: .equ lbl_plus_4, lbl+4 adr Rn, lbl_plus_4

llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-arm

DavidSpickett commented 2 years ago

From the manual, A8.8.12 ADR:

ADR{<c>}{<q>} <Rd>, <label> Normal syntax

So this should be allowed, gcc does allow both styles. We do allow using the label directly if you are thumb2 (armv7-M) and I don't see a reason in the manual to not extend that to armv6-m. (https://godbolt.org/z/fGMYT537a)