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