1; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
3; RUN:   FileCheck %s --check-prefix=CHECK-S
4; RUN: llc -verify-machineinstrs -target-abi=elfv2 -mtriple=powerpc64-- \
5; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
6; RUN:   --filetype=obj < %s | \
7; RUN:   llvm-objdump --mcpu=pwr10 -dr - | FileCheck %s --check-prefix=CHECK-O
8
9; Constant Pool Index.
10; CHECK-S-LABEL: ConstPool
11; CHECK-S:       plfd f1, .LCPI0_0@PCREL(0), 1
12; CHECK-S:       blr
13
14; CHECK-O-LABEL: ConstPool
15; CHECK-O:       plfd 1, 0(0), 1
16; CHECK-O-NEXT:  R_PPC64_PCREL34  .rodata.cst8
17; CHECK-O:       blr
18define dso_local double @ConstPool() local_unnamed_addr {
19  entry:
20    ret double 0x406ECAB439581062
21}
22
23@valIntLoc = common dso_local local_unnamed_addr global i32 0, align 4
24define dso_local signext i32 @ReadLocalVarInt() local_unnamed_addr  {
25; CHECK-S-LABEL: ReadLocalVarInt
26; CHECK-S:       # %bb.0: # %entry
27; CHECK-S-NEXT:    plwa r3, valIntLoc@PCREL(0), 1
28; CHECK-S-NEXT:    blr
29
30; CHECK-O-LABEL: ReadLocalVarInt
31; CHECK-O:         plwa 3, 0(0), 1
32; CHECK-O-NEXT:    R_PPC64_PCREL34 valIntLoc
33; CHECK-O-NEXT:    blr
34entry:
35  %0 = load i32, i32* @valIntLoc, align 4
36  ret i32 %0
37}
38
39@valIntGlob = external global i32, align 4
40define dso_local signext i32 @ReadGlobalVarInt() local_unnamed_addr  {
41; CHECK-S-LABEL: ReadGlobalVarInt
42; CHECK-S:       # %bb.0: # %entry
43; CHECK-S-NEXT:    pld r3, valIntGlob@got@pcrel(0), 1
44; CHECK-S-NEXT: .Lpcrel0:
45; CHECK-S-NEXT:    .reloc .Lpcrel0-8,R_PPC64_PCREL_OPT,.-(.Lpcrel0-8)
46; CHECK-S-NEXT:    lwa r3, 0(r3)
47; CHECK-S-NEXT:    blr
48
49; CHECK-O-LABEL: ReadGlobalVarInt
50; CHECK-O:         pld 3, 0(0), 1
51; CHECK-O-NEXT:    R_PPC64_GOT_PCREL34 valIntGlob
52; CHECK-O-NEXT:    R_PPC64_PCREL_OPT *ABS*+0x8
53; CHECK-O-NEXT:    lwa 3, 0(3)
54; CHECK-O-NEXT:    blr
55entry:
56  %0 = load i32, i32* @valIntGlob, align 4
57  ret i32 %0
58}
59