]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/target-descriptions.h
Return X86_TDESC_MMX in x86_get_ipa_tdesc_idx
[thirdparty/binutils-gdb.git] / gdb / target-descriptions.h
CommitLineData
424163ea
DJ
1/* Target description support for GDB.
2
61baf725 3 Copyright (C) 2006-2017 Free Software Foundation, Inc.
424163ea
DJ
4
5 Contributed by CodeSourcery.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
424163ea
DJ
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
424163ea
DJ
21
22#ifndef TARGET_DESCRIPTIONS_H
23#define TARGET_DESCRIPTIONS_H 1
24
123dc839
DJ
25struct tdesc_feature;
26struct tdesc_arch_data;
ad068eab 27struct tdesc_type;
123dc839 28struct tdesc_reg;
424163ea 29struct target_desc;
123dc839 30struct target_ops;
6ecd4729
PA
31struct target_desc;
32/* An inferior's target description info is stored in this opaque
33 object. There's one such object per inferior. */
34struct target_desc_info;
35struct inferior;
424163ea 36
6ecd4729 37/* Fetch the current inferior's description, and switch its current
424163ea
DJ
38 architecture to one which incorporates that description. */
39
40void target_find_description (void);
41
6ecd4729
PA
42/* Discard any description fetched from the target for the current
43 inferior, and switch the current architecture to one with no target
44 description. */
424163ea
DJ
45
46void target_clear_description (void);
47
6ecd4729
PA
48/* Return the current inferior's target description. This should only
49 be used by gdbarch initialization code; most access should be
50 through an existing gdbarch. */
424163ea
DJ
51
52const struct target_desc *target_current_description (void);
53
6ecd4729
PA
54/* Copy inferior target description data. Used for example when
55 handling (v)forks, where child's description is the same as the
56 parent's, since the child really is a copy of the parent. */
57
58void copy_inferior_target_desc_info (struct inferior *destinf,
59 struct inferior *srcinf);
60
61/* Free a target_desc_info object. */
62
63void target_desc_info_free (struct target_desc_info *tdesc_info);
64
65/* Returns true if INFO indicates the target description had been
66 supplied by the user. */
67
68int target_desc_info_from_user_p (struct target_desc_info *info);
69
123dc839 70/* Record architecture-specific functions to call for pseudo-register
f57d151a 71 support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs
123dc839
DJ
72 is greater than zero, then these should be called as well.
73 They are equivalent to the gdbarch methods with similar names,
74 except that they will only be called for pseudo registers. */
75
76void set_tdesc_pseudo_register_name
77 (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name);
78
79void set_tdesc_pseudo_register_type
80 (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type);
81
82void set_tdesc_pseudo_register_reggroup_p
83 (struct gdbarch *gdbarch,
84 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p);
85
7cc46491
DJ
86/* Update GDBARCH to use the TARGET_DESC for registers. TARGET_DESC
87 may be GDBARCH's target description or (if GDBARCH does not have
88 one which describes registers) another target description
89 constructed by the gdbarch initialization routine.
90
91 Fixed register assignments are taken from EARLY_DATA, which is freed.
123dc839 92 All registers which have not been assigned fixed numbers are given
f57d151a
UW
93 numbers above the current value of gdbarch_num_regs.
94 gdbarch_num_regs and various register-related predicates are updated to
95 refer to the target description. This function should only be called from
96 the architecture's gdbarch initialization routine, and only after
123dc839
DJ
97 successfully validating the required registers. */
98
99void tdesc_use_registers (struct gdbarch *gdbarch,
7cc46491 100 const struct target_desc *target_desc,
123dc839
DJ
101 struct tdesc_arch_data *early_data);
102
103/* Allocate initial data for validation of a target description during
104 gdbarch initialization. */
105
106struct tdesc_arch_data *tdesc_data_alloc (void);
107
108/* Clean up data allocated by tdesc_data_alloc. This should only
109 be called to discard the data; tdesc_use_registers takes ownership
110 of its EARLY_DATA argument. */
111
112void tdesc_data_cleanup (void *data_untyped);
113
114/* Search FEATURE for a register named NAME. Record REGNO and the
115 register in DATA; when tdesc_use_registers is called, REGNO will be
116 assigned to the register. 1 is returned if the register was found,
117 0 if it was not. */
118
119int tdesc_numbered_register (const struct tdesc_feature *feature,
120 struct tdesc_arch_data *data,
121 int regno, const char *name);
122
58d6951d
DJ
123/* Search FEATURE for a register named NAME, but do not assign a fixed
124 register number to it. */
125
126int tdesc_unnumbered_register (const struct tdesc_feature *feature,
127 const char *name);
128
7cc46491
DJ
129/* Search FEATURE for a register named NAME, and return its size in
130 bits. The register must exist. */
131
132int tdesc_register_size (const struct tdesc_feature *feature,
133 const char *name);
134
123dc839
DJ
135/* Search FEATURE for a register with any of the names from NAMES
136 (NULL-terminated). Record REGNO and the register in DATA; when
137 tdesc_use_registers is called, REGNO will be assigned to the
138 register. 1 is returned if the register was found, 0 if it was
139 not. */
140
141int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
142 struct tdesc_arch_data *data,
143 int regno, const char *const names[]);
144
145
424163ea
DJ
146/* Accessors for target descriptions. */
147
23181151
DJ
148/* Return the BFD architecture associated with this target
149 description, or NULL if no architecture was specified. */
150
151const struct bfd_arch_info *tdesc_architecture
152 (const struct target_desc *);
153
08d16641
PA
154/* Return the OSABI associated with this target description, or
155 GDB_OSABI_UNKNOWN if no osabi was specified. */
156
157enum gdb_osabi tdesc_osabi (const struct target_desc *);
158
e35359c5
UW
159/* Return non-zero if this target description is compatible
160 with the given BFD architecture. */
161
162int tdesc_compatible_p (const struct target_desc *,
163 const struct bfd_arch_info *);
164
29709017
DJ
165/* Return the string value of a property named KEY, or NULL if the
166 property was not specified. */
167
168const char *tdesc_property (const struct target_desc *,
169 const char *key);
170
123dc839
DJ
171/* Return 1 if this target description describes any registers. */
172
173int tdesc_has_registers (const struct target_desc *);
174
175/* Return the feature with the given name, if present, or NULL if
176 the named feature is not found. */
177
178const struct tdesc_feature *tdesc_find_feature (const struct target_desc *,
179 const char *name);
180
181/* Return the name of FEATURE. */
182
183const char *tdesc_feature_name (const struct tdesc_feature *feature);
184
185/* Return the type associated with ID in the context of FEATURE, or
186 NULL if none. */
187
ad068eab
UW
188struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
189 const char *id);
123dc839 190
f8b73d13
DJ
191/* Return the name of register REGNO, from the target description or
192 from an architecture-provided pseudo_register_name method. */
193
d93859e2 194const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);
f8b73d13 195
58d6951d
DJ
196/* Return the type of register REGNO, from the target description or
197 from an architecture-provided pseudo_register_type method. */
198
199struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno);
200
c378eb4e 201/* Return the type associated with ID, from the target description. */
9fd3625f
L
202
203struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);
204
f8b73d13
DJ
205/* Check whether REGNUM is a member of REGGROUP using the target
206 description. Return -1 if the target description does not
207 specify a group. */
208
209int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
210 struct reggroup *reggroup);
211
424163ea
DJ
212/* Methods for constructing a target description. */
213
214struct target_desc *allocate_target_description (void);
23181151
DJ
215struct cleanup *make_cleanup_free_target_description (struct target_desc *);
216void set_tdesc_architecture (struct target_desc *,
217 const struct bfd_arch_info *);
08d16641 218void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
29709017
DJ
219void set_tdesc_property (struct target_desc *,
220 const char *key, const char *value);
e35359c5
UW
221void tdesc_add_compatible (struct target_desc *,
222 const struct bfd_arch_info *);
29709017 223
123dc839
DJ
224struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
225 const char *name);
ad068eab
UW
226struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
227 const char *name,
228 struct tdesc_type *field_type,
229 int count);
f5dff777
DJ
230struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature,
231 const char *name);
54157a25 232void tdesc_set_struct_size (struct tdesc_type *type, int size);
ad068eab
UW
233struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature,
234 const char *name);
f5dff777
DJ
235struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature,
236 const char *name,
54157a25 237 int size);
81516450
DE
238struct tdesc_type *tdesc_create_enum (struct tdesc_feature *feature,
239 const char *name,
240 int size);
ad068eab
UW
241void tdesc_add_field (struct tdesc_type *type, const char *field_name,
242 struct tdesc_type *field_type);
81516450
DE
243void tdesc_add_typed_bitfield (struct tdesc_type *type, const char *field_name,
244 int start, int end,
245 struct tdesc_type *field_type);
f5dff777
DJ
246void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
247 int start, int end);
248void tdesc_add_flag (struct tdesc_type *type, int start,
249 const char *flag_name);
81516450
DE
250void tdesc_add_enum_value (struct tdesc_type *type, int value,
251 const char *name);
123dc839
DJ
252void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
253 int regnum, int save_restore, const char *group,
254 int bitsize, const char *type);
255
27d41eac
YQ
256#if GDB_SELF_TEST
257namespace selftests {
258
259/* Record that XML_FILE should generate a target description that equals
260 TDESC, to be verified by the "maintenance check xml-descriptions"
261 command. */
262
263void record_xml_tdesc (const char *xml_file,
264 const struct target_desc *tdesc);
265}
266#endif
267
424163ea 268#endif /* TARGET_DESCRIPTIONS_H */