Home | History | Annotate | Download | only in lib
      1 /* ===-- assembly.h - compiler-rt assembler support macros -----------------===
      2  *
      3  *                     The LLVM Compiler Infrastructure
      4  *
      5  * This file is dual licensed under the MIT and the University of Illinois Open
      6  * Source Licenses. See LICENSE.TXT for details.
      7  *
      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 
     19 #if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
     20 #define SEPARATOR @
     21 #else
     22 #define SEPARATOR ;
     23 #endif
     24 
     25 #if defined(__APPLE__)
     26 #define HIDDEN_DIRECTIVE .private_extern
     27 #define LOCAL_LABEL(name) L_##name
     28 #define FILE_LEVEL_DIRECTIVE  .subsections_via_symbols
     29 #else
     30 #define HIDDEN_DIRECTIVE .hidden
     31 #define LOCAL_LABEL(name) .L_##name
     32 #define FILE_LEVEL_DIRECTIVE
     33 #endif
     34 
     35 #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 
     39 #ifdef VISIBILITY_HIDDEN
     40 #define DECLARE_SYMBOL_VISIBILITY(name)                    \
     41   HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR
     42 #else
     43 #define DECLARE_SYMBOL_VISIBILITY(name)
     44 #endif
     45 
     46 #define DEFINE_COMPILERRT_FUNCTION(name)                   \
     47   FILE_LEVEL_DIRECTIVE     SEPARATOR                       \
     48   .globl SYMBOL_NAME(name) SEPARATOR                       \
     49   DECLARE_SYMBOL_VISIBILITY(name)                          \
     50   SYMBOL_NAME(name):
     51 
     52 #define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name)           \
     53   .globl SYMBOL_NAME(name) SEPARATOR                       \
     54   HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR             \
     55   SYMBOL_NAME(name):
     56 
     57 #define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
     58   .globl name SEPARATOR                                    \
     59   HIDDEN_DIRECTIVE name SEPARATOR                          \
     60   name:
     61 
     62 #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 
     73 #endif /* COMPILERRT_ASSEMBLY_H */
     74