OSDN Git Service

2003-10-22 David Daney <ddaney@avtrex.com>
[pf3gnuchains/gcc-fork.git] / libffi / src / mips / ffitarget.h
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, EXPRESS
17    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19    IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22    OTHER DEALINGS IN THE SOFTWARE.
23
24    ----------------------------------------------------------------------- */
25
26 #ifndef LIBFFI_TARGET_H
27 #define LIBFFI_TARGET_H
28
29 #ifndef LIBFFI_ASM
30 #include <sgidefs.h>
31 #endif
32
33 #if !defined(_MIPS_SIM)
34 -- something is very wrong --
35 #else
36 #  if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
37 #    define FFI_MIPS_N32
38 #  else
39 #    if _MIPS_SIM==_ABIO32 && defined(_ABIO32)
40 #      define FFI_MIPS_O32
41 #    else
42 -- this is an unsupported platform --
43 #    endif
44 #  endif
45 #endif
46
47 #ifdef FFI_MIPS_O32
48 /* O32 stack frames have 32bit integer args */
49 #define FFI_SIZEOF_ARG         4
50 #else
51 /* N32 and N64 frames have 64bit integer args */
52 #define FFI_SIZEOF_ARG         8
53 #endif
54
55 #define FFI_FLAG_BITS 2
56
57 /* SGI's strange assembler requires that we multiply by 4 rather 
58    than shift left by FFI_FLAG_BITS */
59
60 #define FFI_ARGS_D   FFI_TYPE_DOUBLE
61 #define FFI_ARGS_F   FFI_TYPE_FLOAT
62 #define FFI_ARGS_DD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
63 #define FFI_ARGS_FF  FFI_TYPE_FLOAT * 4 +  FFI_TYPE_FLOAT
64 #define FFI_ARGS_FD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
65 #define FFI_ARGS_DF  FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
66
67 /* Needed for N32 structure returns */
68 #define FFI_TYPE_SMALLSTRUCT  FFI_TYPE_UINT8
69 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
70
71 #if 0
72 /* The SGI assembler can't handle this.. */
73 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
74 /* (and so on) */
75 #else
76 /* ...so we calculate these by hand! */
77 #define FFI_TYPE_STRUCT_D      61
78 #define FFI_TYPE_STRUCT_F      45
79 #define FFI_TYPE_STRUCT_DD     253
80 #define FFI_TYPE_STRUCT_FF     173
81 #define FFI_TYPE_STRUCT_FD     237
82 #define FFI_TYPE_STRUCT_DF     189
83 #define FFI_TYPE_STRUCT_SMALL  93
84 #define FFI_TYPE_STRUCT_SMALL2 109
85 #endif
86
87 #ifdef LIBFFI_ASM
88 #define v0 $2
89 #define v1 $3
90 #define a0 $4
91 #define a1 $5
92 #define a2 $6
93 #define a3 $7
94 #define a4 $8           
95 #define a5 $9           
96 #define a6 $10          
97 #define a7 $11          
98 #define t0 $8
99 #define t1 $9
100 #define t2 $10
101 #define t3 $11
102 #define t4 $12          
103 #define t5 $13
104 #define t6 $14  
105 #define t7 $15
106 #define t8 $24
107 #define t9 $25
108 #define ra $31          
109
110 #ifdef FFI_MIPS_O32
111 #define REG_L   lw
112 #define REG_S   sw
113 #define SUBU    subu
114 #define ADDU    addu
115 #define SRL     srl
116 #define LI      li
117 #else /* !FFI_MIPS_O32 */
118 #define REG_L   ld
119 #define REG_S   sd
120 #define SUBU    dsubu
121 #define ADDU    daddu
122 #define SRL     dsrl
123 #define LI      dli
124 #endif /* !FFI_MIPS_O32 */
125 #else /* !LIBFFI_ASM */
126 #ifdef FFI_MIPS_O32
127 /* O32 stack frames have 32bit integer args */
128 typedef unsigned int     ffi_arg __attribute__((__mode__(__SI__)));
129 typedef signed   int     ffi_sarg __attribute__((__mode__(__SI__)));
130 #else
131 /* N32 and N64 frames have 64bit integer args */
132 typedef unsigned int     ffi_arg __attribute__((__mode__(__DI__)));
133 typedef signed   int     ffi_sarg __attribute__((__mode__(__DI__)));
134 #endif
135
136 typedef enum ffi_abi {
137   FFI_FIRST_ABI = 0,
138   FFI_O32,
139   FFI_N32,
140   FFI_N64,
141
142 #ifdef FFI_MIPS_O32
143   FFI_DEFAULT_ABI = FFI_O32,
144 #else
145   FFI_DEFAULT_ABI = FFI_N32,
146 #endif
147
148   FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
149 } ffi_abi;
150
151 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
152 #endif /* !LIBFFI_ASM */
153
154 /* ---- Definitions for closures ----------------------------------------- */
155
156 #define FFI_CLOSURES 0
157 #define FFI_NATIVE_RAW_API 0
158
159 #endif
160