1238b6a9d33bf87e23f86866885394cd453a06495Rafael Espindola// RUN: %clang -target mipsel-unknown-linux -S -o - -emit-llvm %s \ 26e8686794e12b76f822fa71266a2cd76459e6a9aJack Carter// RUN: | FileCheck %s 30ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher 40ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher// This checks that the frontend will accept inline asm constraints 5d2ab6d371e2bb93ced857041b9173ad50bbcbfcdJack Carter// c', 'l' and 'x'. 60ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher 70ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopherint main() 80ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher{ 90ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // 'c': 16 bit address register for Mips16, GPR for all others 100ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // I am using 'c' to constrain both the target and one of the source 110ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // registers. We are looking for syntactical correctness. 124e1125f630e75a52209b928e9d43b638abf39987Bill Wendling // 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]+}} 130ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher int __s, __v = 17; 140ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher int __t; 150ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher __asm__ __volatile__( 160ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher "addi %0,%1,%2 \n\t\t" 170ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "=c" (__t) 180ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "c" (__s), "I" (__v)); 190ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher 200ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // 'l': lo register 210ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // We are making it clear that destination register is lo with the 220ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // use of the 'l' constraint ("=l"). 234e1125f630e75a52209b928e9d43b638abf39987Bill Wendling // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "mtlo $1 \0A\09\09", "=l,r,~{lo}"(i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}} 240ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher int i_temp = 44; 250ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher int i_result; 260ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher __asm__ __volatile__( 270ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher "mtlo %1 \n\t\t" 280ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "=l" (i_result) 290ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "r" (i_temp) 300ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "lo"); 310ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher 320ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // 'x': Combined lo/hi registers 330ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // We are specifying that destination registers are the hi/lo pair with the 340ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher // use of the 'x' constraint ("=x"). 354e1125f630e75a52209b928e9d43b638abf39987Bill Wendling // 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]+}} 360ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher int i_hi = 3; 370ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher int i_lo = 2; 380ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher long long ll_result = 0; 390ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher __asm__ __volatile__( 400ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher "mthi %1 \n\t\t" 410ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher "mtlo %2 \n\t\t" 420ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "=x" (ll_result) 430ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : "r" (i_hi), "r" (i_lo) 440ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher : ); 456e8686794e12b76f822fa71266a2cd76459e6a9aJack Carter 460ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher return 0; 470ea6164a7ff685f64ddfe3ec983a2b052ea91afbEric Christopher} 484e1125f630e75a52209b928e9d43b638abf39987Bill Wendling 494e1125f630e75a52209b928e9d43b638abf39987Bill Wendling// CHECK: attributes [[NUW]] = { nounwind } 50