Split print_rtx into subroutines
[official-gcc.git] / gcc / builtin-attrs.def
blob8dc59c9b726d6d731003080419211c30232836f9
1 /* Copyright (C) 2001-2016 Free Software Foundation, Inc.
2 Contributed by Joseph Myers <jsm28@cam.ac.uk>.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* This header provides a declarative way of describing the attributes
21 that are applied to some functions by default.
23 Before including this header, you must define the following macros.
24 In each case where there is an ENUM, it is an identifier used to
25 reference the tree in subsequent definitions.
27 DEF_ATTR_NULL_TREE (ENUM)
29 Constructs a NULL_TREE.
31 DEF_ATTR_INT (ENUM, VALUE)
33 Constructs an INTEGER_CST with value VALUE (an integer representable
34 in HOST_WIDE_INT).
36 DEF_ATTR_IDENT (ENUM, STRING)
38 Constructs an IDENTIFIER_NODE for STRING.
40 DEF_ATTR_TREE_LIST (ENUM, PURPOSE, VALUE, CHAIN)
42 Constructs a TREE_LIST with given PURPOSE, VALUE and CHAIN (given
43 as previous ENUM names). */
45 DEF_ATTR_NULL_TREE (ATTR_NULL)
47 /* Construct a tree for a given integer and a list containing it. */
48 #define DEF_ATTR_FOR_INT(VALUE) \
49 DEF_ATTR_INT (ATTR_##VALUE, VALUE) \
50 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE, ATTR_NULL, \
51 ATTR_##VALUE, ATTR_NULL)
52 DEF_ATTR_FOR_INT (0)
53 DEF_ATTR_FOR_INT (1)
54 DEF_ATTR_FOR_INT (2)
55 DEF_ATTR_FOR_INT (3)
56 DEF_ATTR_FOR_INT (4)
57 DEF_ATTR_FOR_INT (5)
58 DEF_ATTR_FOR_INT (6)
59 #undef DEF_ATTR_FOR_INT
61 /* Construct a tree for a given string and a list containing it. */
62 #define DEF_ATTR_FOR_STRING(ENUM, VALUE) \
63 DEF_ATTR_STRING (ATTR_##ENUM, VALUE) \
64 DEF_ATTR_TREE_LIST (ATTR_LIST_##ENUM, ATTR_NULL, \
65 ATTR_##ENUM, ATTR_NULL)
66 DEF_ATTR_FOR_STRING (STR1, "1")
67 #undef DEF_ATTR_FOR_STRING
69 /* Construct a tree for a list of two integers. */
70 #define DEF_LIST_INT_INT(VALUE1, VALUE2) \
71 DEF_ATTR_TREE_LIST (ATTR_LIST_##VALUE1##_##VALUE2, ATTR_NULL, \
72 ATTR_##VALUE1, ATTR_LIST_##VALUE2)
73 DEF_LIST_INT_INT (1,0)
74 DEF_LIST_INT_INT (1,2)
75 DEF_LIST_INT_INT (2,0)
76 DEF_LIST_INT_INT (2,3)
77 DEF_LIST_INT_INT (3,0)
78 DEF_LIST_INT_INT (3,4)
79 DEF_LIST_INT_INT (4,0)
80 DEF_LIST_INT_INT (4,5)
81 DEF_LIST_INT_INT (5,0)
82 DEF_LIST_INT_INT (5,6)
83 #undef DEF_LIST_INT_INT
85 /* Construct trees for identifiers. */
86 DEF_ATTR_IDENT (ATTR_COLD, "cold")
87 DEF_ATTR_IDENT (ATTR_CONST, "const")
88 DEF_ATTR_IDENT (ATTR_FORMAT, "format")
89 DEF_ATTR_IDENT (ATTR_FORMAT_ARG, "format_arg")
90 DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
91 DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
92 DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
93 DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
94 DEF_ATTR_IDENT (ATTR_LEAF, "leaf")
95 DEF_ATTR_IDENT (ATTR_FNSPEC, "fn spec")
96 DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
97 DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
98 DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
99 DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
100 DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
101 DEF_ATTR_IDENT (ATTR_PURE, "pure")
102 DEF_ATTR_IDENT (ATTR_NOVOPS, "no vops")
103 DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
104 DEF_ATTR_IDENT (ATTR_SENTINEL, "sentinel")
105 DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
106 DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
107 DEF_ATTR_IDENT (ATTR_TYPEGENERIC, "type generic")
108 DEF_ATTR_IDENT (ATTR_TM_REGPARM, "*tm regparm")
109 DEF_ATTR_IDENT (ATTR_TM_TMPURE, "transaction_pure")
110 DEF_ATTR_IDENT (ATTR_RETURNS_TWICE, "returns_twice")
112 DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
114 DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOVOPS_LIST)
116 DEF_ATTR_TREE_LIST (ATTR_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NULL)
118 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
120 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_LIST)
122 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
123 ATTR_NULL, ATTR_NOTHROW_LIST)
124 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_CONST, \
125 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
126 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
127 ATTR_NULL, ATTR_NOTHROW_LIST)
128 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LEAF_LIST, ATTR_PURE, \
129 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
130 DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
131 ATTR_NULL, ATTR_NOTHROW_LIST)
132 DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_LIST, ATTR_NORETURN,\
133 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
134 DEF_ATTR_TREE_LIST (ATTR_RT_NOTHROW_LEAF_LIST, ATTR_RETURNS_TWICE,\
135 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
136 DEF_ATTR_TREE_LIST (ATTR_COLD_NOTHROW_LEAF_LIST, ATTR_COLD,\
137 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
138 DEF_ATTR_TREE_LIST (ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST, ATTR_COLD,\
139 ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
140 DEF_ATTR_TREE_LIST (ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST, ATTR_CONST,\
141 ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
142 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
143 ATTR_NULL, ATTR_NOTHROW_LIST)
144 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_MALLOC, \
145 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
146 DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL, \
147 ATTR_NULL, ATTR_NOTHROW_LIST)
148 DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LEAF_LIST, ATTR_SENTINEL, \
149 ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
150 DEF_ATTR_TREE_LIST (ATTR_COLD_CONST_NORETURN_NOTHROW_LEAF_LIST, ATTR_CONST,\
151 ATTR_NULL, ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
153 /* Functions whose pointer parameter(s) are all nonnull. */
154 DEF_ATTR_TREE_LIST (ATTR_NONNULL_LIST, ATTR_NONNULL, ATTR_NULL, ATTR_NULL)
155 /* Functions whose first parameter is a nonnull pointer. */
156 DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
157 /* Functions whose second parameter is a nonnull pointer. */
158 DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
159 /* Functions whose third parameter is a nonnull pointer. */
160 DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
161 /* Nothrow functions with the sentinel(1) attribute. */
162 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_SENTINEL_1, ATTR_SENTINEL, ATTR_LIST_1, \
163 ATTR_NOTHROW_LIST)
164 /* Nothrow functions whose pointer parameter(s) are all nonnull. */
165 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL, ATTR_NONNULL, ATTR_NULL, \
166 ATTR_NOTHROW_LIST)
167 /* Nothrow leaf functions whose pointer parameter(s) are all nonnull. */
168 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF, ATTR_NONNULL, ATTR_NULL, \
169 ATTR_NOTHROW_LEAF_LIST)
170 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_NONNULL_LEAF)
171 /* Nothrow functions whose first parameter is a nonnull pointer. */
172 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
173 ATTR_NOTHROW_LIST)
174 /* Nothrow functions whose second parameter is a nonnull pointer. */
175 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
176 ATTR_NOTHROW_LIST)
177 /* Nothrow functions whose third parameter is a nonnull pointer. */
178 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
179 ATTR_NOTHROW_LIST)
180 /* Nothrow functions whose fourth parameter is a nonnull pointer. */
181 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_4, ATTR_NONNULL, ATTR_LIST_4, \
182 ATTR_NOTHROW_LIST)
183 /* Nothrow functions whose fifth parameter is a nonnull pointer. */
184 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_5, ATTR_NONNULL, ATTR_LIST_5, \
185 ATTR_NOTHROW_LIST)
186 /* Nothrow leaf functions which are type-generic. */
187 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
188 ATTR_NOTHROW_LEAF_LIST)
189 /* Nothrow nonnull leaf functions that are type-generic. */
190 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_TYPEGENERIC_LEAF,
191 ATTR_TYPEGENERIC, ATTR_NULL,
192 ATTR_NOTHROW_NONNULL_LEAF)
193 /* Nothrow const functions whose pointer parameter(s) are all nonnull. */
194 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL, ATTR_CONST, ATTR_NULL, \
195 ATTR_NOTHROW_NONNULL)
196 /* Nothrow leaf functions whose pointer parameter(s) are all nonnull,
197 and which return their first argument. */
198 DEF_ATTR_TREE_LIST (ATTR_RET1_NOTHROW_NONNULL_LEAF, ATTR_FNSPEC, ATTR_LIST_STR1, \
199 ATTR_NOTHROW_NONNULL_LEAF)
200 /* Nothrow const leaf functions whose pointer parameter(s) are all nonnull. */
201 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL_LEAF, ATTR_CONST, ATTR_NULL, \
202 ATTR_NOTHROW_NONNULL_LEAF)
203 /* Nothrow const functions which are type-generic. */
204 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC, ATTR_TYPEGENERIC, ATTR_NULL, \
205 ATTR_CONST_NOTHROW_LIST)
206 /* Nothrow const leaf functions which are type-generic. */
207 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
208 ATTR_CONST_NOTHROW_LEAF_LIST)
209 /* Nothrow pure functions whose pointer parameter(s) are all nonnull. */
210 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL, ATTR_PURE, ATTR_NULL, \
211 ATTR_NOTHROW_NONNULL)
212 /* Nothrow pure leaf functions whose pointer parameter(s) are all nonnull. */
213 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_LEAF, ATTR_PURE, ATTR_NULL, \
214 ATTR_NOTHROW_NONNULL_LEAF)
215 /* Nothrow malloc functions whose pointer parameter(s) are all nonnull. */
216 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL, ATTR_MALLOC, ATTR_NULL, \
217 ATTR_NOTHROW_NONNULL)
218 /* Nothrow malloc leaf functions whose pointer parameter(s) are all nonnull. */
219 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL_LEAF, ATTR_MALLOC, ATTR_NULL, \
220 ATTR_NOTHROW_NONNULL_LEAF)
222 /* Construct a tree for a format attribute. */
223 #define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
224 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
225 ATTR_##TYPE, ATTR_LIST_##VALUES) \
226 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
227 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA)
228 #define DEF_FORMAT_ATTRIBUTE_NOTHROW(TYPE, FA, VALUES) \
229 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
230 ATTR_##TYPE, ATTR_LIST_##VALUES) \
231 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
232 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
233 #define DEF_FORMAT_ATTRIBUTE_BOTH(TYPE, FA, VALUES) \
234 DEF_ATTR_TREE_LIST (ATTR_##TYPE##_##VALUES, ATTR_NULL, \
235 ATTR_##TYPE, ATTR_LIST_##VALUES) \
236 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_##VALUES, ATTR_FORMAT, \
237 ATTR_##TYPE##_##VALUES, ATTR_NONNULL_##FA) \
238 DEF_ATTR_TREE_LIST (ATTR_FORMAT_##TYPE##_NOTHROW_##VALUES, ATTR_FORMAT,\
239 ATTR_##TYPE##_##VALUES, ATTR_NOTHROW_NONNULL_##FA)
240 DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
241 DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
242 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_0)
243 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,2,2_3)
244 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_0)
245 DEF_FORMAT_ATTRIBUTE_BOTH(PRINTF,3,3_4)
246 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_0)
247 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,4,4_5)
248 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_0)
249 DEF_FORMAT_ATTRIBUTE_NOTHROW(PRINTF,5,5_6)
250 DEF_FORMAT_ATTRIBUTE(SCANF,1,1_0)
251 DEF_FORMAT_ATTRIBUTE(SCANF,1,1_2)
252 DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_0)
253 DEF_FORMAT_ATTRIBUTE_BOTH(SCANF,2,2_3)
254 DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFTIME,3,3_0)
255 DEF_FORMAT_ATTRIBUTE_NOTHROW(STRFMON,3,3_4)
256 #undef DEF_FORMAT_ATTRIBUTE
257 #undef DEF_FORMAT_ATTRIBUTE_NOTHROW
258 #undef DEF_FORMAT_ATTRIBUTE_BOTH
260 /* Transactional memory variants of the above. */
262 DEF_ATTR_TREE_LIST (ATTR_TM_NOTHROW_LIST,
263 ATTR_TM_REGPARM, ATTR_NULL, ATTR_NOTHROW_LIST)
264 DEF_ATTR_TREE_LIST (ATTR_TM_TMPURE_NOTHROW_LIST,
265 ATTR_TM_TMPURE, ATTR_NULL, ATTR_TM_NOTHROW_LIST)
266 DEF_ATTR_TREE_LIST (ATTR_TM_PURE_TMPURE_NOTHROW_LIST,
267 ATTR_PURE, ATTR_NULL, ATTR_TM_TMPURE_NOTHROW_LIST)
268 DEF_ATTR_TREE_LIST (ATTR_TM_NORETURN_NOTHROW_LIST,
269 ATTR_TM_REGPARM, ATTR_NULL, ATTR_NORETURN_NOTHROW_LIST)
270 DEF_ATTR_TREE_LIST (ATTR_TM_CONST_NOTHROW_LIST,
271 ATTR_TM_REGPARM, ATTR_NULL, ATTR_CONST_NOTHROW_LIST)
272 DEF_ATTR_TREE_LIST (ATTR_TM_NOTHROW_RT_LIST,
273 ATTR_RETURNS_TWICE, ATTR_NULL, ATTR_TM_NOTHROW_LIST)
275 /* Same attributes used for BUILT_IN_MALLOC except with TM_PURE thrown in. */
276 DEF_ATTR_TREE_LIST (ATTR_TMPURE_MALLOC_NOTHROW_LIST,
277 ATTR_TM_TMPURE, ATTR_NULL, ATTR_MALLOC_NOTHROW_LIST)
278 /* Same attributes used for BUILT_IN_FREE except with TM_PURE thrown in. */
279 DEF_ATTR_TREE_LIST (ATTR_TMPURE_NOTHROW_LIST,
280 ATTR_TM_TMPURE, ATTR_NULL, ATTR_NOTHROW_LIST)
282 DEF_ATTR_TREE_LIST (ATTR_TMPURE_NOTHROW_LEAF_LIST,
283 ATTR_TM_TMPURE, ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
284 DEF_ATTR_TREE_LIST (ATTR_TMPURE_NORETURN_NOTHROW_LEAF_LIST,
285 ATTR_TM_TMPURE, ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
287 /* Construct a tree for a format_arg attribute. */
288 #define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
289 DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_##FA, ATTR_FORMAT_ARG, \
290 ATTR_LIST_##FA, ATTR_NOTHROW_NONNULL_##FA)
291 DEF_FORMAT_ARG_ATTRIBUTE(1)
292 DEF_FORMAT_ARG_ATTRIBUTE(2)
293 #undef DEF_FORMAT_ARG_ATTRIBUTE