d24abae55404c3d8a5134fbce778ed01dae307e5
[oota-llvm.git] / test / CodeGen / Mips / cconv / return.ll
1 ; RUN: llc -march=mips -relocation-model=static < %s | FileCheck --check-prefix=ALL --check-prefix=O32 %s
2 ; RUN: llc -march=mipsel -relocation-model=static < %s | FileCheck --check-prefix=ALL --check-prefix=O32 %s
3
4 ; RUN-TODO: llc -march=mips64 -relocation-model=static -mattr=-n64,+o32 < %s | FileCheck --check-prefix=ALL --check-prefix=O32 %s
5 ; RUN-TODO: llc -march=mips64el -relocation-model=static -mattr=-n64,+o32 < %s | FileCheck --check-prefix=ALL --check-prefix=O32 %s
6
7 ; RUN: llc -march=mips64 -relocation-model=static -mattr=-n64,+n32 < %s | FileCheck --check-prefix=ALL --check-prefix=N32 %s
8 ; RUN: llc -march=mips64el -relocation-model=static -mattr=-n64,+n32 < %s | FileCheck --check-prefix=ALL --check-prefix=N32 %s
9
10 ; RUN: llc -march=mips64 -relocation-model=static -mattr=-n64,+n64 < %s | FileCheck --check-prefix=ALL --check-prefix=N64 %s
11 ; RUN: llc -march=mips64el -relocation-model=static -mattr=-n64,+n64 < %s | FileCheck --check-prefix=ALL --check-prefix=N64 %s
12
13 ; Test the integer returns for all ABI's and byte orders as specified by
14 ; section 5 of MD00305 (MIPS ABIs Described).
15 ;
16 @byte = global i8 zeroinitializer
17 @word = global i32 zeroinitializer
18 @dword = global i64 zeroinitializer
19 @float = global float zeroinitializer
20 @double = global double zeroinitializer
21
22 define i8 @reti8() nounwind {
23 entry:
24         %0 = load volatile i8* @byte
25         ret i8 %0
26 }
27
28 ; ALL-LABEL: reti8:
29 ; O32-DAG:           lui [[R1:\$[0-9]+]], %hi(byte)
30 ; O32-DAG:           lbu $2, %lo(byte)([[R1]])
31 ; N32-DAG:           lui [[R1:\$[0-9]+]], %hi(byte)
32 ; N32-DAG:           lbu $2, %lo(byte)([[R1]])
33 ; N64-DAG:           ld  [[R1:\$[0-9]+]], %got_disp(byte)($1)
34 ; N64-DAG:           lbu $2, 0([[R1]])
35
36 define i32 @reti32() nounwind {
37 entry:
38         %0 = load volatile i32* @word
39         ret i32 %0
40 }
41
42 ; ALL-LABEL: reti32:
43 ; O32-DAG:           lui [[R1:\$[0-9]+]], %hi(word)
44 ; O32-DAG:           lw $2, %lo(word)([[R1]])
45 ; N32-DAG:           lui [[R1:\$[0-9]+]], %hi(word)
46 ; N32-DAG:           lw $2, %lo(word)([[R1]])
47 ; N64-DAG:           ld  [[R1:\$[0-9]+]], %got_disp(word)($1)
48 ; N64-DAG:           lw $2, 0([[R1]])
49
50 define i64 @reti64() nounwind {
51 entry:
52         %0 = load volatile i64* @dword
53         ret i64 %0
54 }
55
56 ; ALL-LABEL: reti64:
57 ; On O32, we must use v0 and v1 for the return value
58 ; O32-DAG:           lw $2, %lo(dword)([[R1:\$[0-9]+]])
59 ; O32-DAG:           addiu [[R2:\$[0-9]+]], [[R1]], %lo(dword)
60 ; O32-DAG:           lw $3, 4([[R2]])
61 ; N32-DAG:           ld $2, %lo(dword)([[R1:\$[0-9]+]])
62 ; N64-DAG:           ld  [[R1:\$[0-9]+]], %got_disp(dword)([[R1:\$[0-9]+]])
63 ; N64-DAG:           ld $2, 0([[R1]])