1; RUN: llc < %s -march=mipsel -mcpu=mips32 -O0 -relocation-model=pic \
2; RUN:     -fast-isel-abort=1 -verify-machineinstrs | FileCheck %s \
3; RUN:     -check-prefix=ALL -check-prefix=32R1
4; RUN: llc < %s -march=mipsel -mcpu=mips32r2 -O0 -relocation-model=pic \
5; RUN:     -fast-isel-abort=1 -verify-machineinstrs | FileCheck %s \
6; RUN:     -check-prefix=ALL -check-prefix=32R2
7
8@str = private unnamed_addr constant [12 x i8] c"hello there\00", align 1
9@src = global i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i32 0, i32 0), align 4
10@i = global i32 12, align 4
11@dest = common global [50 x i8] zeroinitializer, align 1
12
13declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1)
14declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1)
15declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1)
16
17define void @cpy(i8* %src, i32 %i) {
18  ; ALL-LABEL:  cpy:
19
20  ; ALL-DAG:        lw    $[[T0:[0-9]+]], %got(dest)(${{[0-9]+}})
21  ; ALL-DAG:        sw    $4, 24($sp)
22  ; ALL-DAG:        move  $4, $[[T0]]
23  ; ALL-DAG:        sw    $5, 20($sp)
24  ; ALL-DAG:        lw    $[[T1:[0-9]+]], 24($sp)
25  ; ALL-DAG:        move  $5, $[[T1]]
26  ; ALL-DAG:        lw    $6, 20($sp)
27  ; ALL-DAG:        lw    $[[T2:[0-9]+]], %got(memcpy)(${{[0-9]+}})
28  ; ALL:            jalr  $[[T2]]
29  ; ALL-NEXT:       nop
30  ; ALL-NOT:        {{.*}}$2{{.*}}
31  call void @llvm.memcpy.p0i8.p0i8.i32(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dest, i32 0, i32 0),
32                                       i8* %src, i32 %i, i32 1, i1 false)
33  ret void
34}
35
36define void @mov(i8* %src, i32 %i) {
37  ; ALL-LABEL:  mov:
38
39
40  ; ALL-DAG:        lw    $[[T0:[0-9]+]], %got(dest)(${{[0-9]+}})
41  ; ALL-DAG:        sw    $4, 24($sp)
42  ; ALL-DAG:        move  $4, $[[T0]]
43  ; ALL-DAG:        sw    $5, 20($sp)
44  ; ALL-DAG:        lw    $[[T1:[0-9]+]], 24($sp)
45  ; ALL-DAG:        move  $5, $[[T1]]
46  ; ALL-DAG:        lw    $6, 20($sp)
47  ; ALL-DAG:        lw    $[[T2:[0-9]+]], %got(memmove)(${{[0-9]+}})
48  ; ALL:            jalr  $[[T2]]
49  ; ALL-NEXT:       nop
50  ; ALL-NOT:        {{.*}}$2{{.*}}
51  call void @llvm.memmove.p0i8.p0i8.i32(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dest, i32 0, i32 0),
52                                        i8* %src, i32 %i, i32 1, i1 false)
53  ret void
54}
55
56define void @clear(i32 %i) {
57  ; ALL-LABEL:  clear:
58
59  ; ALL-DAG:        lw    $[[T0:[0-9]+]], %got(dest)(${{[0-9]+}})
60  ; ALL-DAG:        sw    $4, 16($sp)
61  ; ALL-DAG:        move  $4, $[[T0]]
62  ; ALL-DAG:        addiu $[[T1:[0-9]+]], $zero, 42
63  ; 32R1-DAG:       sll   $[[T2:[0-9]+]], $[[T1]], 24
64  ; 32R1-DAG:       sra   $5, $[[T2]], 24
65  ; 32R2-DAG:       seb   $5, $[[T1]]
66  ; ALL-DAG:        lw    $6, 16($sp)
67  ; ALL-DAG:        lw    $[[T2:[0-9]+]], %got(memset)(${{[0-9]+}})
68  ; ALL:            jalr  $[[T2]]
69  ; ALL-NEXT:       nop
70  ; ALL-NOT:        {{.*}}$2{{.*}}
71  call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @dest, i32 0, i32 0),
72                                  i8 42, i32 %i, i32 1, i1 false)
73  ret void
74}
75