diff options
author | Pawel Wodnicki <pawel@32bitmicro.com> | 2012-12-04 19:47:56 +0000 |
---|---|---|
committer | Pawel Wodnicki <pawel@32bitmicro.com> | 2012-12-04 19:47:56 +0000 |
commit | bdcb22211f5642528f75c1f2b079922f2cc45ee6 (patch) | |
tree | b90e95518a59034ecf7a3955dcaf11ae6309c2a9 /test | |
parent | a9020249400f65612fc9f1c0f5cfebe50a58ff85 (diff) | |
download | llvm-bdcb22211f5642528f75c1f2b079922f2cc45ee6.tar.gz llvm-bdcb22211f5642528f75c1f2b079922f2cc45ee6.tar.bz2 llvm-bdcb22211f5642528f75c1f2b079922f2cc45ee6.tar.xz |
Merging MIPS GOT changeset into 3.2 release branch.
Merging r168471:
Mips direct object xgot support
This patch provides support for the MIPS relocations:
*) R_MIPS_GOT_HI16
*) R_MIPS_GOT_LO16
*) R_MIPS_CALL_HI16
*) R_MIPS_CALL_LO16
These are used for large GOT instruction sequences.
Contributer: Jack Carter
Merging r168460:
[mips] Generate big GOT code.
Merging r168458:
[mips] Simplify lowering functions in MipsISelLowering.cpp by using the helper
functions added in r168456.
Merging r168456:
[mips] Add helper functions that create nodes for computing address.
Merging r168455:
[mips] Add command line option "-mxgot".
Merging r168453:
[mips] When a node which loads from a GOT is created, pass a MachinePointerInfo
referring to a GOT entry.
Merging r168450:
[mips] Add target operand flag enums for big GOT relocations.
Merging r168448:
Add relocations used for mips big GOT.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@169294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/Mips/biggot.ll | 50 | ||||
-rw-r--r-- | test/MC/Mips/xgot.ll | 42 |
2 files changed, 92 insertions, 0 deletions
diff --git a/test/CodeGen/Mips/biggot.ll b/test/CodeGen/Mips/biggot.ll new file mode 100644 index 0000000000..c4ad851c82 --- /dev/null +++ b/test/CodeGen/Mips/biggot.ll @@ -0,0 +1,50 @@ +; RUN: llc -march=mipsel -mxgot < %s | FileCheck %s -check-prefix=O32 +; RUN: llc -march=mips64el -mcpu=mips64r2 -mattr=+n64 -mxgot < %s | \ +; RUN: FileCheck %s -check-prefix=N64 + +@v0 = external global i32 + +define void @foo1() nounwind { +entry: +; O32: lui $[[R0:[0-9]+]], %got_hi(v0) +; O32: addu $[[R1:[0-9]+]], $[[R0]], ${{[a-z0-9]+}} +; O32: lw ${{[0-9]+}}, %got_lo(v0)($[[R1]]) +; O32: lui $[[R2:[0-9]+]], %call_hi(foo0) +; O32: addu $[[R3:[0-9]+]], $[[R2]], ${{[a-z0-9]+}} +; O32: lw ${{[0-9]+}}, %call_lo(foo0)($[[R3]]) + +; N64: lui $[[R0:[0-9]+]], %got_hi(v0) +; N64: daddu $[[R1:[0-9]+]], $[[R0]], ${{[a-z0-9]+}} +; N64: ld ${{[0-9]+}}, %got_lo(v0)($[[R1]]) +; N64: lui $[[R2:[0-9]+]], %call_hi(foo0) +; N64: daddu $[[R3:[0-9]+]], $[[R2]], ${{[a-z0-9]+}} +; N64: ld ${{[0-9]+}}, %call_lo(foo0)($[[R3]]) + + %0 = load i32* @v0, align 4 + tail call void @foo0(i32 %0) nounwind + ret void +} + +declare void @foo0(i32) + +; call to external function. + +define void @foo2(i32* nocapture %d, i32* nocapture %s, i32 %n) nounwind { +entry: +; O32: foo2: +; O32: lui $[[R2:[0-9]+]], %call_hi(memcpy) +; O32: addu $[[R3:[0-9]+]], $[[R2]], ${{[a-z0-9]+}} +; O32: lw ${{[0-9]+}}, %call_lo(memcpy)($[[R3]]) + +; N64: foo2: +; N64: lui $[[R2:[0-9]+]], %call_hi(memcpy) +; N64: daddu $[[R3:[0-9]+]], $[[R2]], ${{[a-z0-9]+}} +; N64: ld ${{[0-9]+}}, %call_lo(memcpy)($[[R3]]) + + %0 = bitcast i32* %d to i8* + %1 = bitcast i32* %s to i8* + tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 %n, i32 4, i1 false) + ret void +} + +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind diff --git a/test/MC/Mips/xgot.ll b/test/MC/Mips/xgot.ll new file mode 100644 index 0000000000..bfe9b9ad66 --- /dev/null +++ b/test/MC/Mips/xgot.ll @@ -0,0 +1,42 @@ +; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux -mxgot %s -o - | elf-dump --dump-section-data | FileCheck %s + +@.str = private unnamed_addr constant [16 x i8] c"ext_1=%d, i=%d\0A\00", align 1 +@ext_1 = external global i32 + +define void @fill() nounwind { +entry: + +; Check that the appropriate relocations were created. +; For the xgot case we want to see R_MIPS_[GOT|CALL]_[HI|LO]16. + +; R_MIPS_HI16 +; CHECK: ('r_type', 0x05) + +; R_MIPS_LO16 +; CHECK: ('r_type', 0x06) + +; R_MIPS_GOT_HI16 +; CHECK: ('r_type', 0x16) + +; R_MIPS_GOT_LO16 +; CHECK: ('r_type', 0x17) + +; R_MIPS_GOT +; CHECK: ('r_type', 0x09) + +; R_MIPS_LO16 +; CHECK: ('r_type', 0x06) + +; R_MIPS_CALL_HI16 +; CHECK: ('r_type', 0x1e) + +; R_MIPS_CALL_LO16 +; CHECK: ('r_type', 0x1f) + + %0 = load i32* @ext_1, align 4 + %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 x i8]* @.str, i32 0, i32 0), i32 %0) nounwind + ret void +} + +declare i32 @printf(i8* nocapture, ...) nounwind + |