Debian Codegraph @

gcc/config/avr/builtins.def

raw
1 /* Copyright (C) 2012-2025 Free Software Foundation, Inc.
2
3 This file is part of GCC.
4
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
9
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING3. If not see
17 <http://www.gnu.org/licenses/>. */
18
19 /* This file contains the definitions and documentation for the
20 builtins defined in the AVR part of the GNU compiler.
21 Befor including this file, define a macro
22
23 DEF_BUILTIN(NAME, N_ARGS, TYPE, ICODE, LIBNAME, ATTRS)
24
25 NAME: `__builtin_avr_name' will be the user-level name of the builtin.
26 `AVR_BUILTIN_NAME' will be the internal builtin's id.
27 N_ARGS: Number of input arguments. If special treatment is needed,
28 set to -1 and handle it by hand, see avr.cc:avr_expand_builtin().
29 TYPE: A tree node describing the prototype of the built-in.
30 ICODE: Name of attached insn or expander. If special treatment in avr.cc
31 is needed to expand the built-in, use `nothing'.
32 LIBNAME: Name of the attached implementation in libgcc which is used if
33 the builtin cannot be folded away and there is no insn.
34 ATTRS: Function attributes like "attr_const" for the `const' attribute
35 or "NULL_TREE" for no attribute. */
36
37 #define AVR_FIRST_C_ONLY_BUILTIN_ID AVR_BUILTIN_FLASH_SEGMENT
38
39 /* Mapped to respective instruction. */
40
41 DEF_BUILTIN (NOP, -1, void_ftype_void, nothing, NULL, NULL_TREE)
42 DEF_BUILTIN (SEI, 0, void_ftype_void, enable_interrupt, NULL, NULL_TREE)
43 DEF_BUILTIN (CLI, 0, void_ftype_void, disable_interrupt, NULL, NULL_TREE)
44 DEF_BUILTIN (WDR, 0, void_ftype_void, wdr, NULL, NULL_TREE)
45 DEF_BUILTIN (SLEEP, 0, void_ftype_void, sleep, NULL, NULL_TREE)
46
47 /* Mapped to respective instruction but might also be folded away
48 or emit as libgcc call if ISA does not provide the instruction. */
49
50 DEF_BUILTIN (SWAP, 1, uintQI_ftype_uintQI, rotlqi3_4, NULL, attr_const)
51 DEF_BUILTIN (FMUL, 2, uintHI_ftype_uintQI_uintQI, fmul, NULL, attr_const)
52 DEF_BUILTIN (FMULS, 2, intHI_ftype_intQI_intQI, fmuls, NULL, attr_const)
53 DEF_BUILTIN (FMULSU, 2, intHI_ftype_intQI_uintQI, fmulsu, NULL, attr_const)
54
55 /* More complex stuff that cannot be mapped 1:1 to an instruction. */
56
57 DEF_BUILTIN (DELAY_CYCLES, -1, void_ftype_uintSI, nothing, NULL, NULL_TREE)
58 DEF_BUILTIN (NOPS, -1, void_ftype_uintSI, nothing, NULL, NULL_TREE)
59 DEF_BUILTIN (MASK1, 2, uintQI_ftype_uintQI_uintQI, gen_mask1, NULL, attr_const)
60 DEF_BUILTIN (INSERT_BITS, 3, uintQI_ftype_uintSI_uintQI_uintQI, insert_bits, NULL, attr_const)
61
62 /* All following built-ins are C only, see avr.cc::avr_builtin_C_only_p()
63 * since they are using named address-spaces or fixed-point types, none
64 * of which are supported for C++. */
65
66 DEF_BUILTIN (FLASH_SEGMENT, 1, intQI_ftype_const_memx_ptr, flash_segment, NULL, attr_const)
67
68 /* strlen for ASes so that __builtin_constant_p can be used wthout raising
69 a diagnostic from -Waddr-space-convert in some AVR-LibC headers. */
70 DEF_BUILTIN (STRLEN_FLASH, 1, strlen_flash_node, nothing, "__strlen_P", attr_const) // AVR-LibC
71 DEF_BUILTIN (STRLEN_FLASHX, 1, strlen_flashx_node, nothing, "strlen_PF", attr_const) // AVR-LibC
72 DEF_BUILTIN (STRLEN_MEMX, 1, strlen_memx_node, nothing, "__strlen_memx", NULL_TREE)
73
74 /* ISO/IEC TR 18037 "Embedded C"
75 The following builtins are undocumented and used by stdfix.h. */
76
77 /* 7.18a.6 The fixed-point intrinsic functions. */
78
79 /* 7.18a.6.2 The fixed-point absolute value functions. */
80
81 DEF_BUILTIN (ABSHR, 1, hr_ftype_hr, ssabsqq2, "__ssabs_1", attr_const)
82 DEF_BUILTIN (ABSR, 1, nr_ftype_nr, ssabshq2, "__ssabs_2", attr_const)
83 DEF_BUILTIN (ABSLR, 1, lr_ftype_lr, ssabssq2, "__ssabs_4", attr_const)
84 DEF_BUILTIN (ABSLLR, -1, llr_ftype_llr, nothing, "__ssabsdq2", attr_const) // GCC extension
85
86 DEF_BUILTIN (ABSHK, 1, hk_ftype_hk, ssabsha2, "__ssabs_2", attr_const)
87 DEF_BUILTIN (ABSK, 1, nk_ftype_nk, ssabssa2, "__ssabs_4", attr_const)
88 DEF_BUILTIN (ABSLK, -1, lk_ftype_lk, nothing, "__ssabsda2", attr_const)
89 DEF_BUILTIN (ABSLLK, -1, llk_ftype_llk, nothing, "__ssabsta2", attr_const) // GCC extension
90
91 /* 7.18a.6.3 The fixed-point round functions. */
92
93 DEF_BUILTIN (ROUNDHR, 2, hr_ftype_hr_int, roundqq3, "__roundhr", attr_const)
94 DEF_BUILTIN (ROUNDR, 2, nr_ftype_nr_int, roundhq3, "__roundr", attr_const)
95 DEF_BUILTIN (ROUNDLR, 2, lr_ftype_lr_int, roundsq3, "__roundlr", attr_const)
96 DEF_BUILTIN (ROUNDLLR, -1, llr_ftype_llr_int, nothing, "__rounddq3", attr_const) // GCC extension
97
98 DEF_BUILTIN (ROUNDUHR, 2, uhr_ftype_uhr_int, rounduqq3, "__rounduhr", attr_const)
99 DEF_BUILTIN (ROUNDUR, 2, unr_ftype_unr_int, rounduhq3, "__roundur", attr_const)
100 DEF_BUILTIN (ROUNDULR, 2, ulr_ftype_ulr_int, roundusq3, "__roundulr", attr_const)
101 DEF_BUILTIN (ROUNDULLR, -1, ullr_ftype_ullr_int, nothing, "__roundudq3", attr_const) // GCC extension
102
103 DEF_BUILTIN (ROUNDHK, 2, hk_ftype_hk_int, roundha3, "__roundhk", attr_const)
104 DEF_BUILTIN (ROUNDK, 2, nk_ftype_nk_int, roundsa3, "__roundk", attr_const)
105 DEF_BUILTIN (ROUNDLK, -1, lk_ftype_lk_int, nothing, "__roundda3", attr_const)
106 DEF_BUILTIN (ROUNDLLK, -1, llk_ftype_llk_int, nothing, "__roundta3", attr_const) // GCC extension
107
108 DEF_BUILTIN (ROUNDUHK, 2, uhk_ftype_uhk_int, rounduha3, "__rounduhk", attr_const)
109 DEF_BUILTIN (ROUNDUK, 2, unk_ftype_unk_int, roundusa3, "__rounduk", attr_const)
110 DEF_BUILTIN (ROUNDULK, -1, ulk_ftype_ulk_int, nothing, "__rounduda3", attr_const)
111 DEF_BUILTIN (ROUNDULLK, -1, ullk_ftype_ullk_int, nothing, "__rounduta3", attr_const) // GCC extension
112
113 /* 7.18a.6.4 The fixed-point bit countls functions. */
114
115 DEF_BUILTIN (COUNTLSHR, -1, int_ftype_hr, nothing, "__countlsqi2", attr_const)
116 DEF_BUILTIN (COUNTLSR, -1, int_ftype_nr, nothing, "__countlshi2", attr_const)
117 DEF_BUILTIN (COUNTLSLR, -1, int_ftype_lr, nothing, "__countlssi2", attr_const)
118 DEF_BUILTIN (COUNTLSLLR, -1, int_ftype_llr, nothing, "__countlsdi2", attr_const) // GCC extension
119
120 DEF_BUILTIN (COUNTLSUHR, -1, int_ftype_uhr, nothing, "__countlsuqi2", attr_const)
121 DEF_BUILTIN (COUNTLSUR, -1, int_ftype_unr, nothing, "__countlsuhi2", attr_const)
122 DEF_BUILTIN (COUNTLSULR, -1, int_ftype_ulr, nothing, "__countlsusi2", attr_const)
123 DEF_BUILTIN (COUNTLSULLR, -1, int_ftype_ullr, nothing, "__countlsudi2", attr_const) // GCC extension
124
125 DEF_BUILTIN (COUNTLSHK, -1, int_ftype_hk, nothing, "__countlshi2", attr_const)
126 DEF_BUILTIN (COUNTLSK, -1, int_ftype_nk, nothing, "__countlssi2", attr_const)
127 DEF_BUILTIN (COUNTLSLK, -1, int_ftype_lk, nothing, "__countlsdi2", attr_const)
128 DEF_BUILTIN (COUNTLSLLK, -1, int_ftype_llk, nothing, "__countlsdi2", attr_const) // GCC extension
129
130 DEF_BUILTIN (COUNTLSUHK, -1, int_ftype_uhk, nothing, "__countlsuhi2", attr_const)
131 DEF_BUILTIN (COUNTLSUK, -1, int_ftype_unk, nothing, "__countlsusi2", attr_const)
132 DEF_BUILTIN (COUNTLSULK, -1, int_ftype_ulk, nothing, "__countlsudi2", attr_const)
133 DEF_BUILTIN (COUNTLSULLK, -1, int_ftype_ullk, nothing, "__countlsudi2", attr_const) // GCC extension
134
135 /* 7.18a.6.5 The bitwise fixed-point to integer conversion functions. */
136
137 DEF_BUILTIN (BITSHR, -1, inthr_ftype_hr, nothing, "__ret", attr_const)
138 DEF_BUILTIN (BITSR, -1, intnr_ftype_nr, nothing, "__ret", attr_const)
139 DEF_BUILTIN (BITSLR, -1, intlr_ftype_lr, nothing, "__ret", attr_const)
140 DEF_BUILTIN (BITSLLR, -1, intllr_ftype_llr, nothing, "__ret", attr_const) // GCC extension
141
142 DEF_BUILTIN (BITSUHR, -1, intuhr_ftype_uhr, nothing, "__ret", attr_const)
143 DEF_BUILTIN (BITSUR, -1, intunr_ftype_unr, nothing, "__ret", attr_const)
144 DEF_BUILTIN (BITSULR, -1, intulr_ftype_ulr, nothing, "__ret", attr_const)
145 DEF_BUILTIN (BITSULLR, -1, intullr_ftype_ullr, nothing, "__ret", attr_const) // GCC extension
146
147 DEF_BUILTIN (BITSHK, -1, inthk_ftype_hk, nothing, "__ret", attr_const)
148 DEF_BUILTIN (BITSK, -1, intnk_ftype_nk, nothing, "__ret", attr_const)
149 DEF_BUILTIN (BITSLK, -1, intlk_ftype_lk, nothing, "__ret", attr_const)
150 DEF_BUILTIN (BITSLLK, -1, intllk_ftype_llk, nothing, "__ret", attr_const) // GCC extension
151
152 DEF_BUILTIN (BITSUHK, -1, intuhk_ftype_uhk, nothing, "__ret", attr_const)
153 DEF_BUILTIN (BITSUK, -1, intunk_ftype_unk, nothing, "__ret", attr_const)
154 DEF_BUILTIN (BITSULK, -1, intulk_ftype_ulk, nothing, "__ret", attr_const)
155 DEF_BUILTIN (BITSULLK, -1, intullk_ftype_ullk, nothing, "__ret", attr_const) // GCC extension
156
157
158 /* 7.18a.6.6 The bitwise integer to fixed-point conversion functions. */
159
160 DEF_BUILTIN ( HRBITS, -1, hr_ftype_inthr, nothing, "__ret", attr_const)
161 DEF_BUILTIN ( RBITS, -1, nr_ftype_intnr, nothing, "__ret", attr_const)
162 DEF_BUILTIN ( LRBITS, -1, lr_ftype_intlr, nothing, "__ret", attr_const)
163 DEF_BUILTIN ( LLRBITS, -1, llr_ftype_intllr, nothing, "__ret", attr_const) // GCC extension
164
165 DEF_BUILTIN ( UHRBITS, -1, uhr_ftype_intuhr, nothing, "__ret", attr_const)
166 DEF_BUILTIN ( URBITS, -1, unr_ftype_intunr, nothing, "__ret", attr_const)
167 DEF_BUILTIN ( ULRBITS, -1, ulr_ftype_intulr, nothing, "__ret", attr_const)
168 DEF_BUILTIN (ULLRBITS, -1, ullr_ftype_intullr, nothing, "__ret", attr_const) // GCC extension
169
170 DEF_BUILTIN ( HKBITS, -1, hk_ftype_inthk, nothing, "__ret", attr_const)
171 DEF_BUILTIN ( KBITS, -1, nk_ftype_intnk, nothing, "__ret", attr_const)
172 DEF_BUILTIN ( LKBITS, -1, lk_ftype_intlk, nothing, "__ret", attr_const)
173 DEF_BUILTIN ( LLKBITS, -1, llk_ftype_intllk, nothing, "__ret", attr_const) // GCC extension
174
175 DEF_BUILTIN ( UHKBITS, -1, uhk_ftype_intuhk, nothing, "__ret", attr_const)
176 DEF_BUILTIN ( UKBITS, -1, unk_ftype_intunk, nothing, "__ret", attr_const)
177 DEF_BUILTIN ( ULKBITS, -1, ulk_ftype_intulk, nothing, "__ret", attr_const)
178 DEF_BUILTIN (ULLKBITS, -1, ullk_ftype_intullk, nothing, "__ret", attr_const) // GCC extension
179
180 /* Overloaded */
181
182 /* 7.18a.6.7 Type-generic fixed-point functions. */
183
184 DEF_BUILTIN (ABSFX, -1, void_ftype_void /* dummy */, nothing, NULL, attr_const)
185 DEF_BUILTIN (ROUNDFX, -1, void_ftype_void /* dummy */, nothing, NULL, attr_const)
186 DEF_BUILTIN (COUNTLSFX, -1, void_ftype_void /* dummy */, nothing, NULL, attr_const)