Back to index

plt-scheme  4.2.1
ffitarget.h
Go to the documentation of this file.
00001 /* -----------------------------------------------------------------*-C-*-
00002    ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
00003    Target configuration macros for MIPS.
00004 
00005    Permission is hereby granted, free of charge, to any person obtaining
00006    a copy of this software and associated documentation files (the
00007    ``Software''), to deal in the Software without restriction, including
00008    without limitation the rights to use, copy, modify, merge, publish,
00009    distribute, sublicense, and/or sell copies of the Software, and to
00010    permit persons to whom the Software is furnished to do so, subject to
00011    the following conditions:
00012 
00013    The above copyright notice and this permission notice shall be included
00014    in all copies or substantial portions of the Software.
00015 
00016    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
00017    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00018    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00019    IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00020    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00021    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00022    OTHER DEALINGS IN THE SOFTWARE.
00023 
00024    ----------------------------------------------------------------------- */
00025 
00026 #ifndef LIBFFI_TARGET_H
00027 #define LIBFFI_TARGET_H
00028 
00029 #if !defined(_MIPS_SIM)
00030 -- something is very wrong --
00031 #else
00032 #  if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
00033 #    define FFI_MIPS_N32
00034 #  else
00035 #    if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
00036 #      define FFI_MIPS_O32
00037 #    else
00038 -- this is an unsupported platform --
00039 #    endif
00040 #  endif
00041 #endif
00042 
00043 #ifdef FFI_MIPS_O32
00044 /* O32 stack frames have 32bit integer args */
00045 #  define FFI_SIZEOF_ARG    4
00046 #else
00047 /* N32 and N64 frames have 64bit integer args */
00048 #  define FFI_SIZEOF_ARG    8
00049 #  if _MIPS_SIM == _ABIN32
00050 #    define FFI_SIZEOF_JAVA_RAW  4
00051 #  endif
00052 #endif
00053 
00054 #define FFI_FLAG_BITS 2
00055 
00056 /* SGI's strange assembler requires that we multiply by 4 rather 
00057    than shift left by FFI_FLAG_BITS */
00058 
00059 #define FFI_ARGS_D   FFI_TYPE_DOUBLE
00060 #define FFI_ARGS_F   FFI_TYPE_FLOAT
00061 #define FFI_ARGS_DD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
00062 #define FFI_ARGS_FF  FFI_TYPE_FLOAT * 4 +  FFI_TYPE_FLOAT
00063 #define FFI_ARGS_FD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
00064 #define FFI_ARGS_DF  FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
00065 
00066 /* Needed for N32 structure returns */
00067 #define FFI_TYPE_SMALLSTRUCT  FFI_TYPE_UINT8
00068 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
00069 
00070 #if 0
00071 /* The SGI assembler can't handle this.. */
00072 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
00073 /* (and so on) */
00074 #else
00075 /* ...so we calculate these by hand! */
00076 #define FFI_TYPE_STRUCT_D      61
00077 #define FFI_TYPE_STRUCT_F      45
00078 #define FFI_TYPE_STRUCT_DD     253
00079 #define FFI_TYPE_STRUCT_FF     173
00080 #define FFI_TYPE_STRUCT_FD     237
00081 #define FFI_TYPE_STRUCT_DF     189
00082 #define FFI_TYPE_STRUCT_SMALL  93
00083 #define FFI_TYPE_STRUCT_SMALL2 109
00084 #endif
00085 
00086 #ifdef LIBFFI_ASM
00087 #define v0 $2
00088 #define v1 $3
00089 #define a0 $4
00090 #define a1 $5
00091 #define a2 $6
00092 #define a3 $7
00093 #define a4 $8        
00094 #define a5 $9        
00095 #define a6 $10              
00096 #define a7 $11              
00097 #define t0 $8
00098 #define t1 $9
00099 #define t2 $10
00100 #define t3 $11
00101 #define t4 $12              
00102 #define t5 $13
00103 #define t6 $14       
00104 #define t7 $15
00105 #define t8 $24
00106 #define t9 $25
00107 #define ra $31              
00108 
00109 #ifdef FFI_MIPS_O32
00110 # define REG_L       lw
00111 # define REG_S       sw
00112 # define SUBU subu
00113 # define ADDU addu
00114 # define SRL  srl
00115 # define LI   li
00116 #else /* !FFI_MIPS_O32 */
00117 # define REG_L       ld
00118 # define REG_S       sd
00119 # define SUBU dsubu
00120 # define ADDU daddu
00121 # define SRL  dsrl
00122 # define LI   dli
00123 # if (_MIPS_SIM==_ABI64)
00124 #  define LA dla
00125 #  define EH_FRAME_ALIGN 3
00126 #  define FDE_ADDR_BYTES .8byte
00127 # else
00128 #  define LA la
00129 #  define EH_FRAME_ALIGN 2
00130 #  define FDE_ADDR_BYTES .4byte
00131 # endif /* _MIPS_SIM==_ABI64 */
00132 #endif /* !FFI_MIPS_O32 */
00133 #else /* !LIBFFI_ASM */
00134 #ifdef FFI_MIPS_O32
00135 /* O32 stack frames have 32bit integer args */
00136 typedef unsigned int     ffi_arg __attribute__((__mode__(__SI__)));
00137 typedef signed   int     ffi_sarg __attribute__((__mode__(__SI__)));
00138 #else
00139 /* N32 and N64 frames have 64bit integer args */
00140 typedef unsigned int     ffi_arg __attribute__((__mode__(__DI__)));
00141 typedef signed   int     ffi_sarg __attribute__((__mode__(__DI__)));
00142 #endif
00143 
00144 typedef enum ffi_abi {
00145   FFI_FIRST_ABI = 0,
00146   FFI_O32,
00147   FFI_N32,
00148   FFI_N64,
00149   FFI_O32_SOFT_FLOAT,
00150 
00151 #ifdef FFI_MIPS_O32
00152 #ifdef __mips_soft_float
00153   FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT,
00154 #else
00155   FFI_DEFAULT_ABI = FFI_O32,
00156 #endif
00157 #else
00158 # if _MIPS_SIM==_ABI64
00159   FFI_DEFAULT_ABI = FFI_N64,
00160 # else
00161   FFI_DEFAULT_ABI = FFI_N32,
00162 # endif
00163 #endif
00164 
00165   FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
00166 } ffi_abi;
00167 
00168 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
00169 #endif /* !LIBFFI_ASM */
00170 
00171 /* ---- Definitions for closures ----------------------------------------- */
00172 
00173 #if defined(FFI_MIPS_O32)
00174 #define FFI_CLOSURES 1
00175 #define FFI_TRAMPOLINE_SIZE 20
00176 #else
00177 /* N32/N64. */
00178 # define FFI_CLOSURES 1
00179 #if _MIPS_SIM==_ABI64
00180 #define FFI_TRAMPOLINE_SIZE 52
00181 #else
00182 #define FFI_TRAMPOLINE_SIZE 20
00183 #endif
00184 #endif /* FFI_MIPS_O32 */
00185 #define FFI_NATIVE_RAW_API 0
00186 
00187 #endif
00188