Commit | Line | Data |
---|---|---|
df8b2c02 DE |
1 | /* Header file for targets using CGEN: Cpu tools GENerator. |
2 | ||
19d45995 | 3 | Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. |
df8b2c02 DE |
4 | |
5 | This file is part of GDB, the GNU debugger, and the GNU Binutils. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
19d45995 DE |
17 | You should have received a copy of the GNU General Public License along |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
df8b2c02 DE |
20 | |
21 | #ifndef CGEN_H | |
22 | #define CGEN_H | |
23 | ||
5eb29e2c DE |
24 | /* Version information. */ |
25 | #define CGEN_VERSION_MAJOR 0 | |
26 | #define CGEN_VERSION_MINOR 6 | |
27 | #define CGEN_VERSION_FIXLEVEL 0 | |
28 | ||
ca2b987f | 29 | /* Prepend the arch name, defined in <arch>-opc.h, and _cgen_ to symbol S. |
df8b2c02 | 30 | The lack of spaces in the arg list is important for non-stdc systems. |
ca2b987f DE |
31 | This file is included by <arch>-opc.h. |
32 | It can be included independently of <arch>-opc.h, in which case the arch | |
df8b2c02 DE |
33 | dependent portions will be declared as "unknown_cgen_foo". */ |
34 | ||
35 | #ifndef CGEN_SYM | |
a2f256c4 | 36 | #define CGEN_SYM(s) CONCAT3 (unknown,_cgen_,s) |
df8b2c02 DE |
37 | #endif |
38 | ||
39 | /* This file contains the static (unchanging) pieces and as much other stuff | |
40 | as we can reasonably put here. It's generally cleaner to put stuff here | |
41 | rather than having it machine generated if possible. */ | |
42 | ||
43 | /* The assembler syntax is made up of expressions (duh...). | |
44 | At the lowest level the values are mnemonics, register names, numbers, etc. | |
45 | Above that are subexpressions, if any (an example might be the | |
46 | "effective address" in m68k cpus). At the second highest level are the | |
47 | insns themselves. Above that are pseudo-insns, synthetic insns, and macros, | |
48 | if any. | |
49 | */ | |
50 | \f | |
51 | /* Lots of cpu's have a fixed insn size, or one which rarely changes, | |
52 | and it's generally easier to handle these by treating the insn as an | |
53 | integer type, rather than an array of characters. So we allow targets | |
54 | to control this. */ | |
55 | ||
56 | #ifdef CGEN_INT_INSN | |
57 | typedef unsigned int cgen_insn_t; | |
58 | #else | |
b61df026 | 59 | typedef char * cgen_insn_t; |
df8b2c02 DE |
60 | #endif |
61 | ||
62 | #ifdef __GNUC__ | |
63 | #define CGEN_INLINE inline | |
64 | #else | |
65 | #define CGEN_INLINE | |
66 | #endif | |
67 | ||
b61df026 NC |
68 | enum cgen_endian |
69 | { | |
df8b2c02 DE |
70 | CGEN_ENDIAN_UNKNOWN, |
71 | CGEN_ENDIAN_LITTLE, | |
72 | CGEN_ENDIAN_BIG | |
73 | }; | |
ca2b987f | 74 | |
ca2b987f DE |
75 | /* Forward decl. */ |
76 | typedef struct cgen_insn CGEN_INSN; | |
df8b2c02 DE |
77 | \f |
78 | /* Attributes. | |
79 | Attributes are used to describe various random things. */ | |
80 | ||
81 | /* Struct to record attribute information. */ | |
b61df026 NC |
82 | typedef struct |
83 | { | |
19d45995 | 84 | unsigned char num_nonbools; |
df8b2c02 DE |
85 | unsigned int bool; |
86 | unsigned int nonbool[1]; | |
87 | } CGEN_ATTR; | |
88 | ||
89 | /* Define a structure member for attributes with N non-boolean entries. | |
90 | The attributes are sorted so that the non-boolean ones come first. | |
91 | num_nonbools: count of nonboolean attributes | |
92 | bool: values of boolean attributes | |
93 | nonbool: values of non-boolean attributes | |
94 | There is a maximum of 32 attributes total. */ | |
95 | #define CGEN_ATTR_TYPE(n) \ | |
030f419b DE |
96 | struct { unsigned char num_nonbools; \ |
97 | unsigned int bool; \ | |
98 | unsigned int nonbool[(n) ? (n) : 1]; } | |
df8b2c02 DE |
99 | |
100 | /* Given an attribute number, return its mask. */ | |
101 | #define CGEN_ATTR_MASK(attr) (1 << (attr)) | |
102 | ||
030f419b DE |
103 | /* Return the value of boolean attribute ATTR in ATTRS. */ |
104 | #define CGEN_BOOL_ATTR(attrs, attr) \ | |
105 | ((CGEN_ATTR_MASK (attr) & (attrs)) != 0) | |
106 | ||
df8b2c02 DE |
107 | /* Return value of attribute ATTR in ATTR_TABLE for OBJ. |
108 | OBJ is a pointer to the entity that has the attributes. | |
109 | It's not used at present but is reserved for future purposes. */ | |
110 | #define CGEN_ATTR_VALUE(obj, attr_table, attr) \ | |
111 | ((unsigned int) (attr) < (attr_table)->num_nonbools \ | |
112 | ? ((attr_table)->nonbool[attr]) \ | |
113 | : (((attr_table)->bool & (1 << (attr))) != 0)) | |
19d45995 DE |
114 | |
115 | /* Attribute name/value tables. | |
116 | These are used to assist parsing of descriptions at runtime. */ | |
117 | ||
b61df026 NC |
118 | typedef struct |
119 | { | |
120 | const char * name; | |
030f419b | 121 | int value; |
19d45995 DE |
122 | } CGEN_ATTR_ENTRY; |
123 | ||
ca2b987f | 124 | /* For each domain (ifld,operand,insn), list of attributes. */ |
19d45995 | 125 | |
b61df026 NC |
126 | typedef struct |
127 | { | |
030f419b | 128 | const char * name; |
19d45995 | 129 | /* NULL for boolean attributes. */ |
b61df026 | 130 | const CGEN_ATTR_ENTRY * vals; |
19d45995 | 131 | } CGEN_ATTR_TABLE; |
df8b2c02 DE |
132 | \f |
133 | /* Parse result (also extraction result). | |
134 | ||
135 | The result of parsing an insn is stored here. | |
136 | To generate the actual insn, this is passed to the insert handler. | |
137 | When printing an insn, the result of extraction is stored here. | |
138 | To print the insn, this is passed to the print handler. | |
139 | ||
140 | It is machine generated so we don't define it here, | |
141 | but we do need a forward decl for the handler fns. | |
142 | ||
143 | There is one member for each possible field in the insn. | |
144 | The type depends on the field. | |
145 | Also recorded here is the computed length of the insn for architectures | |
146 | where it varies. | |
147 | */ | |
148 | ||
42d56c40 | 149 | typedef struct cgen_fields CGEN_FIELDS; |
df8b2c02 DE |
150 | |
151 | /* Total length of the insn, as recorded in the `fields' struct. */ | |
152 | /* ??? The field insert handler has lots of opportunities for optimization | |
153 | if it ever gets inlined. On architectures where insns all have the same | |
154 | size, may wish to detect that and make this macro a constant - to allow | |
155 | further optimizations. */ | |
156 | #define CGEN_FIELDS_BITSIZE(fields) ((fields)->length) | |
157 | \f | |
158 | /* Associated with each insn or expression is a set of "handlers" for | |
ca2b987f DE |
159 | performing operations like parsing, printing, etc. These require a bfd_vma |
160 | value to be passed around but we don't want all applications to need bfd.h. | |
161 | So this stuff is only provided if bfd.h has been included. */ | |
df8b2c02 | 162 | |
ca2b987f | 163 | #ifdef BFD_VERSION |
df8b2c02 DE |
164 | |
165 | /* Parse handler. | |
166 | The first argument is a pointer to a struct describing the insn being | |
167 | parsed. | |
168 | The second argument is a pointer to a pointer to the text being parsed. | |
169 | The third argument is a pointer to a cgen_fields struct | |
170 | in which the results are placed. | |
171 | If the expression is successfully parsed, the pointer to the text is | |
172 | updated. If not it is left alone. | |
173 | The result is NULL if success or an error message. */ | |
174 | typedef const char * (cgen_parse_fn) PARAMS ((const struct cgen_insn *, | |
175 | const char **, | |
42d56c40 | 176 | CGEN_FIELDS *)); |
df8b2c02 DE |
177 | |
178 | /* Print handler. | |
179 | The first argument is a pointer to the disassembly info. | |
180 | Eg: disassemble_info. It's defined as `PTR' so this file can be included | |
181 | without dis-asm.h. | |
182 | The second argument is a pointer to a struct describing the insn being | |
183 | printed. | |
184 | The third argument is a pointer to a cgen_fields struct. | |
185 | The fourth argument is the pc value of the insn. | |
186 | The fifth argument is the length of the insn, in bytes. */ | |
df8b2c02 | 187 | typedef void (cgen_print_fn) PARAMS ((PTR, const struct cgen_insn *, |
42d56c40 | 188 | CGEN_FIELDS *, bfd_vma, int)); |
df8b2c02 DE |
189 | |
190 | /* Insert handler. | |
191 | The first argument is a pointer to a struct describing the insn being | |
192 | parsed. | |
193 | The second argument is a pointer to a cgen_fields struct | |
194 | from which the values are fetched. | |
652af042 | 195 | The third argument is a pointer to a buffer in which to place the insn. |
ca2b987f | 196 | The fourth argument is the pc value of the insn. |
652af042 DE |
197 | The result is an error message or NULL if success. */ |
198 | typedef const char * (cgen_insert_fn) PARAMS ((const struct cgen_insn *, | |
ca2b987f DE |
199 | CGEN_FIELDS *, cgen_insn_t *, |
200 | bfd_vma)); | |
df8b2c02 DE |
201 | |
202 | /* Extract handler. | |
203 | The first argument is a pointer to a struct describing the insn being | |
204 | parsed. | |
205 | The second argument is a pointer to a struct controlling extraction | |
206 | (only used for variable length insns). | |
207 | The third argument is the first CGEN_BASE_INSN_SIZE bytes. | |
208 | The fourth argument is a pointer to a cgen_fields struct | |
209 | in which the results are placed. | |
ca2b987f | 210 | The fifth argument is the pc value of the insn. |
df8b2c02 DE |
211 | The result is the length of the insn or zero if not recognized. */ |
212 | typedef int (cgen_extract_fn) PARAMS ((const struct cgen_insn *, | |
213 | void *, cgen_insn_t, | |
ca2b987f | 214 | CGEN_FIELDS *, bfd_vma)); |
df8b2c02 DE |
215 | |
216 | /* The `parse' and `insert' fields are indices into these tables. | |
217 | The elements are pointer to specialized handler functions. | |
218 | Element 0 is special, it means use the default handler. */ | |
219 | extern cgen_parse_fn * CGEN_SYM (parse_handlers) []; | |
220 | #define CGEN_PARSE_FN(x) (CGEN_SYM (parse_handlers)[(x)->base.parse]) | |
221 | extern cgen_insert_fn * CGEN_SYM (insert_handlers) []; | |
222 | #define CGEN_INSERT_FN(x) (CGEN_SYM (insert_handlers)[(x)->base.insert]) | |
223 | ||
224 | /* Likewise for the `extract' and `print' fields. */ | |
225 | extern cgen_extract_fn * CGEN_SYM (extract_handlers) []; | |
226 | #define CGEN_EXTRACT_FN(x) (CGEN_SYM (extract_handlers)[(x)->base.extract]) | |
227 | extern cgen_print_fn * CGEN_SYM (print_handlers) []; | |
228 | #define CGEN_PRINT_FN(x) (CGEN_SYM (print_handlers)[(x)->base.print]) | |
ca2b987f DE |
229 | |
230 | /* Default insn parser, printer. */ | |
231 | extern cgen_parse_fn CGEN_SYM (parse_insn); | |
232 | extern cgen_insert_fn CGEN_SYM (insert_insn); | |
233 | extern cgen_extract_fn CGEN_SYM (extract_insn); | |
234 | extern cgen_print_fn CGEN_SYM (print_insn); | |
235 | ||
236 | #endif /* BFD_VERSION */ | |
df8b2c02 DE |
237 | \f |
238 | /* Base class of parser/printer. | |
19d45995 DE |
239 | (Don't read too much into the use of the phrase "base class". |
240 | It's a name I'm using to organize my thoughts.) | |
df8b2c02 DE |
241 | |
242 | Instructions and expressions all share this data in common. | |
19d45995 DE |
243 | It's a collection of the common elements needed to parse, insert, extract, |
244 | and print each of them. */ | |
df8b2c02 | 245 | |
b61df026 NC |
246 | struct cgen_base |
247 | { | |
df8b2c02 DE |
248 | /* Indices into the handler tables. |
249 | We could use pointers here instead, but in the case of the insn table, | |
250 | 90% of them would be identical and that's a lot of redundant data. | |
030f419b DE |
251 | 0 means use the default (what the default is is up to the code). |
252 | Using indices also keeps assembler code out of the disassembler and | |
253 | vice versa. */ | |
df8b2c02 | 254 | unsigned char parse, insert, extract, print; |
df8b2c02 DE |
255 | }; |
256 | \f | |
19d45995 | 257 | /* Assembler interface. |
df8b2c02 | 258 | |
19d45995 DE |
259 | The interface to the assembler is intended to be clean in the sense that |
260 | libopcodes.a is a standalone entity and could be used with any assembler. | |
261 | Not that one would necessarily want to do that but rather that it helps | |
262 | keep a clean interface. The interface will obviously be slanted towards | |
263 | GAS, but at least it's a start. | |
ca2b987f | 264 | ??? Note that one possible use of the assembler besides GAS is GDB. |
df8b2c02 | 265 | |
19d45995 DE |
266 | Parsing is controlled by the assembler which calls |
267 | CGEN_SYM (assemble_insn). If it can parse and build the entire insn | |
268 | it doesn't call back to the assembler. If it needs/wants to call back | |
269 | to the assembler, (*cgen_parse_operand_fn) is called which can either | |
df8b2c02 | 270 | |
19d45995 DE |
271 | - return a number to be inserted in the insn |
272 | - return a "register" value to be inserted | |
273 | (the register might not be a register per pe) | |
274 | - queue the argument and return a marker saying the expression has been | |
275 | queued (eg: a fix-up) | |
276 | - return an error message indicating the expression wasn't recognizable | |
277 | ||
278 | The result is an error message or NULL for success. | |
279 | The parsed value is stored in the bfd_vma *. */ | |
df8b2c02 | 280 | |
19d45995 | 281 | /* Values for indicating what the caller wants. */ |
b61df026 NC |
282 | enum cgen_parse_operand_type |
283 | { | |
284 | CGEN_PARSE_OPERAND_INIT, | |
285 | CGEN_PARSE_OPERAND_INTEGER, | |
19d45995 DE |
286 | CGEN_PARSE_OPERAND_ADDRESS |
287 | }; | |
df8b2c02 | 288 | |
ca2b987f | 289 | /* Values for indicating what was parsed. */ |
b61df026 NC |
290 | enum cgen_parse_operand_result |
291 | { | |
292 | CGEN_PARSE_OPERAND_RESULT_NUMBER, | |
293 | CGEN_PARSE_OPERAND_RESULT_REGISTER, | |
294 | CGEN_PARSE_OPERAND_RESULT_QUEUED, | |
295 | CGEN_PARSE_OPERAND_RESULT_ERROR | |
19d45995 | 296 | }; |
df8b2c02 | 297 | |
ca2b987f | 298 | #ifdef BFD_VERSION /* Don't require bfd.h unnecessarily. */ |
19d45995 DE |
299 | extern const char * (*cgen_parse_operand_fn) |
300 | PARAMS ((enum cgen_parse_operand_type, const char **, int, int, | |
301 | enum cgen_parse_operand_result *, bfd_vma *)); | |
df8b2c02 DE |
302 | #endif |
303 | ||
19d45995 | 304 | /* Called before trying to match a table entry with the insn. */ |
030f419b | 305 | extern void cgen_init_parse_operand PARAMS ((void)); |
df8b2c02 | 306 | |
19d45995 DE |
307 | /* The result is an error message or NULL for success. |
308 | The parsed value is stored in the bfd_vma *. */ | |
ca2b987f | 309 | #ifdef BFD_VERSION /* Don't require bfd.h unnecessarily. */ |
030f419b DE |
310 | extern const char * cgen_parse_operand |
311 | PARAMS ((enum cgen_parse_operand_type, | |
312 | const char **, int, int, | |
313 | enum cgen_parse_operand_result *, | |
314 | bfd_vma *)); | |
19d45995 | 315 | #endif |
df8b2c02 DE |
316 | \f |
317 | /* Operand values (keywords, integers, symbols, etc.) */ | |
318 | ||
319 | /* Types of assembler elements. */ | |
320 | ||
b61df026 NC |
321 | enum cgen_asm_type |
322 | { | |
df8b2c02 DE |
323 | CGEN_ASM_KEYWORD, CGEN_ASM_MAX |
324 | }; | |
325 | ||
326 | /* List of hardware elements. */ | |
327 | ||
b61df026 NC |
328 | typedef struct cgen_hw_entry |
329 | { | |
42d56c40 DE |
330 | /* The type of this entry, one of `enum hw_type'. |
331 | This is an int and not the enum as the latter may not be declared yet. */ | |
030f419b | 332 | int type; |
42d56c40 | 333 | const struct cgen_hw_entry * next; |
030f419b DE |
334 | char * name; |
335 | enum cgen_asm_type asm_type; | |
336 | PTR asm_data; | |
df8b2c02 DE |
337 | } CGEN_HW_ENTRY; |
338 | ||
ca2b987f DE |
339 | extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_name PARAMS ((const char *)); |
340 | extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_num PARAMS ((int)); | |
df8b2c02 | 341 | |
df8b2c02 DE |
342 | /* This struct is used to describe things like register names, etc. */ |
343 | ||
b61df026 NC |
344 | typedef struct cgen_keyword_entry |
345 | { | |
df8b2c02 | 346 | /* Name (as in register name). */ |
b61df026 | 347 | char * name; |
df8b2c02 DE |
348 | |
349 | /* Value (as in register number). | |
350 | The value cannot be -1 as that is used to indicate "not found". | |
351 | IDEA: Have "FUNCTION" attribute? [function is called to fetch value]. */ | |
352 | int value; | |
353 | ||
19d45995 DE |
354 | /* Attributes. |
355 | This should, but technically needn't, appear last. It is a variable sized | |
356 | array in that one architecture may have 1 nonbool attribute and another | |
357 | may have more. Having this last means the non-architecture specific code | |
358 | needn't care. */ | |
359 | /* ??? Moving this last should be done by treating keywords like insn lists | |
360 | and moving the `next' fields into a CGEN_KEYWORD_LIST struct. */ | |
df8b2c02 | 361 | /* FIXME: Not used yet. */ |
a2f256c4 DE |
362 | #ifndef CGEN_KEYWORD_NBOOL_ATTRS |
363 | #define CGEN_KEYWORD_NBOOL_ATTRS 1 | |
364 | #endif | |
030f419b | 365 | const CGEN_ATTR_TYPE (CGEN_KEYWORD_NBOOL_ATTRS) attrs; |
df8b2c02 DE |
366 | |
367 | /* Next name hash table entry. */ | |
368 | struct cgen_keyword_entry *next_name; | |
369 | /* Next value hash table entry. */ | |
370 | struct cgen_keyword_entry *next_value; | |
371 | } CGEN_KEYWORD_ENTRY; | |
372 | ||
373 | /* Top level struct for describing a set of related keywords | |
374 | (e.g. register names). | |
375 | ||
376 | This struct supports runtime entry of new values, and hashed lookups. */ | |
377 | ||
b61df026 NC |
378 | typedef struct cgen_keyword |
379 | { | |
df8b2c02 | 380 | /* Pointer to initial [compiled in] values. */ |
b61df026 NC |
381 | CGEN_KEYWORD_ENTRY * init_entries; |
382 | ||
df8b2c02 DE |
383 | /* Number of entries in `init_entries'. */ |
384 | unsigned int num_init_entries; | |
b61df026 | 385 | |
df8b2c02 | 386 | /* Hash table used for name lookup. */ |
b61df026 NC |
387 | CGEN_KEYWORD_ENTRY ** name_hash_table; |
388 | ||
df8b2c02 | 389 | /* Hash table used for value lookup. */ |
b61df026 NC |
390 | CGEN_KEYWORD_ENTRY ** value_hash_table; |
391 | ||
df8b2c02 DE |
392 | /* Number of entries in the hash_tables. */ |
393 | unsigned int hash_table_size; | |
b61df026 | 394 | |
19d45995 | 395 | /* Pointer to null keyword "" entry if present. */ |
b61df026 | 396 | const CGEN_KEYWORD_ENTRY * null_entry; |
df8b2c02 DE |
397 | } CGEN_KEYWORD; |
398 | ||
399 | /* Structure used for searching. */ | |
400 | ||
b61df026 NC |
401 | typedef struct |
402 | { | |
df8b2c02 | 403 | /* Table being searched. */ |
b61df026 NC |
404 | const CGEN_KEYWORD * table; |
405 | ||
df8b2c02 | 406 | /* Specification of what is being searched for. */ |
b61df026 NC |
407 | const char * spec; |
408 | ||
df8b2c02 DE |
409 | /* Current index in hash table. */ |
410 | unsigned int current_hash; | |
b61df026 | 411 | |
df8b2c02 | 412 | /* Current element in current hash chain. */ |
b61df026 | 413 | CGEN_KEYWORD_ENTRY * current_entry; |
df8b2c02 DE |
414 | } CGEN_KEYWORD_SEARCH; |
415 | ||
416 | /* Lookup a keyword from its name. */ | |
19d45995 DE |
417 | const CGEN_KEYWORD_ENTRY * cgen_keyword_lookup_name |
418 | PARAMS ((CGEN_KEYWORD *, const char *)); | |
df8b2c02 | 419 | /* Lookup a keyword from its value. */ |
19d45995 DE |
420 | const CGEN_KEYWORD_ENTRY * cgen_keyword_lookup_value |
421 | PARAMS ((CGEN_KEYWORD *, int)); | |
df8b2c02 | 422 | /* Add a keyword. */ |
19d45995 | 423 | void cgen_keyword_add PARAMS ((CGEN_KEYWORD *, CGEN_KEYWORD_ENTRY *)); |
df8b2c02 DE |
424 | /* Keyword searching. |
425 | This can be used to retrieve every keyword, or a subset. */ | |
19d45995 DE |
426 | CGEN_KEYWORD_SEARCH cgen_keyword_search_init |
427 | PARAMS ((CGEN_KEYWORD *, const char *)); | |
428 | const CGEN_KEYWORD_ENTRY *cgen_keyword_search_next | |
429 | PARAMS ((CGEN_KEYWORD_SEARCH *)); | |
df8b2c02 DE |
430 | |
431 | /* Operand value support routines. */ | |
432 | /* FIXME: some of the long's here will need to be bfd_vma or some such. */ | |
433 | ||
030f419b DE |
434 | extern const char * cgen_parse_keyword PARAMS ((const char **, |
435 | CGEN_KEYWORD *, | |
436 | long *)); | |
437 | extern const char * cgen_parse_signed_integer PARAMS ((const char **, int, | |
438 | long *)); | |
439 | extern const char * cgen_parse_unsigned_integer PARAMS ((const char **, int, | |
440 | unsigned long *)); | |
441 | extern const char * cgen_parse_address PARAMS ((const char **, int, int, | |
442 | enum cgen_parse_operand_result *, | |
443 | long *)); | |
444 | extern const char * cgen_validate_signed_integer PARAMS ((long, long, long)); | |
445 | extern const char * cgen_validate_unsigned_integer PARAMS ((unsigned long, | |
446 | unsigned long, | |
447 | unsigned long)); | |
df8b2c02 | 448 | \f |
42d56c40 DE |
449 | /* Operand modes. */ |
450 | ||
451 | /* ??? This duplicates the values in arch.h. Revisit. | |
452 | These however need the CGEN_ prefix [as does everything in this file]. */ | |
453 | /* ??? Targets may need to add their own modes so we may wish to move this | |
454 | to <arch>-opc.h, or add a hook. */ | |
455 | ||
456 | enum cgen_mode { | |
457 | CGEN_MODE_VOID, /* FIXME: rename simulator's VM to VOID */ | |
458 | CGEN_MODE_BI, CGEN_MODE_QI, CGEN_MODE_HI, CGEN_MODE_SI, CGEN_MODE_DI, | |
459 | CGEN_MODE_UBI, CGEN_MODE_UQI, CGEN_MODE_UHI, CGEN_MODE_USI, CGEN_MODE_UDI, | |
460 | CGEN_MODE_SF, CGEN_MODE_DF, CGEN_MODE_XF, CGEN_MODE_TF, | |
461 | CGEN_MODE_MAX | |
462 | }; | |
463 | ||
464 | /* FIXME: Until simulator is updated. */ | |
465 | #define CGEN_MODE_VM CGEN_MODE_VOID | |
466 | \f | |
df8b2c02 DE |
467 | /* This struct defines each entry in the operand table. */ |
468 | ||
b61df026 NC |
469 | typedef struct cgen_operand |
470 | { | |
19d45995 | 471 | /* Name as it appears in the syntax string. */ |
b61df026 | 472 | char * name; |
df8b2c02 | 473 | |
42d56c40 DE |
474 | /* The hardware element associated with this operand. */ |
475 | const CGEN_HW_ENTRY *hw; | |
476 | ||
477 | /* FIXME: We don't yet record ifield definitions, which we should. | |
478 | When we do it might make sense to delete start/length (since they will | |
479 | be duplicated in the ifield's definition) and replace them with a | |
480 | pointer to the ifield entry. Note that as more complicated situations | |
481 | need to be handled, going more and more with an OOP paradigm will help | |
482 | keep the complication under control. Of course, this was the goal from | |
483 | the start, but getting there in one step was too much too soon. */ | |
484 | ||
df8b2c02 | 485 | /* Bit position (msb of first byte = bit 0). |
19d45995 | 486 | This is just a hint, and may be unused in more complex operands. |
df8b2c02 DE |
487 | May be unused for a modifier. */ |
488 | unsigned char start; | |
489 | ||
490 | /* The number of bits in the operand. | |
19d45995 | 491 | This is just a hint, and may be unused in more complex operands. |
df8b2c02 DE |
492 | May be unused for a modifier. */ |
493 | unsigned char length; | |
494 | ||
19d45995 DE |
495 | #if 0 /* ??? Interesting idea but relocs tend to get too complicated, |
496 | and ABI dependent, for simple table lookups to work. */ | |
df8b2c02 DE |
497 | /* Ideally this would be the internal (external?) reloc type. */ |
498 | int reloc_type; | |
499 | #endif | |
19d45995 DE |
500 | |
501 | /* Attributes. | |
502 | This should, but technically needn't, appear last. It is a variable sized | |
503 | array in that one architecture may have 1 nonbool attribute and another | |
504 | may have more. Having this last means the non-architecture specific code | |
505 | needn't care, now or tomorrow. */ | |
a2f256c4 DE |
506 | #ifndef CGEN_OPERAND_NBOOL_ATTRS |
507 | #define CGEN_OPERAND_NBOOL_ATTRS 1 | |
508 | #endif | |
030f419b | 509 | const CGEN_ATTR_TYPE (CGEN_OPERAND_NBOOL_ATTRS) attrs; |
19d45995 | 510 | #define CGEN_OPERAND_ATTRS(operand) (&(operand)->attrs) |
df8b2c02 DE |
511 | } CGEN_OPERAND; |
512 | ||
513 | /* Return value of attribute ATTR in OPERAND. */ | |
514 | #define CGEN_OPERAND_ATTR(operand, attr) \ | |
515 | CGEN_ATTR_VALUE (operand, CGEN_OPERAND_ATTRS (operand), attr) | |
516 | ||
517 | /* The operand table is currently a very static entity. */ | |
518 | extern const CGEN_OPERAND CGEN_SYM (operand_table)[]; | |
519 | ||
520 | enum cgen_operand_type; | |
521 | ||
522 | #define CGEN_OPERAND_INDEX(operand) ((int) ((operand) - CGEN_SYM (operand_table))) | |
523 | /* FIXME: Rename, cpu-opc.h defines this as the typedef of the enum. */ | |
524 | #define CGEN_OPERAND_TYPE(operand) ((enum cgen_operand_type) CGEN_OPERAND_INDEX (operand)) | |
525 | #define CGEN_OPERAND_ENTRY(n) (& CGEN_SYM (operand_table) [n]) | |
652af042 DE |
526 | |
527 | /* Types of parse/insert/extract/print cover-fn handlers. */ | |
528 | /* FIXME: move opindex first to match caller. */ | |
529 | /* FIXME: also need types of insert/extract/print fns. */ | |
530 | /* FIXME: not currently used as type of 3rd arg varies. */ | |
531 | typedef const char * (CGEN_PARSE_OPERAND_FN) PARAMS ((const char **, int, | |
532 | long *)); | |
df8b2c02 | 533 | \f |
42d56c40 DE |
534 | /* Instruction operand instances. |
535 | ||
536 | For each instruction, a list of the hardware elements that are read and | |
537 | written are recorded. */ | |
538 | ||
539 | /* The type of the instance. */ | |
540 | enum cgen_operand_instance_type { | |
541 | /* End of table marker. */ | |
542 | CGEN_OPERAND_INSTANCE_END = 0, | |
543 | CGEN_OPERAND_INSTANCE_INPUT, CGEN_OPERAND_INSTANCE_OUTPUT | |
544 | }; | |
545 | ||
546 | typedef struct | |
547 | { | |
548 | /* The type of this operand. */ | |
549 | enum cgen_operand_instance_type type; | |
550 | #define CGEN_OPERAND_INSTANCE_TYPE(opinst) ((opinst)->type) | |
551 | ||
552 | /* The hardware element referenced. */ | |
553 | const CGEN_HW_ENTRY *hw; | |
554 | #define CGEN_OPERAND_INSTANCE_HW(opinst) ((opinst)->hw) | |
555 | ||
556 | /* The mode in which the operand is being used. */ | |
557 | enum cgen_mode mode; | |
558 | #define CGEN_OPERAND_INSTANCE_MODE(opinst) ((opinst)->mode) | |
559 | ||
560 | /* The operand table entry or NULL if there is none (i.e. an explicit | |
561 | hardware reference). */ | |
562 | const CGEN_OPERAND *operand; | |
563 | #define CGEN_OPERAND_INSTANCE_OPERAND(opinst) ((opinst)->operand) | |
564 | ||
565 | /* If `operand' is NULL, the index (e.g. into array of registers). */ | |
566 | int index; | |
567 | #define CGEN_OPERAND_INSTANCE_INDEX(opinst) ((opinst)->index) | |
568 | } CGEN_OPERAND_INSTANCE; | |
569 | \f | |
19d45995 DE |
570 | /* Syntax string. |
571 | ||
572 | Each insn format and subexpression has one of these. | |
573 | ||
574 | The syntax "string" consists of characters (n > 0 && n < 128), and operand | |
575 | values (n >= 128), and is terminated by 0. Operand values are 128 + index | |
576 | into the operand table. The operand table doesn't exist in C, per se, as | |
577 | the data is recorded in the parse/insert/extract/print switch statements. */ | |
578 | ||
579 | #ifndef CGEN_MAX_SYNTAX_BYTES | |
580 | #define CGEN_MAX_SYNTAX_BYTES 16 | |
581 | #endif | |
582 | ||
b61df026 NC |
583 | typedef struct |
584 | { | |
19d45995 DE |
585 | unsigned char syntax[CGEN_MAX_SYNTAX_BYTES]; |
586 | } CGEN_SYNTAX; | |
587 | ||
588 | #define CGEN_SYNTAX_STRING(syn) (syn->syntax) | |
589 | #define CGEN_SYNTAX_CHAR_P(c) ((c) < 128) | |
590 | #define CGEN_SYNTAX_CHAR(c) (c) | |
591 | #define CGEN_SYNTAX_FIELD(c) ((c) - 128) | |
deaa0585 | 592 | #define CGEN_SYNTAX_MAKE_FIELD(c) ((c) + 128) |
19d45995 DE |
593 | |
594 | /* ??? I can't currently think of any case where the mnemonic doesn't come | |
595 | first [and if one ever doesn't building the hash tables will be tricky]. | |
596 | However, we treat mnemonics as just another operand of the instruction. | |
597 | A value of 1 means "this is where the mnemonic appears". 1 isn't | |
598 | special other than it's a non-printable ASCII char. */ | |
a2f256c4 DE |
599 | #define CGEN_SYNTAX_MNEMONIC 1 |
600 | #define CGEN_SYNTAX_MNEMONIC_P(ch) ((ch) == CGEN_SYNTAX_MNEMONIC) | |
19d45995 DE |
601 | \f |
602 | /* Instruction formats. | |
603 | ||
604 | Instructions are grouped by format. Associated with an instruction is its | |
a2f256c4 DE |
605 | format. Each opcode table entry contains a format table entry. |
606 | ??? There is usually very few formats compared with the number of insns, | |
607 | so one can reduce the size of the opcode table by recording the format table | |
608 | as a separate entity. Given that we currently don't, format table entries | |
609 | are also distinguished by their operands. This increases the size of the | |
610 | table, but reduces the number of tables. It's all minutiae anyway so it | |
611 | doesn't really matter [at this point in time]. | |
612 | ||
613 | ??? Support for variable length ISA's is wip. */ | |
19d45995 | 614 | |
b61df026 NC |
615 | typedef struct |
616 | { | |
19d45995 DE |
617 | /* Length that MASK and VALUE have been calculated to |
618 | [VALUE is recorded elsewhere]. | |
619 | Normally it is CGEN_BASE_INSN_BITSIZE. On [V]LIW architectures where | |
620 | the base insn size may be larger than the size of an insn, this field is | |
621 | less than CGEN_BASE_INSN_BITSIZE. */ | |
622 | unsigned char mask_length; | |
623 | ||
a2f256c4 | 624 | /* Total length of instruction, in bits. */ |
19d45995 DE |
625 | unsigned char length; |
626 | ||
a2f256c4 | 627 | /* Mask to apply to the first MASK_LENGTH bits. |
19d45995 DE |
628 | Each insn's value is stored with the insn. |
629 | The first step in recognizing an insn for disassembly is | |
630 | (opcode & mask) == value. */ | |
631 | unsigned int mask; | |
632 | } CGEN_FORMAT; | |
633 | \f | |
df8b2c02 DE |
634 | /* This struct defines each entry in the instruction table. */ |
635 | ||
b61df026 NC |
636 | struct cgen_insn |
637 | { | |
030f419b | 638 | /* This field is an array of functions that operand on this entry. */ |
df8b2c02 | 639 | struct cgen_base base; |
df8b2c02 | 640 | #define CGEN_INSN_BASE(insn) (&(insn)->base) |
df8b2c02 | 641 | |
b6ea0170 DE |
642 | /* Each real instruction is enumerated. |
643 | The simulator use to use this value but currently no longer does. | |
644 | This may go away in time. */ | |
030f419b DE |
645 | int num; |
646 | #define CGEN_INSN_NUM(insn) ((insn)->num) | |
647 | ||
19d45995 DE |
648 | /* Name of entry (that distinguishes it from all other entries). |
649 | This is used, for example, in simulator profiling results. */ | |
650 | /* ??? If mnemonics have operands, try to print full mnemonic. */ | |
b61df026 | 651 | const char * name; |
19d45995 DE |
652 | #define CGEN_INSN_NAME(insn) ((insn)->name) |
653 | ||
654 | /* Mnemonic. This is used when parsing and printing the insn. | |
655 | In the case of insns that have operands on the mnemonics, this is | |
656 | only the constant part. E.g. for conditional execution of an `add' insn, | |
657 | where the full mnemonic is addeq, addne, etc., this is only "add". */ | |
b61df026 | 658 | const char * mnemonic; |
19d45995 DE |
659 | #define CGEN_INSN_MNEMONIC(insn) ((insn)->mnemonic) |
660 | ||
a2f256c4 DE |
661 | /* Syntax string. */ |
662 | const CGEN_SYNTAX syntax; | |
663 | #define CGEN_INSN_SYNTAX(insn) (& (insn)->syntax) | |
19d45995 | 664 | |
a2f256c4 DE |
665 | /* Format entry. */ |
666 | const CGEN_FORMAT format; | |
667 | #define CGEN_INSN_MASK_BITSIZE(insn) ((insn)->format.mask_length) | |
668 | #define CGEN_INSN_BITSIZE(insn) ((insn)->format.length) | |
19d45995 DE |
669 | |
670 | /* Instruction opcode value. */ | |
671 | unsigned int value; | |
672 | #define CGEN_INSN_VALUE(insn) ((insn)->value) | |
a2f256c4 | 673 | #define CGEN_INSN_MASK(insn) ((insn)->format.mask) |
19d45995 | 674 | |
030f419b DE |
675 | /* Opaque pointer to "subclass" specific data. |
676 | In the case of real insns this points to a NULL entry terminated | |
677 | table of operands used, or NULL if none. | |
678 | In the case of macro insns this points to data to control the expansion. | |
679 | ??? I'd rather not get carried away and lay things out with pedantic | |
680 | purity right now. Sure, other fields might better be tucked away in | |
681 | `data'. Not now. */ | |
682 | PTR data; | |
683 | #define CGEN_INSN_DATA(insn) ((insn)->data) | |
684 | #define CGEN_INSN_OPERANDS(insn) ((CGEN_OPERAND_INSTANCE *) (insn)->data) | |
42d56c40 | 685 | |
19d45995 DE |
686 | /* Attributes. |
687 | This must appear last. It is a variable sized array in that one | |
688 | architecture may have 1 nonbool attribute and another may have more. | |
689 | Having this last means the non-architecture specific code needn't | |
690 | care. */ | |
a2f256c4 DE |
691 | #ifndef CGEN_INSN_NBOOL_ATTRS |
692 | #define CGEN_INSN_NBOOL_ATTRS 1 | |
693 | #endif | |
030f419b | 694 | const CGEN_ATTR_TYPE (CGEN_INSN_NBOOL_ATTRS) attrs; |
19d45995 | 695 | #define CGEN_INSN_ATTRS(insn) (&(insn)->attrs) |
df8b2c02 DE |
696 | /* Return value of attribute ATTR in INSN. */ |
697 | #define CGEN_INSN_ATTR(insn, attr) \ | |
698 | CGEN_ATTR_VALUE (insn, CGEN_INSN_ATTRS (insn), attr) | |
19d45995 | 699 | }; |
df8b2c02 DE |
700 | |
701 | /* Instruction lists. | |
702 | This is used for adding new entries and for creating the hash lists. */ | |
703 | ||
b61df026 NC |
704 | typedef struct cgen_insn_list |
705 | { | |
706 | struct cgen_insn_list * next; | |
707 | const CGEN_INSN * insn; | |
df8b2c02 DE |
708 | } CGEN_INSN_LIST; |
709 | ||
710 | /* The table of instructions. */ | |
711 | ||
b61df026 NC |
712 | typedef struct |
713 | { | |
df8b2c02 | 714 | /* Pointer to initial [compiled in] entries. */ |
b61df026 NC |
715 | const CGEN_INSN * init_entries; |
716 | ||
19d45995 DE |
717 | /* Size of an entry (since the attribute member is variable sized). */ |
718 | unsigned int entry_size; | |
b61df026 | 719 | |
df8b2c02 DE |
720 | /* Number of entries in `init_entries', including trailing NULL entry. */ |
721 | unsigned int num_init_entries; | |
b61df026 | 722 | |
df8b2c02 | 723 | /* Values added at runtime. */ |
b61df026 | 724 | CGEN_INSN_LIST * new_entries; |
df8b2c02 DE |
725 | } CGEN_INSN_TABLE; |
726 | ||
030f419b | 727 | /* ??? This is currently used by the simulator. */ |
df8b2c02 | 728 | extern const CGEN_INSN CGEN_SYM (insn_table_entries)[]; |
df8b2c02 DE |
729 | |
730 | /* Return number of instructions. This includes any added at runtime. */ | |
731 | ||
030f419b DE |
732 | extern int cgen_insn_count PARAMS ((void)); |
733 | \f | |
734 | /* Macro instructions. | |
735 | Macro insns aren't real insns, they map to one or more real insns. | |
736 | E.g. An architecture's "nop" insn may actually be an "mv r0,r0" or | |
737 | some such. | |
738 | ||
739 | Macro insns can expand to nothing (e.g. a nop that is optimized away). | |
740 | This is useful in multi-insn macros that build a constant in a register. | |
741 | Of course this isn't the default behaviour and must be explicitly enabled. | |
742 | ||
743 | Assembly of macro-insns is relatively straightforward. Disassembly isn't. | |
744 | However, disassembly of at least some kinds of macro insns is important | |
745 | in order that the disassembled code preserve the readability of the original | |
746 | insn. What is attempted here is to disassemble all "simple" macro-insns, | |
747 | where "simple" is currently defined to mean "expands to one real insn". | |
748 | ||
749 | Simple macro-insns are handled specially. They are emitted as ALIAS's | |
750 | of real insns. This simplifies their handling since there's usually more | |
751 | of them than any other kind of macro-insn, and proper disassembly of them | |
752 | falls out for free. */ | |
753 | ||
754 | /* For each macro-insn there may be multiple expansion possibilities, | |
755 | depending on the arguments. This structure is accessed via the `data' | |
756 | member of CGEN_INSN. */ | |
757 | ||
758 | typedef struct cgen_minsn_expansion { | |
759 | /* Function to do the expansion. | |
760 | If the expansion fails (e.g. "no match") NULL is returned. | |
761 | Space for the expansion is obtained with malloc. | |
762 | It is up to the caller to free it. */ | |
763 | const char * (* fn) PARAMS ((const struct cgen_minsn_expansion *, | |
764 | const char *, const char **, int *, CGEN_OPERAND **)); | |
765 | #define CGEN_MIEXPN_FN(ex) ((ex)->fn) | |
766 | ||
767 | /* Instruction(s) the macro expands to. | |
768 | The format of STR is defined by FN. | |
769 | It is typically the assembly code of the real insn, but it could also be | |
770 | the original Scheme expression or a tokenized form of it (with FN being | |
771 | an appropriate interpreter). */ | |
772 | const char * str; | |
773 | #define CGEN_MIEXPN_STR(ex) ((ex)->str) | |
774 | } CGEN_MINSN_EXPANSION; | |
775 | ||
776 | /* Normal expander. | |
777 | When supported, this function will convert the input string to another | |
778 | string and the parser will be invoked recursively. The output string | |
779 | may contain further macro invocations. */ | |
780 | ||
781 | extern const char * cgen_expand_macro_insn | |
782 | PARAMS ((const struct cgen_minsn_expansion *, | |
783 | const char *, const char **, int *, CGEN_OPERAND **)); | |
784 | \f | |
df8b2c02 DE |
785 | /* The assembler insn table is hashed based on some function of the mnemonic |
786 | (the actually hashing done is up to the target, but we provide a few | |
030f419b DE |
787 | examples like the first letter or a function of the entire mnemonic). */ |
788 | ||
789 | #ifndef CGEN_ASM_HASH_P | |
790 | #define CGEN_ASM_HASH_P(insn) 1 | |
791 | #endif | |
df8b2c02 | 792 | |
030f419b DE |
793 | /* INSN is the CGEN_INSN entry when building the hash table and NULL |
794 | when looking up the insn during assembly. */ | |
df8b2c02 | 795 | #ifndef CGEN_ASM_HASH |
df8b2c02 | 796 | #define CGEN_ASM_HASH_SIZE 127 |
030f419b DE |
797 | #ifdef CGEN_MNEMONIC_OPERANDS |
798 | #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) | |
df8b2c02 | 799 | #else |
030f419b | 800 | #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/ |
df8b2c02 DE |
801 | #endif |
802 | #endif | |
803 | ||
030f419b DE |
804 | extern CGEN_INSN_LIST * cgen_asm_lookup_insn PARAMS ((const char *)); |
805 | #define CGEN_ASM_LOOKUP_INSN(string) cgen_asm_lookup_insn (string) | |
df8b2c02 DE |
806 | #define CGEN_ASM_NEXT_INSN(insn) ((insn)->next) |
807 | ||
808 | /* The disassembler insn table is hashed based on some function of machine | |
809 | instruction (the actually hashing done is up to the target). */ | |
810 | ||
030f419b DE |
811 | #ifndef CGEN_DIS_HASH_P |
812 | #define CGEN_DIS_HASH_P(insn) 1 | |
813 | #endif | |
814 | ||
df8b2c02 DE |
815 | /* It doesn't make much sense to provide a default here, |
816 | but while this is under development we do. | |
030f419b DE |
817 | INSN is the CGEN_INSN entry when building the hash table and NULL |
818 | when looking up the insn during assembly. | |
df8b2c02 | 819 | BUFFER is a pointer to the bytes of the insn. |
030f419b | 820 | VALUE is the first CGEN_BASE_INSN_SIZE bytes as an int in host order. */ |
df8b2c02 DE |
821 | #ifndef CGEN_DIS_HASH |
822 | #define CGEN_DIS_HASH_SIZE 256 | |
030f419b | 823 | #define CGEN_DIS_HASH(buffer, value) (*(unsigned char *) (buffer)) |
df8b2c02 DE |
824 | #endif |
825 | ||
030f419b DE |
826 | extern CGEN_INSN_LIST * cgen_dis_lookup_insn PARAMS ((const char *, |
827 | unsigned long)); | |
828 | #define CGEN_DIS_LOOKUP_INSN(buf, value) cgen_dis_lookup_insn ((buf), (value)) | |
df8b2c02 DE |
829 | #define CGEN_DIS_NEXT_INSN(insn) ((insn)->next) |
830 | \f | |
831 | /* Top level structures and functions. */ | |
832 | ||
b61df026 NC |
833 | typedef struct |
834 | { | |
030f419b DE |
835 | const CGEN_HW_ENTRY * hw_list; |
836 | ||
b61df026 | 837 | /*CGEN_OPERAND_TABLE * operand_table; - FIXME:wip */ |
030f419b DE |
838 | |
839 | CGEN_INSN_TABLE * insn_table; | |
840 | ||
841 | /* Macro instructions are defined separately and are combined with real | |
842 | insns during hash table computation. */ | |
843 | CGEN_INSN_TABLE * macro_insn_table; | |
844 | ||
845 | /* Return non-zero if insn should be added to hash table. */ | |
846 | int (* asm_hash_p) PARAMS ((const CGEN_INSN *)); | |
847 | ||
848 | /* Assembler hash function. */ | |
849 | unsigned int (* asm_hash) PARAMS ((const char *)); | |
850 | ||
851 | /* Number of entries in assembler hash table. */ | |
852 | unsigned int asm_hash_table_size; | |
853 | ||
854 | /* Return non-zero if insn should be added to hash table. */ | |
855 | int (* dis_hash_p) PARAMS ((const CGEN_INSN *)); | |
856 | ||
857 | /* Disassembler hash function. */ | |
858 | unsigned int (* dis_hash) PARAMS ((const char *, unsigned long)); | |
859 | ||
860 | /* Number of entries in disassembler hash table. */ | |
861 | unsigned int dis_hash_table_size; | |
862 | } CGEN_OPCODE_TABLE; | |
df8b2c02 DE |
863 | |
864 | /* Each CPU has one of these. */ | |
030f419b | 865 | extern const CGEN_OPCODE_TABLE CGEN_SYM (opcode_table); |
df8b2c02 DE |
866 | |
867 | /* Global state access macros. | |
868 | Some of these are tucked away and accessed with cover fns. | |
869 | Simpler things like the current machine and endian are not. */ | |
870 | ||
871 | extern int cgen_current_machine; | |
872 | #define CGEN_CURRENT_MACHINE cgen_current_machine | |
873 | ||
874 | extern enum cgen_endian cgen_current_endian; | |
875 | #define CGEN_CURRENT_ENDIAN cgen_current_endian | |
876 | ||
877 | /* Prototypes of major functions. */ | |
878 | ||
42d56c40 | 879 | /* Set the current cpu (+ mach number, endian, etc.). */ |
030f419b DE |
880 | extern void cgen_set_cpu PARAMS ((const CGEN_OPCODE_TABLE *, int, |
881 | enum cgen_endian)); | |
df8b2c02 DE |
882 | |
883 | /* Initialize the assembler, disassembler. */ | |
030f419b DE |
884 | extern void cgen_asm_init PARAMS ((void)); |
885 | extern void cgen_dis_init PARAMS ((void)); | |
df8b2c02 DE |
886 | |
887 | /* `init_tables' must be called before `xxx_supported'. */ | |
030f419b DE |
888 | extern void CGEN_SYM (init_tables) PARAMS ((int)); |
889 | extern void CGEN_SYM (init_asm) PARAMS ((int, enum cgen_endian)); | |
890 | extern void CGEN_SYM (init_dis) PARAMS ((int, enum cgen_endian)); | |
42d56c40 DE |
891 | |
892 | /* FIXME: This prototype is wrong ifndef CGEN_INT_INSN. | |
893 | Furthermore, ifdef CGEN_INT_INSN, the insn is created in | |
894 | target byte order (in which case why use int's at all). | |
895 | Perhaps replace cgen_insn_t * with char *? */ | |
030f419b | 896 | extern const struct cgen_insn * |
42d56c40 | 897 | CGEN_SYM (assemble_insn) PARAMS ((const char *, CGEN_FIELDS *, |
fe2dd642 | 898 | cgen_insn_t *, char **)); |
df8b2c02 | 899 | #if 0 /* old */ |
030f419b DE |
900 | extern int CGEN_SYM (insn_supported) PARAMS ((const struct cgen_insn *)); |
901 | extern int CGEN_SYM (opval_supported) PARAMS ((const struct cgen_opval *)); | |
df8b2c02 DE |
902 | #endif |
903 | ||
19d45995 | 904 | extern const CGEN_KEYWORD CGEN_SYM (operand_mach); |
030f419b | 905 | extern int CGEN_SYM (get_mach) PARAMS ((const char *)); |
df8b2c02 | 906 | |
030f419b | 907 | extern const CGEN_INSN * |
42d56c40 | 908 | CGEN_SYM (lookup_insn) PARAMS ((const CGEN_INSN *, cgen_insn_t, |
ad87e865 | 909 | int, CGEN_FIELDS *, int)); |
030f419b DE |
910 | extern void |
911 | CGEN_SYM (get_insn_operands) PARAMS ((const CGEN_INSN *, const CGEN_FIELDS *, | |
912 | int *)); | |
913 | extern const CGEN_INSN * | |
914 | CGEN_SYM (lookup_get_insn_operands) PARAMS ((const CGEN_INSN *, cgen_insn_t, | |
915 | int, int *)); | |
42d56c40 | 916 | |
ca2b987f DE |
917 | /* Get/set fields in the CGEN_FIELDS struct. */ |
918 | int | |
919 | CGEN_SYM (get_int_operand) PARAMS ((int, const CGEN_FIELDS *)); | |
920 | void | |
921 | CGEN_SYM (set_int_operand) PARAMS ((int, CGEN_FIELDS *, int)); | |
922 | #ifdef BFD_VERSION /* Don't require bfd.h unnecessarily. */ | |
923 | bfd_vma | |
924 | CGEN_SYM (get_vma_operand) PARAMS ((int, const CGEN_FIELDS *)); | |
925 | void | |
926 | CGEN_SYM (set_vma_operand) PARAMS ((int, CGEN_FIELDS *, bfd_vma)); | |
927 | #endif | |
df8b2c02 | 928 | |
030f419b | 929 | extern const char * |
42d56c40 | 930 | CGEN_SYM (parse_operand) PARAMS ((int, const char **, CGEN_FIELDS *)); |
df8b2c02 | 931 | |
ca2b987f | 932 | #ifdef BFD_VERSION /* Don't require bfd.h unnecessarily. */ |
030f419b | 933 | extern const char * |
ca2b987f DE |
934 | CGEN_SYM (insert_operand) PARAMS ((int, CGEN_FIELDS *, char *, bfd_vma)); |
935 | #endif | |
df8b2c02 DE |
936 | |
937 | /* Read in a cpu description file. */ | |
030f419b | 938 | extern const char * cgen_read_cpu_file PARAMS ((const char *)); |
df8b2c02 DE |
939 | |
940 | #endif /* CGEN_H */ |