| 1 | /* Miscellaneous macros. |
| 2 | Copyright (C) 2000-2026 Free Software Foundation, Inc. |
| 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 |
| 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 | <https://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef _SYS_ASM_H |
| 20 | #define _SYS_ASM_H |
| 21 | |
| 22 | /* Macros to handle different pointer/register sizes for 32/64-bit code. */ |
| 23 | #if __riscv_xlen == 64 |
| 24 | # define PTRLOG 3 |
| 25 | # define SZREG 8 |
| 26 | # define REG_S sd |
| 27 | # define REG_L ld |
| 28 | #elif __riscv_xlen == 32 |
| 29 | # define PTRLOG 2 |
| 30 | # define SZREG 4 |
| 31 | # define REG_S sw |
| 32 | # define REG_L lw |
| 33 | #else |
| 34 | # error __riscv_xlen must equal 32 or 64 |
| 35 | #endif |
| 36 | |
| 37 | #if !defined __riscv_float_abi_soft |
| 38 | /* For ABI uniformity, reserve 8 bytes for floats, even if double-precision |
| 39 | floating-point is not supported in hardware. */ |
| 40 | # if defined __riscv_float_abi_double |
| 41 | # define FREG_L fld |
| 42 | # define FREG_S fsd |
| 43 | # define SZFREG 8 |
| 44 | # else |
| 45 | # error unsupported FLEN |
| 46 | # endif |
| 47 | #endif |
| 48 | |
| 49 | /* Declare leaf routine. */ |
| 50 | #define	LEAF(symbol)				\ |
| 51 | 		.globl	symbol;			\ |
| 52 | 		.align	2;			\ |
| 53 | 		.type	symbol,@function;	\ |
| 54 | symbol:						\ |
| 55 | 		cfi_startproc; |
| 56 | |
| 57 | /* Mark end of function. */ |
| 58 | #undef END |
| 59 | #define END(function)				\ |
| 60 | 		cfi_endproc;			\ |
| 61 | 		.size	function,.-function |
| 62 | |
| 63 | /* Stack alignment. */ |
| 64 | #define ALMASK	~15 |
| 65 | |
| 66 | #endif /* sys/asm.h */ |