1*67e74705SXin Li // RUN: %clang_cc1 -triple arm-linux-gnueabi -emit-llvm %s -o - | FileCheck %s -check-prefix=ARM
2*67e74705SXin Li // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC32
3*67e74705SXin Li // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC64
4*67e74705SXin Li // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32
5*67e74705SXin Li // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64
6*67e74705SXin Li // RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARC
7*67e74705SXin Li
8*67e74705SXin Li unsigned char c1, c2;
9*67e74705SXin Li unsigned short s1, s2;
10*67e74705SXin Li unsigned int i1, i2;
11*67e74705SXin Li unsigned long long ll1, ll2;
12*67e74705SXin Li unsigned char a1[100], a2[100];
13*67e74705SXin Li
14*67e74705SXin Li enum memory_order {
15*67e74705SXin Li memory_order_relaxed,
16*67e74705SXin Li memory_order_consume,
17*67e74705SXin Li memory_order_acquire,
18*67e74705SXin Li memory_order_release,
19*67e74705SXin Li memory_order_acq_rel,
20*67e74705SXin Li memory_order_seq_cst
21*67e74705SXin Li };
22*67e74705SXin Li
test1(void)23*67e74705SXin Li void test1(void) {
24*67e74705SXin Li (void)__atomic_load(&c1, &c2, memory_order_seq_cst);
25*67e74705SXin Li (void)__atomic_store(&c1, &c2, memory_order_seq_cst);
26*67e74705SXin Li (void)__atomic_load(&s1, &s2, memory_order_seq_cst);
27*67e74705SXin Li (void)__atomic_store(&s1, &s2, memory_order_seq_cst);
28*67e74705SXin Li (void)__atomic_load(&i1, &i2, memory_order_seq_cst);
29*67e74705SXin Li (void)__atomic_store(&i1, &i2, memory_order_seq_cst);
30*67e74705SXin Li (void)__atomic_load(&ll1, &ll2, memory_order_seq_cst);
31*67e74705SXin Li (void)__atomic_store(&ll1, &ll2, memory_order_seq_cst);
32*67e74705SXin Li (void)__atomic_load(&a1, &a2, memory_order_seq_cst);
33*67e74705SXin Li (void)__atomic_store(&a1, &a2, memory_order_seq_cst);
34*67e74705SXin Li
35*67e74705SXin Li // ARM-LABEL: define{{.*}} void @test1
36*67e74705SXin Li // ARM: = call{{.*}} zeroext i8 @__atomic_load_1(i8* @c1
37*67e74705SXin Li // ARM: call{{.*}} void @__atomic_store_1(i8* @c1, i8 zeroext
38*67e74705SXin Li // ARM: = call{{.*}} zeroext i16 @__atomic_load_2(i8* bitcast (i16* @s1 to i8*)
39*67e74705SXin Li // ARM: call{{.*}} void @__atomic_store_2(i8* bitcast (i16* @s1 to i8*), i16 zeroext
40*67e74705SXin Li // ARM: = call{{.*}} i32 @__atomic_load_4(i8* bitcast (i32* @i1 to i8*)
41*67e74705SXin Li // ARM: call{{.*}} void @__atomic_store_4(i8* bitcast (i32* @i1 to i8*), i32
42*67e74705SXin Li // ARM: = call{{.*}} i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
43*67e74705SXin Li // ARM: call{{.*}} void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
44*67e74705SXin Li // ARM: call{{.*}} void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
45*67e74705SXin Li // ARM: call{{.*}} void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
46*67e74705SXin Li
47*67e74705SXin Li // PPC32-LABEL: define void @test1
48*67e74705SXin Li // PPC32: = load atomic i8, i8* @c1 seq_cst
49*67e74705SXin Li // PPC32: store atomic i8 {{.*}}, i8* @c1 seq_cst
50*67e74705SXin Li // PPC32: = load atomic i16, i16* @s1 seq_cst
51*67e74705SXin Li // PPC32: store atomic i16 {{.*}}, i16* @s1 seq_cst
52*67e74705SXin Li // PPC32: = load atomic i32, i32* @i1 seq_cst
53*67e74705SXin Li // PPC32: store atomic i32 {{.*}}, i32* @i1 seq_cst
54*67e74705SXin Li // PPC32: = call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
55*67e74705SXin Li // PPC32: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
56*67e74705SXin Li // PPC32: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
57*67e74705SXin Li // PPC32: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
58*67e74705SXin Li
59*67e74705SXin Li // PPC64-LABEL: define void @test1
60*67e74705SXin Li // PPC64: = load atomic i8, i8* @c1 seq_cst
61*67e74705SXin Li // PPC64: store atomic i8 {{.*}}, i8* @c1 seq_cst
62*67e74705SXin Li // PPC64: = load atomic i16, i16* @s1 seq_cst
63*67e74705SXin Li // PPC64: store atomic i16 {{.*}}, i16* @s1 seq_cst
64*67e74705SXin Li // PPC64: = load atomic i32, i32* @i1 seq_cst
65*67e74705SXin Li // PPC64: store atomic i32 {{.*}}, i32* @i1 seq_cst
66*67e74705SXin Li // PPC64: = load atomic i64, i64* @ll1 seq_cst
67*67e74705SXin Li // PPC64: store atomic i64 {{.*}}, i64* @ll1 seq_cst
68*67e74705SXin Li // PPC64: call void @__atomic_load(i64 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
69*67e74705SXin Li // PPC64: call void @__atomic_store(i64 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
70*67e74705SXin Li
71*67e74705SXin Li // MIPS32-LABEL: define void @test1
72*67e74705SXin Li // MIPS32: = load atomic i8, i8* @c1 seq_cst
73*67e74705SXin Li // MIPS32: store atomic i8 {{.*}}, i8* @c1 seq_cst
74*67e74705SXin Li // MIPS32: = load atomic i16, i16* @s1 seq_cst
75*67e74705SXin Li // MIPS32: store atomic i16 {{.*}}, i16* @s1 seq_cst
76*67e74705SXin Li // MIPS32: = load atomic i32, i32* @i1 seq_cst
77*67e74705SXin Li // MIPS32: store atomic i32 {{.*}}, i32* @i1 seq_cst
78*67e74705SXin Li // MIPS32: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
79*67e74705SXin Li // MIPS32: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
80*67e74705SXin Li // MIPS32: call void @__atomic_load(i32 signext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
81*67e74705SXin Li // MIPS32: call void @__atomic_store(i32 signext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
82*67e74705SXin Li
83*67e74705SXin Li // MIPS64-LABEL: define void @test1
84*67e74705SXin Li // MIPS64: = load atomic i8, i8* @c1 seq_cst
85*67e74705SXin Li // MIPS64: store atomic i8 {{.*}}, i8* @c1 seq_cst
86*67e74705SXin Li // MIPS64: = load atomic i16, i16* @s1 seq_cst
87*67e74705SXin Li // MIPS64: store atomic i16 {{.*}}, i16* @s1 seq_cst
88*67e74705SXin Li // MIPS64: = load atomic i32, i32* @i1 seq_cst
89*67e74705SXin Li // MIPS64: store atomic i32 {{.*}}, i32* @i1 seq_cst
90*67e74705SXin Li // MIPS64: = load atomic i64, i64* @ll1 seq_cst
91*67e74705SXin Li // MIPS64: store atomic i64 {{.*}}, i64* @ll1 seq_cst
92*67e74705SXin Li // MIPS64: call void @__atomic_load(i64 zeroext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0)
93*67e74705SXin Li // MIPS64: call void @__atomic_store(i64 zeroext 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
94*67e74705SXin Li
95*67e74705SXin Li // SPARC-LABEL: define void @test1
96*67e74705SXin Li // SPARC: = load atomic i8, i8* @c1 seq_cst
97*67e74705SXin Li // SPARC: store atomic i8 {{.*}}, i8* @c1 seq_cst
98*67e74705SXin Li // SPARC: = load atomic i16, i16* @s1 seq_cst
99*67e74705SXin Li // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst
100*67e74705SXin Li // SPARC: = load atomic i32, i32* @i1 seq_cst
101*67e74705SXin Li // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst
102*67e74705SXin Li // SPARC: = load atomic i64, i64* @ll1 seq_cst
103*67e74705SXin Li // SPARC: store atomic i64 {{.*}}, i64* @ll1 seq_cst
104*67e74705SXin Li // SPARC: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
105*67e74705SXin Li // SPARC: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
106*67e74705SXin Li }
107