blob: 8398cb0e38e75a81c6ecbdd6e7d18d6a5a91fc57 [file] [log] [blame]
Eric Christopher05b7a502012-05-10 21:48:22 +00001; Positive test for inline register constraints
2;
Jack Carter244a84e2012-07-05 23:58:21 +00003; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=LITTLE
4; RUN: llc -march=mips < %s | FileCheck %s -check-prefix=BIG
Eric Christopher05b7a502012-05-10 21:48:22 +00005
Jack Carter244a84e2012-07-05 23:58:21 +00006%union.u_tag = type { i64 }
7%struct.anon = type { i32, i32 }
8@uval = common global %union.u_tag zeroinitializer, align 8
Eric Christopher05b7a502012-05-10 21:48:22 +00009define i32 @main() nounwind {
10entry:
11
12; X with -3
Jack Carter244a84e2012-07-05 23:58:21 +000013;LITTLE: #APP
14;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},0xfffffffffffffffd
15;LITTLE: #NO_APP
Eric Christopher05b7a502012-05-10 21:48:22 +000016 tail call i32 asm sideeffect "addi $0,$1,${2:X}", "=r,r,I"(i32 7, i32 -3) nounwind
17
Eric Christopher550c25e2012-05-18 17:39:35 +000018; x with -3
Jack Carter244a84e2012-07-05 23:58:21 +000019;LITTLE: #APP
20;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},0xfffd
21;LITTLE: #NO_APP
Eric Christopher550c25e2012-05-18 17:39:35 +000022 tail call i32 asm sideeffect "addi $0,$1,${2:x}", "=r,r,I"(i32 7, i32 -3) nounwind
23
Eric Christopher75f89b52012-05-19 00:51:56 +000024; d with -3
Jack Carter244a84e2012-07-05 23:58:21 +000025;LITTLE: #APP
26;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},-3
27;LITTLE: #NO_APP
Eric Christopher75f89b52012-05-19 00:51:56 +000028 tail call i32 asm sideeffect "addi $0,$1,${2:d}", "=r,r,I"(i32 7, i32 -3) nounwind
29
Eric Christopher6ab75b42012-05-30 19:05:19 +000030; m with -3
Jack Carter244a84e2012-07-05 23:58:21 +000031;LITTLE: #APP
32;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},-4
33;LITTLE: #NO_APP
Eric Christopher6ab75b42012-05-30 19:05:19 +000034 tail call i32 asm sideeffect "addi $0,$1,${2:m}", "=r,r,I"(i32 7, i32 -3) nounwind
35
Jack Carter7c3cd4d2012-06-28 01:33:40 +000036; z with -3
Jack Carter244a84e2012-07-05 23:58:21 +000037;LITTLE: #APP
38;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},-3
39;LITTLE: #NO_APP
Jack Carter7c3cd4d2012-06-28 01:33:40 +000040 tail call i32 asm sideeffect "addi $0,$1,${2:z}", "=r,r,I"(i32 7, i32 -3) nounwind
41
42; z with 0
Jack Carter244a84e2012-07-05 23:58:21 +000043;LITTLE: #APP
44;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},$0
45;LITTLE: #NO_APP
Jack Carter7c3cd4d2012-06-28 01:33:40 +000046 tail call i32 asm sideeffect "addi $0,$1,${2:z}", "=r,r,I"(i32 7, i32 0) nounwind
47
Jack Carter10de0252012-07-02 23:35:23 +000048; a long long in 32 bit mode (use to assert)
Jack Carter244a84e2012-07-05 23:58:21 +000049;LITTLE: #APP
50;LITTLE: addi ${{[0-9]+}},${{[0-9]+}},3
51;LITTLE: #NO_APP
Jack Carter10de0252012-07-02 23:35:23 +000052 tail call i64 asm sideeffect "addi $0,$1,$2 \0A\09", "=r,r,X"(i64 1229801703532086340, i64 3) nounwind
53
Jack Carter244a84e2012-07-05 23:58:21 +000054; D, in little endian the source reg will be 4 bytes into the long long
55;LITTLE: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
56;LITTLE: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
57;LITTLE-NEXT: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
58;LITTLE: #APP
59;LITTLE: or ${{[0-9]+}},$[[SECOND]],${{[0-9]+}}
60;LITTLE: #NO_APP
61
62; D, in big endian the source reg will also be 4 bytes into the long long
63;BIG: #APP
64;BIG: #APP
65;BIG: #APP
66;BIG: #APP
67;BIG: #APP
68;BIG: #APP
69;BIG: #APP
70;BIG: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
71;BIG: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
72;BIG-NEXT: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
73;BIG: #APP
74;BIG: or ${{[0-9]+}},$[[SECOND]],${{[0-9]+}}
75;BIG: #NO_APP
76 %7 = load i64* getelementptr inbounds (%union.u_tag* @uval, i32 0, i32 0), align 8
77 %trunc1 = trunc i64 %7 to i32
78 tail call i32 asm sideeffect "or $0,${1:D},$2", "=r,r,r"(i64 %7, i32 %trunc1) nounwind
79
Eric Christopher05b7a502012-05-10 21:48:22 +000080 ret i32 0
81}
Jack Carter244a84e2012-07-05 23:58:21 +000082