blob: c7d1aeceb92f9055f22bcf6465cf9243297ac444 [file] [log] [blame]
Eli Friedman6d7cfd72010-07-16 00:55:21 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2// PR3800
3int *foo(void);
4
5// CHECK: @test1
6void 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
13void 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 Thompson2f474ea2010-09-18 01:15:13 +000020
21// PR7338
Bill Wendling263e0a62012-03-22 23:34:01 +000022// CHECK: @test3
John Thompson2f474ea2010-09-18 01:15:13 +000023void test3(int *vout, int vin)
24{
Eric Christophercfd323d2011-06-21 00:05:20 +000025 // CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}"
Bill Wendling263e0a62012-03-22 23:34:01 +000026 asm ("opr %[vout],%[vin]"
27 : [vout] "=r,=m,=r" (*vout)
28 : [vin] "r,m,r" (vin)
29 : "edi");
John Thompson2f474ea2010-09-18 01:15:13 +000030}
Chris Lattner935f0f02011-02-21 22:09:29 +000031
32// PR8959 - This should implicitly truncate the immediate to a byte.
Bill Wendling263e0a62012-03-22 23:34:01 +000033// CHECK: @test4
Chris Lattner935f0f02011-02-21 22:09:29 +000034int test4(volatile int *addr) {
35 unsigned char oldval;
Bill Wendling263e0a62012-03-22 23:34:01 +000036 // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
Chris Lattner935f0f02011-02-21 22:09:29 +000037 __asm__ ("frob %0" : "=r"(oldval) : "0"(0xff));
38 return (int)oldval;
Chris Lattner935f0f02011-02-21 22:09:29 +000039}
Bill Wendlingacb53102012-03-22 23:25:07 +000040
41// <rdar://problem/10919182> - This should have both inputs be of type x86_mmx.
42// CHECK: @test5
43typedef long long __m64 __attribute__((__vector_size__(8)));
44__m64 test5(__m64 __A, __m64 __B) {
Bill Wendling8ff60592012-03-22 23:32:07 +000045 // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}})
Bill Wendling263e0a62012-03-22 23:34:01 +000046 asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
Bill Wendlingacb53102012-03-22 23:25:07 +000047 return __A;
48}