[ARM] support symbolic expression as immediate in memory instructions
authorJian Cai <jiancai@google.com>
Mon, 12 Apr 2021 19:00:01 +0000 (12:00 -0700)
committerJian Cai <caij2003@gmail.com>
Mon, 12 Apr 2021 19:13:55 +0000 (12:13 -0700)
commitcfce5b26a888cb979d65252275df1f977dc1e6c8
tree4f469c4a1cea1984800501bf36b5912b16f3c502
parent661cc71a1c50081389d73b2baae02f51df670ba1
[ARM] support symbolic expression as immediate in memory instructions

Currently the ARM backend only accpets constant expressions as the
immediate operand in load and store instructions. This allows the
result of symbolic expressions to be used in memory instructions. For
example,

0:
.space 2048
strb r2, [r0, #(.-0b)]

would be assembled into the following instructions.

strb r2, [r0, #2048]

This only adds support to ldr, ldrb, str, and strb in arm mode to
address the build failure of Linux kernel for now, but should facilitate
adding support to similar instructions in the future if the need arises.

Link:
https://github.com/ClangBuiltLinux/linux/issues/1329

Reviewed By: peter.smith, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D98916
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMFixupKinds.h
llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
llvm/test/MC/ARM/arm-memory-instructions-immediate.s [new file with mode: 0644]