PageRenderTime 312ms CodeModel.GetById 121ms app.highlight 5ms RepoModel.GetById 176ms app.codeStats 7ms

/Modules/_ctypes/libffi/src/mips/ffitarget.h

http://unladen-swallow.googlecode.com/
C++ Header | 202 lines | 146 code | 19 blank | 37 comment | 10 complexity | 857e59bae0c8ca9f3672fafc484b1311 MD5 | raw file
  1/* -----------------------------------------------------------------*-C-*-
  2   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
  3   Target configuration macros for MIPS.
  4
  5   Permission is hereby granted, free of charge, to any person obtaining
  6   a copy of this software and associated documentation files (the
  7   ``Software''), to deal in the Software without restriction, including
  8   without limitation the rights to use, copy, modify, merge, publish,
  9   distribute, sublicense, and/or sell copies of the Software, and to
 10   permit persons to whom the Software is furnished to do so, subject to
 11   the following conditions:
 12
 13   The above copyright notice and this permission notice shall be included
 14   in all copies or substantial portions of the Software.
 15
 16   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
 17   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 18   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 19   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 20   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 21   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 22   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 23   DEALINGS IN THE SOFTWARE.
 24
 25   ----------------------------------------------------------------------- */
 26
 27#ifndef LIBFFI_TARGET_H
 28#define LIBFFI_TARGET_H
 29
 30#ifdef linux
 31#include <asm/sgidefs.h>
 32#  ifndef _ABIN32
 33#    define _ABIN32 _MIPS_SIM_NABI32
 34#  endif
 35#  ifndef _ABI64
 36#    define _ABI64 _MIPS_SIM_ABI64
 37#  endif
 38#  ifndef _ABIO32
 39#    define _ABIO32 _MIPS_SIM_ABI32
 40#  endif
 41#endif
 42
 43#if !defined(_MIPS_SIM)
 44-- something is very wrong --
 45#else
 46#  if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
 47#    define FFI_MIPS_N32
 48#  else
 49#    if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
 50#      define FFI_MIPS_O32
 51#    else
 52-- this is an unsupported platform --
 53#    endif
 54#  endif
 55#endif
 56
 57#ifdef FFI_MIPS_O32
 58/* O32 stack frames have 32bit integer args */
 59#  define FFI_SIZEOF_ARG    4
 60#else
 61/* N32 and N64 frames have 64bit integer args */
 62#  define FFI_SIZEOF_ARG    8
 63#  if _MIPS_SIM == _ABIN32
 64#    define FFI_SIZEOF_JAVA_RAW  4
 65#  endif
 66#endif
 67
 68#define FFI_FLAG_BITS 2
 69
 70/* SGI's strange assembler requires that we multiply by 4 rather 
 71   than shift left by FFI_FLAG_BITS */
 72
 73#define FFI_ARGS_D   FFI_TYPE_DOUBLE
 74#define FFI_ARGS_F   FFI_TYPE_FLOAT
 75#define FFI_ARGS_DD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
 76#define FFI_ARGS_FF  FFI_TYPE_FLOAT * 4 +  FFI_TYPE_FLOAT
 77#define FFI_ARGS_FD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
 78#define FFI_ARGS_DF  FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
 79
 80/* Needed for N32 structure returns */
 81#define FFI_TYPE_SMALLSTRUCT  FFI_TYPE_UINT8
 82#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
 83
 84#if 0
 85/* The SGI assembler can't handle this.. */
 86#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
 87/* (and so on) */
 88#else
 89/* ...so we calculate these by hand! */
 90#define FFI_TYPE_STRUCT_D      61
 91#define FFI_TYPE_STRUCT_F      45
 92#define FFI_TYPE_STRUCT_DD     253
 93#define FFI_TYPE_STRUCT_FF     173
 94#define FFI_TYPE_STRUCT_FD     237
 95#define FFI_TYPE_STRUCT_DF     189
 96#define FFI_TYPE_STRUCT_SMALL  93
 97#define FFI_TYPE_STRUCT_SMALL2 109
 98#endif
 99
100#ifdef LIBFFI_ASM
101#define v0 $2
102#define v1 $3
103#define a0 $4
104#define a1 $5
105#define a2 $6
106#define a3 $7
107#define a4 $8		
108#define a5 $9		
109#define a6 $10		
110#define a7 $11		
111#define t0 $8
112#define t1 $9
113#define t2 $10
114#define t3 $11
115#define t4 $12		
116#define t5 $13
117#define t6 $14	
118#define t7 $15
119#define t8 $24
120#define t9 $25
121#define ra $31		
122
123#ifdef FFI_MIPS_O32
124# define REG_L	lw
125# define REG_S	sw
126# define SUBU	subu
127# define ADDU	addu
128# define SRL	srl
129# define LI	li
130#else /* !FFI_MIPS_O32 */
131# define REG_L	ld
132# define REG_S	sd
133# define SUBU	dsubu
134# define ADDU	daddu
135# define SRL	dsrl
136# define LI 	dli
137# if (_MIPS_SIM==_ABI64)
138#  define LA dla
139#  define EH_FRAME_ALIGN 3
140#  define FDE_ADDR_BYTES .8byte
141# else
142#  define LA la
143#  define EH_FRAME_ALIGN 2
144#  define FDE_ADDR_BYTES .4byte
145# endif /* _MIPS_SIM==_ABI64 */
146#endif /* !FFI_MIPS_O32 */
147#else /* !LIBFFI_ASM */
148#ifdef FFI_MIPS_O32
149/* O32 stack frames have 32bit integer args */
150typedef unsigned int     ffi_arg __attribute__((__mode__(__SI__)));
151typedef signed   int     ffi_sarg __attribute__((__mode__(__SI__)));
152#else
153/* N32 and N64 frames have 64bit integer args */
154typedef unsigned int     ffi_arg __attribute__((__mode__(__DI__)));
155typedef signed   int     ffi_sarg __attribute__((__mode__(__DI__)));
156#endif
157
158typedef enum ffi_abi {
159  FFI_FIRST_ABI = 0,
160  FFI_O32,
161  FFI_N32,
162  FFI_N64,
163  FFI_O32_SOFT_FLOAT,
164
165#ifdef FFI_MIPS_O32
166#ifdef __mips_soft_float
167  FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT,
168#else
169  FFI_DEFAULT_ABI = FFI_O32,
170#endif
171#else
172# if _MIPS_SIM==_ABI64
173  FFI_DEFAULT_ABI = FFI_N64,
174# else
175  FFI_DEFAULT_ABI = FFI_N32,
176# endif
177#endif
178
179  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
180} ffi_abi;
181
182#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
183#endif /* !LIBFFI_ASM */
184
185/* ---- Definitions for closures ----------------------------------------- */
186
187#if defined(FFI_MIPS_O32)
188#define FFI_CLOSURES 1
189#define FFI_TRAMPOLINE_SIZE 20
190#else
191/* N32/N64. */
192# define FFI_CLOSURES 1
193#if _MIPS_SIM==_ABI64
194#define FFI_TRAMPOLINE_SIZE 52
195#else
196#define FFI_TRAMPOLINE_SIZE 20
197#endif
198#endif /* FFI_MIPS_O32 */
199#define FFI_NATIVE_RAW_API 0
200
201#endif
202