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