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 |
Jack Carter | d2ab6d3 | 2013-03-04 21:36:11 +0000 | [diff] [blame^] | 5 | // c', 'l' and 'x'. |
Eric Christopher | 0ea6164 | 2012-04-03 01:16:32 +0000 | [diff] [blame] | 6 | |
| 7 | int main() |
| 8 | { |
| 9 | // 'c': 16 bit address register for Mips16, GPR for all others |
| 10 | // I am using 'c' to constrain both the target and one of the source |
| 11 | // registers. We are looking for syntactical correctness. |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 12 | // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "addi $0,$1,$2 \0A\09\09", "=c,c,I"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW:#[0-9]+]], !srcloc !{{[0-9]+}} |
Eric Christopher | 0ea6164 | 2012-04-03 01:16:32 +0000 | [diff] [blame] | 13 | int __s, __v = 17; |
| 14 | int __t; |
| 15 | __asm__ __volatile__( |
| 16 | "addi %0,%1,%2 \n\t\t" |
| 17 | : "=c" (__t) |
| 18 | : "c" (__s), "I" (__v)); |
| 19 | |
| 20 | // 'l': lo register |
| 21 | // We are making it clear that destination register is lo with the |
| 22 | // use of the 'l' constraint ("=l"). |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 23 | // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "mtlo $1 \0A\09\09", "=l,r,~{lo}"(i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}} |
Eric Christopher | 0ea6164 | 2012-04-03 01:16:32 +0000 | [diff] [blame] | 24 | int i_temp = 44; |
| 25 | int i_result; |
| 26 | __asm__ __volatile__( |
| 27 | "mtlo %1 \n\t\t" |
| 28 | : "=l" (i_result) |
| 29 | : "r" (i_temp) |
| 30 | : "lo"); |
| 31 | |
| 32 | // 'x': Combined lo/hi registers |
| 33 | // We are specifying that destination registers are the hi/lo pair with the |
| 34 | // use of the 'x' constraint ("=x"). |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 35 | // 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]+}}) [[NUW]], !srcloc !{{[0-9]+}} |
Eric Christopher | 0ea6164 | 2012-04-03 01:16:32 +0000 | [diff] [blame] | 36 | int i_hi = 3; |
| 37 | int i_lo = 2; |
| 38 | long long ll_result = 0; |
| 39 | __asm__ __volatile__( |
| 40 | "mthi %1 \n\t\t" |
| 41 | "mtlo %2 \n\t\t" |
| 42 | : "=x" (ll_result) |
| 43 | : "r" (i_hi), "r" (i_lo) |
| 44 | : ); |
Jack Carter | 6e86867 | 2012-08-21 00:59:48 +0000 | [diff] [blame] | 45 | |
Eric Christopher | 0ea6164 | 2012-04-03 01:16:32 +0000 | [diff] [blame] | 46 | return 0; |
| 47 | } |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 48 | |
| 49 | // CHECK: attributes [[NUW]] = { nounwind } |