diff options
| author | Hal Finkel <hfinkel@anl.gov> | 2014-07-18 23:29:49 +0000 |
|---|---|---|
| committer | Hal Finkel <hfinkel@anl.gov> | 2014-07-18 23:29:49 +0000 |
| commit | 3ee2af7d1c0decb43729d239b5c6c0052b5308b7 (patch) | |
| tree | ed2c775d579da6195162e9146eea3a83c8e0d678 /llvm/test/CodeGen/PowerPC | |
| parent | 8924d27c02b546d1f4da3be97b353792df4e6211 (diff) | |
| download | bcm5719-llvm-3ee2af7d1c0decb43729d239b5c6c0052b5308b7.tar.gz bcm5719-llvm-3ee2af7d1c0decb43729d239b5c6c0052b5308b7.zip | |
[PowerPC] 32-bit ELF PIC support
This adds initial support for PPC32 ELF PIC (Position Independent Code; the
-fPIC variety), thus rectifying a long-standing deficiency in the PowerPC
backend.
Patch by Justin Hibbits!
llvm-svn: 213427
Diffstat (limited to 'llvm/test/CodeGen/PowerPC')
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/available-externally.ll | 9 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/ppc32-pic.ll | 21 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/sections.ll | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/stack-realign.ll | 53 |
4 files changed, 84 insertions, 3 deletions
diff --git a/llvm/test/CodeGen/PowerPC/available-externally.ll b/llvm/test/CodeGen/PowerPC/available-externally.ll index abed0de80b8..53c43599548 100644 --- a/llvm/test/CodeGen/PowerPC/available-externally.ll +++ b/llvm/test/CodeGen/PowerPC/available-externally.ll @@ -1,7 +1,8 @@ ; RUN: llc < %s -relocation-model=static | FileCheck %s -check-prefix=STATIC -; RUN: llc < %s -relocation-model=pic | FileCheck %s -check-prefix=PIC +; RUN: llc < %s -relocation-model=pic -mtriple=powerpc-apple-darwin8 | FileCheck %s -check-prefix=PIC +; RUN: llc < %s -relocation-model=pic -mtriple=powerpc-unknown-linux | FileCheck %s -check-prefix=PICELF ; RUN: llc < %s -relocation-model=pic -mtriple=powerpc64-apple-darwin8 | FileCheck %s -check-prefix=PIC64 -; RUN: llc < %s -relocation-model=dynamic-no-pic | FileCheck %s -check-prefix=DYNAMIC +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=powerpc-apple-darwin8 | FileCheck %s -check-prefix=DYNAMIC ; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=powerpc64-apple-darwin8 | FileCheck %s -check-prefix=DYNAMIC64 ; PR4482 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" @@ -18,6 +19,10 @@ entry: ; PIC: bl L_exact_log2$stub ; PIC: blr +; PICELF: foo: +; PICELF: bl exact_log2@PLT +; PICELF: blr + ; PIC64: _foo: ; PIC64: bl L_exact_log2$stub ; PIC64: blr diff --git a/llvm/test/CodeGen/PowerPC/ppc32-pic.ll b/llvm/test/CodeGen/PowerPC/ppc32-pic.ll new file mode 100644 index 00000000000..5bb78a4655a --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/ppc32-pic.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic | FileCheck %s +@foobar = common global i32 0, align 4 + +define i32 @foo() { +entry: + %0 = load i32* @foobar, align 4 + ret i32 %0 +} + +; CHECK: [[POFF:\.L[0-9]+\$poff]]: +; CHECK-NEXT: .long .L.TOC.-[[PB:\.L[0-9]+\$pb]] +; CHECK-NEXT: foo: +; CHECK: bl [[PB]] +; CHECK-NEXT: [[PB]]: +; CHECK: mflr 30 +; CHECK: lwz [[REG:[0-9]+]], [[POFF]]-[[PB]](30) +; CHECK-NEXT: add 30, [[REG]], 30 +; CHECK: lwz [[VREG:[0-9]+]], [[VREF:\.LC[0-9]+]]-.L.TOC.(30) +; CHECK: lwz {{[0-9]+}}, 0([[VREG]]) +; CHECK: [[VREF]]: +; CHECK-NEXT: .long foobar diff --git a/llvm/test/CodeGen/PowerPC/sections.ll b/llvm/test/CodeGen/PowerPC/sections.ll index 0ff4a89ff37..d77dfddd0f9 100644 --- a/llvm/test/CodeGen/PowerPC/sections.ll +++ b/llvm/test/CodeGen/PowerPC/sections.ll @@ -1,8 +1,12 @@ ; Test to make sure that bss sections are printed with '.section' directive. ; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu | FileCheck %s +; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic | FileCheck %s -check-prefix=PIC @A = global i32 0 ; CHECK: .section .bss,"aw",@nobits ; CHECK: .globl A +; PIC: .section .got2,"aw",@progbits +; PIC: .section .bss,"aw",@nobits +; PIC: .globl A diff --git a/llvm/test/CodeGen/PowerPC/stack-realign.ll b/llvm/test/CodeGen/PowerPC/stack-realign.ll index 1c7a36aeeab..a59fceb5bdd 100644 --- a/llvm/test/CodeGen/PowerPC/stack-realign.ll +++ b/llvm/test/CodeGen/PowerPC/stack-realign.ll @@ -1,5 +1,7 @@ ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -disable-fp-elim < %s | FileCheck -check-prefix=CHECK-FP %s +; RUN: llc -mtriple=powerpc-unknown-linux-gnu -disable-fp-elim < %s | FileCheck -check-prefix=CHECK-32 %s +; RUN: llc -mtriple=powerpc-unknown-linux-gnu -disable-fp-elim -relocation-model=pic < %s | FileCheck -check-prefix=CHECK-32-PIC %s target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64" target triple = "powerpc64-unknown-linux-gnu" @@ -7,6 +9,8 @@ target triple = "powerpc64-unknown-linux-gnu" declare void @bar(i32*) +@barbaz = external global i32 + define void @goo(%struct.s* byval nocapture readonly %a) { entry: %x = alloca [2 x i32], align 32 @@ -16,8 +20,9 @@ entry: store i32 %0, i32* %arrayidx, align 32 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1 %1 = load i32* %b, align 4 + %2 = load i32* @barbaz, align 4 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1 - store i32 %1, i32* %arrayidx2, align 4 + store i32 %2, i32* %arrayidx2, align 4 call void @bar(i32* %arrayidx) ret void } @@ -69,6 +74,24 @@ entry: ; CHECK-FP-DAG: mtlr 0 ; CHECK-FP: blr +; CHECK-32-LABEL: @goo +; CHECK-32-DAG: mflr 0 +; CHECK-32-DAG: rlwinm [[REG:[0-9]+]], 1, 0, 27, 31 +; CHECK-32-DAG: stw 30, -8(1) +; CHECK-32-DAG: mr 30, 1 +; CHECK-32-DAG: stw 0, 4(1) +; CHECK-32-DAG: subfic 0, [[REG]], -64 +; CHECK-32: stwux 1, 1, 0 + +; CHECK-32-PIC-LABEL: @goo +; CHECK-32-PIC-DAG: mflr 0 +; CHECK-32-PIC-DAG: rlwinm [[REG:[0-9]+]], 1, 0, 27, 31 +; CHECK-32-PIC-DAG: stw 29, -12(1) +; CHECK-32-PIC-DAG: mr 29, 1 +; CHECK-32-PIC-DAG: stw 0, 4(1) +; CHECK-32-PIC-DAG: subfic 0, [[REG]], -64 +; CHECK-32-PIC: stwux 1, 1, 0 + ; The large-frame-size case. define void @hoo(%struct.s* byval nocapture readonly %a) { entry: @@ -99,6 +122,34 @@ entry: ; CHECK: blr +; CHECK-32-LABEL: @hoo + +; CHECK-32-DAG: lis [[REG1:[0-9]+]], -13 +; CHECK-32-DAG: rlwinm [[REG3:[0-9]+]], 1, 0, 27, 31 +; CHECK-32-DAG: mflr 0 +; CHECK-32-DAG: ori [[REG2:[0-9]+]], [[REG1]], 51904 +; CHECK-32-DAG: stw 30, -8(1) +; CHECK-32-DAG: mr 30, 1 +; CHECK-32-DAG: stw 0, 4(1) +; CHECK-32-DAG: subfc 0, [[REG3]], [[REG2]] +; CHECK-32: stwux 1, 1, 0 + +; CHECK-32: blr + +; CHECK-32-PIC-LABEL: @hoo + +; CHECK-32-PIC-DAG: lis [[REG1:[0-9]+]], -13 +; CHECK-32-PIC-DAG: rlwinm [[REG3:[0-9]+]], 1, 0, 27, 31 +; CHECK-32-PIC-DAG: mflr 0 +; CHECK-32-PIC-DAG: ori [[REG2:[0-9]+]], [[REG1]], 51904 +; CHECK-32-PIC-DAG: stw 29, -12(1) +; CHECK-32-PIC-DAG: mr 29, 1 +; CHECK-32-PIC-DAG: stw 0, 4(1) +; CHECK-32-PIC-DAG: subfc 0, [[REG3]], [[REG2]] +; CHECK-32: stwux 1, 1, 0 + +; CHECK-32: blr + ; Make sure that the FP save area is still allocated correctly relative to ; where r30 is saved. define void @loo(%struct.s* byval nocapture readonly %a) { |

