github.com/prattmic/llgo-embedded@v0.0.0-20150820070356-41cfecea0e1e/third_party/gofrontend/libffi/src/powerpc/ffitarget.h (about)

     1  /* -----------------------------------------------------------------*-C-*-
     2     ffitarget.h - Copyright (c) 2012  Anthony Green
     3                   Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc
     4                   Copyright (c) 1996-2003  Red Hat, Inc.
     5  
     6     Target configuration macros for PowerPC.
     7  
     8     Permission is hereby granted, free of charge, to any person obtaining
     9     a copy of this software and associated documentation files (the
    10     ``Software''), to deal in the Software without restriction, including
    11     without limitation the rights to use, copy, modify, merge, publish,
    12     distribute, sublicense, and/or sell copies of the Software, and to
    13     permit persons to whom the Software is furnished to do so, subject to
    14     the following conditions:
    15  
    16     The above copyright notice and this permission notice shall be included
    17     in all copies or substantial portions of the Software.
    18  
    19     THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
    20     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    21     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    22     NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    23     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    24     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    25     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    26     DEALINGS IN THE SOFTWARE.
    27  
    28     ----------------------------------------------------------------------- */
    29  
    30  #ifndef LIBFFI_TARGET_H
    31  #define LIBFFI_TARGET_H
    32  
    33  #ifndef LIBFFI_H
    34  #error "Please do not include ffitarget.h directly into your source.  Use ffi.h instead."
    35  #endif
    36  
    37  /* ---- System specific configurations ----------------------------------- */
    38  
    39  #if defined (POWERPC) && defined (__powerpc64__)	/* linux64 */
    40  #ifndef POWERPC64
    41  #define POWERPC64
    42  #endif
    43  #elif defined (POWERPC_DARWIN) && defined (__ppc64__)	/* Darwin64 */
    44  #ifndef POWERPC64
    45  #define POWERPC64
    46  #endif
    47  #ifndef POWERPC_DARWIN64
    48  #define POWERPC_DARWIN64
    49  #endif
    50  #elif defined (POWERPC_AIX) && defined (__64BIT__)	/* AIX64 */
    51  #ifndef POWERPC64
    52  #define POWERPC64
    53  #endif
    54  #endif
    55  
    56  #ifndef LIBFFI_ASM
    57  typedef unsigned long          ffi_arg;
    58  typedef signed long            ffi_sarg;
    59  
    60  typedef enum ffi_abi {
    61    FFI_FIRST_ABI = 0,
    62  
    63  #if defined (POWERPC_AIX)
    64    FFI_AIX,
    65    FFI_DARWIN,
    66    FFI_DEFAULT_ABI = FFI_AIX,
    67    FFI_LAST_ABI
    68  
    69  #elif defined (POWERPC_DARWIN)
    70    FFI_AIX,
    71    FFI_DARWIN,
    72    FFI_DEFAULT_ABI = FFI_DARWIN,
    73    FFI_LAST_ABI
    74  
    75  #else
    76    /* The FFI_COMPAT values are used by old code.  Since libffi may be
    77       a shared library we have to support old values for backwards
    78       compatibility.  */
    79    FFI_COMPAT_SYSV,
    80    FFI_COMPAT_GCC_SYSV,
    81    FFI_COMPAT_LINUX64,
    82    FFI_COMPAT_LINUX,
    83    FFI_COMPAT_LINUX_SOFT_FLOAT,
    84  
    85  # if defined (POWERPC64)
    86    /* This bit, always set in new code, must not be set in any of the
    87       old FFI_COMPAT values that might be used for 64-bit linux.  We
    88       only need worry about FFI_COMPAT_LINUX64, but to be safe avoid
    89       all old values.  */
    90    FFI_LINUX = 8,
    91    /* This and following bits can reuse FFI_COMPAT values.  */
    92    FFI_LINUX_STRUCT_ALIGN = 1,
    93    FFI_LINUX_LONG_DOUBLE_128 = 2,
    94    FFI_DEFAULT_ABI = (FFI_LINUX
    95  #  ifdef __STRUCT_PARM_ALIGN__
    96  		     | FFI_LINUX_STRUCT_ALIGN
    97  #  endif
    98  #  ifdef __LONG_DOUBLE_128__
    99  		     | FFI_LINUX_LONG_DOUBLE_128
   100  #  endif
   101  		     ),
   102    FFI_LAST_ABI = 12
   103  
   104  # else
   105    /* This bit, always set in new code, must not be set in any of the
   106       old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd.  */
   107    FFI_SYSV = 8,
   108    /* This and following bits can reuse FFI_COMPAT values.  */
   109    FFI_SYSV_SOFT_FLOAT = 1,
   110    FFI_SYSV_STRUCT_RET = 2,
   111    FFI_SYSV_IBM_LONG_DOUBLE = 4,
   112    FFI_SYSV_LONG_DOUBLE_128 = 16,
   113  
   114    FFI_DEFAULT_ABI = (FFI_SYSV
   115  #  ifdef __NO_FPRS__
   116  		     | FFI_SYSV_SOFT_FLOAT
   117  #  endif
   118  #  if (defined (__SVR4_STRUCT_RETURN)					\
   119         || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
   120  		     | FFI_SYSV_STRUCT_RET
   121  #  endif
   122  #  if __LDBL_MANT_DIG__ == 106
   123  		     | FFI_SYSV_IBM_LONG_DOUBLE
   124  #  endif
   125  #  ifdef __LONG_DOUBLE_128__
   126  		     | FFI_SYSV_LONG_DOUBLE_128
   127  #  endif
   128  		     ),
   129    FFI_LAST_ABI = 32
   130  # endif
   131  #endif
   132  
   133  } ffi_abi;
   134  #endif
   135  
   136  /* ---- Definitions for closures ----------------------------------------- */
   137  
   138  #define FFI_CLOSURES 1
   139  #define FFI_NATIVE_RAW_API 0
   140  #if defined (POWERPC) || defined (POWERPC_FREEBSD)
   141  # define FFI_GO_CLOSURES 1
   142  # define FFI_TARGET_SPECIFIC_VARIADIC 1
   143  # define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs
   144  #endif
   145  
   146  /* ppc_closure.S and linux64_closure.S expect this.  */
   147  #define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER
   148  
   149  /* We define additional types below.  If generic types are added that
   150     must be supported by powerpc libffi then it is likely that
   151     FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in
   152     ppc_closure.S and linux64_closure.S be extended.  */
   153  
   154  #if !(FFI_TYPE_LAST == FFI_PPC_TYPE_LAST		\
   155        || (FFI_TYPE_LAST == FFI_TYPE_COMPLEX		\
   156  	  && !defined FFI_TARGET_HAS_COMPLEX_TYPE))
   157  # error "You likely have a broken powerpc libffi"
   158  #endif
   159  
   160  /* Needed for soft-float long-double-128 support.  */
   161  #define FFI_TYPE_UINT128 (FFI_PPC_TYPE_LAST + 1)
   162  
   163  /* Needed for FFI_SYSV small structure returns.  */
   164  #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2)
   165  
   166  /* Used by ELFv2 for homogenous structure returns.  */
   167  #define FFI_V2_TYPE_FLOAT_HOMOG		(FFI_PPC_TYPE_LAST + 1)
   168  #define FFI_V2_TYPE_DOUBLE_HOMOG	(FFI_PPC_TYPE_LAST + 2)
   169  #define FFI_V2_TYPE_SMALL_STRUCT	(FFI_PPC_TYPE_LAST + 3)
   170  
   171  #if _CALL_ELF == 2
   172  # define FFI_TRAMPOLINE_SIZE 32
   173  #else
   174  # if defined(POWERPC64) || defined(POWERPC_AIX)
   175  #  if defined(POWERPC_DARWIN64)
   176  #    define FFI_TRAMPOLINE_SIZE 48
   177  #  else
   178  #    define FFI_TRAMPOLINE_SIZE 24
   179  #  endif
   180  # else /* POWERPC || POWERPC_AIX */
   181  #  define FFI_TRAMPOLINE_SIZE 40
   182  # endif
   183  #endif
   184  
   185  #ifndef LIBFFI_ASM
   186  #if defined(POWERPC_DARWIN) || defined(POWERPC_AIX)
   187  struct ffi_aix_trampoline_struct {
   188      void * code_pointer;	/* Pointer to ffi_closure_ASM */
   189      void * toc;			/* TOC */
   190      void * static_chain;	/* Pointer to closure */
   191  };
   192  #endif
   193  #endif
   194  
   195  #endif