1f4a2713aSLionel Sambuc // RUN: %clang -target mipsel-unknown-linux -S -o - -emit-llvm %s \
2f4a2713aSLionel Sambuc // RUN: | FileCheck %s
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc // This checks that the frontend will accept inline asm constraints
5f4a2713aSLionel Sambuc // c', 'l' and 'x'.
6f4a2713aSLionel Sambuc
main()7f4a2713aSLionel Sambuc int main()
8f4a2713aSLionel Sambuc {
9f4a2713aSLionel Sambuc // 'c': 16 bit address register for Mips16, GPR for all others
10f4a2713aSLionel Sambuc // I am using 'c' to constrain both the target and one of the source
11f4a2713aSLionel Sambuc // registers. We are looking for syntactical correctness.
12*0a6a1f1dSLionel Sambuc // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "addi $0,$1,$2 \0A\09\09", "=c,c,I,~{$1}"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW:#[0-9]+]], !srcloc !{{[0-9]+}}
13f4a2713aSLionel Sambuc int __s, __v = 17;
14f4a2713aSLionel Sambuc int __t;
15f4a2713aSLionel Sambuc __asm__ __volatile__(
16f4a2713aSLionel Sambuc "addi %0,%1,%2 \n\t\t"
17f4a2713aSLionel Sambuc : "=c" (__t)
18f4a2713aSLionel Sambuc : "c" (__s), "I" (__v));
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc // 'l': lo register
21f4a2713aSLionel Sambuc // We are making it clear that destination register is lo with the
22f4a2713aSLionel Sambuc // use of the 'l' constraint ("=l").
23*0a6a1f1dSLionel Sambuc // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "mtlo $1 \0A\09\09", "=l,r,~{lo},~{$1}"(i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}}
24f4a2713aSLionel Sambuc int i_temp = 44;
25f4a2713aSLionel Sambuc int i_result;
26f4a2713aSLionel Sambuc __asm__ __volatile__(
27f4a2713aSLionel Sambuc "mtlo %1 \n\t\t"
28f4a2713aSLionel Sambuc : "=l" (i_result)
29f4a2713aSLionel Sambuc : "r" (i_temp)
30f4a2713aSLionel Sambuc : "lo");
31f4a2713aSLionel Sambuc
32f4a2713aSLionel Sambuc // 'x': Combined lo/hi registers
33f4a2713aSLionel Sambuc // We are specifying that destination registers are the hi/lo pair with the
34f4a2713aSLionel Sambuc // use of the 'x' constraint ("=x").
35*0a6a1f1dSLionel Sambuc // CHECK: %{{[0-9]+}} = call i64 asm sideeffect "mthi $1 \0A\09\09mtlo $2 \0A\09\09", "=x,r,r,~{$1}"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}}
36f4a2713aSLionel Sambuc int i_hi = 3;
37f4a2713aSLionel Sambuc int i_lo = 2;
38f4a2713aSLionel Sambuc long long ll_result = 0;
39f4a2713aSLionel Sambuc __asm__ __volatile__(
40f4a2713aSLionel Sambuc "mthi %1 \n\t\t"
41f4a2713aSLionel Sambuc "mtlo %2 \n\t\t"
42f4a2713aSLionel Sambuc : "=x" (ll_result)
43f4a2713aSLionel Sambuc : "r" (i_hi), "r" (i_lo)
44f4a2713aSLionel Sambuc : );
45f4a2713aSLionel Sambuc
46f4a2713aSLionel Sambuc return 0;
47f4a2713aSLionel Sambuc }
48f4a2713aSLionel Sambuc
49f4a2713aSLionel Sambuc // CHECK: attributes [[NUW]] = { nounwind }
50