~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to libffi/src/mips/ffitarget.h

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#if !defined(_MIPS_SIM)
 
30
-- something is very wrong --
 
31
#else
 
32
#  if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
 
33
#    define FFI_MIPS_N32
 
34
#  else
 
35
#    if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
 
36
#      define FFI_MIPS_O32
 
37
#    else
 
38
-- this is an unsupported platform --
 
39
#    endif
 
40
#  endif
 
41
#endif
 
42
 
 
43
#ifdef FFI_MIPS_O32
 
44
/* O32 stack frames have 32bit integer args */
 
45
#define FFI_SIZEOF_ARG         4
 
46
#else
 
47
/* N32 and N64 frames have 64bit integer args */
 
48
#define FFI_SIZEOF_ARG         8
 
49
#endif
 
50
 
 
51
#define FFI_FLAG_BITS 2
 
52
 
 
53
/* SGI's strange assembler requires that we multiply by 4 rather 
 
54
   than shift left by FFI_FLAG_BITS */
 
55
 
 
56
#define FFI_ARGS_D   FFI_TYPE_DOUBLE
 
57
#define FFI_ARGS_F   FFI_TYPE_FLOAT
 
58
#define FFI_ARGS_DD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
 
59
#define FFI_ARGS_FF  FFI_TYPE_FLOAT * 4 +  FFI_TYPE_FLOAT
 
60
#define FFI_ARGS_FD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
 
61
#define FFI_ARGS_DF  FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
 
62
 
 
63
/* Needed for N32 structure returns */
 
64
#define FFI_TYPE_SMALLSTRUCT  FFI_TYPE_UINT8
 
65
#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
 
66
 
 
67
#if 0
 
68
/* The SGI assembler can't handle this.. */
 
69
#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
 
70
/* (and so on) */
 
71
#else
 
72
/* ...so we calculate these by hand! */
 
73
#define FFI_TYPE_STRUCT_D      61
 
74
#define FFI_TYPE_STRUCT_F      45
 
75
#define FFI_TYPE_STRUCT_DD     253
 
76
#define FFI_TYPE_STRUCT_FF     173
 
77
#define FFI_TYPE_STRUCT_FD     237
 
78
#define FFI_TYPE_STRUCT_DF     189
 
79
#define FFI_TYPE_STRUCT_SMALL  93
 
80
#define FFI_TYPE_STRUCT_SMALL2 109
 
81
#endif
 
82
 
 
83
#ifdef LIBFFI_ASM
 
84
#define v0 $2
 
85
#define v1 $3
 
86
#define a0 $4
 
87
#define a1 $5
 
88
#define a2 $6
 
89
#define a3 $7
 
90
#define a4 $8           
 
91
#define a5 $9           
 
92
#define a6 $10          
 
93
#define a7 $11          
 
94
#define t0 $8
 
95
#define t1 $9
 
96
#define t2 $10
 
97
#define t3 $11
 
98
#define t4 $12          
 
99
#define t5 $13
 
100
#define t6 $14  
 
101
#define t7 $15
 
102
#define t8 $24
 
103
#define t9 $25
 
104
#define ra $31          
 
105
 
 
106
#ifdef FFI_MIPS_O32
 
107
#define REG_L   lw
 
108
#define REG_S   sw
 
109
#define SUBU    subu
 
110
#define ADDU    addu
 
111
#define SRL     srl
 
112
#define LI      li
 
113
#else /* !FFI_MIPS_O32 */
 
114
#define REG_L   ld
 
115
#define REG_S   sd
 
116
#define SUBU    dsubu
 
117
#define ADDU    daddu
 
118
#define SRL     dsrl
 
119
#define LI      dli
 
120
#endif /* !FFI_MIPS_O32 */
 
121
#else /* !LIBFFI_ASM */
 
122
#ifdef FFI_MIPS_O32
 
123
/* O32 stack frames have 32bit integer args */
 
124
typedef unsigned int     ffi_arg __attribute__((__mode__(__SI__)));
 
125
typedef signed   int     ffi_sarg __attribute__((__mode__(__SI__)));
 
126
#else
 
127
/* N32 and N64 frames have 64bit integer args */
 
128
typedef unsigned int     ffi_arg __attribute__((__mode__(__DI__)));
 
129
typedef signed   int     ffi_sarg __attribute__((__mode__(__DI__)));
 
130
#endif
 
131
 
 
132
typedef enum ffi_abi {
 
133
  FFI_FIRST_ABI = 0,
 
134
  FFI_O32,
 
135
  FFI_N32,
 
136
  FFI_N64,
 
137
  FFI_O32_SOFT_FLOAT,
 
138
 
 
139
#ifdef FFI_MIPS_O32
 
140
#ifdef __mips_soft_float
 
141
  FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT,
 
142
#else
 
143
  FFI_DEFAULT_ABI = FFI_O32,
 
144
#endif
 
145
#else
 
146
  FFI_DEFAULT_ABI = FFI_N32,
 
147
#endif
 
148
 
 
149
  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
 
150
} ffi_abi;
 
151
 
 
152
#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
 
153
#endif /* !LIBFFI_ASM */
 
154
 
 
155
/* ---- Definitions for closures ----------------------------------------- */
 
156
 
 
157
#if defined(FFI_MIPS_O32)
 
158
#define FFI_CLOSURES 1
 
159
#define FFI_TRAMPOLINE_SIZE 20
 
160
#else
 
161
/* N32/N64 not implemented yet. */
 
162
#define FFI_CLOSURES 0
 
163
#endif /* FFI_MIPS_O32 */
 
164
#define FFI_NATIVE_RAW_API 0
 
165
 
 
166
#endif
 
167