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