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