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