Eli Friedman | 6d7cfd7 | 2010-07-16 00:55:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s |
| 2 | // PR3800 |
| 3 | int *foo(void); |
| 4 | |
| 5 | // CHECK: @test1 |
| 6 | void test1() { |
| 7 | // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo() |
| 8 | // CHECK: call void asm "foobar", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* [[REGCALLRESULT]], i32* [[REGCALLRESULT]]) |
| 9 | asm ("foobar" : "+m"(*foo())); |
| 10 | } |
| 11 | |
| 12 | // CHECK: @test2 |
| 13 | void test2() { |
| 14 | // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo() |
| 15 | // CHECK: load i32* [[REGCALLRESULT]] |
| 16 | // CHECK: call i32 asm |
| 17 | // CHECK: store i32 {{%[a-zA-Z0-9\.]+}}, i32* [[REGCALLRESULT]] |
| 18 | asm ("foobar" : "+r"(*foo())); |
| 19 | } |
John Thompson | 2f474ea | 2010-09-18 01:15:13 +0000 | [diff] [blame] | 20 | |
| 21 | // PR7338 |
Bill Wendling | 263e0a6 | 2012-03-22 23:34:01 +0000 | [diff] [blame] | 22 | // CHECK: @test3 |
John Thompson | 2f474ea | 2010-09-18 01:15:13 +0000 | [diff] [blame] | 23 | void test3(int *vout, int vin) |
| 24 | { |
Eric Christopher | cfd323d | 2011-06-21 00:05:20 +0000 | [diff] [blame] | 25 | // CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}" |
Bill Wendling | 263e0a6 | 2012-03-22 23:34:01 +0000 | [diff] [blame] | 26 | asm ("opr %[vout],%[vin]" |
| 27 | : [vout] "=r,=m,=r" (*vout) |
| 28 | : [vin] "r,m,r" (vin) |
| 29 | : "edi"); |
John Thompson | 2f474ea | 2010-09-18 01:15:13 +0000 | [diff] [blame] | 30 | } |
Chris Lattner | 935f0f0 | 2011-02-21 22:09:29 +0000 | [diff] [blame] | 31 | |
| 32 | // PR8959 - This should implicitly truncate the immediate to a byte. |
Bill Wendling | 263e0a6 | 2012-03-22 23:34:01 +0000 | [diff] [blame] | 33 | // CHECK: @test4 |
Chris Lattner | 935f0f0 | 2011-02-21 22:09:29 +0000 | [diff] [blame] | 34 | int test4(volatile int *addr) { |
| 35 | unsigned char oldval; |
Bill Wendling | 263e0a6 | 2012-03-22 23:34:01 +0000 | [diff] [blame] | 36 | // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1) |
Chris Lattner | 935f0f0 | 2011-02-21 22:09:29 +0000 | [diff] [blame] | 37 | __asm__ ("frob %0" : "=r"(oldval) : "0"(0xff)); |
| 38 | return (int)oldval; |
Chris Lattner | 935f0f0 | 2011-02-21 22:09:29 +0000 | [diff] [blame] | 39 | } |
Bill Wendling | acb5310 | 2012-03-22 23:25:07 +0000 | [diff] [blame] | 40 | |
| 41 | // <rdar://problem/10919182> - This should have both inputs be of type x86_mmx. |
| 42 | // CHECK: @test5 |
| 43 | typedef long long __m64 __attribute__((__vector_size__(8))); |
| 44 | __m64 test5(__m64 __A, __m64 __B) { |
Bill Wendling | 8ff6059 | 2012-03-22 23:32:07 +0000 | [diff] [blame] | 45 | // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}}) |
Bill Wendling | 263e0a6 | 2012-03-22 23:34:01 +0000 | [diff] [blame] | 46 | asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B)); |
Bill Wendling | acb5310 | 2012-03-22 23:25:07 +0000 | [diff] [blame] | 47 | return __A; |
| 48 | } |