1 /* ----------------------------------------------------------------------- 2 ppc-darwin.h - Copyright (c) 2002, 2003, 2004, Free Software Foundation, 3 Inc. 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 THE AUTHOR 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 #define L(x) x 26 27 #define SF_ARG9 MODE_CHOICE(56,112) 28 #define SF_ARG10 MODE_CHOICE(60,120) 29 #define SF_ARG11 MODE_CHOICE(64,128) 30 #define SF_ARG12 MODE_CHOICE(68,136) 31 #define SF_ARG13 MODE_CHOICE(72,144) 32 #define SF_ARG14 MODE_CHOICE(76,152) 33 #define SF_ARG15 MODE_CHOICE(80,160) 34 #define SF_ARG16 MODE_CHOICE(84,168) 35 #define SF_ARG17 MODE_CHOICE(88,176) 36 #define SF_ARG18 MODE_CHOICE(92,184) 37 #define SF_ARG19 MODE_CHOICE(96,192) 38 #define SF_ARG20 MODE_CHOICE(100,200) 39 #define SF_ARG21 MODE_CHOICE(104,208) 40 #define SF_ARG22 MODE_CHOICE(108,216) 41 #define SF_ARG23 MODE_CHOICE(112,224) 42 #define SF_ARG24 MODE_CHOICE(116,232) 43 #define SF_ARG25 MODE_CHOICE(120,240) 44 #define SF_ARG26 MODE_CHOICE(124,248) 45 #define SF_ARG27 MODE_CHOICE(128,256) 46 #define SF_ARG28 MODE_CHOICE(132,264) 47 #define SF_ARG29 MODE_CHOICE(136,272) 48 49 #define ASM_NEEDS_REGISTERS 4 50 #define NUM_GPR_ARG_REGISTERS 8 51 #define NUM_FPR_ARG_REGISTERS 13 52 53 #define FFI_TYPE_1_BYTE(x) ((x) == FFI_TYPE_UINT8 || (x) == FFI_TYPE_SINT8) 54 #define FFI_TYPE_2_BYTE(x) ((x) == FFI_TYPE_UINT16 || (x) == FFI_TYPE_SINT16) 55 #define FFI_TYPE_4_BYTE(x) \ 56 ((x) == FFI_TYPE_UINT32 || (x) == FFI_TYPE_SINT32 ||\ 57 (x) == FFI_TYPE_INT || (x) == FFI_TYPE_FLOAT) 58 59 #if !defined(LIBFFI_ASM) 60 61 enum { 62 FLAG_RETURNS_NOTHING = 1 << (31 - 30), // cr7 63 FLAG_RETURNS_FP = 1 << (31 - 29), 64 FLAG_RETURNS_64BITS = 1 << (31 - 28), 65 FLAG_RETURNS_128BITS = 1 << (31 - 31), 66 67 FLAG_RETURNS_STRUCT = 1 << (31 - 27), // cr6 68 FLAG_STRUCT_CONTAINS_FP = 1 << (31 - 26), 69 70 FLAG_ARG_NEEDS_COPY = 1 << (31 - 7), 71 FLAG_FP_ARGUMENTS = 1 << (31 - 6), // cr1.eq; specified by ABI 72 FLAG_4_GPR_ARGUMENTS = 1 << (31 - 5), 73 FLAG_RETVAL_REFERENCE = 1 << (31 - 4) 74 }; 75 76 #if defined(__ppc64__) 77 void ffi64_struct_to_ram_form(const ffi_type*, const char*, unsigned int*, 78 const char*, unsigned int*, unsigned int*, char*, unsigned int*); 79 void ffi64_struct_to_reg_form(const ffi_type*, const char*, unsigned int*, 80 unsigned int*, char*, unsigned int*, char*, unsigned int*); 81 bool ffi64_stret_needs_ptr(const ffi_type* inType, 82 unsigned short*, unsigned short*); 83 #endif 84 85 #endif // !defined(LIBFFI_ASM)