@@ -1196,3 +1196,78 @@ void clear(void *p, volatile void *vp) {
11961196
11971197 // LLVM: store atomic volatile i8 0, ptr %{{.+}} seq_cst, align 1
11981198}
1199+
1200+ // CHECK-LABEL: @_Z17lock_test_and_setPii
1201+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!s32i>, {{.*}} : !s32i, seq_cst) fetch_first : !s32i
1202+
1203+ // LLVM-LABEL: @_Z17lock_test_and_setPii
1204+ // LLVM: atomicrmw xchg ptr {{.*}}, i32 {{.*}} seq_cst, align 4
1205+ void lock_test_and_set (int * a, int b) {
1206+ int c = __sync_lock_test_and_set (a, b);
1207+ }
1208+
1209+
1210+ // CHECK-LABEL: @_Z17lock_test_and_setPll
1211+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!s64i>, {{.*}} : !s64i, seq_cst) fetch_first : !s64i
1212+
1213+ // LLVM-LABEL: @_Z17lock_test_and_setPll
1214+ // LLVM: atomicrmw xchg ptr {{.*}}, i64 {{.*}} seq_cst, align 8
1215+ void lock_test_and_set (long * a, long b) {
1216+ long c = __sync_lock_test_and_set (a, b);
1217+ }
1218+
1219+ // CHECK-LABEL: @_Z17lock_test_and_setPss
1220+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!s16i>, {{.*}} : !s16i, seq_cst) fetch_first : !s16i
1221+
1222+ // LLVM-LABEL: @_Z17lock_test_and_setPss
1223+ // LLVM: atomicrmw xchg ptr {{.*}}, i16 {{.*}} seq_cst, align 2
1224+ void lock_test_and_set (short * a, short b) {
1225+ short c = __sync_lock_test_and_set (a, 2 );
1226+ }
1227+
1228+
1229+ // CHECK-LABEL: @_Z17lock_test_and_setPcc
1230+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!s8i>, {{.*}} : !s8i, seq_cst) fetch_first : !s8i
1231+
1232+ // LLVM-LABEL: @_Z17lock_test_and_setPcc
1233+ // LLVM: atomicrmw xchg ptr {{.*}}, i8 {{.*}} seq_cst, align 1
1234+ void lock_test_and_set (char * a, char b) {
1235+ char c = __sync_lock_test_and_set (a, b);
1236+ }
1237+
1238+ // CHECK-LABEL: @_Z17lock_test_and_setPji
1239+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!u32i>, {{.*}} : !u32i, seq_cst) fetch_first : !u32i
1240+
1241+ // LLVM-LABEL: @_Z17lock_test_and_setPji
1242+ // LLVM: atomicrmw xchg ptr {{.*}}, i32 {{.*}} seq_cst, align 4
1243+ void lock_test_and_set (unsigned int * a, int b) {
1244+ unsigned int c = __sync_lock_test_and_set (a, b);
1245+ }
1246+
1247+
1248+ // CHECK-LABEL: @_Z17lock_test_and_setPml
1249+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!u64i>, {{.*}} : !u64i, seq_cst) fetch_first : !u64i
1250+
1251+ // LLVM-LABEL: @_Z17lock_test_and_setPml
1252+ // LLVM: atomicrmw xchg ptr {{.*}}, i64 {{.*}} seq_cst, align 8
1253+ void lock_test_and_set (unsigned long * a, long b) {
1254+ unsigned long c = __sync_lock_test_and_set (a, b);
1255+ }
1256+
1257+ // CHECK-LABEL: @_Z17lock_test_and_setPts
1258+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!u16i>, {{.*}} : !u16i, seq_cst) fetch_first : !u16i
1259+ //
1260+ // LLVM-LABEL: @_Z17lock_test_and_setPts
1261+ // LLVM: atomicrmw xchg ptr {{.*}}, i16 {{.*}} seq_cst, align 2
1262+ void lock_test_and_set (unsigned short * a, short b) {
1263+ unsigned long long c = __sync_lock_test_and_set (a, b);
1264+ }
1265+
1266+ // CHECK-LABEL: @_Z17lock_test_and_setPhc
1267+ // CHECK: cir.atomic.fetch(xchg, {{.*}} : !cir.ptr<!u8i>, {{.*}} : !u8i, seq_cst) fetch_first : !u8i
1268+
1269+ // LLVM-LABEL: @_Z17lock_test_and_setPhc
1270+ // LLVM: atomicrmw xchg ptr {{.*}}, i8 {{.*}} seq_cst, align 1
1271+ void lock_test_and_set (unsigned char * a, char b) {
1272+ unsigned char c = __sync_lock_test_and_set (a, b);
1273+ }
0 commit comments