xref: /openbsd-src/gnu/usr.bin/binutils/include/opcode/cgen.h (revision cf2f2c5620d6d9a4fd01930983c4b9a1f76d7aa3)
1fddef416Sniklas /* Header file for targets using CGEN: Cpu tools GENerator.
2fddef416Sniklas 
3d2201f2fSdrahn Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4d2201f2fSdrahn Free Software Foundation, Inc.
5fddef416Sniklas 
6fddef416Sniklas This file is part of GDB, the GNU debugger, and the GNU Binutils.
7fddef416Sniklas 
8fddef416Sniklas This program is free software; you can redistribute it and/or modify
9fddef416Sniklas it under the terms of the GNU General Public License as published by
10fddef416Sniklas the Free Software Foundation; either version 2 of the License, or
11fddef416Sniklas (at your option) any later version.
12fddef416Sniklas 
13fddef416Sniklas This program is distributed in the hope that it will be useful,
14fddef416Sniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
15fddef416Sniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16fddef416Sniklas GNU General Public License for more details.
17fddef416Sniklas 
18f7cc78ecSespie You should have received a copy of the GNU General Public License along
19f7cc78ecSespie with this program; if not, write to the Free Software Foundation, Inc.,
20f7cc78ecSespie 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21fddef416Sniklas 
22fddef416Sniklas #ifndef CGEN_H
23fddef416Sniklas #define CGEN_H
24fddef416Sniklas 
25f7cc78ecSespie /* ??? This file requires bfd.h but only to get bfd_vma.
26f7cc78ecSespie    Seems like an awful lot to require just to get such a fundamental type.
27f7cc78ecSespie    Perhaps the definition of bfd_vma can be moved outside of bfd.h.
28f7cc78ecSespie    Or perhaps one could duplicate its definition in another file.
29f7cc78ecSespie    Until such time, this file conditionally compiles definitions that require
30d2201f2fSdrahn    bfd_vma using __BFD_H_SEEN__.  */
31fddef416Sniklas 
32f7cc78ecSespie /* Enums must be defined before they can be used.
33f7cc78ecSespie    Allow them to be used in struct definitions, even though the enum must
34f7cc78ecSespie    be defined elsewhere.
35f7cc78ecSespie    If CGEN_ARCH isn't defined, this file is being included by something other
36f7cc78ecSespie    than <arch>-desc.h.  */
37f7cc78ecSespie 
38f7cc78ecSespie /* Prepend the arch name, defined in <arch>-desc.h, and _cgen_ to symbol S.
39fddef416Sniklas    The lack of spaces in the arg list is important for non-stdc systems.
40f7cc78ecSespie    This file is included by <arch>-desc.h.
41f7cc78ecSespie    It can be included independently of <arch>-desc.h, in which case the arch
42fddef416Sniklas    dependent portions will be declared as "unknown_cgen_foo".  */
43fddef416Sniklas 
44fddef416Sniklas #ifndef CGEN_SYM
45f7cc78ecSespie #define CGEN_SYM(s) CONCAT3 (unknown,_cgen_,s)
46fddef416Sniklas #endif
47fddef416Sniklas 
48fddef416Sniklas /* This file contains the static (unchanging) pieces and as much other stuff
49fddef416Sniklas    as we can reasonably put here.  It's generally cleaner to put stuff here
50fddef416Sniklas    rather than having it machine generated if possible.  */
51fddef416Sniklas 
52fddef416Sniklas /* The assembler syntax is made up of expressions (duh...).
53fddef416Sniklas    At the lowest level the values are mnemonics, register names, numbers, etc.
54fddef416Sniklas    Above that are subexpressions, if any (an example might be the
55f7cc78ecSespie    "effective address" in m68k cpus).  Subexpressions are wip.
56f7cc78ecSespie    At the second highest level are the insns themselves.  Above that are
57f7cc78ecSespie    pseudo-insns, synthetic insns, and macros, if any.  */
58fddef416Sniklas 
59fddef416Sniklas /* Lots of cpu's have a fixed insn size, or one which rarely changes,
60fddef416Sniklas    and it's generally easier to handle these by treating the insn as an
61fddef416Sniklas    integer type, rather than an array of characters.  So we allow targets
62f7cc78ecSespie    to control this.  When an integer type the value is in host byte order,
63f7cc78ecSespie    when an array of characters the value is in target byte order.  */
64fddef416Sniklas 
65f7cc78ecSespie typedef unsigned int CGEN_INSN_INT;
66f7cc78ecSespie #if CGEN_INT_INSN_P
67f7cc78ecSespie typedef CGEN_INSN_INT CGEN_INSN_BYTES;
68f7cc78ecSespie typedef CGEN_INSN_INT *CGEN_INSN_BYTES_PTR;
69fddef416Sniklas #else
70f7cc78ecSespie typedef unsigned char *CGEN_INSN_BYTES;
71f7cc78ecSespie typedef unsigned char *CGEN_INSN_BYTES_PTR;
72fddef416Sniklas #endif
73fddef416Sniklas 
74fddef416Sniklas #ifdef __GNUC__
75f7cc78ecSespie #define CGEN_INLINE __inline__
76fddef416Sniklas #else
77fddef416Sniklas #define CGEN_INLINE
78fddef416Sniklas #endif
79fddef416Sniklas 
80f7cc78ecSespie enum cgen_endian
81f7cc78ecSespie {
82fddef416Sniklas   CGEN_ENDIAN_UNKNOWN,
83fddef416Sniklas   CGEN_ENDIAN_LITTLE,
84fddef416Sniklas   CGEN_ENDIAN_BIG
85fddef416Sniklas };
86f7cc78ecSespie 
87f7cc78ecSespie /* Forward decl.  */
88f7cc78ecSespie 
89f7cc78ecSespie typedef struct cgen_insn CGEN_INSN;
90f7cc78ecSespie 
91f7cc78ecSespie /* Opaque pointer version for use by external world.  */
92f7cc78ecSespie 
93f7cc78ecSespie typedef struct cgen_cpu_desc *CGEN_CPU_DESC;
94fddef416Sniklas 
95fddef416Sniklas /* Attributes.
96f7cc78ecSespie    Attributes are used to describe various random things associated with
97f7cc78ecSespie    an object (ifield, hardware, operand, insn, whatever) and are specified
98f7cc78ecSespie    as name/value pairs.
99f7cc78ecSespie    Integer attributes computed at compile time are currently all that's
100f7cc78ecSespie    supported, though adding string attributes and run-time computation is
101f7cc78ecSespie    straightforward.  Integer attribute values are always host int's
102f7cc78ecSespie    (signed or unsigned).  For portability, this means 32 bits.
103f7cc78ecSespie    Integer attributes are further categorized as boolean, bitset, integer,
104f7cc78ecSespie    and enum types.  Boolean attributes appear frequently enough that they're
105f7cc78ecSespie    recorded in one host int.  This limits the maximum number of boolean
106f7cc78ecSespie    attributes to 32, though that's a *lot* of attributes.  */
107f7cc78ecSespie 
108f7cc78ecSespie /* Type of attribute values.  */
109f7cc78ecSespie 
110f7cc78ecSespie typedef int CGEN_ATTR_VALUE_TYPE;
111fddef416Sniklas 
112fddef416Sniklas /* Struct to record attribute information.  */
113f7cc78ecSespie 
114f7cc78ecSespie typedef struct
115f7cc78ecSespie {
116f7cc78ecSespie   /* Boolean attributes.  */
117fddef416Sniklas   unsigned int bool;
118f7cc78ecSespie   /* Non-boolean integer attributes.  */
119f7cc78ecSespie   CGEN_ATTR_VALUE_TYPE nonbool[1];
120fddef416Sniklas } CGEN_ATTR;
121fddef416Sniklas 
122fddef416Sniklas /* Define a structure member for attributes with N non-boolean entries.
123f7cc78ecSespie    There is no maximum number of non-boolean attributes.
124f7cc78ecSespie    There is a maximum of 32 boolean attributes (since they are all recorded
125f7cc78ecSespie    in one host int).  */
126fddef416Sniklas 
127f7cc78ecSespie #define CGEN_ATTR_TYPE(n) \
128f7cc78ecSespie struct { unsigned int bool; \
129f7cc78ecSespie 	 CGEN_ATTR_VALUE_TYPE nonbool[(n) ? (n) : 1]; }
130f7cc78ecSespie 
131f7cc78ecSespie /* Return the boolean attributes.  */
132f7cc78ecSespie 
133f7cc78ecSespie #define CGEN_ATTR_BOOLS(a) ((a)->bool)
134f7cc78ecSespie 
135f7cc78ecSespie /* Non-boolean attribute numbers are offset by this much.  */
136f7cc78ecSespie 
137f7cc78ecSespie #define CGEN_ATTR_NBOOL_OFFSET 32
138f7cc78ecSespie 
139f7cc78ecSespie /* Given a boolean attribute number, return its mask.  */
140f7cc78ecSespie 
141fddef416Sniklas #define CGEN_ATTR_MASK(attr) (1 << (attr))
142fddef416Sniklas 
143f7cc78ecSespie /* Return the value of boolean attribute ATTR in ATTRS.  */
144f7cc78ecSespie 
145f7cc78ecSespie #define CGEN_BOOL_ATTR(attrs, attr) ((CGEN_ATTR_MASK (attr) & (attrs)) != 0)
146f7cc78ecSespie 
147fddef416Sniklas /* Return value of attribute ATTR in ATTR_TABLE for OBJ.
148f7cc78ecSespie    OBJ is a pointer to the entity that has the attributes
149f7cc78ecSespie    (??? not used at present but is reserved for future purposes - eventually
150f7cc78ecSespie    the goal is to allow recording attributes in source form and computing
151f7cc78ecSespie    them lazily at runtime, not sure of the details yet).  */
152f7cc78ecSespie 
153fddef416Sniklas #define CGEN_ATTR_VALUE(obj, attr_table, attr) \
154f7cc78ecSespie ((unsigned int) (attr) < CGEN_ATTR_NBOOL_OFFSET \
155f7cc78ecSespie  ? ((CGEN_ATTR_BOOLS (attr_table) & CGEN_ATTR_MASK (attr)) != 0) \
156f7cc78ecSespie  : ((attr_table)->nonbool[(attr) - CGEN_ATTR_NBOOL_OFFSET]))
157f7cc78ecSespie 
158f7cc78ecSespie /* Attribute name/value tables.
159f7cc78ecSespie    These are used to assist parsing of descriptions at run-time.  */
160f7cc78ecSespie 
161f7cc78ecSespie typedef struct
162f7cc78ecSespie {
163f7cc78ecSespie   const char * name;
164f7cc78ecSespie   CGEN_ATTR_VALUE_TYPE value;
165f7cc78ecSespie } CGEN_ATTR_ENTRY;
166f7cc78ecSespie 
167f7cc78ecSespie /* For each domain (ifld,hw,operand,insn), list of attributes.  */
168f7cc78ecSespie 
169f7cc78ecSespie typedef struct
170f7cc78ecSespie {
171f7cc78ecSespie   const char * name;
172f7cc78ecSespie   const CGEN_ATTR_ENTRY * dfault;
173f7cc78ecSespie   const CGEN_ATTR_ENTRY * vals;
174f7cc78ecSespie } CGEN_ATTR_TABLE;
175f7cc78ecSespie 
176f7cc78ecSespie /* Instruction set variants.  */
177f7cc78ecSespie 
178f7cc78ecSespie typedef struct {
179f7cc78ecSespie   const char *name;
180f7cc78ecSespie 
181f7cc78ecSespie   /* Default instruction size (in bits).
182f7cc78ecSespie      This is used by the assembler when it encounters an unknown insn.  */
183f7cc78ecSespie   unsigned int default_insn_bitsize;
184f7cc78ecSespie 
185f7cc78ecSespie   /* Base instruction size (in bits).
186f7cc78ecSespie      For non-LIW cpus this is generally the length of the smallest insn.
187f7cc78ecSespie      For LIW cpus its wip (work-in-progress).  For the m32r its 32.  */
188f7cc78ecSespie   unsigned int base_insn_bitsize;
189f7cc78ecSespie 
190f7cc78ecSespie   /* Minimum/maximum instruction size (in bits).  */
191f7cc78ecSespie   unsigned int min_insn_bitsize;
192f7cc78ecSespie   unsigned int max_insn_bitsize;
193f7cc78ecSespie } CGEN_ISA;
194f7cc78ecSespie 
195f7cc78ecSespie /* Machine variants.  */
196f7cc78ecSespie 
197f7cc78ecSespie typedef struct {
198f7cc78ecSespie   const char *name;
199f7cc78ecSespie   /* The argument to bfd_arch_info->scan.  */
200f7cc78ecSespie   const char *bfd_name;
201f7cc78ecSespie   /* one of enum mach_attr */
202f7cc78ecSespie   int num;
203d2201f2fSdrahn   /* parameter from mach->cpu */
204d2201f2fSdrahn   unsigned int insn_chunk_bitsize;
205f7cc78ecSespie } CGEN_MACH;
206fddef416Sniklas 
207fddef416Sniklas /* Parse result (also extraction result).
208fddef416Sniklas 
209fddef416Sniklas    The result of parsing an insn is stored here.
210fddef416Sniklas    To generate the actual insn, this is passed to the insert handler.
211fddef416Sniklas    When printing an insn, the result of extraction is stored here.
212fddef416Sniklas    To print the insn, this is passed to the print handler.
213fddef416Sniklas 
214fddef416Sniklas    It is machine generated so we don't define it here,
215fddef416Sniklas    but we do need a forward decl for the handler fns.
216fddef416Sniklas 
217fddef416Sniklas    There is one member for each possible field in the insn.
218fddef416Sniklas    The type depends on the field.
219fddef416Sniklas    Also recorded here is the computed length of the insn for architectures
220fddef416Sniklas    where it varies.
221fddef416Sniklas */
222fddef416Sniklas 
223f7cc78ecSespie typedef struct cgen_fields CGEN_FIELDS;
224fddef416Sniklas 
225fddef416Sniklas /* Total length of the insn, as recorded in the `fields' struct.  */
226fddef416Sniklas /* ??? The field insert handler has lots of opportunities for optimization
227fddef416Sniklas    if it ever gets inlined.  On architectures where insns all have the same
228fddef416Sniklas    size, may wish to detect that and make this macro a constant - to allow
229fddef416Sniklas    further optimizations.  */
230f7cc78ecSespie 
231fddef416Sniklas #define CGEN_FIELDS_BITSIZE(fields) ((fields)->length)
232fddef416Sniklas 
233f7cc78ecSespie /* Extraction support for variable length insn sets.  */
234fddef416Sniklas 
235f7cc78ecSespie /* When disassembling we don't know the number of bytes to read at the start.
236f7cc78ecSespie    So the first CGEN_BASE_INSN_SIZE bytes are read at the start and the rest
237f7cc78ecSespie    are read when needed.  This struct controls this.  It is basically the
238f7cc78ecSespie    disassemble_info stuff, except that we provide a cache for values already
239f7cc78ecSespie    read (since bytes can typically be read several times to fetch multiple
240f7cc78ecSespie    operands that may be in them), and that extraction of fields is needed
241f7cc78ecSespie    in contexts other than disassembly.  */
242f7cc78ecSespie 
243f7cc78ecSespie typedef struct {
244f7cc78ecSespie   /* A pointer to the disassemble_info struct.
245*cf2f2c56Smiod      We don't require dis-asm.h so we use void * for the type here.
246f7cc78ecSespie      If NULL, BYTES is full of valid data (VALID == -1).  */
247*cf2f2c56Smiod   void *dis_info;
248f7cc78ecSespie   /* Points to a working buffer of sufficient size.  */
249f7cc78ecSespie   unsigned char *insn_bytes;
250f7cc78ecSespie   /* Mask of bytes that are valid in INSN_BYTES.  */
251f7cc78ecSespie   unsigned int valid;
252f7cc78ecSespie } CGEN_EXTRACT_INFO;
253f7cc78ecSespie 
254f7cc78ecSespie /* Associated with each insn or expression is a set of "handlers" for
255f7cc78ecSespie    performing operations like parsing, printing, etc.  These require a bfd_vma
256f7cc78ecSespie    value to be passed around but we don't want all applications to need bfd.h.
257f7cc78ecSespie    So this stuff is only provided if bfd.h has been included.  */
258fddef416Sniklas 
259fddef416Sniklas /* Parse handler.
260f7cc78ecSespie    CD is a cpu table descriptor.
261f7cc78ecSespie    INSN is a pointer to a struct describing the insn being parsed.
262f7cc78ecSespie    STRP is a pointer to a pointer to the text being parsed.
263f7cc78ecSespie    FIELDS is a pointer to a cgen_fields struct in which the results are placed.
264f7cc78ecSespie    If the expression is successfully parsed, *STRP is updated.
265f7cc78ecSespie    If not it is left alone.
266fddef416Sniklas    The result is NULL if success or an error message.  */
267f7cc78ecSespie typedef const char * (cgen_parse_fn)
268*cf2f2c56Smiod   (CGEN_CPU_DESC, const CGEN_INSN *insn_,
269*cf2f2c56Smiod    const char **strp_, CGEN_FIELDS *fields_);
270f7cc78ecSespie 
271f7cc78ecSespie /* Insert handler.
272f7cc78ecSespie    CD is a cpu table descriptor.
273f7cc78ecSespie    INSN is a pointer to a struct describing the insn being parsed.
274f7cc78ecSespie    FIELDS is a pointer to a cgen_fields struct from which the values
275f7cc78ecSespie    are fetched.
276f7cc78ecSespie    INSNP is a pointer to a buffer in which to place the insn.
277f7cc78ecSespie    PC is the pc value of the insn.
278f7cc78ecSespie    The result is an error message or NULL if success.  */
279f7cc78ecSespie 
280d2201f2fSdrahn #ifdef __BFD_H_SEEN__
281f7cc78ecSespie typedef const char * (cgen_insert_fn)
282*cf2f2c56Smiod   (CGEN_CPU_DESC, const CGEN_INSN *insn_,
283f7cc78ecSespie    CGEN_FIELDS *fields_, CGEN_INSN_BYTES_PTR insnp_,
284*cf2f2c56Smiod    bfd_vma pc_);
285f7cc78ecSespie #else
286f7cc78ecSespie typedef const char * (cgen_insert_fn) ();
287f7cc78ecSespie #endif
288f7cc78ecSespie 
289f7cc78ecSespie /* Extract handler.
290f7cc78ecSespie    CD is a cpu table descriptor.
291f7cc78ecSespie    INSN is a pointer to a struct describing the insn being parsed.
292f7cc78ecSespie    The second argument is a pointer to a struct controlling extraction
293f7cc78ecSespie    (only used for variable length insns).
294f7cc78ecSespie    EX_INFO is a pointer to a struct for controlling reading of further
295f7cc78ecSespie    bytes for the insn.
296f7cc78ecSespie    BASE_INSN is the first CGEN_BASE_INSN_SIZE bytes (host order).
297f7cc78ecSespie    FIELDS is a pointer to a cgen_fields struct in which the results are placed.
298f7cc78ecSespie    PC is the pc value of the insn.
299f7cc78ecSespie    The result is the length of the insn in bits or zero if not recognized.  */
300f7cc78ecSespie 
301d2201f2fSdrahn #ifdef __BFD_H_SEEN__
302f7cc78ecSespie typedef int (cgen_extract_fn)
303*cf2f2c56Smiod   (CGEN_CPU_DESC, const CGEN_INSN *insn_,
304f7cc78ecSespie    CGEN_EXTRACT_INFO *ex_info_, CGEN_INSN_INT base_insn_,
305*cf2f2c56Smiod    CGEN_FIELDS *fields_, bfd_vma pc_);
306f7cc78ecSespie #else
307f7cc78ecSespie typedef int (cgen_extract_fn) ();
308f7cc78ecSespie #endif
309fddef416Sniklas 
310fddef416Sniklas /* Print handler.
311f7cc78ecSespie    CD is a cpu table descriptor.
312f7cc78ecSespie    INFO is a pointer to the disassembly info.
313fddef416Sniklas    Eg: disassemble_info.  It's defined as `PTR' so this file can be included
314fddef416Sniklas    without dis-asm.h.
315f7cc78ecSespie    INSN is a pointer to a struct describing the insn being printed.
316f7cc78ecSespie    FIELDS is a pointer to a cgen_fields struct.
317f7cc78ecSespie    PC is the pc value of the insn.
318f7cc78ecSespie    LEN is the length of the insn, in bits.  */
319f7cc78ecSespie 
320d2201f2fSdrahn #ifdef __BFD_H_SEEN__
321f7cc78ecSespie typedef void (cgen_print_fn)
322*cf2f2c56Smiod   (CGEN_CPU_DESC, void * info_, const CGEN_INSN *insn_,
323*cf2f2c56Smiod    CGEN_FIELDS *fields_, bfd_vma pc_, int len_);
324fddef416Sniklas #else
325fddef416Sniklas typedef void (cgen_print_fn) ();
326fddef416Sniklas #endif
327fddef416Sniklas 
328f7cc78ecSespie /* Parse/insert/extract/print handlers.
329fddef416Sniklas 
330f7cc78ecSespie    Indices into the handler tables.
331f7cc78ecSespie    We could use pointers here instead, but 90% of them are generally identical
332f7cc78ecSespie    and that's a lot of redundant data.  Making these unsigned char indices
333f7cc78ecSespie    into tables of pointers saves a bit of space.
334f7cc78ecSespie    Using indices also keeps assembler code out of the disassembler and
335f7cc78ecSespie    vice versa.  */
336fddef416Sniklas 
337f7cc78ecSespie struct cgen_opcode_handler
338f7cc78ecSespie {
339fddef416Sniklas   unsigned char parse, insert, extract, print;
340fddef416Sniklas };
341fddef416Sniklas 
342fddef416Sniklas /* Assembler interface.
343fddef416Sniklas 
344fddef416Sniklas    The interface to the assembler is intended to be clean in the sense that
345fddef416Sniklas    libopcodes.a is a standalone entity and could be used with any assembler.
346fddef416Sniklas    Not that one would necessarily want to do that but rather that it helps
347fddef416Sniklas    keep a clean interface.  The interface will obviously be slanted towards
348fddef416Sniklas    GAS, but at least it's a start.
349f7cc78ecSespie    ??? Note that one possible user of the assembler besides GAS is GDB.
350fddef416Sniklas 
351fddef416Sniklas    Parsing is controlled by the assembler which calls
352fddef416Sniklas    CGEN_SYM (assemble_insn).  If it can parse and build the entire insn
353fddef416Sniklas    it doesn't call back to the assembler.  If it needs/wants to call back
354f7cc78ecSespie    to the assembler, cgen_parse_operand_fn is called which can either
355fddef416Sniklas 
356fddef416Sniklas    - return a number to be inserted in the insn
357fddef416Sniklas    - return a "register" value to be inserted
358fddef416Sniklas      (the register might not be a register per pe)
359fddef416Sniklas    - queue the argument and return a marker saying the expression has been
360fddef416Sniklas      queued (eg: a fix-up)
361fddef416Sniklas    - return an error message indicating the expression wasn't recognizable
362fddef416Sniklas 
363fddef416Sniklas    The result is an error message or NULL for success.
364fddef416Sniklas    The parsed value is stored in the bfd_vma *.  */
365fddef416Sniklas 
366fddef416Sniklas /* Values for indicating what the caller wants.  */
367f7cc78ecSespie 
368f7cc78ecSespie enum cgen_parse_operand_type
369f7cc78ecSespie {
370f7cc78ecSespie   CGEN_PARSE_OPERAND_INIT,
371f7cc78ecSespie   CGEN_PARSE_OPERAND_INTEGER,
372fddef416Sniklas   CGEN_PARSE_OPERAND_ADDRESS
373fddef416Sniklas };
374fddef416Sniklas 
375f7cc78ecSespie /* Values for indicating what was parsed.  */
376f7cc78ecSespie 
377f7cc78ecSespie enum cgen_parse_operand_result
378f7cc78ecSespie {
379f7cc78ecSespie   CGEN_PARSE_OPERAND_RESULT_NUMBER,
380f7cc78ecSespie   CGEN_PARSE_OPERAND_RESULT_REGISTER,
381f7cc78ecSespie   CGEN_PARSE_OPERAND_RESULT_QUEUED,
382f7cc78ecSespie   CGEN_PARSE_OPERAND_RESULT_ERROR
383fddef416Sniklas };
384fddef416Sniklas 
385d2201f2fSdrahn #ifdef __BFD_H_SEEN__ /* Don't require bfd.h unnecessarily.  */
386f7cc78ecSespie typedef const char * (cgen_parse_operand_fn)
387*cf2f2c56Smiod   (CGEN_CPU_DESC,
388f7cc78ecSespie    enum cgen_parse_operand_type, const char **, int, int,
389*cf2f2c56Smiod    enum cgen_parse_operand_result *, bfd_vma *);
390f7cc78ecSespie #else
391f7cc78ecSespie typedef const char * (cgen_parse_operand_fn) ();
392fddef416Sniklas #endif
393fddef416Sniklas 
394f7cc78ecSespie /* Set the cgen_parse_operand_fn callback.  */
395f7cc78ecSespie 
396f7cc78ecSespie extern void cgen_set_parse_operand_fn
397*cf2f2c56Smiod   (CGEN_CPU_DESC, cgen_parse_operand_fn);
398f7cc78ecSespie 
399fddef416Sniklas /* Called before trying to match a table entry with the insn.  */
400fddef416Sniklas 
401*cf2f2c56Smiod extern void cgen_init_parse_operand (CGEN_CPU_DESC);
402f7cc78ecSespie 
403f7cc78ecSespie /* Operand values (keywords, integers, symbols, etc.)  */
404fddef416Sniklas 
405f7cc78ecSespie /* Types of assembler elements.  */
406fddef416Sniklas 
407f7cc78ecSespie enum cgen_asm_type
408f7cc78ecSespie {
409f7cc78ecSespie   CGEN_ASM_NONE, CGEN_ASM_KEYWORD, CGEN_ASM_MAX
410f7cc78ecSespie };
411fddef416Sniklas 
412f7cc78ecSespie #ifndef CGEN_ARCH
413f7cc78ecSespie enum cgen_hw_type { CGEN_HW_MAX };
414fddef416Sniklas #endif
415fddef416Sniklas 
416f7cc78ecSespie /* List of hardware elements.  */
417fddef416Sniklas 
418f7cc78ecSespie typedef struct
419f7cc78ecSespie {
420f7cc78ecSespie   char *name;
421f7cc78ecSespie   enum cgen_hw_type type;
422f7cc78ecSespie   /* There is currently no example where both index specs and value specs
423f7cc78ecSespie      are required, so for now both are clumped under "asm_data".  */
424f7cc78ecSespie   enum cgen_asm_type asm_type;
425*cf2f2c56Smiod   void *asm_data;
426f7cc78ecSespie #ifndef CGEN_HW_NBOOL_ATTRS
427f7cc78ecSespie #define CGEN_HW_NBOOL_ATTRS 1
428f7cc78ecSespie #endif
429f7cc78ecSespie   CGEN_ATTR_TYPE (CGEN_HW_NBOOL_ATTRS) attrs;
430f7cc78ecSespie #define CGEN_HW_ATTRS(hw) (&(hw)->attrs)
431f7cc78ecSespie } CGEN_HW_ENTRY;
432f7cc78ecSespie 
433f7cc78ecSespie /* Return value of attribute ATTR in HW.  */
434f7cc78ecSespie 
435f7cc78ecSespie #define CGEN_HW_ATTR_VALUE(hw, attr) \
436f7cc78ecSespie CGEN_ATTR_VALUE ((hw), CGEN_HW_ATTRS (hw), (attr))
437f7cc78ecSespie 
438f7cc78ecSespie /* Table of hardware elements for selected mach, computed at runtime.
439f7cc78ecSespie    enum cgen_hw_type is an index into this table (specifically `entries').  */
440f7cc78ecSespie 
441f7cc78ecSespie typedef struct {
442f7cc78ecSespie   /* Pointer to null terminated table of all compiled in entries.  */
443f7cc78ecSespie   const CGEN_HW_ENTRY *init_entries;
444f7cc78ecSespie   unsigned int entry_size; /* since the attribute member is variable sized */
445f7cc78ecSespie   /* Array of all entries, initial and run-time added.  */
446f7cc78ecSespie   const CGEN_HW_ENTRY **entries;
447f7cc78ecSespie   /* Number of elements in `entries'.  */
448f7cc78ecSespie   unsigned int num_entries;
449f7cc78ecSespie   /* For now, xrealloc is called each time a new entry is added at runtime.
450f7cc78ecSespie      ??? May wish to keep track of some slop to reduce the number of calls to
451f7cc78ecSespie      xrealloc, except that there's unlikely to be many and not expected to be
452f7cc78ecSespie      in speed critical code.  */
453f7cc78ecSespie } CGEN_HW_TABLE;
454f7cc78ecSespie 
455f7cc78ecSespie extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_name
456*cf2f2c56Smiod   (CGEN_CPU_DESC, const char *);
457f7cc78ecSespie extern const CGEN_HW_ENTRY * cgen_hw_lookup_by_num
458*cf2f2c56Smiod   (CGEN_CPU_DESC, unsigned int);
459f7cc78ecSespie 
460f7cc78ecSespie /* This struct is used to describe things like register names, etc.  */
461f7cc78ecSespie 
462f7cc78ecSespie typedef struct cgen_keyword_entry
463f7cc78ecSespie {
464f7cc78ecSespie   /* Name (as in register name).  */
465f7cc78ecSespie   char * name;
466f7cc78ecSespie 
467f7cc78ecSespie   /* Value (as in register number).
468f7cc78ecSespie      The value cannot be -1 as that is used to indicate "not found".
469f7cc78ecSespie      IDEA: Have "FUNCTION" attribute? [function is called to fetch value].  */
470f7cc78ecSespie   int value;
471f7cc78ecSespie 
472f7cc78ecSespie   /* Attributes.
473f7cc78ecSespie      This should, but technically needn't, appear last.  It is a variable sized
474f7cc78ecSespie      array in that one architecture may have 1 nonbool attribute and another
475f7cc78ecSespie      may have more.  Having this last means the non-architecture specific code
476f7cc78ecSespie      needn't care.  The goal is to eventually record
477f7cc78ecSespie      attributes in their raw form, evaluate them at run-time, and cache the
478f7cc78ecSespie      values, so this worry will go away anyway.  */
479f7cc78ecSespie   /* ??? Moving this last should be done by treating keywords like insn lists
480f7cc78ecSespie      and moving the `next' fields into a CGEN_KEYWORD_LIST struct.  */
481f7cc78ecSespie   /* FIXME: Not used yet.  */
482f7cc78ecSespie #ifndef CGEN_KEYWORD_NBOOL_ATTRS
483f7cc78ecSespie #define CGEN_KEYWORD_NBOOL_ATTRS 1
484f7cc78ecSespie #endif
485f7cc78ecSespie   CGEN_ATTR_TYPE (CGEN_KEYWORD_NBOOL_ATTRS) attrs;
486f7cc78ecSespie 
487f7cc78ecSespie   /* ??? Putting these here means compiled in entries can't be const.
488f7cc78ecSespie      Not a really big deal, but something to consider.  */
489f7cc78ecSespie   /* Next name hash table entry.  */
490f7cc78ecSespie   struct cgen_keyword_entry *next_name;
491f7cc78ecSespie   /* Next value hash table entry.  */
492f7cc78ecSespie   struct cgen_keyword_entry *next_value;
493f7cc78ecSespie } CGEN_KEYWORD_ENTRY;
494f7cc78ecSespie 
495f7cc78ecSespie /* Top level struct for describing a set of related keywords
496f7cc78ecSespie    (e.g. register names).
497f7cc78ecSespie 
498f7cc78ecSespie    This struct supports run-time entry of new values, and hashed lookups.  */
499f7cc78ecSespie 
500f7cc78ecSespie typedef struct cgen_keyword
501f7cc78ecSespie {
502f7cc78ecSespie   /* Pointer to initial [compiled in] values.  */
503f7cc78ecSespie   CGEN_KEYWORD_ENTRY *init_entries;
504f7cc78ecSespie 
505f7cc78ecSespie   /* Number of entries in `init_entries'.  */
506f7cc78ecSespie   unsigned int num_init_entries;
507f7cc78ecSespie 
508f7cc78ecSespie   /* Hash table used for name lookup.  */
509f7cc78ecSespie   CGEN_KEYWORD_ENTRY **name_hash_table;
510f7cc78ecSespie 
511f7cc78ecSespie   /* Hash table used for value lookup.  */
512f7cc78ecSespie   CGEN_KEYWORD_ENTRY **value_hash_table;
513f7cc78ecSespie 
514f7cc78ecSespie   /* Number of entries in the hash_tables.  */
515f7cc78ecSespie   unsigned int hash_table_size;
516f7cc78ecSespie 
517f7cc78ecSespie   /* Pointer to null keyword "" entry if present.  */
518f7cc78ecSespie   const CGEN_KEYWORD_ENTRY *null_entry;
519d2201f2fSdrahn 
520d2201f2fSdrahn   /* String containing non-alphanumeric characters used
521d2201f2fSdrahn      in keywords.
522d2201f2fSdrahn      At present, the highest number of entries used is 1.  */
523d2201f2fSdrahn   char nonalpha_chars[8];
524f7cc78ecSespie } CGEN_KEYWORD;
525f7cc78ecSespie 
526f7cc78ecSespie /* Structure used for searching.  */
527f7cc78ecSespie 
528f7cc78ecSespie typedef struct
529f7cc78ecSespie {
530f7cc78ecSespie   /* Table being searched.  */
531f7cc78ecSespie   const CGEN_KEYWORD *table;
532f7cc78ecSespie 
533f7cc78ecSespie   /* Specification of what is being searched for.  */
534f7cc78ecSespie   const char *spec;
535f7cc78ecSespie 
536f7cc78ecSespie   /* Current index in hash table.  */
537f7cc78ecSespie   unsigned int current_hash;
538f7cc78ecSespie 
539f7cc78ecSespie   /* Current element in current hash chain.  */
540f7cc78ecSespie   CGEN_KEYWORD_ENTRY *current_entry;
541f7cc78ecSespie } CGEN_KEYWORD_SEARCH;
542f7cc78ecSespie 
543f7cc78ecSespie /* Lookup a keyword from its name.  */
544f7cc78ecSespie 
545f7cc78ecSespie const CGEN_KEYWORD_ENTRY *cgen_keyword_lookup_name
546*cf2f2c56Smiod   (CGEN_KEYWORD *, const char *);
547f7cc78ecSespie 
548f7cc78ecSespie /* Lookup a keyword from its value.  */
549f7cc78ecSespie 
550f7cc78ecSespie const CGEN_KEYWORD_ENTRY *cgen_keyword_lookup_value
551*cf2f2c56Smiod   (CGEN_KEYWORD *, int);
552f7cc78ecSespie 
553f7cc78ecSespie /* Add a keyword.  */
554f7cc78ecSespie 
555*cf2f2c56Smiod void cgen_keyword_add (CGEN_KEYWORD *, CGEN_KEYWORD_ENTRY *);
556f7cc78ecSespie 
557f7cc78ecSespie /* Keyword searching.
558f7cc78ecSespie    This can be used to retrieve every keyword, or a subset.  */
559f7cc78ecSespie 
560f7cc78ecSespie CGEN_KEYWORD_SEARCH cgen_keyword_search_init
561*cf2f2c56Smiod   (CGEN_KEYWORD *, const char *);
562f7cc78ecSespie const CGEN_KEYWORD_ENTRY *cgen_keyword_search_next
563*cf2f2c56Smiod   (CGEN_KEYWORD_SEARCH *);
564f7cc78ecSespie 
565f7cc78ecSespie /* Operand value support routines.  */
566f7cc78ecSespie 
567f7cc78ecSespie extern const char *cgen_parse_keyword
568*cf2f2c56Smiod   (CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *);
569d2201f2fSdrahn #ifdef __BFD_H_SEEN__ /* Don't require bfd.h unnecessarily.  */
570f7cc78ecSespie extern const char *cgen_parse_signed_integer
571*cf2f2c56Smiod   (CGEN_CPU_DESC, const char **, int, long *);
572f7cc78ecSespie extern const char *cgen_parse_unsigned_integer
573*cf2f2c56Smiod   (CGEN_CPU_DESC, const char **, int, unsigned long *);
574f7cc78ecSespie extern const char *cgen_parse_address
575*cf2f2c56Smiod   (CGEN_CPU_DESC, const char **, int, int,
576*cf2f2c56Smiod    enum cgen_parse_operand_result *, bfd_vma *);
577f7cc78ecSespie extern const char *cgen_validate_signed_integer
578*cf2f2c56Smiod   (long, long, long);
579f7cc78ecSespie extern const char *cgen_validate_unsigned_integer
580*cf2f2c56Smiod   (unsigned long, unsigned long, unsigned long);
581f7cc78ecSespie #endif
582f7cc78ecSespie 
583f7cc78ecSespie /* Operand modes.  */
584f7cc78ecSespie 
585f7cc78ecSespie /* ??? This duplicates the values in arch.h.  Revisit.
586f7cc78ecSespie    These however need the CGEN_ prefix [as does everything in this file].  */
587f7cc78ecSespie /* ??? Targets may need to add their own modes so we may wish to move this
588f7cc78ecSespie    to <arch>-opc.h, or add a hook.  */
589f7cc78ecSespie 
590f7cc78ecSespie enum cgen_mode {
591f7cc78ecSespie   CGEN_MODE_VOID, /* ??? rename simulator's VM to VOID? */
592f7cc78ecSespie   CGEN_MODE_BI, CGEN_MODE_QI, CGEN_MODE_HI, CGEN_MODE_SI, CGEN_MODE_DI,
593f7cc78ecSespie   CGEN_MODE_UBI, CGEN_MODE_UQI, CGEN_MODE_UHI, CGEN_MODE_USI, CGEN_MODE_UDI,
594f7cc78ecSespie   CGEN_MODE_SF, CGEN_MODE_DF, CGEN_MODE_XF, CGEN_MODE_TF,
595f7cc78ecSespie   CGEN_MODE_TARGET_MAX,
596f7cc78ecSespie   CGEN_MODE_INT, CGEN_MODE_UINT,
597f7cc78ecSespie   CGEN_MODE_MAX
598f7cc78ecSespie };
599f7cc78ecSespie 
600f7cc78ecSespie /* FIXME: Until simulator is updated.  */
601f7cc78ecSespie 
602f7cc78ecSespie #define CGEN_MODE_VM CGEN_MODE_VOID
603f7cc78ecSespie 
604f7cc78ecSespie /* Operands.  */
605f7cc78ecSespie 
606f7cc78ecSespie #ifndef CGEN_ARCH
607f7cc78ecSespie enum cgen_operand_type { CGEN_OPERAND_MAX };
608f7cc78ecSespie #endif
609f7cc78ecSespie 
610f7cc78ecSespie /* "nil" indicator for the operand instance table */
611f7cc78ecSespie #define CGEN_OPERAND_NIL CGEN_OPERAND_MAX
612f7cc78ecSespie 
613d2201f2fSdrahn /* A tree of these structs represents the multi-ifield
614d2201f2fSdrahn    structure of an operand's hw-index value, if it exists.  */
615d2201f2fSdrahn 
616d2201f2fSdrahn struct cgen_ifld;
617d2201f2fSdrahn 
618d2201f2fSdrahn typedef struct cgen_maybe_multi_ifield
619d2201f2fSdrahn {
620d2201f2fSdrahn   int count; /* 0: indexed by single cgen_ifld (possibly null: dead entry);
621d2201f2fSdrahn 		n: indexed by array of more cgen_maybe_multi_ifields.  */
622d2201f2fSdrahn   union
623d2201f2fSdrahn   {
624*cf2f2c56Smiod     const void *p;
625d2201f2fSdrahn     const struct cgen_maybe_multi_ifield * multi;
626d2201f2fSdrahn     const struct cgen_ifld * leaf;
627d2201f2fSdrahn   } val;
628d2201f2fSdrahn }
629d2201f2fSdrahn CGEN_MAYBE_MULTI_IFLD;
630d2201f2fSdrahn 
631f7cc78ecSespie /* This struct defines each entry in the operand table.  */
632f7cc78ecSespie 
633f7cc78ecSespie typedef struct
634f7cc78ecSespie {
635f7cc78ecSespie   /* Name as it appears in the syntax string.  */
636f7cc78ecSespie   char *name;
637f7cc78ecSespie 
638f7cc78ecSespie   /* Operand type.  */
639f7cc78ecSespie   enum cgen_operand_type type;
640f7cc78ecSespie 
641f7cc78ecSespie   /* The hardware element associated with this operand.  */
642f7cc78ecSespie   enum cgen_hw_type hw_type;
643f7cc78ecSespie 
644f7cc78ecSespie   /* FIXME: We don't yet record ifield definitions, which we should.
645f7cc78ecSespie      When we do it might make sense to delete start/length (since they will
646f7cc78ecSespie      be duplicated in the ifield's definition) and replace them with a
647f7cc78ecSespie      pointer to the ifield entry.  */
648f7cc78ecSespie 
649f7cc78ecSespie   /* Bit position.
650f7cc78ecSespie      This is just a hint, and may be unused in more complex operands.
651f7cc78ecSespie      May be unused for a modifier.  */
652f7cc78ecSespie   unsigned char start;
653f7cc78ecSespie 
654f7cc78ecSespie   /* The number of bits in the operand.
655f7cc78ecSespie      This is just a hint, and may be unused in more complex operands.
656f7cc78ecSespie      May be unused for a modifier.  */
657f7cc78ecSespie   unsigned char length;
658f7cc78ecSespie 
659d2201f2fSdrahn   /* The (possibly-multi) ifield used as an index for this operand, if it
660d2201f2fSdrahn      is indexed by a field at all. This substitutes / extends the start and
661d2201f2fSdrahn      length fields above, but unsure at this time whether they are used
662d2201f2fSdrahn      anywhere.  */
663d2201f2fSdrahn   CGEN_MAYBE_MULTI_IFLD index_fields;
664f7cc78ecSespie #if 0 /* ??? Interesting idea but relocs tend to get too complicated,
665f7cc78ecSespie 	 and ABI dependent, for simple table lookups to work.  */
666f7cc78ecSespie   /* Ideally this would be the internal (external?) reloc type.  */
667f7cc78ecSespie   int reloc_type;
668f7cc78ecSespie #endif
669f7cc78ecSespie 
670f7cc78ecSespie   /* Attributes.
671f7cc78ecSespie      This should, but technically needn't, appear last.  It is a variable sized
672f7cc78ecSespie      array in that one architecture may have 1 nonbool attribute and another
673f7cc78ecSespie      may have more.  Having this last means the non-architecture specific code
674f7cc78ecSespie      needn't care, now or tomorrow.  The goal is to eventually record
675f7cc78ecSespie      attributes in their raw form, evaluate them at run-time, and cache the
676f7cc78ecSespie      values, so this worry will go away anyway.  */
677f7cc78ecSespie #ifndef CGEN_OPERAND_NBOOL_ATTRS
678f7cc78ecSespie #define CGEN_OPERAND_NBOOL_ATTRS 1
679f7cc78ecSespie #endif
680f7cc78ecSespie   CGEN_ATTR_TYPE (CGEN_OPERAND_NBOOL_ATTRS) attrs;
681f7cc78ecSespie #define CGEN_OPERAND_ATTRS(operand) (&(operand)->attrs)
682f7cc78ecSespie } CGEN_OPERAND;
683f7cc78ecSespie 
684f7cc78ecSespie /* Return value of attribute ATTR in OPERAND.  */
685f7cc78ecSespie 
686f7cc78ecSespie #define CGEN_OPERAND_ATTR_VALUE(operand, attr) \
687f7cc78ecSespie CGEN_ATTR_VALUE ((operand), CGEN_OPERAND_ATTRS (operand), (attr))
688f7cc78ecSespie 
689f7cc78ecSespie /* Table of operands for selected mach/isa, computed at runtime.
690f7cc78ecSespie    enum cgen_operand_type is an index into this table (specifically
691f7cc78ecSespie    `entries').  */
692f7cc78ecSespie 
693f7cc78ecSespie typedef struct {
694f7cc78ecSespie   /* Pointer to null terminated table of all compiled in entries.  */
695f7cc78ecSespie   const CGEN_OPERAND *init_entries;
696f7cc78ecSespie   unsigned int entry_size; /* since the attribute member is variable sized */
697f7cc78ecSespie   /* Array of all entries, initial and run-time added.  */
698f7cc78ecSespie   const CGEN_OPERAND **entries;
699f7cc78ecSespie   /* Number of elements in `entries'.  */
700f7cc78ecSespie   unsigned int num_entries;
701f7cc78ecSespie   /* For now, xrealloc is called each time a new entry is added at runtime.
702f7cc78ecSespie      ??? May wish to keep track of some slop to reduce the number of calls to
703f7cc78ecSespie      xrealloc, except that there's unlikely to be many and not expected to be
704f7cc78ecSespie      in speed critical code.  */
705f7cc78ecSespie } CGEN_OPERAND_TABLE;
706f7cc78ecSespie 
707f7cc78ecSespie extern const CGEN_OPERAND * cgen_operand_lookup_by_name
708*cf2f2c56Smiod   (CGEN_CPU_DESC, const char *);
709f7cc78ecSespie extern const CGEN_OPERAND * cgen_operand_lookup_by_num
710*cf2f2c56Smiod   (CGEN_CPU_DESC, int);
711f7cc78ecSespie 
712f7cc78ecSespie /* Instruction operand instances.
713f7cc78ecSespie 
714f7cc78ecSespie    For each instruction, a list of the hardware elements that are read and
715f7cc78ecSespie    written are recorded.  */
716f7cc78ecSespie 
717f7cc78ecSespie /* The type of the instance.  */
718f7cc78ecSespie 
719f7cc78ecSespie enum cgen_opinst_type {
720f7cc78ecSespie   /* End of table marker.  */
721f7cc78ecSespie   CGEN_OPINST_END = 0,
722f7cc78ecSespie   CGEN_OPINST_INPUT, CGEN_OPINST_OUTPUT
723f7cc78ecSespie };
724f7cc78ecSespie 
725f7cc78ecSespie typedef struct
726f7cc78ecSespie {
727f7cc78ecSespie   /* Input or output indicator.  */
728f7cc78ecSespie   enum cgen_opinst_type type;
729f7cc78ecSespie 
730f7cc78ecSespie   /* Name of operand.  */
731f7cc78ecSespie   const char *name;
732f7cc78ecSespie 
733f7cc78ecSespie   /* The hardware element referenced.  */
734f7cc78ecSespie   enum cgen_hw_type hw_type;
735f7cc78ecSespie 
736f7cc78ecSespie   /* The mode in which the operand is being used.  */
737f7cc78ecSespie   enum cgen_mode mode;
738f7cc78ecSespie 
739f7cc78ecSespie   /* The operand table entry CGEN_OPERAND_NIL if there is none
740f7cc78ecSespie      (i.e. an explicit hardware reference).  */
741f7cc78ecSespie   enum cgen_operand_type op_type;
742f7cc78ecSespie 
743f7cc78ecSespie   /* If `operand' is "nil", the index (e.g. into array of registers).  */
744f7cc78ecSespie   int index;
745f7cc78ecSespie 
746f7cc78ecSespie   /* Attributes.
747f7cc78ecSespie      ??? This perhaps should be a real attribute struct but there's
748f7cc78ecSespie      no current need, so we save a bit of space and just have a set of
749f7cc78ecSespie      flags.  The interface is such that this can easily be made attributes
750f7cc78ecSespie      should it prove useful.  */
751f7cc78ecSespie   unsigned int attrs;
752f7cc78ecSespie #define CGEN_OPINST_ATTRS(opinst) ((opinst)->attrs)
753f7cc78ecSespie /* Return value of attribute ATTR in OPINST.  */
754f7cc78ecSespie #define CGEN_OPINST_ATTR(opinst, attr) \
755f7cc78ecSespie ((CGEN_OPINST_ATTRS (opinst) & (attr)) != 0)
756f7cc78ecSespie /* Operand is conditionally referenced (read/written).  */
757f7cc78ecSespie #define CGEN_OPINST_COND_REF 1
758f7cc78ecSespie } CGEN_OPINST;
759f7cc78ecSespie 
760f7cc78ecSespie /* Syntax string.
761f7cc78ecSespie 
762f7cc78ecSespie    Each insn format and subexpression has one of these.
763f7cc78ecSespie 
764f7cc78ecSespie    The syntax "string" consists of characters (n > 0 && n < 128), and operand
765f7cc78ecSespie    values (n >= 128), and is terminated by 0.  Operand values are 128 + index
766f7cc78ecSespie    into the operand table.  The operand table doesn't exist in C, per se, as
767f7cc78ecSespie    the data is recorded in the parse/insert/extract/print switch statements. */
768f7cc78ecSespie 
7695f210c2aSfgsch /* This should be at least as large as necessary for any target. */
770d2201f2fSdrahn #define CGEN_MAX_SYNTAX_ELEMENTS 48
7715f210c2aSfgsch 
7725f210c2aSfgsch /* A target may know its own precise maximum.  Assert that it falls below
7735f210c2aSfgsch    the above limit. */
774d2201f2fSdrahn #ifdef CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS
775d2201f2fSdrahn #if CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS > CGEN_MAX_SYNTAX_ELEMENTS
776d2201f2fSdrahn #error "CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS too high - enlarge CGEN_MAX_SYNTAX_ELEMENTS"
7775f210c2aSfgsch #endif
7785f210c2aSfgsch #endif
7795f210c2aSfgsch 
7805f210c2aSfgsch typedef unsigned short CGEN_SYNTAX_CHAR_TYPE;
781f7cc78ecSespie 
782f7cc78ecSespie typedef struct
783f7cc78ecSespie {
784d2201f2fSdrahn   CGEN_SYNTAX_CHAR_TYPE syntax[CGEN_MAX_SYNTAX_ELEMENTS];
785f7cc78ecSespie } CGEN_SYNTAX;
786f7cc78ecSespie 
787f7cc78ecSespie #define CGEN_SYNTAX_STRING(syn) (syn->syntax)
788f7cc78ecSespie #define CGEN_SYNTAX_CHAR_P(c) ((c) < 128)
7895f210c2aSfgsch #define CGEN_SYNTAX_CHAR(c) ((unsigned char)c)
790f7cc78ecSespie #define CGEN_SYNTAX_FIELD(c) ((c) - 128)
791f7cc78ecSespie #define CGEN_SYNTAX_MAKE_FIELD(c) ((c) + 128)
792f7cc78ecSespie 
793f7cc78ecSespie /* ??? I can't currently think of any case where the mnemonic doesn't come
794f7cc78ecSespie    first [and if one ever doesn't building the hash tables will be tricky].
795f7cc78ecSespie    However, we treat mnemonics as just another operand of the instruction.
796f7cc78ecSespie    A value of 1 means "this is where the mnemonic appears".  1 isn't
797f7cc78ecSespie    special other than it's a non-printable ASCII char.  */
798f7cc78ecSespie 
799f7cc78ecSespie #define CGEN_SYNTAX_MNEMONIC       1
800f7cc78ecSespie #define CGEN_SYNTAX_MNEMONIC_P(ch) ((ch) == CGEN_SYNTAX_MNEMONIC)
801f7cc78ecSespie 
802f7cc78ecSespie /* Instruction fields.
803f7cc78ecSespie 
804f7cc78ecSespie    ??? We currently don't allow adding fields at run-time.
805f7cc78ecSespie    Easy to fix when needed.  */
806f7cc78ecSespie 
807f7cc78ecSespie typedef struct cgen_ifld {
808f7cc78ecSespie   /* Enum of ifield.  */
809f7cc78ecSespie   int num;
810f7cc78ecSespie #define CGEN_IFLD_NUM(f) ((f)->num)
811f7cc78ecSespie 
812f7cc78ecSespie   /* Name of the field, distinguishes it from all other fields.  */
813f7cc78ecSespie   const char *name;
814f7cc78ecSespie #define CGEN_IFLD_NAME(f) ((f)->name)
815f7cc78ecSespie 
816f7cc78ecSespie   /* Default offset, in bits, from the start of the insn to the word
817f7cc78ecSespie      containing the field.  */
818f7cc78ecSespie   int word_offset;
819f7cc78ecSespie #define CGEN_IFLD_WORD_OFFSET(f) ((f)->word_offset)
820f7cc78ecSespie 
821f7cc78ecSespie   /* Default length of the word containing the field.  */
822f7cc78ecSespie   int word_size;
823f7cc78ecSespie #define CGEN_IFLD_WORD_SIZE(f) ((f)->word_size)
824f7cc78ecSespie 
825f7cc78ecSespie   /* Default starting bit number.
826f7cc78ecSespie      Whether lsb=0 or msb=0 is determined by CGEN_INSN_LSB0_P.  */
827f7cc78ecSespie   int start;
828f7cc78ecSespie #define CGEN_IFLD_START(f) ((f)->start)
829f7cc78ecSespie 
830f7cc78ecSespie   /* Length of the field, in bits.  */
831f7cc78ecSespie   int length;
832f7cc78ecSespie #define CGEN_IFLD_LENGTH(f) ((f)->length)
833f7cc78ecSespie 
834f7cc78ecSespie #ifndef CGEN_IFLD_NBOOL_ATTRS
835f7cc78ecSespie #define CGEN_IFLD_NBOOL_ATTRS 1
836f7cc78ecSespie #endif
837f7cc78ecSespie   CGEN_ATTR_TYPE (CGEN_IFLD_NBOOL_ATTRS) attrs;
838f7cc78ecSespie #define CGEN_IFLD_ATTRS(f) (&(f)->attrs)
839f7cc78ecSespie } CGEN_IFLD;
840f7cc78ecSespie 
841f7cc78ecSespie /* Return value of attribute ATTR in IFLD.  */
842f7cc78ecSespie #define CGEN_IFLD_ATTR_VALUE(ifld, attr) \
843f7cc78ecSespie CGEN_ATTR_VALUE ((ifld), CGEN_IFLD_ATTRS (ifld), (attr))
844f7cc78ecSespie 
845f7cc78ecSespie /* Instruction data.  */
846f7cc78ecSespie 
847f7cc78ecSespie /* Instruction formats.
848f7cc78ecSespie 
849f7cc78ecSespie    Instructions are grouped by format.  Associated with an instruction is its
850f7cc78ecSespie    format.  Each insn's opcode table entry contains a format table entry.
851f7cc78ecSespie    ??? There is usually very few formats compared with the number of insns,
852f7cc78ecSespie    so one can reduce the size of the opcode table by recording the format table
853f7cc78ecSespie    as a separate entity.  Given that we currently don't, format table entries
854f7cc78ecSespie    are also distinguished by their operands.  This increases the size of the
855f7cc78ecSespie    table, but reduces the number of tables.  It's all minutiae anyway so it
856f7cc78ecSespie    doesn't really matter [at this point in time].
857f7cc78ecSespie 
858f7cc78ecSespie    ??? Support for variable length ISA's is wip.  */
859f7cc78ecSespie 
860f7cc78ecSespie /* Accompanying each iformat description is a list of its fields.  */
861f7cc78ecSespie 
862f7cc78ecSespie typedef struct {
863f7cc78ecSespie   const CGEN_IFLD *ifld;
864f7cc78ecSespie #define CGEN_IFMT_IFLD_IFLD(ii) ((ii)->ifld)
865f7cc78ecSespie } CGEN_IFMT_IFLD;
866f7cc78ecSespie 
8675f210c2aSfgsch /* This should be at least as large as necessary for any target. */
8685f210c2aSfgsch #define CGEN_MAX_IFMT_OPERANDS 16
8695f210c2aSfgsch 
8705f210c2aSfgsch /* A target may know its own precise maximum.  Assert that it falls below
8715f210c2aSfgsch    the above limit. */
8725f210c2aSfgsch #ifdef CGEN_ACTUAL_MAX_IFMT_OPERANDS
8735f210c2aSfgsch #if CGEN_ACTUAL_MAX_IFMT_OPERANDS > CGEN_MAX_IFMT_OPERANDS
8745f210c2aSfgsch #error "CGEN_ACTUAL_MAX_IFMT_OPERANDS too high - enlarge CGEN_MAX_IFMT_OPERANDS"
875f7cc78ecSespie #endif
8765f210c2aSfgsch #endif
8775f210c2aSfgsch 
878f7cc78ecSespie 
879f7cc78ecSespie typedef struct
880f7cc78ecSespie {
881f7cc78ecSespie   /* Length that MASK and VALUE have been calculated to
882f7cc78ecSespie      [VALUE is recorded elsewhere].
883f7cc78ecSespie      Normally it is base_insn_bitsize.  On [V]LIW architectures where the base
884f7cc78ecSespie      insn size may be larger than the size of an insn, this field is less than
885f7cc78ecSespie      base_insn_bitsize.  */
886f7cc78ecSespie   unsigned char mask_length;
887f7cc78ecSespie #define CGEN_IFMT_MASK_LENGTH(ifmt) ((ifmt)->mask_length)
888f7cc78ecSespie 
889f7cc78ecSespie   /* Total length of instruction, in bits.  */
890f7cc78ecSespie   unsigned char length;
891f7cc78ecSespie #define CGEN_IFMT_LENGTH(ifmt) ((ifmt)->length)
892f7cc78ecSespie 
893f7cc78ecSespie   /* Mask to apply to the first MASK_LENGTH bits.
894f7cc78ecSespie      Each insn's value is stored with the insn.
895f7cc78ecSespie      The first step in recognizing an insn for disassembly is
896f7cc78ecSespie      (opcode & mask) == value.  */
897f7cc78ecSespie   CGEN_INSN_INT mask;
898f7cc78ecSespie #define CGEN_IFMT_MASK(ifmt) ((ifmt)->mask)
899f7cc78ecSespie 
900f7cc78ecSespie   /* Instruction fields.
901f7cc78ecSespie      +1 for trailing NULL.  */
902f7cc78ecSespie   CGEN_IFMT_IFLD iflds[CGEN_MAX_IFMT_OPERANDS + 1];
903f7cc78ecSespie #define CGEN_IFMT_IFLDS(ifmt) ((ifmt)->iflds)
904f7cc78ecSespie } CGEN_IFMT;
905f7cc78ecSespie 
906f7cc78ecSespie /* Instruction values.  */
907f7cc78ecSespie 
908f7cc78ecSespie typedef struct
909f7cc78ecSespie {
910f7cc78ecSespie   /* The opcode portion of the base insn.  */
911f7cc78ecSespie   CGEN_INSN_INT base_value;
912f7cc78ecSespie 
913f7cc78ecSespie #ifdef CGEN_MAX_EXTRA_OPCODE_OPERANDS
914f7cc78ecSespie   /* Extra opcode values beyond base_value.  */
915f7cc78ecSespie   unsigned long ifield_values[CGEN_MAX_EXTRA_OPCODE_OPERANDS];
916f7cc78ecSespie #endif
917f7cc78ecSespie } CGEN_IVALUE;
918f7cc78ecSespie 
919f7cc78ecSespie /* Instruction opcode table.
920f7cc78ecSespie    This contains the syntax and format data of an instruction.  */
921f7cc78ecSespie 
922f7cc78ecSespie /* ??? Some ports already have an opcode table yet still need to use the rest
923f7cc78ecSespie    of what cgen_insn has.  Plus keeping the opcode data with the operand
924f7cc78ecSespie    instance data can create a pretty big file.  So we keep them separately.
925f7cc78ecSespie    Not sure this is a good idea in the long run.  */
926f7cc78ecSespie 
927f7cc78ecSespie typedef struct
928f7cc78ecSespie {
929f7cc78ecSespie   /* Indices into parse/insert/extract/print handler tables.  */
930f7cc78ecSespie   struct cgen_opcode_handler handlers;
931f7cc78ecSespie #define CGEN_OPCODE_HANDLERS(opc) (& (opc)->handlers)
932f7cc78ecSespie 
933f7cc78ecSespie   /* Syntax string.  */
934f7cc78ecSespie   CGEN_SYNTAX syntax;
935f7cc78ecSespie #define CGEN_OPCODE_SYNTAX(opc) (& (opc)->syntax)
936f7cc78ecSespie 
937f7cc78ecSespie   /* Format entry.  */
938f7cc78ecSespie   const CGEN_IFMT *format;
939f7cc78ecSespie #define CGEN_OPCODE_FORMAT(opc) ((opc)->format)
940f7cc78ecSespie #define CGEN_OPCODE_MASK_BITSIZE(opc) CGEN_IFMT_MASK_LENGTH (CGEN_OPCODE_FORMAT (opc))
941f7cc78ecSespie #define CGEN_OPCODE_BITSIZE(opc) CGEN_IFMT_LENGTH (CGEN_OPCODE_FORMAT (opc))
942f7cc78ecSespie #define CGEN_OPCODE_IFLDS(opc) CGEN_IFMT_IFLDS (CGEN_OPCODE_FORMAT (opc))
943f7cc78ecSespie 
944f7cc78ecSespie   /* Instruction opcode value.  */
945f7cc78ecSespie   CGEN_IVALUE value;
946f7cc78ecSespie #define CGEN_OPCODE_VALUE(opc) (& (opc)->value)
947f7cc78ecSespie #define CGEN_OPCODE_BASE_VALUE(opc) (CGEN_OPCODE_VALUE (opc)->base_value)
948f7cc78ecSespie #define CGEN_OPCODE_BASE_MASK(opc) CGEN_IFMT_MASK (CGEN_OPCODE_FORMAT (opc))
949f7cc78ecSespie } CGEN_OPCODE;
950f7cc78ecSespie 
951f7cc78ecSespie /* Instruction attributes.
952f7cc78ecSespie    This is made a published type as applications can cache a pointer to
953f7cc78ecSespie    the attributes for speed.  */
954f7cc78ecSespie 
955f7cc78ecSespie #ifndef CGEN_INSN_NBOOL_ATTRS
956f7cc78ecSespie #define CGEN_INSN_NBOOL_ATTRS 1
957f7cc78ecSespie #endif
958f7cc78ecSespie typedef CGEN_ATTR_TYPE (CGEN_INSN_NBOOL_ATTRS) CGEN_INSN_ATTR_TYPE;
959f7cc78ecSespie 
960f7cc78ecSespie /* Enum of architecture independent attributes.  */
961f7cc78ecSespie 
962f7cc78ecSespie #ifndef CGEN_ARCH
963f7cc78ecSespie /* ??? Numbers here are recorded in two places.  */
964f7cc78ecSespie typedef enum cgen_insn_attr {
965f7cc78ecSespie   CGEN_INSN_ALIAS = 0
966f7cc78ecSespie } CGEN_INSN_ATTR;
967f7cc78ecSespie #endif
968f7cc78ecSespie 
969f7cc78ecSespie /* This struct defines each entry in the instruction table.  */
970f7cc78ecSespie 
971f7cc78ecSespie typedef struct
972f7cc78ecSespie {
973f7cc78ecSespie   /* Each real instruction is enumerated.  */
974f7cc78ecSespie   /* ??? This may go away in time.  */
975f7cc78ecSespie   int num;
976f7cc78ecSespie #define CGEN_INSN_NUM(insn) ((insn)->base->num)
977f7cc78ecSespie 
978f7cc78ecSespie   /* Name of entry (that distinguishes it from all other entries).  */
979f7cc78ecSespie   /* ??? If mnemonics have operands, try to print full mnemonic.  */
980f7cc78ecSespie   const char *name;
981f7cc78ecSespie #define CGEN_INSN_NAME(insn) ((insn)->base->name)
982f7cc78ecSespie 
983f7cc78ecSespie   /* Mnemonic.  This is used when parsing and printing the insn.
984f7cc78ecSespie      In the case of insns that have operands on the mnemonics, this is
985f7cc78ecSespie      only the constant part.  E.g. for conditional execution of an `add' insn,
986f7cc78ecSespie      where the full mnemonic is addeq, addne, etc., and the condition is
987f7cc78ecSespie      treated as an operand, this is only "add".  */
988f7cc78ecSespie   const char *mnemonic;
989f7cc78ecSespie #define CGEN_INSN_MNEMONIC(insn) ((insn)->base->mnemonic)
990f7cc78ecSespie 
991f7cc78ecSespie   /* Total length of instruction, in bits.  */
992f7cc78ecSespie   int bitsize;
993f7cc78ecSespie #define CGEN_INSN_BITSIZE(insn) ((insn)->base->bitsize)
994f7cc78ecSespie 
995f7cc78ecSespie #if 0 /* ??? Disabled for now as there is a problem with embedded newlines
996f7cc78ecSespie 	 and the table is already pretty big.  Should perhaps be moved
997f7cc78ecSespie 	 to a file of its own.  */
998f7cc78ecSespie   /* Semantics, as RTL.  */
999f7cc78ecSespie   /* ??? Plain text or bytecodes?  */
1000f7cc78ecSespie   /* ??? Note that the operand instance table could be computed at run-time
1001f7cc78ecSespie      if we parse this and cache the results.  Something to eventually do.  */
1002f7cc78ecSespie   const char *rtx;
1003f7cc78ecSespie #define CGEN_INSN_RTX(insn) ((insn)->base->rtx)
1004f7cc78ecSespie #endif
1005f7cc78ecSespie 
1006f7cc78ecSespie   /* Attributes.
1007f7cc78ecSespie      This must appear last.  It is a variable sized array in that one
1008f7cc78ecSespie      architecture may have 1 nonbool attribute and another may have more.
1009f7cc78ecSespie      Having this last means the non-architecture specific code needn't
1010f7cc78ecSespie      care.  The goal is to eventually record attributes in their raw form,
1011f7cc78ecSespie      evaluate them at run-time, and cache the values, so this worry will go
1012f7cc78ecSespie      away anyway.  */
1013f7cc78ecSespie   CGEN_INSN_ATTR_TYPE attrs;
1014f7cc78ecSespie #define CGEN_INSN_ATTRS(insn) (&(insn)->base->attrs)
1015f7cc78ecSespie /* Return value of attribute ATTR in INSN.  */
1016f7cc78ecSespie #define CGEN_INSN_ATTR_VALUE(insn, attr) \
1017f7cc78ecSespie CGEN_ATTR_VALUE ((insn), CGEN_INSN_ATTRS (insn), (attr))
1018f7cc78ecSespie } CGEN_IBASE;
1019f7cc78ecSespie 
1020f7cc78ecSespie /* Return non-zero if INSN is the "invalid" insn marker.  */
1021f7cc78ecSespie 
1022f7cc78ecSespie #define CGEN_INSN_INVALID_P(insn) (CGEN_INSN_MNEMONIC (insn) == 0)
1023f7cc78ecSespie 
1024f7cc78ecSespie /* Main struct contain instruction information.
1025f7cc78ecSespie    BASE is always present, the rest is present only if asked for.  */
1026f7cc78ecSespie 
1027f7cc78ecSespie struct cgen_insn
1028f7cc78ecSespie {
1029f7cc78ecSespie   /* ??? May be of use to put a type indicator here.
1030f7cc78ecSespie      Then this struct could different info for different classes of insns.  */
1031f7cc78ecSespie   /* ??? A speedup can be had by moving `base' into this struct.
1032f7cc78ecSespie      Maybe later.  */
1033f7cc78ecSespie   const CGEN_IBASE *base;
1034f7cc78ecSespie   const CGEN_OPCODE *opcode;
1035f7cc78ecSespie   const CGEN_OPINST *opinst;
1036d2201f2fSdrahn 
1037d2201f2fSdrahn   /* Regex to disambiguate overloaded opcodes */
1038d2201f2fSdrahn   void *rx;
1039d2201f2fSdrahn #define CGEN_INSN_RX(insn) ((insn)->rx)
1040d2201f2fSdrahn #define CGEN_MAX_RX_ELEMENTS (CGEN_MAX_SYNTAX_ELEMENTS * 5)
1041f7cc78ecSespie };
1042f7cc78ecSespie 
1043f7cc78ecSespie /* Instruction lists.
1044f7cc78ecSespie    This is used for adding new entries and for creating the hash lists.  */
1045f7cc78ecSespie 
1046f7cc78ecSespie typedef struct cgen_insn_list
1047f7cc78ecSespie {
1048f7cc78ecSespie   struct cgen_insn_list *next;
1049f7cc78ecSespie   const CGEN_INSN *insn;
1050f7cc78ecSespie } CGEN_INSN_LIST;
1051f7cc78ecSespie 
1052f7cc78ecSespie /* Table of instructions.  */
1053f7cc78ecSespie 
1054f7cc78ecSespie typedef struct
1055f7cc78ecSespie {
1056f7cc78ecSespie   const CGEN_INSN *init_entries;
1057f7cc78ecSespie   unsigned int entry_size; /* since the attribute member is variable sized */
1058f7cc78ecSespie   unsigned int num_init_entries;
1059f7cc78ecSespie   CGEN_INSN_LIST *new_entries;
1060f7cc78ecSespie } CGEN_INSN_TABLE;
1061f7cc78ecSespie 
1062f7cc78ecSespie /* Return number of instructions.  This includes any added at run-time.  */
1063f7cc78ecSespie 
1064*cf2f2c56Smiod extern int cgen_insn_count (CGEN_CPU_DESC);
1065*cf2f2c56Smiod extern int cgen_macro_insn_count (CGEN_CPU_DESC);
1066f7cc78ecSespie 
1067f7cc78ecSespie /* Macros to access the other insn elements not recorded in CGEN_IBASE.  */
1068f7cc78ecSespie 
1069f7cc78ecSespie /* Fetch INSN's operand instance table.  */
1070f7cc78ecSespie /* ??? Doesn't handle insns added at runtime.  */
1071f7cc78ecSespie #define CGEN_INSN_OPERANDS(insn) ((insn)->opinst)
1072f7cc78ecSespie 
1073f7cc78ecSespie /* Return INSN's opcode table entry.  */
1074f7cc78ecSespie #define CGEN_INSN_OPCODE(insn) ((insn)->opcode)
1075f7cc78ecSespie 
1076f7cc78ecSespie /* Return INSN's handler data.  */
1077f7cc78ecSespie #define CGEN_INSN_HANDLERS(insn) CGEN_OPCODE_HANDLERS (CGEN_INSN_OPCODE (insn))
1078f7cc78ecSespie 
1079f7cc78ecSespie /* Return INSN's syntax.  */
1080f7cc78ecSespie #define CGEN_INSN_SYNTAX(insn) CGEN_OPCODE_SYNTAX (CGEN_INSN_OPCODE (insn))
1081f7cc78ecSespie 
1082f7cc78ecSespie /* Return size of base mask in bits.  */
1083f7cc78ecSespie #define CGEN_INSN_MASK_BITSIZE(insn) \
1084f7cc78ecSespie   CGEN_OPCODE_MASK_BITSIZE (CGEN_INSN_OPCODE (insn))
1085f7cc78ecSespie 
1086f7cc78ecSespie /* Return mask of base part of INSN.  */
1087f7cc78ecSespie #define CGEN_INSN_BASE_MASK(insn) \
1088f7cc78ecSespie   CGEN_OPCODE_BASE_MASK (CGEN_INSN_OPCODE (insn))
1089f7cc78ecSespie 
1090f7cc78ecSespie /* Return value of base part of INSN.  */
1091f7cc78ecSespie #define CGEN_INSN_BASE_VALUE(insn) \
1092f7cc78ecSespie   CGEN_OPCODE_BASE_VALUE (CGEN_INSN_OPCODE (insn))
1093f7cc78ecSespie 
1094f7cc78ecSespie /* Standard way to test whether INSN is supported by MACH.
1095f7cc78ecSespie    MACH is one of enum mach_attr.
1096f7cc78ecSespie    The "|1" is because the base mach is always selected.  */
1097f7cc78ecSespie #define CGEN_INSN_MACH_HAS_P(insn, mach) \
1098f7cc78ecSespie ((CGEN_INSN_ATTR_VALUE ((insn), CGEN_INSN_MACH) & ((1 << (mach)) | 1)) != 0)
1099f7cc78ecSespie 
1100f7cc78ecSespie /* Macro instructions.
1101f7cc78ecSespie    Macro insns aren't real insns, they map to one or more real insns.
1102f7cc78ecSespie    E.g. An architecture's "nop" insn may actually be an "mv r0,r0" or
1103f7cc78ecSespie    some such.
1104f7cc78ecSespie 
1105f7cc78ecSespie    Macro insns can expand to nothing (e.g. a nop that is optimized away).
1106f7cc78ecSespie    This is useful in multi-insn macros that build a constant in a register.
1107f7cc78ecSespie    Of course this isn't the default behaviour and must be explicitly enabled.
1108f7cc78ecSespie 
1109f7cc78ecSespie    Assembly of macro-insns is relatively straightforward.  Disassembly isn't.
1110f7cc78ecSespie    However, disassembly of at least some kinds of macro insns is important
1111f7cc78ecSespie    in order that the disassembled code preserve the readability of the original
1112f7cc78ecSespie    insn.  What is attempted here is to disassemble all "simple" macro-insns,
1113f7cc78ecSespie    where "simple" is currently defined to mean "expands to one real insn".
1114f7cc78ecSespie 
1115f7cc78ecSespie    Simple macro-insns are handled specially.  They are emitted as ALIAS's
1116f7cc78ecSespie    of real insns.  This simplifies their handling since there's usually more
1117f7cc78ecSespie    of them than any other kind of macro-insn, and proper disassembly of them
1118f7cc78ecSespie    falls out for free.  */
1119f7cc78ecSespie 
1120f7cc78ecSespie /* For each macro-insn there may be multiple expansion possibilities,
1121f7cc78ecSespie    depending on the arguments.  This structure is accessed via the `data'
1122f7cc78ecSespie    member of CGEN_INSN.  */
1123f7cc78ecSespie 
1124f7cc78ecSespie typedef struct cgen_minsn_expansion {
1125f7cc78ecSespie   /* Function to do the expansion.
1126f7cc78ecSespie      If the expansion fails (e.g. "no match") NULL is returned.
1127f7cc78ecSespie      Space for the expansion is obtained with malloc.
1128f7cc78ecSespie      It is up to the caller to free it.  */
1129*cf2f2c56Smiod   const char * (* fn)
1130*cf2f2c56Smiod      (const struct cgen_minsn_expansion *,
1131f7cc78ecSespie       const char *, const char **, int *,
1132*cf2f2c56Smiod       CGEN_OPERAND **);
1133f7cc78ecSespie #define CGEN_MIEXPN_FN(ex) ((ex)->fn)
1134f7cc78ecSespie 
1135f7cc78ecSespie   /* Instruction(s) the macro expands to.
1136f7cc78ecSespie      The format of STR is defined by FN.
1137f7cc78ecSespie      It is typically the assembly code of the real insn, but it could also be
1138f7cc78ecSespie      the original Scheme expression or a tokenized form of it (with FN being
1139f7cc78ecSespie      an appropriate interpreter).  */
1140f7cc78ecSespie   const char * str;
1141f7cc78ecSespie #define CGEN_MIEXPN_STR(ex) ((ex)->str)
1142f7cc78ecSespie } CGEN_MINSN_EXPANSION;
1143f7cc78ecSespie 
1144f7cc78ecSespie /* Normal expander.
1145f7cc78ecSespie    When supported, this function will convert the input string to another
1146f7cc78ecSespie    string and the parser will be invoked recursively.  The output string
1147f7cc78ecSespie    may contain further macro invocations.  */
1148f7cc78ecSespie 
1149f7cc78ecSespie extern const char * cgen_expand_macro_insn
1150*cf2f2c56Smiod   (CGEN_CPU_DESC, const struct cgen_minsn_expansion *,
1151*cf2f2c56Smiod    const char *, const char **, int *, CGEN_OPERAND **);
1152f7cc78ecSespie 
1153f7cc78ecSespie /* The assembler insn table is hashed based on some function of the mnemonic
1154f7cc78ecSespie    (the actually hashing done is up to the target, but we provide a few
1155f7cc78ecSespie    examples like the first letter or a function of the entire mnemonic).  */
1156f7cc78ecSespie 
1157f7cc78ecSespie extern CGEN_INSN_LIST * cgen_asm_lookup_insn
1158*cf2f2c56Smiod   (CGEN_CPU_DESC, const char *);
1159f7cc78ecSespie #define CGEN_ASM_LOOKUP_INSN(cd, string) cgen_asm_lookup_insn ((cd), (string))
1160f7cc78ecSespie #define CGEN_ASM_NEXT_INSN(insn) ((insn)->next)
1161f7cc78ecSespie 
1162f7cc78ecSespie /* The disassembler insn table is hashed based on some function of machine
1163f7cc78ecSespie    instruction (the actually hashing done is up to the target).  */
1164f7cc78ecSespie 
1165f7cc78ecSespie extern CGEN_INSN_LIST * cgen_dis_lookup_insn
1166*cf2f2c56Smiod   (CGEN_CPU_DESC, const char *, CGEN_INSN_INT);
1167f7cc78ecSespie /* FIXME: delete these two */
1168f7cc78ecSespie #define CGEN_DIS_LOOKUP_INSN(cd, buf, value) cgen_dis_lookup_insn ((cd), (buf), (value))
1169f7cc78ecSespie #define CGEN_DIS_NEXT_INSN(insn) ((insn)->next)
1170f7cc78ecSespie 
1171f7cc78ecSespie /* The CPU description.
1172f7cc78ecSespie    A copy of this is created when the cpu table is "opened".
1173f7cc78ecSespie    All global state information is recorded here.
1174f7cc78ecSespie    Access macros are provided for "public" members.  */
1175f7cc78ecSespie 
1176f7cc78ecSespie typedef struct cgen_cpu_desc
1177f7cc78ecSespie {
1178f7cc78ecSespie   /* Bitmap of selected machine(s) (a la BFD machine number).  */
1179f7cc78ecSespie   int machs;
1180f7cc78ecSespie 
1181f7cc78ecSespie   /* Bitmap of selected isa(s).
1182f7cc78ecSespie      ??? Simultaneous multiple isas might not make sense, but it's not (yet)
1183f7cc78ecSespie      precluded.  */
1184f7cc78ecSespie   int isas;
1185f7cc78ecSespie 
1186f7cc78ecSespie   /* Current endian.  */
1187f7cc78ecSespie   enum cgen_endian endian;
1188f7cc78ecSespie #define CGEN_CPU_ENDIAN(cd) ((cd)->endian)
1189f7cc78ecSespie 
1190f7cc78ecSespie   /* Current insn endian.  */
1191f7cc78ecSespie   enum cgen_endian insn_endian;
1192f7cc78ecSespie #define CGEN_CPU_INSN_ENDIAN(cd) ((cd)->insn_endian)
1193f7cc78ecSespie 
1194f7cc78ecSespie   /* Word size (in bits).  */
1195f7cc78ecSespie   /* ??? Or maybe maximum word size - might we ever need to allow a cpu table
1196f7cc78ecSespie      to be opened for both sparc32/sparc64?
1197f7cc78ecSespie      ??? Another alternative is to create a table of selected machs and
1198f7cc78ecSespie      lazily fetch the data from there.  */
1199f7cc78ecSespie   unsigned int word_bitsize;
1200f7cc78ecSespie 
1201d2201f2fSdrahn   /* Instruction chunk size (in bits), for purposes of endianness
1202d2201f2fSdrahn      conversion.  */
1203d2201f2fSdrahn   unsigned int insn_chunk_bitsize;
1204d2201f2fSdrahn 
1205f7cc78ecSespie   /* Indicator if sizes are unknown.
1206f7cc78ecSespie      This is used by default_insn_bitsize,base_insn_bitsize if there is a
1207f7cc78ecSespie      difference between the selected isa's.  */
1208f7cc78ecSespie #define CGEN_SIZE_UNKNOWN 65535
1209f7cc78ecSespie 
1210f7cc78ecSespie   /* Default instruction size (in bits).
1211f7cc78ecSespie      This is used by the assembler when it encounters an unknown insn.  */
1212f7cc78ecSespie   unsigned int default_insn_bitsize;
1213f7cc78ecSespie 
1214f7cc78ecSespie   /* Base instruction size (in bits).
1215f7cc78ecSespie      For non-LIW cpus this is generally the length of the smallest insn.
1216f7cc78ecSespie      For LIW cpus its wip (work-in-progress).  For the m32r its 32.  */
1217f7cc78ecSespie   unsigned int base_insn_bitsize;
1218f7cc78ecSespie 
1219f7cc78ecSespie   /* Minimum/maximum instruction size (in bits).  */
1220f7cc78ecSespie   unsigned int min_insn_bitsize;
1221f7cc78ecSespie   unsigned int max_insn_bitsize;
1222f7cc78ecSespie 
1223f7cc78ecSespie   /* Instruction set variants.  */
1224f7cc78ecSespie   const CGEN_ISA *isa_table;
1225f7cc78ecSespie 
1226f7cc78ecSespie   /* Machine variants.  */
1227f7cc78ecSespie   const CGEN_MACH *mach_table;
1228f7cc78ecSespie 
1229f7cc78ecSespie   /* Hardware elements.  */
1230f7cc78ecSespie   CGEN_HW_TABLE hw_table;
1231f7cc78ecSespie 
1232f7cc78ecSespie   /* Instruction fields.  */
1233f7cc78ecSespie   const CGEN_IFLD *ifld_table;
1234f7cc78ecSespie 
1235f7cc78ecSespie   /* Operands.  */
1236f7cc78ecSespie   CGEN_OPERAND_TABLE operand_table;
1237f7cc78ecSespie 
1238f7cc78ecSespie   /* Main instruction table.  */
1239f7cc78ecSespie   CGEN_INSN_TABLE insn_table;
1240f7cc78ecSespie #define CGEN_CPU_INSN_TABLE(cd) (& (cd)->insn_table)
1241f7cc78ecSespie 
1242f7cc78ecSespie   /* Macro instructions are defined separately and are combined with real
1243f7cc78ecSespie      insns during hash table computation.  */
1244f7cc78ecSespie   CGEN_INSN_TABLE macro_insn_table;
1245f7cc78ecSespie 
1246f7cc78ecSespie   /* Copy of CGEN_INT_INSN_P.  */
1247f7cc78ecSespie   int int_insn_p;
1248f7cc78ecSespie 
1249f7cc78ecSespie   /* Called to rebuild the tables after something has changed.  */
1250*cf2f2c56Smiod   void (*rebuild_tables) (CGEN_CPU_DESC);
1251f7cc78ecSespie 
1252f7cc78ecSespie   /* Operand parser callback.  */
1253f7cc78ecSespie   cgen_parse_operand_fn * parse_operand_fn;
1254f7cc78ecSespie 
1255f7cc78ecSespie   /* Parse/insert/extract/print cover fns for operands.  */
1256f7cc78ecSespie   const char * (*parse_operand)
1257*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, const char **, CGEN_FIELDS *fields_);
1258d2201f2fSdrahn #ifdef __BFD_H_SEEN__
1259f7cc78ecSespie   const char * (*insert_operand)
1260*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_,
1261*cf2f2c56Smiod      CGEN_INSN_BYTES_PTR, bfd_vma pc_);
1262f7cc78ecSespie   int (*extract_operand)
1263*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
1264*cf2f2c56Smiod      CGEN_FIELDS *fields_, bfd_vma pc_);
1265f7cc78ecSespie   void (*print_operand)
1266*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, void * info_, CGEN_FIELDS * fields_,
1267*cf2f2c56Smiod      void const *attrs_, bfd_vma pc_, int length_);
1268f7cc78ecSespie #else
1269f7cc78ecSespie   const char * (*insert_operand) ();
1270f7cc78ecSespie   int (*extract_operand) ();
1271f7cc78ecSespie   void (*print_operand) ();
1272f7cc78ecSespie #endif
1273f7cc78ecSespie #define CGEN_CPU_PARSE_OPERAND(cd) ((cd)->parse_operand)
1274f7cc78ecSespie #define CGEN_CPU_INSERT_OPERAND(cd) ((cd)->insert_operand)
1275f7cc78ecSespie #define CGEN_CPU_EXTRACT_OPERAND(cd) ((cd)->extract_operand)
1276f7cc78ecSespie #define CGEN_CPU_PRINT_OPERAND(cd) ((cd)->print_operand)
1277f7cc78ecSespie 
1278f7cc78ecSespie   /* Size of CGEN_FIELDS struct.  */
1279f7cc78ecSespie   unsigned int sizeof_fields;
1280f7cc78ecSespie #define CGEN_CPU_SIZEOF_FIELDS(cd) ((cd)->sizeof_fields)
1281f7cc78ecSespie 
1282f7cc78ecSespie   /* Set the bitsize field.  */
1283*cf2f2c56Smiod   void (*set_fields_bitsize) (CGEN_FIELDS *fields_, int size_);
1284f7cc78ecSespie #define CGEN_CPU_SET_FIELDS_BITSIZE(cd) ((cd)->set_fields_bitsize)
1285f7cc78ecSespie 
1286f7cc78ecSespie   /* CGEN_FIELDS accessors.  */
1287f7cc78ecSespie   int (*get_int_operand)
1288*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, const CGEN_FIELDS *fields_);
1289f7cc78ecSespie   void (*set_int_operand)
1290*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_, int value_);
1291d2201f2fSdrahn #ifdef __BFD_H_SEEN__
1292f7cc78ecSespie   bfd_vma (*get_vma_operand)
1293*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, const CGEN_FIELDS *fields_);
1294f7cc78ecSespie   void (*set_vma_operand)
1295*cf2f2c56Smiod     (CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_, bfd_vma value_);
1296f7cc78ecSespie #else
1297f7cc78ecSespie   long (*get_vma_operand) ();
1298f7cc78ecSespie   void (*set_vma_operand) ();
1299f7cc78ecSespie #endif
1300f7cc78ecSespie #define CGEN_CPU_GET_INT_OPERAND(cd) ((cd)->get_int_operand)
1301f7cc78ecSespie #define CGEN_CPU_SET_INT_OPERAND(cd) ((cd)->set_int_operand)
1302f7cc78ecSespie #define CGEN_CPU_GET_VMA_OPERAND(cd) ((cd)->get_vma_operand)
1303f7cc78ecSespie #define CGEN_CPU_SET_VMA_OPERAND(cd) ((cd)->set_vma_operand)
1304f7cc78ecSespie 
1305f7cc78ecSespie   /* Instruction parse/insert/extract/print handlers.  */
1306f7cc78ecSespie   /* FIXME: make these types uppercase.  */
1307f7cc78ecSespie   cgen_parse_fn * const *parse_handlers;
1308f7cc78ecSespie   cgen_insert_fn * const *insert_handlers;
1309f7cc78ecSespie   cgen_extract_fn * const *extract_handlers;
1310f7cc78ecSespie   cgen_print_fn * const *print_handlers;
1311f7cc78ecSespie #define CGEN_PARSE_FN(cd, insn)   (cd->parse_handlers[(insn)->opcode->handlers.parse])
1312f7cc78ecSespie #define CGEN_INSERT_FN(cd, insn)  (cd->insert_handlers[(insn)->opcode->handlers.insert])
1313f7cc78ecSespie #define CGEN_EXTRACT_FN(cd, insn) (cd->extract_handlers[(insn)->opcode->handlers.extract])
1314f7cc78ecSespie #define CGEN_PRINT_FN(cd, insn)   (cd->print_handlers[(insn)->opcode->handlers.print])
1315f7cc78ecSespie 
1316f7cc78ecSespie   /* Return non-zero if insn should be added to hash table.  */
1317*cf2f2c56Smiod   int (* asm_hash_p) (const CGEN_INSN *);
1318f7cc78ecSespie 
1319f7cc78ecSespie   /* Assembler hash function.  */
1320*cf2f2c56Smiod   unsigned int (* asm_hash) (const char *);
1321f7cc78ecSespie 
1322f7cc78ecSespie   /* Number of entries in assembler hash table.  */
1323f7cc78ecSespie   unsigned int asm_hash_size;
1324f7cc78ecSespie 
1325f7cc78ecSespie   /* Return non-zero if insn should be added to hash table.  */
1326*cf2f2c56Smiod   int (* dis_hash_p) (const CGEN_INSN *);
1327f7cc78ecSespie 
1328f7cc78ecSespie   /* Disassembler hash function.  */
1329*cf2f2c56Smiod   unsigned int (* dis_hash) (const char *, CGEN_INSN_INT);
1330f7cc78ecSespie 
1331f7cc78ecSespie   /* Number of entries in disassembler hash table.  */
1332f7cc78ecSespie   unsigned int dis_hash_size;
1333f7cc78ecSespie 
1334f7cc78ecSespie   /* Assembler instruction hash table.  */
1335f7cc78ecSespie   CGEN_INSN_LIST **asm_hash_table;
1336f7cc78ecSespie   CGEN_INSN_LIST *asm_hash_table_entries;
1337f7cc78ecSespie 
1338f7cc78ecSespie   /* Disassembler instruction hash table.  */
1339f7cc78ecSespie   CGEN_INSN_LIST **dis_hash_table;
1340f7cc78ecSespie   CGEN_INSN_LIST *dis_hash_table_entries;
1341f7cc78ecSespie 
1342f7cc78ecSespie   /* This field could be turned into a bitfield if room for other flags is needed.  */
1343f7cc78ecSespie   unsigned int signed_overflow_ok_p;
1344f7cc78ecSespie 
1345f7cc78ecSespie } CGEN_CPU_TABLE;
1346f7cc78ecSespie 
1347f7cc78ecSespie /* wip */
1348f7cc78ecSespie #ifndef CGEN_WORD_ENDIAN
1349f7cc78ecSespie #define CGEN_WORD_ENDIAN(cd) CGEN_CPU_ENDIAN (cd)
1350f7cc78ecSespie #endif
1351f7cc78ecSespie #ifndef CGEN_INSN_WORD_ENDIAN
1352f7cc78ecSespie #define CGEN_INSN_WORD_ENDIAN(cd) CGEN_CPU_INSN_ENDIAN (cd)
1353f7cc78ecSespie #endif
1354f7cc78ecSespie 
1355f7cc78ecSespie /* Prototypes of major functions.  */
1356f7cc78ecSespie /* FIXME: Move more CGEN_SYM-defined functions into CGEN_CPU_DESC.
1357f7cc78ecSespie    Not the init fns though, as that would drag in things that mightn't be
1358f7cc78ecSespie    used and might not even exist.  */
1359f7cc78ecSespie 
1360f7cc78ecSespie /* Argument types to cpu_open.  */
1361f7cc78ecSespie 
1362f7cc78ecSespie enum cgen_cpu_open_arg {
1363f7cc78ecSespie   CGEN_CPU_OPEN_END,
1364f7cc78ecSespie   /* Select instruction set(s), arg is bitmap or 0 meaning "unspecified".  */
1365f7cc78ecSespie   CGEN_CPU_OPEN_ISAS,
1366f7cc78ecSespie   /* Select machine(s), arg is bitmap or 0 meaning "unspecified".  */
1367f7cc78ecSespie   CGEN_CPU_OPEN_MACHS,
1368f7cc78ecSespie   /* Select machine, arg is mach's bfd name.
1369f7cc78ecSespie      Multiple machines can be specified by repeated use.  */
1370f7cc78ecSespie   CGEN_CPU_OPEN_BFDMACH,
1371f7cc78ecSespie   /* Select endian, arg is CGEN_ENDIAN_*.  */
1372f7cc78ecSespie   CGEN_CPU_OPEN_ENDIAN
1373f7cc78ecSespie };
1374f7cc78ecSespie 
1375f7cc78ecSespie /* Open a cpu descriptor table for use.
1376f7cc78ecSespie    ??? We only support ISO C stdargs here, not K&R.
1377f7cc78ecSespie    Laziness, plus experiment to see if anything requires K&R - eventually
1378f7cc78ecSespie    K&R will no longer be supported - e.g. GDB is currently trying this.  */
1379f7cc78ecSespie 
1380f7cc78ecSespie extern CGEN_CPU_DESC CGEN_SYM (cpu_open) (enum cgen_cpu_open_arg, ...);
1381f7cc78ecSespie 
1382f7cc78ecSespie /* Cover fn to handle simple case.  */
1383f7cc78ecSespie 
1384*cf2f2c56Smiod extern CGEN_CPU_DESC CGEN_SYM (cpu_open_1)
1385*cf2f2c56Smiod    (const char *mach_name_, enum cgen_endian endian_);
1386f7cc78ecSespie 
1387f7cc78ecSespie /* Close it.  */
1388f7cc78ecSespie 
1389*cf2f2c56Smiod extern void CGEN_SYM (cpu_close) (CGEN_CPU_DESC);
1390f7cc78ecSespie 
1391f7cc78ecSespie /* Initialize the opcode table for use.
1392f7cc78ecSespie    Called by init_asm/init_dis.  */
1393f7cc78ecSespie 
1394*cf2f2c56Smiod extern void CGEN_SYM (init_opcode_table) (CGEN_CPU_DESC cd_);
1395f7cc78ecSespie 
1396d2201f2fSdrahn /* build the insn selection regex.
1397d2201f2fSdrahn    called by init_opcode_table */
1398d2201f2fSdrahn 
1399*cf2f2c56Smiod extern char * CGEN_SYM(build_insn_regex) (CGEN_INSN *insn_);
1400d2201f2fSdrahn 
1401f7cc78ecSespie /* Initialize the ibld table for use.
1402f7cc78ecSespie    Called by init_asm/init_dis.  */
1403f7cc78ecSespie 
1404*cf2f2c56Smiod extern void CGEN_SYM (init_ibld_table) (CGEN_CPU_DESC cd_);
1405f7cc78ecSespie 
1406f7cc78ecSespie /* Initialize an cpu table for assembler or disassembler use.
1407f7cc78ecSespie    These must be called immediately after cpu_open.  */
1408f7cc78ecSespie 
1409*cf2f2c56Smiod extern void CGEN_SYM (init_asm) (CGEN_CPU_DESC);
1410*cf2f2c56Smiod extern void CGEN_SYM (init_dis) (CGEN_CPU_DESC);
1411f7cc78ecSespie 
1412f7cc78ecSespie /* Initialize the operand instance table for use.  */
1413f7cc78ecSespie 
1414*cf2f2c56Smiod extern void CGEN_SYM (init_opinst_table) (CGEN_CPU_DESC cd_);
1415f7cc78ecSespie 
1416f7cc78ecSespie /* Assemble an instruction.  */
1417f7cc78ecSespie 
1418f7cc78ecSespie extern const CGEN_INSN * CGEN_SYM (assemble_insn)
1419*cf2f2c56Smiod   (CGEN_CPU_DESC, const char *, CGEN_FIELDS *,
1420*cf2f2c56Smiod    CGEN_INSN_BYTES_PTR, char **);
1421f7cc78ecSespie 
1422f7cc78ecSespie extern const CGEN_KEYWORD CGEN_SYM (operand_mach);
1423*cf2f2c56Smiod extern int CGEN_SYM (get_mach) (const char *);
1424f7cc78ecSespie 
1425f7cc78ecSespie /* Operand index computation.  */
1426f7cc78ecSespie extern const CGEN_INSN * cgen_lookup_insn
1427*cf2f2c56Smiod   (CGEN_CPU_DESC, const CGEN_INSN * insn_,
1428f7cc78ecSespie    CGEN_INSN_INT int_value_, unsigned char *bytes_value_,
1429*cf2f2c56Smiod    int length_, CGEN_FIELDS *fields_, int alias_p_);
1430f7cc78ecSespie extern void cgen_get_insn_operands
1431*cf2f2c56Smiod   (CGEN_CPU_DESC, const CGEN_INSN * insn_,
1432*cf2f2c56Smiod    const CGEN_FIELDS *fields_, int *indices_);
1433f7cc78ecSespie extern const CGEN_INSN * cgen_lookup_get_insn_operands
1434*cf2f2c56Smiod   (CGEN_CPU_DESC, const CGEN_INSN *insn_,
1435f7cc78ecSespie    CGEN_INSN_INT int_value_, unsigned char *bytes_value_,
1436*cf2f2c56Smiod    int length_, int *indices_, CGEN_FIELDS *fields_);
1437f7cc78ecSespie 
1438f7cc78ecSespie /* Cover fns to bfd_get/set.  */
1439f7cc78ecSespie 
1440f7cc78ecSespie extern CGEN_INSN_INT cgen_get_insn_value
1441*cf2f2c56Smiod   (CGEN_CPU_DESC, unsigned char *, int);
1442f7cc78ecSespie extern void cgen_put_insn_value
1443*cf2f2c56Smiod   (CGEN_CPU_DESC, unsigned char *, int, CGEN_INSN_INT);
1444f7cc78ecSespie 
1445f7cc78ecSespie /* Read in a cpu description file.
1446f7cc78ecSespie    ??? For future concerns, including adding instructions to the assembler/
1447f7cc78ecSespie    disassembler at run-time.  */
1448f7cc78ecSespie 
1449*cf2f2c56Smiod extern const char * cgen_read_cpu_file (CGEN_CPU_DESC, const char * filename_);
1450f7cc78ecSespie 
1451f7cc78ecSespie /* Allow signed overflow of instruction fields.  */
1452*cf2f2c56Smiod extern void cgen_set_signed_overflow_ok (CGEN_CPU_DESC);
1453f7cc78ecSespie 
1454f7cc78ecSespie /* Generate an error message if a signed field in an instruction overflows.  */
1455*cf2f2c56Smiod extern void cgen_clear_signed_overflow_ok (CGEN_CPU_DESC);
1456f7cc78ecSespie 
1457f7cc78ecSespie /* Will an error message be generated if a signed field in an instruction overflows ? */
1458*cf2f2c56Smiod extern unsigned int cgen_signed_overflow_ok_p (CGEN_CPU_DESC);
1459fddef416Sniklas 
1460fddef416Sniklas #endif /* CGEN_H */
1461