annotate gcc/attribs.h @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Declarations and definitions dealing with attribute handling.
kono
parents:
diff changeset
2 Copyright (C) 2013-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #ifndef GCC_ATTRIBS_H
kono
parents:
diff changeset
21 #define GCC_ATTRIBS_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 extern const struct attribute_spec *lookup_attribute_spec (const_tree);
kono
parents:
diff changeset
24 extern void init_attributes (void);
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 /* Process the attributes listed in ATTRIBUTES and install them in *NODE,
kono
parents:
diff changeset
27 which is either a DECL (including a TYPE_DECL) or a TYPE. If a DECL,
kono
parents:
diff changeset
28 it should be modified in place; if a TYPE, a copy should be created
kono
parents:
diff changeset
29 unless ATTR_FLAG_TYPE_IN_PLACE is set in FLAGS. FLAGS gives further
kono
parents:
diff changeset
30 information, in the form of a bitwise OR of flags in enum attribute_flags
kono
parents:
diff changeset
31 from tree.h. Depending on these flags, some attributes may be
kono
parents:
diff changeset
32 returned to be applied at a later stage (for example, to apply
kono
parents:
diff changeset
33 a decl attribute to the declaration rather than to its type). */
kono
parents:
diff changeset
34 extern tree decl_attributes (tree *, tree, int);
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 extern bool cxx11_attribute_p (const_tree);
kono
parents:
diff changeset
37 extern tree get_attribute_name (const_tree);
kono
parents:
diff changeset
38 extern void apply_tm_attr (tree, tree);
kono
parents:
diff changeset
39 extern tree make_attribute (const char *, const char *, tree);
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 extern struct scoped_attributes* register_scoped_attributes (const struct attribute_spec *,
kono
parents:
diff changeset
42 const char *);
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 extern char *sorted_attr_string (tree);
kono
parents:
diff changeset
45 extern bool common_function_versions (tree, tree);
kono
parents:
diff changeset
46 extern char *make_unique_name (tree, const char *, bool);
kono
parents:
diff changeset
47 extern tree make_dispatcher_decl (const tree);
kono
parents:
diff changeset
48 extern bool is_function_default_version (const tree);
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 /* Return a type like TTYPE except that its TYPE_ATTRIBUTES
kono
parents:
diff changeset
51 is ATTRIBUTE.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 Such modified types already made are recorded so that duplicates
kono
parents:
diff changeset
54 are not made. */
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 extern tree build_type_attribute_variant (tree, tree);
kono
parents:
diff changeset
57 extern tree build_decl_attribute_variant (tree, tree);
kono
parents:
diff changeset
58 extern tree build_type_attribute_qual_variant (tree, tree, int);
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 extern bool attribute_value_equal (const_tree, const_tree);
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 /* Return 0 if the attributes for two types are incompatible, 1 if they
kono
parents:
diff changeset
63 are compatible, and 2 if they are nearly compatible (which causes a
kono
parents:
diff changeset
64 warning to be generated). */
kono
parents:
diff changeset
65 extern int comp_type_attributes (const_tree, const_tree);
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 /* Default versions of target-overridable functions. */
kono
parents:
diff changeset
68 extern tree merge_decl_attributes (tree, tree);
kono
parents:
diff changeset
69 extern tree merge_type_attributes (tree, tree);
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 /* Remove any instances of attribute ATTR_NAME in LIST and return the
kono
parents:
diff changeset
72 modified list. */
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 extern tree remove_attribute (const char *, tree);
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 /* Given two attributes lists, return a list of their union. */
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 extern tree merge_attributes (tree, tree);
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 /* Duplicate all attributes with name NAME in ATTR list to *ATTRS if
kono
parents:
diff changeset
81 they are missing there. */
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 extern void duplicate_one_attribute (tree *, tree, const char *);
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 /* Duplicate all attributes from user DECL to the corresponding
kono
parents:
diff changeset
86 builtin that should be propagated. */
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 extern void copy_attributes_to_builtin (tree);
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* Given two Windows decl attributes lists, possibly including
kono
parents:
diff changeset
91 dllimport, return a list of their union . */
kono
parents:
diff changeset
92 extern tree merge_dllimport_decl_attributes (tree, tree);
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 /* Handle a "dllimport" or "dllexport" attribute. */
kono
parents:
diff changeset
95 extern tree handle_dll_attribute (tree *, tree, tree, int, bool *);
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 extern int attribute_list_equal (const_tree, const_tree);
kono
parents:
diff changeset
98 extern int attribute_list_contained (const_tree, const_tree);
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* The backbone of lookup_attribute(). ATTR_LEN is the string length
kono
parents:
diff changeset
101 of ATTR_NAME, and LIST is not NULL_TREE.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 The function is called from lookup_attribute in order to optimize
kono
parents:
diff changeset
104 for size. */
kono
parents:
diff changeset
105 extern tree private_lookup_attribute (const char *attr_name, size_t attr_len,
kono
parents:
diff changeset
106 tree list);
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 /* For a given IDENTIFIER_NODE, strip leading and trailing '_' characters
kono
parents:
diff changeset
109 so that we have a canonical form of attribute names. */
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 static inline tree
kono
parents:
diff changeset
112 canonicalize_attr_name (tree attr_name)
kono
parents:
diff changeset
113 {
kono
parents:
diff changeset
114 const size_t l = IDENTIFIER_LENGTH (attr_name);
kono
parents:
diff changeset
115 const char *s = IDENTIFIER_POINTER (attr_name);
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 if (l > 4 && s[0] == '_' && s[1] == '_' && s[l - 1] == '_' && s[l - 2] == '_')
kono
parents:
diff changeset
118 return get_identifier_with_length (s + 2, l - 4);
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 return attr_name;
kono
parents:
diff changeset
121 }
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 /* Compare attribute identifiers ATTR1 and ATTR2 with length ATTR1_LEN and
kono
parents:
diff changeset
124 ATTR2_LEN. */
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 static inline bool
kono
parents:
diff changeset
127 cmp_attribs (const char *attr1, size_t attr1_len,
kono
parents:
diff changeset
128 const char *attr2, size_t attr2_len)
kono
parents:
diff changeset
129 {
kono
parents:
diff changeset
130 return attr1_len == attr2_len && strncmp (attr1, attr2, attr1_len) == 0;
kono
parents:
diff changeset
131 }
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 /* Compare attribute identifiers ATTR1 and ATTR2. */
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 static inline bool
kono
parents:
diff changeset
136 cmp_attribs (const char *attr1, const char *attr2)
kono
parents:
diff changeset
137 {
kono
parents:
diff changeset
138 return cmp_attribs (attr1, strlen (attr1), attr2, strlen (attr2));
kono
parents:
diff changeset
139 }
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 /* Given an identifier node IDENT and a string ATTR_NAME, return true
kono
parents:
diff changeset
142 if the identifier node is a valid attribute name for the string. */
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 static inline bool
kono
parents:
diff changeset
145 is_attribute_p (const char *attr_name, const_tree ident)
kono
parents:
diff changeset
146 {
kono
parents:
diff changeset
147 return cmp_attribs (attr_name, strlen (attr_name),
kono
parents:
diff changeset
148 IDENTIFIER_POINTER (ident), IDENTIFIER_LENGTH (ident));
kono
parents:
diff changeset
149 }
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 /* Given an attribute name ATTR_NAME and a list of attributes LIST,
kono
parents:
diff changeset
152 return a pointer to the attribute's list element if the attribute
kono
parents:
diff changeset
153 is part of the list, or NULL_TREE if not found. If the attribute
kono
parents:
diff changeset
154 appears more than once, this only returns the first occurrence; the
kono
parents:
diff changeset
155 TREE_CHAIN of the return value should be passed back in if further
kono
parents:
diff changeset
156 occurrences are wanted. ATTR_NAME must be in the form 'text' (not
kono
parents:
diff changeset
157 '__text__'). */
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 static inline tree
kono
parents:
diff changeset
160 lookup_attribute (const char *attr_name, tree list)
kono
parents:
diff changeset
161 {
kono
parents:
diff changeset
162 gcc_checking_assert (attr_name[0] != '_');
kono
parents:
diff changeset
163 /* In most cases, list is NULL_TREE. */
kono
parents:
diff changeset
164 if (list == NULL_TREE)
kono
parents:
diff changeset
165 return NULL_TREE;
kono
parents:
diff changeset
166 else
kono
parents:
diff changeset
167 {
kono
parents:
diff changeset
168 size_t attr_len = strlen (attr_name);
kono
parents:
diff changeset
169 /* Do the strlen() before calling the out-of-line implementation.
kono
parents:
diff changeset
170 In most cases attr_name is a string constant, and the compiler
kono
parents:
diff changeset
171 will optimize the strlen() away. */
kono
parents:
diff changeset
172 return private_lookup_attribute (attr_name, attr_len, list);
kono
parents:
diff changeset
173 }
kono
parents:
diff changeset
174 }
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 /* Given an attribute name ATTR_NAME and a list of attributes LIST,
kono
parents:
diff changeset
177 return a pointer to the attribute's list first element if the attribute
kono
parents:
diff changeset
178 starts with ATTR_NAME. ATTR_NAME must be in the form 'text' (not
kono
parents:
diff changeset
179 '__text__'). */
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 static inline tree
kono
parents:
diff changeset
182 lookup_attribute_by_prefix (const char *attr_name, tree list)
kono
parents:
diff changeset
183 {
kono
parents:
diff changeset
184 gcc_checking_assert (attr_name[0] != '_');
kono
parents:
diff changeset
185 /* In most cases, list is NULL_TREE. */
kono
parents:
diff changeset
186 if (list == NULL_TREE)
kono
parents:
diff changeset
187 return NULL_TREE;
kono
parents:
diff changeset
188 else
kono
parents:
diff changeset
189 {
kono
parents:
diff changeset
190 size_t attr_len = strlen (attr_name);
kono
parents:
diff changeset
191 while (list)
kono
parents:
diff changeset
192 {
kono
parents:
diff changeset
193 size_t ident_len = IDENTIFIER_LENGTH (get_attribute_name (list));
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 if (attr_len > ident_len)
kono
parents:
diff changeset
196 {
kono
parents:
diff changeset
197 list = TREE_CHAIN (list);
kono
parents:
diff changeset
198 continue;
kono
parents:
diff changeset
199 }
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 const char *p = IDENTIFIER_POINTER (get_attribute_name (list));
kono
parents:
diff changeset
202 gcc_checking_assert (attr_len == 0 || p[0] != '_');
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 if (strncmp (attr_name, p, attr_len) == 0)
kono
parents:
diff changeset
205 break;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 list = TREE_CHAIN (list);
kono
parents:
diff changeset
208 }
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 return list;
kono
parents:
diff changeset
211 }
kono
parents:
diff changeset
212 }
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 #endif // GCC_ATTRIBS_H