1 /* -----------------------------------------------------------------------
2 sysv.S - Copyright (c) 2003, 2004, 2006, 2008 Kaz Kojima
4 SuperH SHmedia Foreign Function Interface
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 ----------------------------------------------------------------------- */
29 #include <fficonfig.h>
31 #ifdef HAVE_MACHINE_ASM_H
32 #include <machine/asm.h>
34 /* XXX these lose for some platforms, I'm sure. */
36 #define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
39 #ifdef __LITTLE_ENDIAN__
45 .section .text..SHmedia32,"ax"
55 # This assumes we are using gas.
92 bnei/l r29, FFI_TYPE_STRUCT, tr1
106 beqi/l r20, FFI_TYPE_VOID, tr0
107 beqi/l r20, FFI_TYPE_INT, tr1
108 beqi/l r20, FFI_TYPE_FLOAT, tr2
127 pt/l .L_pop_d_tbl, tr1
164 pt/l .L_pop_f_tbl, tr1
183 fld.s r15, OFS_FLT, fr0
185 fld.s r15, OFS_FLT, fr1
187 fld.s r15, OFS_FLT, fr2
189 fld.s r15, OFS_FLT, fr3
191 fld.s r15, OFS_FLT, fr4
193 fld.s r15, OFS_FLT, fr5
195 fld.s r15, OFS_FLT, fr6
197 fld.s r15, OFS_FLT, fr7
199 fld.s r15, OFS_FLT, fr8
201 fld.s r15, OFS_FLT, fr9
203 fld.s r15, OFS_FLT, fr10
205 fld.s r15, OFS_FLT, fr11
224 pt/l .L_pop_i_tbl, tr1
252 bnei/l r29, FFI_TYPE_STRUCT, tr1
263 pt/l .L_epilogue, tr4
265 beqi/l r29, FFI_TYPE_INT, tr0
266 beqi/l r29, FFI_TYPE_UINT32, tr0
267 beqi/l r29, FFI_TYPE_SINT64, tr1
268 beqi/l r29, FFI_TYPE_UINT64, tr1
269 beqi/l r29, FFI_TYPE_DOUBLE, tr2
270 beqi/l r29, FFI_TYPE_FLOAT, tr3
275 beqi/l r29, FFI_TYPE_UINT8, tr0
276 beqi/l r29, FFI_TYPE_UINT16, tr1
288 fst.s r31, OFS_FLT, fr0
304 # Remove the space we pushed for the args
320 .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
323 ENTRY(ffi_closure_SYSV)
325 addi.l r15, -136, r15
335 64 bytes (register parameters)
336 48 bytes (floating register parameters)
365 movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12
366 shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12
367 .LPCS0: ptrel/u r12, tr0
368 movi ((ffi_closure_helper_SYSV@GOTPLT) & 65535), r1
373 pt/l ffi_closure_helper_SYSV, tr0
378 movi (((datalabel .L_table) >> 16) & 65535), r2
379 shori ((datalabel .L_table) & 65535), r2
388 .word .L_case_v - datalabel .L_table /* FFI_TYPE_VOID */
389 .word .L_case_i - datalabel .L_table /* FFI_TYPE_INT */
390 .word .L_case_f - datalabel .L_table /* FFI_TYPE_FLOAT */
391 .word .L_case_d - datalabel .L_table /* FFI_TYPE_DOUBLE */
392 .word .L_case_d - datalabel .L_table /* FFI_TYPE_LONGDOUBLE */
393 .word .L_case_uq - datalabel .L_table /* FFI_TYPE_UINT8 */
394 .word .L_case_q - datalabel .L_table /* FFI_TYPE_SINT8 */
395 .word .L_case_uh - datalabel .L_table /* FFI_TYPE_UINT16 */
396 .word .L_case_h - datalabel .L_table /* FFI_TYPE_SINT16 */
397 .word .L_case_i - datalabel .L_table /* FFI_TYPE_UINT32 */
398 .word .L_case_i - datalabel .L_table /* FFI_TYPE_SINT32 */
399 .word .L_case_ll - datalabel .L_table /* FFI_TYPE_UINT64 */
400 .word .L_case_ll - datalabel .L_table /* FFI_TYPE_SINT64 */
401 .word .L_case_v - datalabel .L_table /* FFI_TYPE_STRUCT */
402 .word .L_case_i - datalabel .L_table /* FFI_TYPE_POINTER */
439 .ffi_closure_SYSV_end:
440 .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
442 #if defined __ELF__ && defined __linux__
443 .section .note.GNU-stack,"",@progbits
446 .section ".eh_frame","aw",@progbits
448 .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
450 .4byte 0x0 /* CIE Identifier Tag */
451 .byte 0x1 /* CIE Version */
453 .ascii "zR\0" /* CIE Augmentation */
455 .byte 0x0 /* CIE Augmentation */
457 .uleb128 0x1 /* CIE Code Alignment Factor */
458 .sleb128 -4 /* CIE Data Alignment Factor */
459 .byte 0x12 /* CIE RA Column */
461 .uleb128 0x1 /* Augmentation size */
462 .byte 0x10 /* FDE Encoding (pcrel) */
464 .byte 0xc /* DW_CFA_def_cfa */
470 .4byte datalabel .LEFDE1-datalabel .LASFDE1 /* FDE Length */
472 .4byte datalabel .LASFDE1-datalabel __FRAME_BEGIN__
474 .4byte .LFB1-. /* FDE initial location */
476 .4byte .LFB1 /* FDE initial location */
478 .4byte datalabel .LFE1-datalabel .LFB1 /* FDE address range */
480 .uleb128 0x0 /* Augmentation size */
482 .byte 0x4 /* DW_CFA_advance_loc4 */
483 .4byte datalabel .LCFI0-datalabel .LFB1
484 .byte 0xe /* DW_CFA_def_cfa_offset */
486 .byte 0x4 /* DW_CFA_advance_loc4 */
487 .4byte datalabel .LCFI1-datalabel .LCFI0
488 .byte 0x8e /* DW_CFA_offset, column 0xe */
490 .byte 0x92 /* DW_CFA_offset, column 0x12 */
492 .byte 0x9c /* DW_CFA_offset, column 0x1c */
494 .byte 0x9d /* DW_CFA_offset, column 0x1d */
496 .byte 0x9e /* DW_CFA_offset, column 0x1e */
498 .byte 0x9f /* DW_CFA_offset, column 0x1f */
500 .byte 0xa0 /* DW_CFA_offset, column 0x20 */
502 .byte 0x4 /* DW_CFA_advance_loc4 */
503 .4byte datalabel .LCFI2-datalabel .LCFI1
504 .byte 0xd /* DW_CFA_def_cfa_register */
510 .4byte datalabel .LEFDE3-datalabel .LASFDE3 /* FDE Length */
512 .4byte datalabel .LASFDE3-datalabel __FRAME_BEGIN__
514 .4byte .LFB2-. /* FDE initial location */
516 .4byte .LFB2 /* FDE initial location */
518 .4byte datalabel .LFE2-datalabel .LFB2 /* FDE address range */
520 .uleb128 0x0 /* Augmentation size */
522 .byte 0x4 /* DW_CFA_advance_loc4 */
523 .4byte datalabel .LCFI3-datalabel .LFB2
524 .byte 0xe /* DW_CFA_def_cfa_offset */
526 .byte 0x4 /* DW_CFA_advance_loc4 */
527 .4byte datalabel .LCFI4-datalabel .LCFI3
528 .byte 0x8c /* DW_CFA_offset, column 0xc */
530 .byte 0x8e /* DW_CFA_offset, column 0xe */
532 .byte 0x92 /* DW_CFA_offset, column 0x12 */
534 .byte 0x4 /* DW_CFA_advance_loc4 */
535 .4byte datalabel .LCFI5-datalabel .LCFI4
536 .byte 0xd /* DW_CFA_def_cfa_register */