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