• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names < %s | FileCheck %s --check-prefix=CHECK-S
3; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
4; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names --filetype=obj -o %t.o < %s
5; RUN: llvm-objdump --mcpu=pwr10 -dr %t.o | FileCheck %s --check-prefix=CHECK-O
6; RUN: llvm-readelf -s %t.o | FileCheck %s --check-prefix=CHECK-SYM
7
8; These test cases are to ensure that when using pc relative memory operations
9; ABI correct code and relocations are produced for Initial Exec TLS Model.
10; Note that with R_PPC64_TLS relocations, to distinguish PC relative
11; TLS the relocation has a field value displaced by one byte from the
12; beginning of the instruction.
13
14@x = external thread_local global i32, align 4
15
16define i32* @InitialExecAddressLoad() {
17; CHECK-S-LABEL: InitialExecAddressLoad:
18; CHECK-S:       # %bb.0: # %entry
19; CHECK-S-NEXT:    pld r3, x@got@tprel@pcrel(0), 1
20; CHECK-S-NEXT:    add r3, r3, x@tls@pcrel
21; CHECK-S-NEXT:    blr
22; CHECK-O-LABEL: <InitialExecAddressLoad>:
23; CHECK-O:         00 00 10 04 00 00 60 e4      	pld 3, 0(0), 1
24; CHECK-O-NEXT:    0000000000000000:  R_PPC64_GOT_TPREL_PCREL34	x
25; CHECK-O-NEXT:    14 6a 63 7c                  	add 3, 3, 13
26; CHECK-O-NEXT:    0000000000000009:  R_PPC64_TLS	x
27; CHECK-O-NEXT:    20 00 80 4e                  	blr
28entry:
29  ret i32* @x
30}
31
32define i32 @InitialExecValueLoad() {
33; CHECK-S-LABEL: InitialExecValueLoad:
34; CHECK-S:       # %bb.0: # %entry
35; CHECK-S-NEXT:    pld r3, x@got@tprel@pcrel(0), 1
36; CHECK-S-NEXT:    lwzx r3, r3, x@tls@pcrel
37; CHECK-S-NEXT:    blr
38; CHECK-O-LABEL: <InitialExecValueLoad>:
39; CHECK-O:         00 00 10 04 00 00 60 e4      	pld 3, 0(0), 1
40; CHECK-O-NEXT:    0000000000000020:  R_PPC64_GOT_TPREL_PCREL34	x
41; CHECK-O-NEXT:    2e 68 63 7c                  	lwzx 3, 3, 13
42; CHECK-O-NEXT:    0000000000000029:  R_PPC64_TLS	x
43; CHECK-O-NEXT:    20 00 80 4e                  	blr
44
45; CHECK-SYM-LABEL: Symbol table '.symtab' contains 6 entries
46; CHECK-SYM:         5: 0000000000000000     0 TLS     GLOBAL DEFAULT  UND x
47entry:
48  %0 = load i32, i32* @x, align 4
49  ret i32 %0
50}
51