Home | History | Annotate | Line # | Download | only in builtins
assembly.h revision 1.1.1.2.2.2
      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 #define SYMBOL_IS_FUNC(name)
     30 #else
     31 #define HIDDEN_DIRECTIVE .hidden
     32 #define LOCAL_LABEL(name) .L_##name
     33 #define FILE_LEVEL_DIRECTIVE
     34 #  if defined(__arm__)
     35 #  define SYMBOL_IS_FUNC(name) .type name, %function
     36 #  else
     37 #  define SYMBOL_IS_FUNC(name) .type name, @function
     38 #  endif
     39 #endif
     40 
     41 #if defined(__arm__)
     42 # ifndef __ARM_ARCH
     43 #  if defined (__ARM_ARCH_7__) || defined (__ARM_ARCH_7A__) || \
     44      defined (__ARM_ARCH_7R__) || defined (__ARM_ARCH_7M__) || \
     45      defined (__ARM_ARCH_7EM__)
     46 #  define __ARM_ARCH 7
     47 #  endif
     48 # endif
     49 
     50 # ifndef __ARM_ARCH
     51 #  if defined (__ARM_ARCH_6__) || \
     52       defined (__ARM_ARCH_6J__) || defined (__ARM_ARCH_6K__) || \
     53       defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__) || \
     54       defined (__ARM_ARCH_6ZM__)
     55 #  define __ARM_ARCH 6
     56 #  endif
     57 # endif
     58 
     59 # ifndef __ARM_ARCH
     60 #  if defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5T__) || \
     61       defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__)
     62 #  define __ARM_ARCH 5
     63 #  endif
     64 # endif
     65 
     66 # ifndef __ARM_ARCH
     67 # define __ARM_ARCH 4
     68 # endif
     69 
     70 # if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5
     71 # define ARM_HAS_BX
     72 # endif
     73 # if !defined(__ARM_FEATURE_CLZ) && \
     74      (__ARM_ARCH >= 6 || (__ARM_ARCH == 5 && !defined(__ARM_ARCH_5__)))
     75 # define __ARM_FEATURE_CLZ
     76 # endif
     77 
     78 # ifdef ARM_HAS_BX
     79 # define JMP(r)		bx	r
     80 # define JMPc(r,c)	bx##c	r
     81 # else
     82 # define JMP(r)		mov	pc, r
     83 # define JMPc(r,c)	mov##c	pc, r
     84 # endif
     85 #endif
     86 
     87 #define GLUE2(a, b) a ## b
     88 #define GLUE(a, b) GLUE2(a, b)
     89 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
     90 
     91 #ifdef VISIBILITY_HIDDEN
     92 #define DECLARE_SYMBOL_VISIBILITY(name)                    \
     93   HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR
     94 #else
     95 #define DECLARE_SYMBOL_VISIBILITY(name)
     96 #endif
     97 
     98 #define DEFINE_COMPILERRT_FUNCTION(name)                   \
     99   FILE_LEVEL_DIRECTIVE     SEPARATOR                       \
    100   .globl SYMBOL_NAME(name) SEPARATOR                       \
    101   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR              \
    102   DECLARE_SYMBOL_VISIBILITY(name)                          \
    103   SYMBOL_NAME(name):
    104 
    105 #define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name)           \
    106   .globl SYMBOL_NAME(name) SEPARATOR                       \
    107   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR              \
    108   HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR             \
    109   SYMBOL_NAME(name):
    110 
    111 #define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
    112   .globl name SEPARATOR                                    \
    113   SYMBOL_IS_FUNC(name) SEPARATOR                           \
    114   HIDDEN_DIRECTIVE name SEPARATOR                          \
    115   name:
    116 
    117 #define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target)     \
    118   .globl SYMBOL_NAME(name) SEPARATOR                       \
    119   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR              \
    120   .set SYMBOL_NAME(name), SYMBOL_NAME(target) SEPARATOR
    121 
    122 #if defined (__ARM_EABI__)
    123 # define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name)      \
    124   DEFINE_COMPILERRT_FUNCTION_ALIAS(aeabi_name, name)
    125 #else
    126 # define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name)
    127 #endif
    128 
    129 #ifdef __ELF__
    130 #define END_COMPILERRT_FUNCTION(name) \
    131 	.size	SYMBOL_NAME(name), . - SYMBOL_NAME(name)
    132 #else
    133 #define END_COMPILERRT_FUNCTION(name)
    134 #endif
    135 
    136 #endif /* COMPILERRT_ASSEMBLY_H */
    137