1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/MC/ARM/arm-memory-instructions-immediate.s
Jian Cai ea3b76544c [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
2021-04-12 12:13:55 -07:00

26 lines
825 B
ArmAsm

// RUN: llvm-mc -triple=armv7 -filetype=obj %s | llvm-objdump --triple=armv7 -d - | FileCheck %s
// RUN: not llvm-mc -triple=armv7 -filetype=obj --defsym=ERR=1 < %s -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
.syntax unified
// Check that the assembler accepts the result of symbolic expressions as the
// immediate operand in load and stores.
0:
// CHECK-LABEL: foo
.space 1024
1:
foo:
ldr r0, [r1, #(1b - 0b)]
// CHECK-NEXT: ldr r0, [r1, #1024]
ldr r0, [r1, #(0b - 1b)]
// CHECK-NEXT: ldr r0, [r1, #-1024]
ldrb r0, [r1, #(1b-0b)]
// CHECK-NEXT: ldrb r0, [r1, #1024]
str r0, [r1, #(1b-0b)]
// CHECK-NEXT: str r0, [r1, #1024]
strb r0, [r1, #(1b-0b)]
// CHECK-NEXT: strb r0, [r1, #1024]
.ifdef ERR
str r0, [r1, 1b]
// ERR:[[#@LINE-1]]:5: error: unsupported relocation on symbol
.endif