blob: 3d8e50dc8ad992895e302ffc42c76cf506c3acf4 [file] [log] [blame]
Daniel Dunbar19336a22009-10-27 17:49:50 +00001/* ===-- assembly.h - compiler-rt assembler support macros -----------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
Howard Hinnant9ad441f2010-11-16 22:13:33 +00005 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
Daniel Dunbar19336a22009-10-27 17:49:50 +00007 *
8 * ===----------------------------------------------------------------------===
9 *
10 * This file defines macros for use in compiler-rt assembler source.
11 * This file is not part of the interface of this library.
12 *
13 * ===----------------------------------------------------------------------===
14 */
15
16#ifndef COMPILERRT_ASSEMBLY_H
17#define COMPILERRT_ASSEMBLY_H
18
Daniel Dunbar19336a22009-10-27 17:49:50 +000019#if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
Daniel Dunbar19336a22009-10-27 17:49:50 +000020#define SEPARATOR @
Daniel Dunbar19336a22009-10-27 17:49:50 +000021#else
Daniel Dunbar19336a22009-10-27 17:49:50 +000022#define SEPARATOR ;
Daniel Dunbar4c01bb72010-01-18 22:19:25 +000023#endif
Daniel Dunbar19336a22009-10-27 17:49:50 +000024
Daniel Dunbar4c01bb72010-01-18 22:19:25 +000025#if defined(__APPLE__)
Anton Korobeynikov647fc732011-04-19 17:50:09 +000026#define HIDDEN_DIRECTIVE .private_extern
27#define LOCAL_LABEL(name) L_##name
Nick Kledzikeb1b5f32012-07-11 19:21:39 +000028#define FILE_LEVEL_DIRECTIVE .subsections_via_symbols
Daniel Dunbar4c01bb72010-01-18 22:19:25 +000029#else
Anton Korobeynikov647fc732011-04-19 17:50:09 +000030#define HIDDEN_DIRECTIVE .hidden
31#define LOCAL_LABEL(name) .L_##name
Nick Kledzikeb1b5f32012-07-11 19:21:39 +000032#define FILE_LEVEL_DIRECTIVE
Daniel Dunbar19336a22009-10-27 17:49:50 +000033#endif
34
Anton Korobeynikove2949352011-04-19 21:22:14 +000035#define GLUE2(a, b) a ## b
36#define GLUE(a, b) GLUE2(a, b)
37#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
38
Bob Wilson36c24252012-02-10 16:41:46 +000039#ifdef VISIBILITY_HIDDEN
Bob Wilson41ae71d2011-08-22 21:49:47 +000040#define DECLARE_SYMBOL_VISIBILITY(name) \
Bob Wilson36c24252012-02-10 16:41:46 +000041 HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR
Daniel Dunbar6a571fb2010-01-18 22:19:34 +000042#else
Bob Wilson41ae71d2011-08-22 21:49:47 +000043#define DECLARE_SYMBOL_VISIBILITY(name)
44#endif
45
Anton Korobeynikov647fc732011-04-19 17:50:09 +000046#define DEFINE_COMPILERRT_FUNCTION(name) \
Nick Kledzikeb1b5f32012-07-11 19:21:39 +000047 FILE_LEVEL_DIRECTIVE SEPARATOR \
Anton Korobeynikov647fc732011-04-19 17:50:09 +000048 .globl SYMBOL_NAME(name) SEPARATOR \
Bob Wilson36c24252012-02-10 16:41:46 +000049 DECLARE_SYMBOL_VISIBILITY(name) \
Daniel Dunbar19336a22009-10-27 17:49:50 +000050 SYMBOL_NAME(name):
51
Anton Korobeynikov647fc732011-04-19 17:50:09 +000052#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \
53 .globl SYMBOL_NAME(name) SEPARATOR \
54 HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR \
Daniel Dunbar19336a22009-10-27 17:49:50 +000055 SYMBOL_NAME(name):
56
Daniel Dunbare136da92010-01-18 22:19:20 +000057#define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
Anton Korobeynikov647fc732011-04-19 17:50:09 +000058 .globl name SEPARATOR \
59 HIDDEN_DIRECTIVE name SEPARATOR \
Daniel Dunbare136da92010-01-18 22:19:20 +000060 name:
61
Anton Korobeynikov37b97d12011-04-19 17:51:24 +000062#define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target) \
63 .globl SYMBOL_NAME(name) SEPARATOR \
64 .set SYMBOL_NAME(name), SYMBOL_NAME(target) SEPARATOR
65
66#if defined (__ARM_EABI__)
67# define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name) \
68 DEFINE_COMPILERRT_FUNCTION_ALIAS(aeabi_name, name)
69#else
70# define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name)
71#endif
72
Daniel Dunbar19336a22009-10-27 17:49:50 +000073#endif /* COMPILERRT_ASSEMBLY_H */