lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* Copyright (C) 1997-2015 Free Software Foundation, Inc. |
| 2 | |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public License as |
| 7 | published by the Free Software Foundation; either version 2.1 of the |
| 8 | License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, see |
| 17 | <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #include <sysdeps/generic/sysdep.h> |
| 20 | |
| 21 | #ifdef __ASSEMBLER__ |
| 22 | |
| 23 | /* Syntactic details of assembler. */ |
| 24 | |
| 25 | # define ALIGNARG(log2) log2 |
| 26 | # define ASM_SIZE_DIRECTIVE(name) .size name,.-name |
| 27 | |
| 28 | /* Define an entry point visible from C. */ |
| 29 | # define ENTRY(name) \ |
| 30 | .globl C_SYMBOL_NAME(name); \ |
| 31 | .type C_SYMBOL_NAME(name),@function; \ |
| 32 | .align ALIGNARG(2); \ |
| 33 | C_LABEL(name) \ |
| 34 | CALL_MCOUNT |
| 35 | |
| 36 | # undef END |
| 37 | # define END(name) ASM_SIZE_DIRECTIVE(name) |
| 38 | |
| 39 | |
| 40 | /* If compiled for profiling, call `_mcount' at the start of each function. */ |
| 41 | # ifdef PROF |
| 42 | /* The mcount code relies on a normal frame pointer being on the stack |
| 43 | to locate our caller, so push one just for its benefit. */ |
| 44 | # define CALL_MCOUNT \ |
| 45 | addik r1,r1,-4; \ |
| 46 | swi r15,r1,0; \ |
| 47 | brlid r15,JUMPTARGET(mcount); \ |
| 48 | nop; \ |
| 49 | lwi r15,r1,0; \ |
| 50 | addik r1,r1,4; |
| 51 | # else |
| 52 | # define CALL_MCOUNT /* Do nothing. */ |
| 53 | # endif |
| 54 | |
| 55 | /* Since C identifiers are not normally prefixed with an underscore |
| 56 | on this system, the asm identifier `syscall_error' intrudes on the |
| 57 | C name space. Make sure we use an innocuous name. */ |
| 58 | # define syscall_error __syscall_error |
| 59 | # define mcount _mcount |
| 60 | |
| 61 | # define PSEUDO(name, syscall_name, args) \ |
| 62 | .globl syscall_error; \ |
| 63 | ENTRY (name) \ |
| 64 | DO_CALL (syscall_name, args); |
| 65 | |
| 66 | # define ret \ |
| 67 | rtsd r15,8; nop; |
| 68 | |
| 69 | # undef PSEUDO_END |
| 70 | # define PSEUDO_END(name) \ |
| 71 | END (name) |
| 72 | |
| 73 | # undef JUMPTARGET |
| 74 | # ifdef PIC |
| 75 | # define JUMPTARGET(name) name##@PLTPC |
| 76 | # else |
| 77 | # define JUMPTARGET(name) name |
| 78 | # endif |
| 79 | |
| 80 | /* Local label name for asm code. */ |
| 81 | # ifndef L |
| 82 | # define L(name) $L##name |
| 83 | # endif |
| 84 | |
| 85 | # endif /* __ASSEMBLER__ */ |