File: ppc64-toc-relax2.s

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (66 lines) | stat: -rw-r--r-- 1,977 bytes parent folder | download | duplicates (24)
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
# REQUIRES: ppc
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
# RUN: echo 'addis 5, 2, .LC0@toc@ha; ld 5, .LC0@toc@l(5); foo: \
# RUN:   .section .toc,"aw",@progbits; .LC0: .tc foo[TC], foo' \
# RUN:   | llvm-mc -filetype=obj -triple=powerpc64le - -o %t1.o
# RUN: ld.lld %t.o %t1.o -o %t
# RUN: llvm-objdump -d %t | FileCheck %s

# CHECK-LABEL: <_start>:
.globl _start
_start:
## Perform toc-indirect to toc-relative relaxation even if there are unrelated instructions in between.
# CHECK-NEXT:   addis 3, 2, -2
# CHECK-NEXT:   li 9, 0
# CHECK-NEXT:   addi 3, 3, 32752
# CHECK-NEXT:   lwa 3, 0(3)
  addis 3, 2, .LC1@toc@ha  # R_PPC64_TOC16_HA
  li    9, 0
  ld    3, .LC1@toc@l(3)   # R_PPC64_TOC16_LO_DS
  lwa   3, 0(3)

## R_PPC64_TOC16_HA and R_PPC64_TOC16_LO_DS can interleave.
# CHECK-NEXT:   addis 3, 2, -2
# CHECK-NEXT:   addis 4, 2, -2
# CHECK-NEXT:   addi 3, 3, 32752
# CHECK-NEXT:   addi 4, 4, 32756
  addis 3, 2, .LC1@toc@ha
  addis 4, 2, .LC2@toc@ha
  ld    3, .LC1@toc@l(3)
  ld    4, .LC2@toc@l(4)

## We choose to be conservative: the presence of R_PPC64_TOC16_LO
## suppresses relaxation for the symbol.
## R_PPC64_TOC16_HA and R_PPC64_TOC16_LO_DS pairs are not relaxed as well.
# CHECK-NEXT:   nop
# CHECK-NEXT:   addi 3, 2, -32768
# CHECK-NEXT:   li 9, 0
# CHECK-NEXT:   nop
# CHECK-NEXT:   ld 4, -32768(2)
  addis 3, 2, .LC0@toc@ha  # R_PPC64_TOC16_HA
  addi  3, 3, .LC0@toc@l   # R_PPC64_TOC16_LO
  li    9, 0
  addis 4, 2, .LC0@toc@ha
  ld    4, .LC0@toc@l(4)

# CHECK-COUNT-3:   blr
AES_encrypt:
  blr
AES_decrypt:
  blr
BN_free:
  blr

## %t1.o has relaxable relocation pairs referencing its .toc which is different
## from %t.o(.toc). The suppression in %t.o does not affect %t1.o even if
## the relocation addends are the same.
# CHECK-NEXT:   addis 5, 2, -1
# CHECK-NEXT:   addi 5, 5, -32768

.section .toc,"aw",@progbits
.LC0:
  .tc AES_encrypt[TC], AES_encrypt
.LC1:
  .tc AES_decrypt[TC], AES_decrypt
.LC2:
  .tc BN_free[TC], BN_free