Debian Codegraph @

libgcc/config/riscv/riscv-asm.h

raw
1 /* Copyright (C) 2017-2025 Free Software Foundation, Inc.
2
3 This file is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 3, or (at your option) any
6 later version.
7
8 This file is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
12
13 Under Section 7 of GPL version 3, you are granted additional
14 permissions described in the GCC Runtime Library Exception, version
15 3.1, as published by the Free Software Foundation.
16
17 You should have received a copy of the GNU General Public License and
18 a copy of the GCC Runtime Library Exception along with this program;
19 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
20 <http://www.gnu.org/licenses/>. */
21
22 #define FUNC_TYPE(X) .type X,@function
23 #define FUNC_SIZE(X) .size X,.-X
24
25 #define FUNC_BEGIN(X) \
26 .align 2; \
27 .globl X; \
28 FUNC_TYPE (X); \
29 X: \
30 LPAD
31
32 #define FUNC_END(X) \
33 FUNC_SIZE(X)
34
35 #define FUNC_ALIAS(X,Y) \
36 .globl X; \
37 X = Y
38
39 #define CONCAT1(a, b) CONCAT2(a, b)
40 #define CONCAT2(a, b) a ## b
41 #define HIDDEN_JUMPTARGET(X) CONCAT1(__hidden_, X)
42 #define HIDDEN_DEF(X) FUNC_ALIAS(HIDDEN_JUMPTARGET(X), X); \
43 .hidden HIDDEN_JUMPTARGET(X)
44
45 /* GNU_PROPERTY_RISCV64_* macros from elf.h for use in asm code. */
46 #define FEATURE_1_AND 0xc0000000
47 #define FEATURE_1_FCFI 1
48 #define FEATURE_1_BCFI 2
49
50 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
51 #if __riscv_xlen == 32
52 # define GNU_PROPERTY(type, value) \
53 .section .note.gnu.property, "a"; \
54 .p2align 2; \
55 .word 4; \
56 .word 12; \
57 .word 5; \
58 .asciz "GNU"; \
59 .word type; \
60 .word 4; \
61 .word value; \
62 .text
63 #else
64 # define GNU_PROPERTY(type, value) \
65 .section .note.gnu.property, "a"; \
66 .p2align 3; \
67 .word 4; \
68 .word 16; \
69 .word 5; \
70 .asciz "GNU"; \
71 .word type; \
72 .word 4; \
73 .word value; \
74 .word 0; \
75 .text
76 #endif
77
78 /* Add GNU property note with the supported features to all asm code
79 where sysdep.h is included. */
80 #undef __VALUE_FOR_FEATURE_1_AND
81 #if defined (__riscv_zicfilp) || defined (__riscv_zicfiss)
82 # if defined (__riscv_zicfilp)
83 # if defined (__riscv_zicfiss)
84 # define __VALUE_FOR_FEATURE_1_AND 0x3
85 # else
86 # define __VALUE_FOR_FEATURE_1_AND 0x1
87 # endif
88 # else
89 # if defined (__riscv_zicfiss)
90 # define __VALUE_FOR_FEATURE_1_AND 0x2
91 # else
92 # error "What?"
93 # endif
94 # endif
95 #endif
96
97 #if defined (__VALUE_FOR_FEATURE_1_AND)
98 GNU_PROPERTY (FEATURE_1_AND, __VALUE_FOR_FEATURE_1_AND)
99 #endif
100 #undef __VALUE_FOR_FEATURE_1_AND
101
102 #ifdef __riscv_zicfilp
103 # define SET_LPAD lui t2, 0
104 # define LPAD lpad 0
105 #else
106 # define SET_LPAD
107 # define LPAD
108 #endif