1 /* $NetBSD: abi.h,v 1.8 2013/09/12 15:36:16 joerg Exp $ */ 2 3 /* 4 * Written by Frank van der Linden (fvdl@wasabisystems.com) 5 */ 6 7 /* 8 * The x86-64 ABI specifies that float and double arguments 9 * are passed in SSE2 (xmm) registers. Unfortunately, 10 * there is no way to push those on to the FP stack, which is 11 * where the fancier instructions get their arguments from. 12 * 13 * Define some prologues and epilogues to store and retrieve 14 * xmm regs to local variables. 15 */ 16 17 #ifdef __x86_64__ 18 19 #define ARG_LONG_DOUBLE_ONE 8(%rsp) 20 #define ARG_LONG_DOUBLE_TWO 24(%rsp) 21 #define ARG_DOUBLE_ONE -8(%rsp) 22 #define ARG_DOUBLE_ONE_LSW -8(%rsp) 23 #define ARG_DOUBLE_ONE_MSW -4(%rsp) 24 #define ARG_DOUBLE_TWO -16(%rsp) 25 #define ARG_FLOAT_ONE -4(%rsp) 26 #define ARG_FLOAT_TWO -8(%rsp) 27 28 #define XMM_ONE_ARG_DOUBLE_PROLOGUE \ 29 movsd %xmm0, ARG_DOUBLE_ONE 30 31 #define XMM_TWO_ARG_DOUBLE_PROLOGUE \ 32 movsd %xmm0, ARG_DOUBLE_ONE ; \ 33 movsd %xmm1, ARG_DOUBLE_TWO 34 35 #define XMM_ONE_ARG_FLOAT_PROLOGUE \ 36 movss %xmm0, ARG_FLOAT_ONE 37 38 #define XMM_TWO_ARG_FLOAT_PROLOGUE \ 39 movss %xmm0, ARG_FLOAT_ONE ; \ 40 movss %xmm1, ARG_FLOAT_TWO 41 42 #define XMM_DOUBLE_EPILOGUE \ 43 fstpl ARG_DOUBLE_ONE ; \ 44 movsd ARG_DOUBLE_ONE, %xmm0 45 46 #define XMM_FLOAT_EPILOGUE \ 47 fstps ARG_FLOAT_ONE ; \ 48 movss ARG_FLOAT_ONE, %xmm0 49 50 #define FLDL_VAR(x) fldl x(%rip) 51 52 #else 53 54 #define ARG_LONG_DOUBLE_ONE 4(%esp) 55 #define ARG_LONG_DOUBLE_TWO 16(%esp) 56 #define ARG_DOUBLE_ONE 4(%esp) 57 #define ARG_DOUBLE_ONE_LSW 4(%esp) 58 #define ARG_DOUBLE_ONE_MSW 8(%esp) 59 #define ARG_DOUBLE_TWO 12(%esp) 60 #define ARG_FLOAT_ONE 4(%esp) 61 #define ARG_FLOAT_TWO 8(%esp) 62 63 #define XMM_ONE_ARG_DOUBLE_PROLOGUE 64 #define XMM_TWO_ARG_DOUBLE_PROLOGUE 65 #define XMM_ONE_ARG_FLOAT_PROLOGUE 66 #define XMM_TWO_ARG_FLOAT_PROLOGUE 67 68 #define XMM_DOUBLE_EPILOGUE 69 #define XMM_FLOAT_EPILOGUE 70 71 #ifdef __PIC__ 72 #define FLDL_VAR(x) \ 73 PIC_PROLOGUE ; \ 74 fldl PIC_GOTOFF(x) ; \ 75 PIC_EPILOGUE 76 #else 77 #define FLDL_VAR(x) \ 78 fldl x 79 80 #endif 81 #endif 82