2022-04-07 18:03:55 +08:00
|
|
|
// RUN: %clang_cc1 -no-opaque-pointers -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
|
2010-07-16 08:55:21 +08:00
|
|
|
// PR3800
|
|
|
|
int *foo(void);
|
|
|
|
|
|
|
|
// CHECK: @test1
|
2022-02-15 22:27:12 +08:00
|
|
|
void test1(void) {
|
2010-07-16 08:55:21 +08:00
|
|
|
// CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo()
|
2022-01-05 22:16:24 +08:00
|
|
|
// CHECK: call void asm "foobar", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* elementtype(i32) [[REGCALLRESULT]], i32* elementtype(i32) [[REGCALLRESULT]])
|
2010-07-16 08:55:21 +08:00
|
|
|
asm ("foobar" : "+m"(*foo()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @test2
|
2022-02-15 22:27:12 +08:00
|
|
|
void test2(void) {
|
2010-07-16 08:55:21 +08:00
|
|
|
// CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo()
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32* [[REGCALLRESULT]]
|
2010-07-16 08:55:21 +08:00
|
|
|
// CHECK: call i32 asm
|
|
|
|
// CHECK: store i32 {{%[a-zA-Z0-9\.]+}}, i32* [[REGCALLRESULT]]
|
|
|
|
asm ("foobar" : "+r"(*foo()));
|
|
|
|
}
|
2010-09-18 09:15:13 +08:00
|
|
|
|
|
|
|
// PR7338
|
2012-03-23 07:34:01 +08:00
|
|
|
// CHECK: @test3
|
2010-09-18 09:15:13 +08:00
|
|
|
void test3(int *vout, int vin)
|
|
|
|
{
|
2011-06-21 08:05:20 +08:00
|
|
|
// CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}"
|
2012-03-23 07:34:01 +08:00
|
|
|
asm ("opr %[vout],%[vin]"
|
|
|
|
: [vout] "=r,=m,=r" (*vout)
|
|
|
|
: [vin] "r,m,r" (vin)
|
|
|
|
: "edi");
|
2010-09-18 09:15:13 +08:00
|
|
|
}
|
2011-02-22 06:09:29 +08:00
|
|
|
|
|
|
|
// PR8959 - This should implicitly truncate the immediate to a byte.
|
2012-03-23 07:34:01 +08:00
|
|
|
// CHECK: @test4
|
2011-02-22 06:09:29 +08:00
|
|
|
int test4(volatile int *addr) {
|
|
|
|
unsigned char oldval;
|
2012-03-23 07:34:01 +08:00
|
|
|
// CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
|
2011-02-22 06:09:29 +08:00
|
|
|
__asm__ ("frob %0" : "=r"(oldval) : "0"(0xff));
|
|
|
|
return (int)oldval;
|
|
|
|
}
|
2012-03-23 07:25:07 +08:00
|
|
|
|
|
|
|
// <rdar://problem/10919182> - This should have both inputs be of type x86_mmx.
|
|
|
|
// CHECK: @test5
|
|
|
|
typedef long long __m64 __attribute__((__vector_size__(8)));
|
|
|
|
__m64 test5(__m64 __A, __m64 __B) {
|
2012-03-23 07:32:07 +08:00
|
|
|
// CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}})
|
2012-03-23 07:34:01 +08:00
|
|
|
asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
|
2012-03-23 07:25:07 +08:00
|
|
|
return __A;
|
|
|
|
}
|
2019-03-15 03:46:51 +08:00
|
|
|
|
|
|
|
// CHECK: @test6
|
|
|
|
int test6(void) {
|
|
|
|
typedef unsigned char __attribute__((vector_size(8))) _m64u8;
|
|
|
|
_m64u8 __attribute__((aligned(16))) Mu8_0, __attribute__((aligned(16))) Mu8_1;
|
|
|
|
// CHECK: call x86_mmx asm "nop", "=y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %1)
|
|
|
|
asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));
|
|
|
|
return 0;
|
|
|
|
}
|