summaryrefslogtreecommitdiff
path: root/lib/assembly.h
blob: 3d8e50dc8ad992895e302ffc42c76cf506c3acf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* ===-- assembly.h - compiler-rt assembler support macros -----------------===
 *
 *                     The LLVM Compiler Infrastructure
 *
 * This file is dual licensed under the MIT and the University of Illinois Open
 * Source Licenses. See LICENSE.TXT for details.
 *
 * ===----------------------------------------------------------------------===
 *
 * This file defines macros for use in compiler-rt assembler source.
 * This file is not part of the interface of this library.
 *
 * ===----------------------------------------------------------------------===
 */

#ifndef COMPILERRT_ASSEMBLY_H
#define COMPILERRT_ASSEMBLY_H

#if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
#define SEPARATOR @
#else
#define SEPARATOR ;
#endif

#if defined(__APPLE__)
#define HIDDEN_DIRECTIVE .private_extern
#define LOCAL_LABEL(name) L_##name
#define FILE_LEVEL_DIRECTIVE  .subsections_via_symbols
#else
#define HIDDEN_DIRECTIVE .hidden
#define LOCAL_LABEL(name) .L_##name
#define FILE_LEVEL_DIRECTIVE  
#endif

#define GLUE2(a, b) a ## b
#define GLUE(a, b) GLUE2(a, b)
#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)

#ifdef VISIBILITY_HIDDEN
#define DECLARE_SYMBOL_VISIBILITY(name)                    \
  HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR
#else
#define DECLARE_SYMBOL_VISIBILITY(name)
#endif

#define DEFINE_COMPILERRT_FUNCTION(name)                   \
  FILE_LEVEL_DIRECTIVE     SEPARATOR                       \
  .globl SYMBOL_NAME(name) SEPARATOR                       \
  DECLARE_SYMBOL_VISIBILITY(name)                          \
  SYMBOL_NAME(name):

#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name)           \
  .globl SYMBOL_NAME(name) SEPARATOR                       \
  HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR             \
  SYMBOL_NAME(name):

#define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
  .globl name SEPARATOR                                    \
  HIDDEN_DIRECTIVE name SEPARATOR                          \
  name:

#define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target)     \
  .globl SYMBOL_NAME(name) SEPARATOR                       \
  .set SYMBOL_NAME(name), SYMBOL_NAME(target) SEPARATOR

#if defined (__ARM_EABI__)
# define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name)      \
  DEFINE_COMPILERRT_FUNCTION_ALIAS(aeabi_name, name)
#else
# define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name)
#endif

#endif /* COMPILERRT_ASSEMBLY_H */