File: ppc64-pcrel-call-to-toc.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 (83 lines) | stat: -rw-r--r-- 2,539 bytes parent folder | download | duplicates (12)
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
# REQUIRES: ppc
# RUN: echo 'SECTIONS { \
# RUN:   .text_func   0x10010000 : { *(.text_func) } \
# RUN:   .text_callee 0x10020000 : { *(.text_callee) } \
# RUN:   .text_caller 0x10030000 : { *(.text_caller) } \
# RUN:   }' > %t.script

# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
# RUN: ld.lld -T %t.script %t.o -o %t
# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s

# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
# RUN: ld.lld -T %t.script %t.o -o %t --no-power10-stubs --power10-stubs=yes
# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s

# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
# RUN: ld.lld -T %t.script %t.o -o %t --power10-stubs=auto --no-power10-stubs
# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
# RUN: llvm-objdump -d --no-show-raw-insn %t \
# RUN: | FileCheck %s --check-prefix=CHECK-NOP10

## When a function without TOC accesses a function using TOC, an r12 setup stub
## is inserted

# SYMBOL:      1: 0000000010010000 0 NOTYPE LOCAL DEFAULT 1 func
# SYMBOL-NEXT: 2: 0000000010020000 0 NOTYPE LOCAL DEFAULT [<other: 0x60>] 2 callee
# SYMBOL:      4: 0000000010030000 0 NOTYPE LOCAL DEFAULT [<other: 0x20>] 3 caller
# SYMBOL:      6: 0000000010030010 32 FUNC LOCAL DEFAULT 3 __gep_setup_callee

# CHECK-LABEL: <func>:
# CHECK-NEXT:  blr

# CHECK-LABEL: <callee>:
# CHECK:       bl 0x10010000
# CHECK-NEXT:  addis 4, 2, -1
# CHECK-NEXT:  lwz 4, 32728(4)
# CHECK-NEXT:  blr

# CHECK-LABEL: <caller>:
# CHECK-NEXT:  bl 0x10030010
# CHECK-NEXT:  blr

# CHECK-LABEL: <__gep_setup_callee>:
# CHECK-NEXT:  paddi 12, 0, -65552, 1
# CHECK-NEXT:  mtctr 12
# CHECK-NEXT:  bctr

# CHECK-NOP10-LABEL: <__gep_setup_callee>:
# CHECK-NOP10-NEXT:  mflr 12
# CHECK-NOP10-NEXT:  bcl 20, 31, 0x10030018
# CHECK-NOP10-NEXT:  mflr 11
# CHECK-NOP10-NEXT:  mtlr 12
# CHECK-NOP10-NEXT:  addis 12, 11, -1
# CHECK-NOP10-NEXT:  addi 12, 12, -24
# CHECK-NOP10-NEXT:  mtctr 12
# CHECK-NOP10-NEXT:  bctr

.section .text_func, "ax", %progbits
func:
  blr

.section .text_callee, "ax", %progbits
callee:
.Lfunc_gep1:
  addis 2, 12, .TOC.-.Lfunc_gep1@ha
  addi 2, 2, .TOC.-.Lfunc_gep1@l
.Lfunc_lep1:
  .localentry callee, .Lfunc_lep1-.Lfunc_gep1
  bl func
  addis 4, 2, global@toc@ha
  lwz 4, global@toc@l(4)
  blr

.section .text_caller, "ax", %progbits
caller:
  .localentry caller, 1
  bl callee@notoc
  blr
global:
  .long	0
  .size	global, 4