1 //===-- sync-ops.h - --===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements outline macros for the __sync_fetch_and_*
10 // operations. Different instantiations will generate appropriate assembly for
11 // ARM and Thumb-2 versions of the functions.
13 //===----------------------------------------------------------------------===//
15 #include "../assembly.h"
17 #define SYNC_OP_4(op) \
21 DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \
24 LOCAL_LABEL(tryatomic_##op) : ldrex r0, [r12]; \
26 strex r3, r2, [r12]; \
28 bne LOCAL_LABEL(tryatomic_##op); \
32 #define SYNC_OP_8(op) \
36 DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \
37 push {r4, r5, r6, lr}; \
40 LOCAL_LABEL(tryatomic_##op) : ldrexd r0, r1, [r12]; \
41 op(r4, r5, r0, r1, r2, r3); \
42 strexd r6, r4, r5, [r12]; \
44 bne LOCAL_LABEL(tryatomic_##op); \
46 pop { r4, r5, r6, pc }
48 #define MINMAX_4(rD, rN, rM, cmp_kind) \
54 #define MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, cmp_kind) \
60 mov##cmp_kind rD_LO, rN_LO; \
61 mov##cmp_kind rD_HI, rN_HI