blob: 63ee42c0c7cd8c1a699e5b17f678456d7a60fcb2 [file] [log] [blame]
Eric Christopher1d6c89e2012-05-07 03:13:32 +00001; Positive test for inline register constraints
2;
Daniel Sanders8bb4c852014-06-11 15:48:00 +00003; RUN: llc -march=mipsel -mcpu=mips32 < %s | FileCheck %s
4; RUN: llc -march=mipsel -mcpu=mips32r2 < %s | FileCheck %s
Eric Christopher1d6c89e2012-05-07 03:13:32 +00005
6define i32 @main() nounwind {
7entry:
8
9; r with char
Daniel Sanders00a4aac2015-11-16 14:14:59 +000010;CHECK: #APP
11;CHECK: addiu ${{[0-9]+}}, ${{[0-9]+}}, 23
12;CHECK: #NO_APP
13 tail call i8 asm sideeffect "addiu $0, $1, $2", "=r,r,n"(i8 27, i8 23) nounwind
Eric Christopher1d6c89e2012-05-07 03:13:32 +000014
15; r with short
Daniel Sanders00a4aac2015-11-16 14:14:59 +000016;CHECK: #APP
17;CHECK: addiu ${{[0-9]+}}, ${{[0-9]+}}, 13
18;CHECK: #NO_APP
19 tail call i16 asm sideeffect "addiu $0, $1, $2", "=r,r,n"(i16 17, i16 13) nounwind
Eric Christopher1d6c89e2012-05-07 03:13:32 +000020
21; r with int
Daniel Sanders00a4aac2015-11-16 14:14:59 +000022;CHECK: #APP
23;CHECK: addiu ${{[0-9]+}}, ${{[0-9]+}}, 3
24;CHECK: #NO_APP
25 tail call i32 asm sideeffect "addiu $0, $1, $2", "=r,r,n"(i32 7, i32 3) nounwind
Eric Christophere3c494d2012-05-07 06:25:10 +000026
27; Now c with 1024: make sure register $25 is picked
28; CHECK: #APP
Daniel Sanders00a4aac2015-11-16 14:14:59 +000029; CHECK: addiu $25, ${{[0-9]+}}, 1024
30; CHECK: #NO_APP
31 tail call i32 asm sideeffect "addiu $0, $1, $2", "=c,c,I"(i32 4194304, i32 1024) nounwind
Eric Christophere3c494d2012-05-07 06:25:10 +000032
Eric Christopher9c492e62012-05-07 06:25:15 +000033; Now l with 1024: make sure register lo is picked. We do this by checking the instruction
34; after the inline expression for a mflo to pull the value out of lo.
Toma Tabacua23f13c2014-12-17 10:56:16 +000035; CHECK: #APP
36; CHECK: mtlo ${{[0-9]+}}
Daniel Sanders00a4aac2015-11-16 14:14:59 +000037; CHECK-NEXT: madd ${{[0-9]+}}, ${{[0-9]+}}
Toma Tabacua23f13c2014-12-17 10:56:16 +000038; CHECK: #NO_APP
Daniel Sanders00a4aac2015-11-16 14:14:59 +000039; CHECK-NEXT: mflo ${{[0-9]+}}
Eric Christopher9c492e62012-05-07 06:25:15 +000040 %bosco = alloca i32, align 4
Daniel Sanders00a4aac2015-11-16 14:14:59 +000041 call i32 asm sideeffect "\09mtlo $3 \0A\09\09madd $1, $2 ", "=l,r,r,r"(i32 7, i32 6, i32 44) nounwind
Eric Christopher9c492e62012-05-07 06:25:15 +000042 store volatile i32 %4, i32* %bosco, align 4
43
Eric Christopher1d6c89e2012-05-07 03:13:32 +000044 ret i32 0
45}