lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* Copyright (C) 2011-2015 Free Software Foundation, Inc. |
| 2 | This file is part of the GNU C Library. |
| 3 | Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. |
| 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 |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the 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 | #include <bits/wordsize.h> |
| 21 | #include <arch/abi.h> |
| 22 | |
| 23 | #if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS |
| 24 | |
| 25 | #include <feedback.h> |
| 26 | |
| 27 | /* Make use of .size directive. */ |
| 28 | #define ASM_SIZE_DIRECTIVE(name) .size name,.-name; |
| 29 | |
| 30 | /* Define an entry point visible from C. */ |
| 31 | #define ENTRY(name) \ |
| 32 | .globl C_SYMBOL_NAME(name); \ |
| 33 | .type C_SYMBOL_NAME(name),@function; \ |
| 34 | .align 8; \ |
| 35 | C_LABEL(name) \ |
| 36 | cfi_startproc; \ |
| 37 | CALL_MCOUNT |
| 38 | |
| 39 | #undef END |
| 40 | #define END(name) \ |
| 41 | cfi_endproc; \ |
| 42 | ASM_SIZE_DIRECTIVE(name) |
| 43 | |
| 44 | /* Since C identifiers are not normally prefixed with an underscore |
| 45 | on this system, the asm identifier `syscall_error' intrudes on the |
| 46 | C name space. Make sure we use an innocuous name. */ |
| 47 | #define syscall_error __syscall_error |
| 48 | #define mcount __mcount |
| 49 | |
| 50 | /* If compiled for profiling, call `mcount' at the start of each function. |
| 51 | The mcount code requires the caller PC in r10. The `mcount' function |
| 52 | sets lr back to the value r10 had on entry when it returns. */ |
| 53 | #ifdef PROF |
| 54 | #define CALL_MCOUNT { move r10, lr; jal mcount } |
| 55 | #else |
| 56 | #define CALL_MCOUNT /* Do nothing. */ |
| 57 | #endif |
| 58 | |
| 59 | /* Local label name for asm code. */ |
| 60 | #define L(name) .L##name |
| 61 | |
| 62 | /* Specify the size in bytes of a machine register. */ |
| 63 | #ifdef __tilegx__ |
| 64 | #define REGSIZE 8 |
| 65 | #else |
| 66 | #define REGSIZE 4 |
| 67 | #endif |
| 68 | |
| 69 | /* Support a limited form of shared assembly between tilepro and tilegx. |
| 70 | The presumption is that LD/ST are used for manipulating registers. |
| 71 | Since opcode parsing is case-insensitive, we don't need to provide |
| 72 | definitions for these on tilegx. */ |
| 73 | #ifndef __tilegx__ |
| 74 | #define LD lw |
| 75 | #define LD4U lw |
| 76 | #define ST sw |
| 77 | #define ST4 sw |
| 78 | #define BNEZ bnz |
| 79 | #define BEQZ bz |
| 80 | #define BEQZT bzt |
| 81 | #define BGTZ bgz |
| 82 | #define CMPEQI seqi |
| 83 | #define CMPEQ seq |
| 84 | #define CMOVEQZ mvz |
| 85 | #define CMOVNEZ mvnz |
| 86 | #endif |
| 87 | |
| 88 | /* Provide "pointer-oriented" instruction variants. These differ not |
| 89 | just for tilepro vs tilegx, but also for tilegx -m64 vs -m32. */ |
| 90 | #if defined __tilegx__ && __WORDSIZE == 32 |
| 91 | #define ADD_PTR addx |
| 92 | #define ADDI_PTR addxi |
| 93 | #define ADDLI_PTR addxli |
| 94 | #define LD_PTR ld4s |
| 95 | #define ST_PTR st4 |
| 96 | #define SHL_PTR_ADD shl2add |
| 97 | #else |
| 98 | #define ADD_PTR add |
| 99 | #define ADDI_PTR addi |
| 100 | #define ADDLI_PTR addli |
| 101 | #define LD_PTR LD |
| 102 | #define ST_PTR ST |
| 103 | #ifdef __tilegx__ |
| 104 | #define SHL_PTR_ADD shl3add |
| 105 | #else |
| 106 | #define SHL_PTR_ADD s2a |
| 107 | #endif |
| 108 | #endif |
| 109 | |
| 110 | #endif /* __ASSEMBLER__ */ |
| 111 | |
| 112 | /* On tilegx, 32-bit values must have their high 32 bits sign extended; |
| 113 | random values are not allowed. */ |
| 114 | #define REGISTER_CAST_INT32_TO_INT64 1 |