File: aarch64-adrp-add.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (107 lines) | stat: -rw-r--r-- 3,454 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# REQUIRES: aarch64
# RUN: rm -rf %t && split-file %s %t

# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
# RUN: ld.lld %t/a.o -T %t/out-of-adr-range-low.t -o %t/a-low
# RUN: llvm-objdump --no-show-raw-insn -d %t/a-low | FileCheck %s --check-prefix=OUT-OF-RANGE
# RUN: ld.lld %t/a.o -T %t/out-of-adr-range-high.t -o %t/a-high
# RUN: llvm-objdump --no-show-raw-insn -d %t/a-high | FileCheck %s --check-prefix=OUT-OF-RANGE

# OUT-OF-RANGE:      adrp  x30
# OUT-OF-RANGE-NEXT: add   x30, x30

# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
# RUN: ld.lld %t/a.o -T %t/within-adr-range-low.t -o %t/a-low
# RUN: llvm-objdump --no-show-raw-insn -d %t/a-low | FileCheck %s --check-prefix=IN-RANGE-LOW

# IN-RANGE-LOW:      nop
# IN-RANGE-LOW-NEXT: adr   x30
# IN-RANGE-LOW-NEXT: adrp  x1
# IN-RANGE-LOW-NEXT: add   x1
# IN-RANGE-LOW-NEXT: adrp  x15
# IN-RANGE-LOW-NEXT: add   x15

## ADRP and ADD use different registers, no relaxations should be applied.
# IN-RANGE-LOW-NEXT: adrp  x2
# IN-RANGE-LOW-NEXT: add   x3, x2

## ADRP and ADD use different registers, no relaxations should be applied.
# IN-RANGE-LOW-NEXT: adrp  x2
# IN-RANGE-LOW-NEXT: add   x2, x3

# RUN: ld.lld %t/a.o -T %t/within-adr-range-high.t -o %t/a-high
# RUN: llvm-objdump --no-show-raw-insn -d %t/a-high | FileCheck %s --check-prefix=IN-RANGE-HIGH

# IN-RANGE-HIGH:      nop
# IN-RANGE-HIGH-NEXT: adr   x30
# IN-RANGE-HIGH-NEXT: nop
# IN-RANGE-HIGH-NEXT: adr   x1
# IN-RANGE-HIGH-NEXT: nop
# IN-RANGE-HIGH-NEXT: adr   x15

## ADRP and ADD use different registers, no relaxations should be applied.
# IN-RANGE-HIGH-NEXT: adrp  x2
# IN-RANGE-HIGH-NEXT: add   x3, x2

## ADRP and ADD use different registers, no relaxations should be applied.
# IN-RANGE-HIGH-NEXT: adrp  x2
# IN-RANGE-HIGH-NEXT: add   x2, x3

# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
# RUN: ld.lld %t/a.o -T %t/within-adr-range-low.t --no-relax -o %t/a
## --no-relax disables relaxations.
# RUN: llvm-objdump --no-show-raw-insn -d %t/a | FileCheck %s --check-prefix=OUT-OF-RANGE

## .rodata and .text are close to each other,
## the adrp + add pair can be relaxed to nop + adr, moreover, the address difference
## is equal to the lowest allowed value.
#--- within-adr-range-low.t
SECTIONS {
 .rodata 0x1000: { *(.rodata) }
 .text   0x100ffc: { *(.text) }
}

## .rodata and .text are far apart,
## the adrp + add pair cannot be relaxed to nop + adr, moreover, the address difference
## is equal to the lowest allowed value minus one.
#--- out-of-adr-range-low.t
SECTIONS {
 .rodata 0x1000: { *(.rodata) }
 .text   0x100ffd: { *(.text) }
}

## .rodata and .text are close to each other,
## the adrp + add pair can be relaxed to nop + adr, moreover, the address difference
## is equal to the highest allowed value.
#--- within-adr-range-high.t
SECTIONS {
 .text   0x1000: { *(.text) }
 .rodata 0x101003: { *(.rodata) }
}

## .rodata and .text are far apart,
## the adrp + add pair cannot be relaxed to nop + adr, moreover, the address difference
## is equal to the highest allowed value plus one.
#--- out-of-adr-range-high.t
SECTIONS {
 .text   0x1000: { *(.text) }
 .rodata 0x101004: { *(.rodata) }
}

#--- a.s
.rodata
x:
.word 10
.text
.global _start
_start:
  adrp    x30, x
  add     x30, x30, :lo12:x
  adrp    x1, x
  add     x1, x1, :lo12:x
  adrp    x15, x
  add     x15, x15, :lo12:x
  adrp    x2, x
  add     x3, x2, :lo12:x
  adrp    x2, x
  add     x2, x3, :lo12:x