1//===-- sync_synchronize - Implement memory barrier * ----------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "../assembly.h"
10
11// When compiling a use of the gcc built-in __sync_synchronize() in thumb1 mode
12// the compiler may emit a call to __sync_synchronize.
13// On Darwin the implementation jumps to an OS supplied function named
14// OSMemoryBarrier
15
16	.text
17	.syntax unified
18
19#if __APPLE__
20
21	.p2align 2
22DEFINE_COMPILERRT_PRIVATE_FUNCTION(__sync_synchronize)
23	stmfd	sp!, {r7, lr}
24	add		r7, sp, #0
25	bl		_OSMemoryBarrier
26	ldmfd	sp!, {r7, pc}
27END_COMPILERRT_FUNCTION(__sync_synchronize)
28
29	// tell linker it can break up file at label boundaries
30	.subsections_via_symbols
31
32#endif
33
34NO_EXEC_STACK_DIRECTIVE
35
36