master
1/* Miscellaneous macros.
2 Copyright (C) 2022-2025 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#include <sys/regdef.h>
23#include <sysdeps/generic/sysdep.h>
24
25/* Macros to handle different pointer/register sizes for 32/64-bit code. */
26#define SZREG 8
27#define SZFREG 8
28#define SZVREG 16
29#define SZXREG 32
30#define REG_L ld.d
31#define REG_S st.d
32#define SRLI srli.d
33#define SLLI slli.d
34#define ADDI addi.d
35#define ADD add.d
36#define SUB sub.d
37#define BSTRINS bstrins.d
38#define LI li.d
39#define FREG_L fld.d
40#define FREG_S fst.d
41
42/* Declare leaf routine.
43 The usage of macro LEAF/ENTRY is as follows:
44 1. LEAF(fcn) -- the align value of fcn is .align 3 (default value)
45 2. LEAF(fcn, 6) -- the align value of fcn is .align 6
46*/
47#define LEAF_IMPL(symbol, aln, ...) \
48 .text; \
49 .globl symbol; \
50 .align aln; \
51 .type symbol, @function; \
52symbol: \
53 cfi_startproc;
54
55
56#define LEAF(...) LEAF_IMPL(__VA_ARGS__, 3)
57#define ENTRY(...) LEAF(__VA_ARGS__)
58
59#define LEAF_NO_ALIGN(symbol) \
60 .text; \
61 .globl symbol; \
62 .type symbol, @function; \
63symbol: \
64 cfi_startproc;
65
66#define ENTRY_NO_ALIGN(symbol) LEAF_NO_ALIGN(symbol)
67
68
69/* Mark end of function. */
70#undef END
71#define END(function) \
72 cfi_endproc; \
73 .size function, .- function;
74
75/* Stack alignment. */
76#define ALMASK ~15
77
78#endif /* sys/asm.h */