Commit | Line | Data |
---|---|---|
d031aafb | 1 | /* Instruction building/extraction support for mt. -*- C -*- |
ac188222 | 2 | |
47b0e7ad NC |
3 | THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. |
4 | - the resultant file is machine generated, cgen-ibld.in isn't | |
ac188222 | 5 | |
47b0e7ad NC |
6 | Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 |
7 | Free Software Foundation, Inc. | |
ac188222 | 8 | |
47b0e7ad | 9 | This file is part of the GNU Binutils and GDB, the GNU debugger. |
ac188222 | 10 | |
47b0e7ad NC |
11 | This program is free software; you can redistribute it and/or modify |
12 | it under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation; either version 2, or (at your option) | |
14 | any later version. | |
ac188222 | 15 | |
47b0e7ad NC |
16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
ac188222 | 20 | |
47b0e7ad NC |
21 | You should have received a copy of the GNU General Public License |
22 | along with this program; if not, write to the Free Software Foundation, Inc., | |
23 | 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ | |
ac188222 DB |
24 | |
25 | /* ??? Eventually more and more of this stuff can go to cpu-independent files. | |
26 | Keep that in mind. */ | |
27 | ||
28 | #include "sysdep.h" | |
29 | #include <stdio.h> | |
30 | #include "ansidecl.h" | |
31 | #include "dis-asm.h" | |
32 | #include "bfd.h" | |
33 | #include "symcat.h" | |
d031aafb NS |
34 | #include "mt-desc.h" |
35 | #include "mt-opc.h" | |
ac188222 DB |
36 | #include "opintl.h" |
37 | #include "safe-ctype.h" | |
38 | ||
47b0e7ad | 39 | #undef min |
ac188222 | 40 | #define min(a,b) ((a) < (b) ? (a) : (b)) |
47b0e7ad | 41 | #undef max |
ac188222 DB |
42 | #define max(a,b) ((a) > (b) ? (a) : (b)) |
43 | ||
44 | /* Used by the ifield rtx function. */ | |
45 | #define FLD(f) (fields->f) | |
46 | ||
47 | static const char * insert_normal | |
48 | (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int, | |
49 | unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR); | |
50 | static const char * insert_insn_normal | |
51 | (CGEN_CPU_DESC, const CGEN_INSN *, | |
52 | CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); | |
53 | static int extract_normal | |
54 | (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, | |
55 | unsigned int, unsigned int, unsigned int, unsigned int, | |
56 | unsigned int, unsigned int, bfd_vma, long *); | |
57 | static int extract_insn_normal | |
58 | (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *, | |
59 | CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); | |
60 | #if CGEN_INT_INSN_P | |
61 | static void put_insn_int_value | |
62 | (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT); | |
63 | #endif | |
64 | #if ! CGEN_INT_INSN_P | |
65 | static CGEN_INLINE void insert_1 | |
66 | (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *); | |
67 | static CGEN_INLINE int fill_cache | |
68 | (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma); | |
69 | static CGEN_INLINE long extract_1 | |
70 | (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma); | |
71 | #endif | |
72 | \f | |
73 | /* Operand insertion. */ | |
74 | ||
75 | #if ! CGEN_INT_INSN_P | |
76 | ||
77 | /* Subroutine of insert_normal. */ | |
78 | ||
79 | static CGEN_INLINE void | |
80 | insert_1 (CGEN_CPU_DESC cd, | |
81 | unsigned long value, | |
82 | int start, | |
83 | int length, | |
84 | int word_length, | |
85 | unsigned char *bufp) | |
86 | { | |
87 | unsigned long x,mask; | |
88 | int shift; | |
89 | ||
90 | x = cgen_get_insn_value (cd, bufp, word_length); | |
91 | ||
92 | /* Written this way to avoid undefined behaviour. */ | |
93 | mask = (((1L << (length - 1)) - 1) << 1) | 1; | |
94 | if (CGEN_INSN_LSB0_P) | |
95 | shift = (start + 1) - length; | |
96 | else | |
97 | shift = (word_length - (start + length)); | |
98 | x = (x & ~(mask << shift)) | ((value & mask) << shift); | |
99 | ||
100 | cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x); | |
101 | } | |
102 | ||
103 | #endif /* ! CGEN_INT_INSN_P */ | |
104 | ||
105 | /* Default insertion routine. | |
106 | ||
107 | ATTRS is a mask of the boolean attributes. | |
108 | WORD_OFFSET is the offset in bits from the start of the insn of the value. | |
109 | WORD_LENGTH is the length of the word in bits in which the value resides. | |
110 | START is the starting bit number in the word, architecture origin. | |
111 | LENGTH is the length of VALUE in bits. | |
112 | TOTAL_LENGTH is the total length of the insn in bits. | |
113 | ||
114 | The result is an error message or NULL if success. */ | |
115 | ||
116 | /* ??? This duplicates functionality with bfd's howto table and | |
117 | bfd_install_relocation. */ | |
118 | /* ??? This doesn't handle bfd_vma's. Create another function when | |
119 | necessary. */ | |
120 | ||
121 | static const char * | |
122 | insert_normal (CGEN_CPU_DESC cd, | |
123 | long value, | |
124 | unsigned int attrs, | |
125 | unsigned int word_offset, | |
126 | unsigned int start, | |
127 | unsigned int length, | |
128 | unsigned int word_length, | |
129 | unsigned int total_length, | |
130 | CGEN_INSN_BYTES_PTR buffer) | |
131 | { | |
132 | static char errbuf[100]; | |
133 | /* Written this way to avoid undefined behaviour. */ | |
134 | unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1; | |
135 | ||
136 | /* If LENGTH is zero, this operand doesn't contribute to the value. */ | |
137 | if (length == 0) | |
138 | return NULL; | |
139 | ||
ac188222 DB |
140 | if (word_length > 32) |
141 | abort (); | |
142 | ||
143 | /* For architectures with insns smaller than the base-insn-bitsize, | |
144 | word_length may be too big. */ | |
145 | if (cd->min_insn_bitsize < cd->base_insn_bitsize) | |
146 | { | |
147 | if (word_offset == 0 | |
148 | && word_length > total_length) | |
149 | word_length = total_length; | |
150 | } | |
151 | ||
152 | /* Ensure VALUE will fit. */ | |
153 | if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT)) | |
154 | { | |
155 | long minval = - (1L << (length - 1)); | |
156 | unsigned long maxval = mask; | |
157 | ||
158 | if ((value > 0 && (unsigned long) value > maxval) | |
159 | || value < minval) | |
160 | { | |
161 | /* xgettext:c-format */ | |
162 | sprintf (errbuf, | |
163 | _("operand out of range (%ld not between %ld and %lu)"), | |
164 | value, minval, maxval); | |
165 | return errbuf; | |
166 | } | |
167 | } | |
168 | else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) | |
169 | { | |
170 | unsigned long maxval = mask; | |
171 | ||
172 | if ((unsigned long) value > maxval) | |
173 | { | |
174 | /* xgettext:c-format */ | |
175 | sprintf (errbuf, | |
176 | _("operand out of range (%lu not between 0 and %lu)"), | |
177 | value, maxval); | |
178 | return errbuf; | |
179 | } | |
180 | } | |
181 | else | |
182 | { | |
183 | if (! cgen_signed_overflow_ok_p (cd)) | |
184 | { | |
185 | long minval = - (1L << (length - 1)); | |
186 | long maxval = (1L << (length - 1)) - 1; | |
187 | ||
188 | if (value < minval || value > maxval) | |
189 | { | |
190 | sprintf | |
191 | /* xgettext:c-format */ | |
192 | (errbuf, _("operand out of range (%ld not between %ld and %ld)"), | |
193 | value, minval, maxval); | |
194 | return errbuf; | |
195 | } | |
196 | } | |
197 | } | |
198 | ||
199 | #if CGEN_INT_INSN_P | |
200 | ||
201 | { | |
202 | int shift; | |
203 | ||
204 | if (CGEN_INSN_LSB0_P) | |
205 | shift = (word_offset + start + 1) - length; | |
206 | else | |
207 | shift = total_length - (word_offset + start + length); | |
208 | *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); | |
209 | } | |
210 | ||
211 | #else /* ! CGEN_INT_INSN_P */ | |
212 | ||
213 | { | |
214 | unsigned char *bufp = (unsigned char *) buffer + word_offset / 8; | |
215 | ||
216 | insert_1 (cd, value, start, length, word_length, bufp); | |
217 | } | |
218 | ||
219 | #endif /* ! CGEN_INT_INSN_P */ | |
220 | ||
221 | return NULL; | |
222 | } | |
223 | ||
224 | /* Default insn builder (insert handler). | |
225 | The instruction is recorded in CGEN_INT_INSN_P byte order (meaning | |
226 | that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is | |
227 | recorded in host byte order, otherwise BUFFER is an array of bytes | |
228 | and the value is recorded in target byte order). | |
229 | The result is an error message or NULL if success. */ | |
230 | ||
231 | static const char * | |
232 | insert_insn_normal (CGEN_CPU_DESC cd, | |
233 | const CGEN_INSN * insn, | |
234 | CGEN_FIELDS * fields, | |
235 | CGEN_INSN_BYTES_PTR buffer, | |
236 | bfd_vma pc) | |
237 | { | |
238 | const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); | |
239 | unsigned long value; | |
240 | const CGEN_SYNTAX_CHAR_TYPE * syn; | |
241 | ||
242 | CGEN_INIT_INSERT (cd); | |
243 | value = CGEN_INSN_BASE_VALUE (insn); | |
244 | ||
245 | /* If we're recording insns as numbers (rather than a string of bytes), | |
246 | target byte order handling is deferred until later. */ | |
247 | ||
248 | #if CGEN_INT_INSN_P | |
249 | ||
250 | put_insn_int_value (cd, buffer, cd->base_insn_bitsize, | |
251 | CGEN_FIELDS_BITSIZE (fields), value); | |
252 | ||
253 | #else | |
254 | ||
255 | cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, | |
256 | (unsigned) CGEN_FIELDS_BITSIZE (fields)), | |
257 | value); | |
258 | ||
259 | #endif /* ! CGEN_INT_INSN_P */ | |
260 | ||
261 | /* ??? It would be better to scan the format's fields. | |
262 | Still need to be able to insert a value based on the operand though; | |
263 | e.g. storing a branch displacement that got resolved later. | |
264 | Needs more thought first. */ | |
265 | ||
266 | for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) | |
267 | { | |
268 | const char *errmsg; | |
269 | ||
270 | if (CGEN_SYNTAX_CHAR_P (* syn)) | |
271 | continue; | |
272 | ||
273 | errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn), | |
274 | fields, buffer, pc); | |
275 | if (errmsg) | |
276 | return errmsg; | |
277 | } | |
278 | ||
279 | return NULL; | |
280 | } | |
281 | ||
282 | #if CGEN_INT_INSN_P | |
283 | /* Cover function to store an insn value into an integral insn. Must go here | |
47b0e7ad | 284 | because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */ |
ac188222 DB |
285 | |
286 | static void | |
287 | put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, | |
288 | CGEN_INSN_BYTES_PTR buf, | |
289 | int length, | |
290 | int insn_length, | |
291 | CGEN_INSN_INT value) | |
292 | { | |
293 | /* For architectures with insns smaller than the base-insn-bitsize, | |
294 | length may be too big. */ | |
295 | if (length > insn_length) | |
296 | *buf = value; | |
297 | else | |
298 | { | |
299 | int shift = insn_length - length; | |
300 | /* Written this way to avoid undefined behaviour. */ | |
301 | CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; | |
47b0e7ad | 302 | |
ac188222 DB |
303 | *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); |
304 | } | |
305 | } | |
306 | #endif | |
307 | \f | |
308 | /* Operand extraction. */ | |
309 | ||
310 | #if ! CGEN_INT_INSN_P | |
311 | ||
312 | /* Subroutine of extract_normal. | |
313 | Ensure sufficient bytes are cached in EX_INFO. | |
314 | OFFSET is the offset in bytes from the start of the insn of the value. | |
315 | BYTES is the length of the needed value. | |
316 | Returns 1 for success, 0 for failure. */ | |
317 | ||
318 | static CGEN_INLINE int | |
319 | fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, | |
320 | CGEN_EXTRACT_INFO *ex_info, | |
321 | int offset, | |
322 | int bytes, | |
323 | bfd_vma pc) | |
324 | { | |
325 | /* It's doubtful that the middle part has already been fetched so | |
326 | we don't optimize that case. kiss. */ | |
327 | unsigned int mask; | |
328 | disassemble_info *info = (disassemble_info *) ex_info->dis_info; | |
329 | ||
330 | /* First do a quick check. */ | |
331 | mask = (1 << bytes) - 1; | |
332 | if (((ex_info->valid >> offset) & mask) == mask) | |
333 | return 1; | |
334 | ||
335 | /* Search for the first byte we need to read. */ | |
336 | for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1) | |
337 | if (! (mask & ex_info->valid)) | |
338 | break; | |
339 | ||
340 | if (bytes) | |
341 | { | |
342 | int status; | |
343 | ||
344 | pc += offset; | |
345 | status = (*info->read_memory_func) | |
346 | (pc, ex_info->insn_bytes + offset, bytes, info); | |
347 | ||
348 | if (status != 0) | |
349 | { | |
350 | (*info->memory_error_func) (status, pc, info); | |
351 | return 0; | |
352 | } | |
353 | ||
354 | ex_info->valid |= ((1 << bytes) - 1) << offset; | |
355 | } | |
356 | ||
357 | return 1; | |
358 | } | |
359 | ||
360 | /* Subroutine of extract_normal. */ | |
361 | ||
362 | static CGEN_INLINE long | |
363 | extract_1 (CGEN_CPU_DESC cd, | |
364 | CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, | |
365 | int start, | |
366 | int length, | |
367 | int word_length, | |
368 | unsigned char *bufp, | |
369 | bfd_vma pc ATTRIBUTE_UNUSED) | |
370 | { | |
371 | unsigned long x; | |
372 | int shift; | |
47b0e7ad | 373 | |
ac188222 DB |
374 | x = cgen_get_insn_value (cd, bufp, word_length); |
375 | ||
376 | if (CGEN_INSN_LSB0_P) | |
377 | shift = (start + 1) - length; | |
378 | else | |
379 | shift = (word_length - (start + length)); | |
380 | return x >> shift; | |
381 | } | |
382 | ||
383 | #endif /* ! CGEN_INT_INSN_P */ | |
384 | ||
385 | /* Default extraction routine. | |
386 | ||
387 | INSN_VALUE is the first base_insn_bitsize bits of the insn in host order, | |
388 | or sometimes less for cases like the m32r where the base insn size is 32 | |
389 | but some insns are 16 bits. | |
390 | ATTRS is a mask of the boolean attributes. We only need `SIGNED', | |
391 | but for generality we take a bitmask of all of them. | |
392 | WORD_OFFSET is the offset in bits from the start of the insn of the value. | |
393 | WORD_LENGTH is the length of the word in bits in which the value resides. | |
394 | START is the starting bit number in the word, architecture origin. | |
395 | LENGTH is the length of VALUE in bits. | |
396 | TOTAL_LENGTH is the total length of the insn in bits. | |
397 | ||
398 | Returns 1 for success, 0 for failure. */ | |
399 | ||
400 | /* ??? The return code isn't properly used. wip. */ | |
401 | ||
402 | /* ??? This doesn't handle bfd_vma's. Create another function when | |
403 | necessary. */ | |
404 | ||
405 | static int | |
406 | extract_normal (CGEN_CPU_DESC cd, | |
407 | #if ! CGEN_INT_INSN_P | |
408 | CGEN_EXTRACT_INFO *ex_info, | |
409 | #else | |
410 | CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, | |
411 | #endif | |
412 | CGEN_INSN_INT insn_value, | |
413 | unsigned int attrs, | |
414 | unsigned int word_offset, | |
415 | unsigned int start, | |
416 | unsigned int length, | |
417 | unsigned int word_length, | |
418 | unsigned int total_length, | |
419 | #if ! CGEN_INT_INSN_P | |
420 | bfd_vma pc, | |
421 | #else | |
422 | bfd_vma pc ATTRIBUTE_UNUSED, | |
423 | #endif | |
424 | long *valuep) | |
425 | { | |
426 | long value, mask; | |
427 | ||
428 | /* If LENGTH is zero, this operand doesn't contribute to the value | |
429 | so give it a standard value of zero. */ | |
430 | if (length == 0) | |
431 | { | |
432 | *valuep = 0; | |
433 | return 1; | |
434 | } | |
435 | ||
ac188222 DB |
436 | if (word_length > 32) |
437 | abort (); | |
438 | ||
439 | /* For architectures with insns smaller than the insn-base-bitsize, | |
440 | word_length may be too big. */ | |
441 | if (cd->min_insn_bitsize < cd->base_insn_bitsize) | |
442 | { | |
443 | if (word_offset == 0 | |
444 | && word_length > total_length) | |
445 | word_length = total_length; | |
446 | } | |
447 | ||
448 | /* Does the value reside in INSN_VALUE, and at the right alignment? */ | |
449 | ||
450 | if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length)) | |
451 | { | |
452 | if (CGEN_INSN_LSB0_P) | |
453 | value = insn_value >> ((word_offset + start + 1) - length); | |
454 | else | |
455 | value = insn_value >> (total_length - ( word_offset + start + length)); | |
456 | } | |
457 | ||
458 | #if ! CGEN_INT_INSN_P | |
459 | ||
460 | else | |
461 | { | |
462 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; | |
463 | ||
464 | if (word_length > 32) | |
465 | abort (); | |
466 | ||
467 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) | |
468 | return 0; | |
469 | ||
470 | value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); | |
471 | } | |
472 | ||
473 | #endif /* ! CGEN_INT_INSN_P */ | |
474 | ||
475 | /* Written this way to avoid undefined behaviour. */ | |
476 | mask = (((1L << (length - 1)) - 1) << 1) | 1; | |
477 | ||
478 | value &= mask; | |
479 | /* sign extend? */ | |
480 | if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) | |
481 | && (value & (1L << (length - 1)))) | |
482 | value |= ~mask; | |
483 | ||
484 | *valuep = value; | |
485 | ||
486 | return 1; | |
487 | } | |
488 | ||
489 | /* Default insn extractor. | |
490 | ||
491 | INSN_VALUE is the first base_insn_bitsize bits, translated to host order. | |
492 | The extracted fields are stored in FIELDS. | |
493 | EX_INFO is used to handle reading variable length insns. | |
494 | Return the length of the insn in bits, or 0 if no match, | |
495 | or -1 if an error occurs fetching data (memory_error_func will have | |
496 | been called). */ | |
497 | ||
498 | static int | |
499 | extract_insn_normal (CGEN_CPU_DESC cd, | |
500 | const CGEN_INSN *insn, | |
501 | CGEN_EXTRACT_INFO *ex_info, | |
502 | CGEN_INSN_INT insn_value, | |
503 | CGEN_FIELDS *fields, | |
504 | bfd_vma pc) | |
505 | { | |
506 | const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); | |
507 | const CGEN_SYNTAX_CHAR_TYPE *syn; | |
508 | ||
509 | CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); | |
510 | ||
511 | CGEN_INIT_EXTRACT (cd); | |
512 | ||
513 | for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) | |
514 | { | |
515 | int length; | |
516 | ||
517 | if (CGEN_SYNTAX_CHAR_P (*syn)) | |
518 | continue; | |
519 | ||
520 | length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn), | |
521 | ex_info, insn_value, fields, pc); | |
522 | if (length <= 0) | |
523 | return length; | |
524 | } | |
525 | ||
526 | /* We recognized and successfully extracted this insn. */ | |
527 | return CGEN_INSN_BITSIZE (insn); | |
528 | } | |
529 | \f | |
47b0e7ad | 530 | /* Machine generated code added here. */ |
ac188222 | 531 | |
d031aafb | 532 | const char * mt_cgen_insert_operand |
47b0e7ad | 533 | (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); |
ac188222 DB |
534 | |
535 | /* Main entry point for operand insertion. | |
536 | ||
537 | This function is basically just a big switch statement. Earlier versions | |
538 | used tables to look up the function to use, but | |
539 | - if the table contains both assembler and disassembler functions then | |
540 | the disassembler contains much of the assembler and vice-versa, | |
541 | - there's a lot of inlining possibilities as things grow, | |
542 | - using a switch statement avoids the function call overhead. | |
543 | ||
544 | This function could be moved into `parse_insn_normal', but keeping it | |
545 | separate makes clear the interface between `parse_insn_normal' and each of | |
546 | the handlers. It's also needed by GAS to insert operands that couldn't be | |
547 | resolved during parsing. */ | |
548 | ||
549 | const char * | |
d031aafb | 550 | mt_cgen_insert_operand (CGEN_CPU_DESC cd, |
47b0e7ad NC |
551 | int opindex, |
552 | CGEN_FIELDS * fields, | |
553 | CGEN_INSN_BYTES_PTR buffer, | |
554 | bfd_vma pc ATTRIBUTE_UNUSED) | |
ac188222 DB |
555 | { |
556 | const char * errmsg = NULL; | |
557 | unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); | |
558 | ||
559 | switch (opindex) | |
560 | { | |
d031aafb | 561 | case MT_OPERAND_A23 : |
ac188222 DB |
562 | errmsg = insert_normal (cd, fields->f_a23, 0, 0, 23, 1, 32, total_length, buffer); |
563 | break; | |
d031aafb | 564 | case MT_OPERAND_BALL : |
ac188222 DB |
565 | errmsg = insert_normal (cd, fields->f_ball, 0, 0, 19, 1, 32, total_length, buffer); |
566 | break; | |
d031aafb | 567 | case MT_OPERAND_BALL2 : |
ac188222 DB |
568 | errmsg = insert_normal (cd, fields->f_ball2, 0, 0, 15, 1, 32, total_length, buffer); |
569 | break; | |
d031aafb | 570 | case MT_OPERAND_BANKADDR : |
ac188222 DB |
571 | errmsg = insert_normal (cd, fields->f_bankaddr, 0, 0, 25, 13, 32, total_length, buffer); |
572 | break; | |
d031aafb | 573 | case MT_OPERAND_BRC : |
ac188222 DB |
574 | errmsg = insert_normal (cd, fields->f_brc, 0, 0, 18, 3, 32, total_length, buffer); |
575 | break; | |
d031aafb | 576 | case MT_OPERAND_BRC2 : |
ac188222 DB |
577 | errmsg = insert_normal (cd, fields->f_brc2, 0, 0, 14, 3, 32, total_length, buffer); |
578 | break; | |
d031aafb | 579 | case MT_OPERAND_CB1INCR : |
6f84a2a6 NS |
580 | errmsg = insert_normal (cd, fields->f_cb1incr, 0|(1<<CGEN_IFLD_SIGNED), 0, 19, 6, 32, total_length, buffer); |
581 | break; | |
d031aafb | 582 | case MT_OPERAND_CB1SEL : |
6f84a2a6 NS |
583 | errmsg = insert_normal (cd, fields->f_cb1sel, 0, 0, 25, 3, 32, total_length, buffer); |
584 | break; | |
d031aafb | 585 | case MT_OPERAND_CB2INCR : |
6f84a2a6 NS |
586 | errmsg = insert_normal (cd, fields->f_cb2incr, 0|(1<<CGEN_IFLD_SIGNED), 0, 13, 6, 32, total_length, buffer); |
587 | break; | |
d031aafb | 588 | case MT_OPERAND_CB2SEL : |
6f84a2a6 NS |
589 | errmsg = insert_normal (cd, fields->f_cb2sel, 0, 0, 22, 3, 32, total_length, buffer); |
590 | break; | |
d031aafb | 591 | case MT_OPERAND_CBRB : |
ac188222 DB |
592 | errmsg = insert_normal (cd, fields->f_cbrb, 0, 0, 10, 1, 32, total_length, buffer); |
593 | break; | |
d031aafb | 594 | case MT_OPERAND_CBS : |
ac188222 DB |
595 | errmsg = insert_normal (cd, fields->f_cbs, 0, 0, 19, 2, 32, total_length, buffer); |
596 | break; | |
d031aafb | 597 | case MT_OPERAND_CBX : |
ac188222 DB |
598 | errmsg = insert_normal (cd, fields->f_cbx, 0, 0, 14, 3, 32, total_length, buffer); |
599 | break; | |
d031aafb | 600 | case MT_OPERAND_CCB : |
ac188222 DB |
601 | errmsg = insert_normal (cd, fields->f_ccb, 0, 0, 11, 1, 32, total_length, buffer); |
602 | break; | |
d031aafb | 603 | case MT_OPERAND_CDB : |
ac188222 DB |
604 | errmsg = insert_normal (cd, fields->f_cdb, 0, 0, 10, 1, 32, total_length, buffer); |
605 | break; | |
d031aafb | 606 | case MT_OPERAND_CELL : |
ac188222 DB |
607 | errmsg = insert_normal (cd, fields->f_cell, 0, 0, 9, 3, 32, total_length, buffer); |
608 | break; | |
d031aafb | 609 | case MT_OPERAND_COLNUM : |
ac188222 DB |
610 | errmsg = insert_normal (cd, fields->f_colnum, 0, 0, 18, 3, 32, total_length, buffer); |
611 | break; | |
d031aafb | 612 | case MT_OPERAND_CONTNUM : |
ac188222 DB |
613 | errmsg = insert_normal (cd, fields->f_contnum, 0, 0, 8, 9, 32, total_length, buffer); |
614 | break; | |
d031aafb | 615 | case MT_OPERAND_CR : |
ac188222 DB |
616 | errmsg = insert_normal (cd, fields->f_cr, 0, 0, 22, 3, 32, total_length, buffer); |
617 | break; | |
d031aafb | 618 | case MT_OPERAND_CTXDISP : |
ac188222 DB |
619 | errmsg = insert_normal (cd, fields->f_ctxdisp, 0, 0, 5, 6, 32, total_length, buffer); |
620 | break; | |
d031aafb | 621 | case MT_OPERAND_DUP : |
ac188222 DB |
622 | errmsg = insert_normal (cd, fields->f_dup, 0, 0, 6, 1, 32, total_length, buffer); |
623 | break; | |
d031aafb | 624 | case MT_OPERAND_FBDISP : |
ac188222 DB |
625 | errmsg = insert_normal (cd, fields->f_fbdisp, 0, 0, 15, 6, 32, total_length, buffer); |
626 | break; | |
d031aafb | 627 | case MT_OPERAND_FBINCR : |
ac188222 DB |
628 | errmsg = insert_normal (cd, fields->f_fbincr, 0, 0, 23, 4, 32, total_length, buffer); |
629 | break; | |
d031aafb | 630 | case MT_OPERAND_FRDR : |
ac188222 DB |
631 | errmsg = insert_normal (cd, fields->f_dr, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, buffer); |
632 | break; | |
d031aafb | 633 | case MT_OPERAND_FRDRRR : |
ac188222 DB |
634 | errmsg = insert_normal (cd, fields->f_drrr, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 4, 32, total_length, buffer); |
635 | break; | |
d031aafb | 636 | case MT_OPERAND_FRSR1 : |
ac188222 DB |
637 | errmsg = insert_normal (cd, fields->f_sr1, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 23, 4, 32, total_length, buffer); |
638 | break; | |
d031aafb | 639 | case MT_OPERAND_FRSR2 : |
ac188222 DB |
640 | errmsg = insert_normal (cd, fields->f_sr2, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, buffer); |
641 | break; | |
d031aafb | 642 | case MT_OPERAND_ID : |
ac188222 DB |
643 | errmsg = insert_normal (cd, fields->f_id, 0, 0, 14, 1, 32, total_length, buffer); |
644 | break; | |
d031aafb | 645 | case MT_OPERAND_IMM16 : |
ac188222 DB |
646 | { |
647 | long value = fields->f_imm16s; | |
648 | value = ((value) + (0)); | |
649 | errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer); | |
650 | } | |
651 | break; | |
d031aafb | 652 | case MT_OPERAND_IMM16L : |
6f84a2a6 NS |
653 | errmsg = insert_normal (cd, fields->f_imm16l, 0, 0, 23, 16, 32, total_length, buffer); |
654 | break; | |
d031aafb | 655 | case MT_OPERAND_IMM16O : |
ac188222 DB |
656 | { |
657 | long value = fields->f_imm16s; | |
658 | value = ((value) + (0)); | |
659 | errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer); | |
660 | } | |
661 | break; | |
d031aafb | 662 | case MT_OPERAND_IMM16Z : |
ac188222 DB |
663 | errmsg = insert_normal (cd, fields->f_imm16u, 0, 0, 15, 16, 32, total_length, buffer); |
664 | break; | |
d031aafb | 665 | case MT_OPERAND_INCAMT : |
ac188222 DB |
666 | errmsg = insert_normal (cd, fields->f_incamt, 0, 0, 19, 8, 32, total_length, buffer); |
667 | break; | |
d031aafb | 668 | case MT_OPERAND_INCR : |
ac188222 DB |
669 | errmsg = insert_normal (cd, fields->f_incr, 0, 0, 17, 6, 32, total_length, buffer); |
670 | break; | |
d031aafb | 671 | case MT_OPERAND_LENGTH : |
ac188222 DB |
672 | errmsg = insert_normal (cd, fields->f_length, 0, 0, 15, 3, 32, total_length, buffer); |
673 | break; | |
d031aafb | 674 | case MT_OPERAND_LOOPSIZE : |
6f84a2a6 NS |
675 | { |
676 | long value = fields->f_loopo; | |
677 | value = ((unsigned int) (value) >> (2)); | |
678 | errmsg = insert_normal (cd, value, 0, 0, 7, 8, 32, total_length, buffer); | |
679 | } | |
680 | break; | |
d031aafb | 681 | case MT_OPERAND_MASK : |
ac188222 DB |
682 | errmsg = insert_normal (cd, fields->f_mask, 0, 0, 25, 16, 32, total_length, buffer); |
683 | break; | |
d031aafb | 684 | case MT_OPERAND_MASK1 : |
ac188222 DB |
685 | errmsg = insert_normal (cd, fields->f_mask1, 0, 0, 22, 3, 32, total_length, buffer); |
686 | break; | |
d031aafb | 687 | case MT_OPERAND_MODE : |
ac188222 DB |
688 | errmsg = insert_normal (cd, fields->f_mode, 0, 0, 25, 2, 32, total_length, buffer); |
689 | break; | |
d031aafb | 690 | case MT_OPERAND_PERM : |
ac188222 DB |
691 | errmsg = insert_normal (cd, fields->f_perm, 0, 0, 25, 2, 32, total_length, buffer); |
692 | break; | |
d031aafb | 693 | case MT_OPERAND_RBBC : |
ac188222 DB |
694 | errmsg = insert_normal (cd, fields->f_rbbc, 0, 0, 25, 2, 32, total_length, buffer); |
695 | break; | |
d031aafb | 696 | case MT_OPERAND_RC : |
ac188222 DB |
697 | errmsg = insert_normal (cd, fields->f_rc, 0, 0, 15, 1, 32, total_length, buffer); |
698 | break; | |
d031aafb | 699 | case MT_OPERAND_RC1 : |
ac188222 DB |
700 | errmsg = insert_normal (cd, fields->f_rc1, 0, 0, 11, 1, 32, total_length, buffer); |
701 | break; | |
d031aafb | 702 | case MT_OPERAND_RC2 : |
ac188222 DB |
703 | errmsg = insert_normal (cd, fields->f_rc2, 0, 0, 6, 1, 32, total_length, buffer); |
704 | break; | |
d031aafb | 705 | case MT_OPERAND_RC3 : |
6f84a2a6 NS |
706 | errmsg = insert_normal (cd, fields->f_rc3, 0, 0, 7, 1, 32, total_length, buffer); |
707 | break; | |
d031aafb | 708 | case MT_OPERAND_RCNUM : |
ac188222 DB |
709 | errmsg = insert_normal (cd, fields->f_rcnum, 0, 0, 14, 3, 32, total_length, buffer); |
710 | break; | |
d031aafb | 711 | case MT_OPERAND_RDA : |
ac188222 DB |
712 | errmsg = insert_normal (cd, fields->f_rda, 0, 0, 25, 1, 32, total_length, buffer); |
713 | break; | |
d031aafb | 714 | case MT_OPERAND_ROWNUM : |
ac188222 DB |
715 | errmsg = insert_normal (cd, fields->f_rownum, 0, 0, 14, 3, 32, total_length, buffer); |
716 | break; | |
d031aafb | 717 | case MT_OPERAND_ROWNUM1 : |
ac188222 DB |
718 | errmsg = insert_normal (cd, fields->f_rownum1, 0, 0, 12, 3, 32, total_length, buffer); |
719 | break; | |
d031aafb | 720 | case MT_OPERAND_ROWNUM2 : |
ac188222 DB |
721 | errmsg = insert_normal (cd, fields->f_rownum2, 0, 0, 9, 3, 32, total_length, buffer); |
722 | break; | |
d031aafb | 723 | case MT_OPERAND_SIZE : |
ac188222 DB |
724 | errmsg = insert_normal (cd, fields->f_size, 0, 0, 13, 14, 32, total_length, buffer); |
725 | break; | |
d031aafb | 726 | case MT_OPERAND_TYPE : |
ac188222 DB |
727 | errmsg = insert_normal (cd, fields->f_type, 0, 0, 21, 2, 32, total_length, buffer); |
728 | break; | |
d031aafb | 729 | case MT_OPERAND_WR : |
ac188222 DB |
730 | errmsg = insert_normal (cd, fields->f_wr, 0, 0, 24, 1, 32, total_length, buffer); |
731 | break; | |
d031aafb | 732 | case MT_OPERAND_XMODE : |
ac188222 DB |
733 | errmsg = insert_normal (cd, fields->f_xmode, 0, 0, 23, 1, 32, total_length, buffer); |
734 | break; | |
735 | ||
736 | default : | |
737 | /* xgettext:c-format */ | |
738 | fprintf (stderr, _("Unrecognized field %d while building insn.\n"), | |
739 | opindex); | |
740 | abort (); | |
741 | } | |
742 | ||
743 | return errmsg; | |
744 | } | |
745 | ||
d031aafb | 746 | int mt_cgen_extract_operand |
47b0e7ad | 747 | (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); |
ac188222 DB |
748 | |
749 | /* Main entry point for operand extraction. | |
750 | The result is <= 0 for error, >0 for success. | |
751 | ??? Actual values aren't well defined right now. | |
752 | ||
753 | This function is basically just a big switch statement. Earlier versions | |
754 | used tables to look up the function to use, but | |
755 | - if the table contains both assembler and disassembler functions then | |
756 | the disassembler contains much of the assembler and vice-versa, | |
757 | - there's a lot of inlining possibilities as things grow, | |
758 | - using a switch statement avoids the function call overhead. | |
759 | ||
760 | This function could be moved into `print_insn_normal', but keeping it | |
761 | separate makes clear the interface between `print_insn_normal' and each of | |
762 | the handlers. */ | |
763 | ||
764 | int | |
d031aafb | 765 | mt_cgen_extract_operand (CGEN_CPU_DESC cd, |
47b0e7ad NC |
766 | int opindex, |
767 | CGEN_EXTRACT_INFO *ex_info, | |
768 | CGEN_INSN_INT insn_value, | |
769 | CGEN_FIELDS * fields, | |
770 | bfd_vma pc) | |
ac188222 DB |
771 | { |
772 | /* Assume success (for those operands that are nops). */ | |
773 | int length = 1; | |
774 | unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); | |
775 | ||
776 | switch (opindex) | |
777 | { | |
d031aafb | 778 | case MT_OPERAND_A23 : |
ac188222 DB |
779 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 1, 32, total_length, pc, & fields->f_a23); |
780 | break; | |
d031aafb | 781 | case MT_OPERAND_BALL : |
ac188222 DB |
782 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 1, 32, total_length, pc, & fields->f_ball); |
783 | break; | |
d031aafb | 784 | case MT_OPERAND_BALL2 : |
ac188222 DB |
785 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_ball2); |
786 | break; | |
d031aafb | 787 | case MT_OPERAND_BANKADDR : |
ac188222 DB |
788 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 13, 32, total_length, pc, & fields->f_bankaddr); |
789 | break; | |
d031aafb | 790 | case MT_OPERAND_BRC : |
ac188222 DB |
791 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 3, 32, total_length, pc, & fields->f_brc); |
792 | break; | |
d031aafb | 793 | case MT_OPERAND_BRC2 : |
ac188222 DB |
794 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_brc2); |
795 | break; | |
d031aafb | 796 | case MT_OPERAND_CB1INCR : |
6f84a2a6 NS |
797 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 19, 6, 32, total_length, pc, & fields->f_cb1incr); |
798 | break; | |
d031aafb | 799 | case MT_OPERAND_CB1SEL : |
6f84a2a6 NS |
800 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_cb1sel); |
801 | break; | |
d031aafb | 802 | case MT_OPERAND_CB2INCR : |
6f84a2a6 NS |
803 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 13, 6, 32, total_length, pc, & fields->f_cb2incr); |
804 | break; | |
d031aafb | 805 | case MT_OPERAND_CB2SEL : |
6f84a2a6 NS |
806 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_cb2sel); |
807 | break; | |
d031aafb | 808 | case MT_OPERAND_CBRB : |
ac188222 DB |
809 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 1, 32, total_length, pc, & fields->f_cbrb); |
810 | break; | |
d031aafb | 811 | case MT_OPERAND_CBS : |
ac188222 DB |
812 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 2, 32, total_length, pc, & fields->f_cbs); |
813 | break; | |
d031aafb | 814 | case MT_OPERAND_CBX : |
ac188222 DB |
815 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_cbx); |
816 | break; | |
d031aafb | 817 | case MT_OPERAND_CCB : |
ac188222 DB |
818 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_ccb); |
819 | break; | |
d031aafb | 820 | case MT_OPERAND_CDB : |
ac188222 DB |
821 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 1, 32, total_length, pc, & fields->f_cdb); |
822 | break; | |
d031aafb | 823 | case MT_OPERAND_CELL : |
ac188222 DB |
824 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_cell); |
825 | break; | |
d031aafb | 826 | case MT_OPERAND_COLNUM : |
ac188222 DB |
827 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 3, 32, total_length, pc, & fields->f_colnum); |
828 | break; | |
d031aafb | 829 | case MT_OPERAND_CONTNUM : |
ac188222 DB |
830 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 9, 32, total_length, pc, & fields->f_contnum); |
831 | break; | |
d031aafb | 832 | case MT_OPERAND_CR : |
ac188222 DB |
833 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_cr); |
834 | break; | |
d031aafb | 835 | case MT_OPERAND_CTXDISP : |
ac188222 DB |
836 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_ctxdisp); |
837 | break; | |
d031aafb | 838 | case MT_OPERAND_DUP : |
ac188222 DB |
839 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_dup); |
840 | break; | |
d031aafb | 841 | case MT_OPERAND_FBDISP : |
ac188222 DB |
842 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_fbdisp); |
843 | break; | |
d031aafb | 844 | case MT_OPERAND_FBINCR : |
ac188222 DB |
845 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 4, 32, total_length, pc, & fields->f_fbincr); |
846 | break; | |
d031aafb | 847 | case MT_OPERAND_FRDR : |
ac188222 DB |
848 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, pc, & fields->f_dr); |
849 | break; | |
d031aafb | 850 | case MT_OPERAND_FRDRRR : |
ac188222 DB |
851 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 4, 32, total_length, pc, & fields->f_drrr); |
852 | break; | |
d031aafb | 853 | case MT_OPERAND_FRSR1 : |
ac188222 DB |
854 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 23, 4, 32, total_length, pc, & fields->f_sr1); |
855 | break; | |
d031aafb | 856 | case MT_OPERAND_FRSR2 : |
ac188222 DB |
857 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, pc, & fields->f_sr2); |
858 | break; | |
d031aafb | 859 | case MT_OPERAND_ID : |
ac188222 DB |
860 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 1, 32, total_length, pc, & fields->f_id); |
861 | break; | |
d031aafb | 862 | case MT_OPERAND_IMM16 : |
ac188222 DB |
863 | { |
864 | long value; | |
865 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & value); | |
866 | value = ((value) + (0)); | |
867 | fields->f_imm16s = value; | |
868 | } | |
869 | break; | |
d031aafb | 870 | case MT_OPERAND_IMM16L : |
6f84a2a6 NS |
871 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 16, 32, total_length, pc, & fields->f_imm16l); |
872 | break; | |
d031aafb | 873 | case MT_OPERAND_IMM16O : |
ac188222 DB |
874 | { |
875 | long value; | |
876 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & value); | |
877 | value = ((value) + (0)); | |
878 | fields->f_imm16s = value; | |
879 | } | |
880 | break; | |
d031aafb | 881 | case MT_OPERAND_IMM16Z : |
ac188222 DB |
882 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm16u); |
883 | break; | |
d031aafb | 884 | case MT_OPERAND_INCAMT : |
ac188222 DB |
885 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 8, 32, total_length, pc, & fields->f_incamt); |
886 | break; | |
d031aafb | 887 | case MT_OPERAND_INCR : |
ac188222 DB |
888 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_incr); |
889 | break; | |
d031aafb | 890 | case MT_OPERAND_LENGTH : |
ac188222 DB |
891 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_length); |
892 | break; | |
d031aafb | 893 | case MT_OPERAND_LOOPSIZE : |
6f84a2a6 NS |
894 | { |
895 | long value; | |
896 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 8, 32, total_length, pc, & value); | |
897 | value = ((((value) << (2))) + (8)); | |
898 | fields->f_loopo = value; | |
899 | } | |
900 | break; | |
d031aafb | 901 | case MT_OPERAND_MASK : |
ac188222 DB |
902 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 16, 32, total_length, pc, & fields->f_mask); |
903 | break; | |
d031aafb | 904 | case MT_OPERAND_MASK1 : |
ac188222 DB |
905 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_mask1); |
906 | break; | |
d031aafb | 907 | case MT_OPERAND_MODE : |
ac188222 DB |
908 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_mode); |
909 | break; | |
d031aafb | 910 | case MT_OPERAND_PERM : |
ac188222 DB |
911 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_perm); |
912 | break; | |
d031aafb | 913 | case MT_OPERAND_RBBC : |
ac188222 DB |
914 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_rbbc); |
915 | break; | |
d031aafb | 916 | case MT_OPERAND_RC : |
ac188222 DB |
917 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_rc); |
918 | break; | |
d031aafb | 919 | case MT_OPERAND_RC1 : |
ac188222 DB |
920 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_rc1); |
921 | break; | |
d031aafb | 922 | case MT_OPERAND_RC2 : |
ac188222 DB |
923 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_rc2); |
924 | break; | |
d031aafb | 925 | case MT_OPERAND_RC3 : |
6f84a2a6 NS |
926 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_rc3); |
927 | break; | |
d031aafb | 928 | case MT_OPERAND_RCNUM : |
ac188222 DB |
929 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_rcnum); |
930 | break; | |
d031aafb | 931 | case MT_OPERAND_RDA : |
ac188222 DB |
932 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_rda); |
933 | break; | |
d031aafb | 934 | case MT_OPERAND_ROWNUM : |
ac188222 DB |
935 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_rownum); |
936 | break; | |
d031aafb | 937 | case MT_OPERAND_ROWNUM1 : |
ac188222 DB |
938 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rownum1); |
939 | break; | |
d031aafb | 940 | case MT_OPERAND_ROWNUM2 : |
ac188222 DB |
941 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rownum2); |
942 | break; | |
d031aafb | 943 | case MT_OPERAND_SIZE : |
ac188222 DB |
944 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 14, 32, total_length, pc, & fields->f_size); |
945 | break; | |
d031aafb | 946 | case MT_OPERAND_TYPE : |
ac188222 DB |
947 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 21, 2, 32, total_length, pc, & fields->f_type); |
948 | break; | |
d031aafb | 949 | case MT_OPERAND_WR : |
ac188222 DB |
950 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 1, 32, total_length, pc, & fields->f_wr); |
951 | break; | |
d031aafb | 952 | case MT_OPERAND_XMODE : |
ac188222 DB |
953 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 1, 32, total_length, pc, & fields->f_xmode); |
954 | break; | |
955 | ||
956 | default : | |
957 | /* xgettext:c-format */ | |
958 | fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), | |
959 | opindex); | |
960 | abort (); | |
961 | } | |
962 | ||
963 | return length; | |
964 | } | |
965 | ||
d031aafb | 966 | cgen_insert_fn * const mt_cgen_insert_handlers[] = |
ac188222 DB |
967 | { |
968 | insert_insn_normal, | |
969 | }; | |
970 | ||
d031aafb | 971 | cgen_extract_fn * const mt_cgen_extract_handlers[] = |
ac188222 DB |
972 | { |
973 | extract_insn_normal, | |
974 | }; | |
975 | ||
d031aafb NS |
976 | int mt_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); |
977 | bfd_vma mt_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); | |
ac188222 DB |
978 | |
979 | /* Getting values from cgen_fields is handled by a collection of functions. | |
980 | They are distinguished by the type of the VALUE argument they return. | |
981 | TODO: floating point, inlining support, remove cases where result type | |
982 | not appropriate. */ | |
983 | ||
984 | int | |
d031aafb | 985 | mt_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
47b0e7ad NC |
986 | int opindex, |
987 | const CGEN_FIELDS * fields) | |
ac188222 DB |
988 | { |
989 | int value; | |
990 | ||
991 | switch (opindex) | |
992 | { | |
d031aafb | 993 | case MT_OPERAND_A23 : |
ac188222 DB |
994 | value = fields->f_a23; |
995 | break; | |
d031aafb | 996 | case MT_OPERAND_BALL : |
ac188222 DB |
997 | value = fields->f_ball; |
998 | break; | |
d031aafb | 999 | case MT_OPERAND_BALL2 : |
ac188222 DB |
1000 | value = fields->f_ball2; |
1001 | break; | |
d031aafb | 1002 | case MT_OPERAND_BANKADDR : |
ac188222 DB |
1003 | value = fields->f_bankaddr; |
1004 | break; | |
d031aafb | 1005 | case MT_OPERAND_BRC : |
ac188222 DB |
1006 | value = fields->f_brc; |
1007 | break; | |
d031aafb | 1008 | case MT_OPERAND_BRC2 : |
ac188222 DB |
1009 | value = fields->f_brc2; |
1010 | break; | |
d031aafb | 1011 | case MT_OPERAND_CB1INCR : |
6f84a2a6 NS |
1012 | value = fields->f_cb1incr; |
1013 | break; | |
d031aafb | 1014 | case MT_OPERAND_CB1SEL : |
6f84a2a6 NS |
1015 | value = fields->f_cb1sel; |
1016 | break; | |
d031aafb | 1017 | case MT_OPERAND_CB2INCR : |
6f84a2a6 NS |
1018 | value = fields->f_cb2incr; |
1019 | break; | |
d031aafb | 1020 | case MT_OPERAND_CB2SEL : |
6f84a2a6 NS |
1021 | value = fields->f_cb2sel; |
1022 | break; | |
d031aafb | 1023 | case MT_OPERAND_CBRB : |
ac188222 DB |
1024 | value = fields->f_cbrb; |
1025 | break; | |
d031aafb | 1026 | case MT_OPERAND_CBS : |
ac188222 DB |
1027 | value = fields->f_cbs; |
1028 | break; | |
d031aafb | 1029 | case MT_OPERAND_CBX : |
ac188222 DB |
1030 | value = fields->f_cbx; |
1031 | break; | |
d031aafb | 1032 | case MT_OPERAND_CCB : |
ac188222 DB |
1033 | value = fields->f_ccb; |
1034 | break; | |
d031aafb | 1035 | case MT_OPERAND_CDB : |
ac188222 DB |
1036 | value = fields->f_cdb; |
1037 | break; | |
d031aafb | 1038 | case MT_OPERAND_CELL : |
ac188222 DB |
1039 | value = fields->f_cell; |
1040 | break; | |
d031aafb | 1041 | case MT_OPERAND_COLNUM : |
ac188222 DB |
1042 | value = fields->f_colnum; |
1043 | break; | |
d031aafb | 1044 | case MT_OPERAND_CONTNUM : |
ac188222 DB |
1045 | value = fields->f_contnum; |
1046 | break; | |
d031aafb | 1047 | case MT_OPERAND_CR : |
ac188222 DB |
1048 | value = fields->f_cr; |
1049 | break; | |
d031aafb | 1050 | case MT_OPERAND_CTXDISP : |
ac188222 DB |
1051 | value = fields->f_ctxdisp; |
1052 | break; | |
d031aafb | 1053 | case MT_OPERAND_DUP : |
ac188222 DB |
1054 | value = fields->f_dup; |
1055 | break; | |
d031aafb | 1056 | case MT_OPERAND_FBDISP : |
ac188222 DB |
1057 | value = fields->f_fbdisp; |
1058 | break; | |
d031aafb | 1059 | case MT_OPERAND_FBINCR : |
ac188222 DB |
1060 | value = fields->f_fbincr; |
1061 | break; | |
d031aafb | 1062 | case MT_OPERAND_FRDR : |
ac188222 DB |
1063 | value = fields->f_dr; |
1064 | break; | |
d031aafb | 1065 | case MT_OPERAND_FRDRRR : |
ac188222 DB |
1066 | value = fields->f_drrr; |
1067 | break; | |
d031aafb | 1068 | case MT_OPERAND_FRSR1 : |
ac188222 DB |
1069 | value = fields->f_sr1; |
1070 | break; | |
d031aafb | 1071 | case MT_OPERAND_FRSR2 : |
ac188222 DB |
1072 | value = fields->f_sr2; |
1073 | break; | |
d031aafb | 1074 | case MT_OPERAND_ID : |
ac188222 DB |
1075 | value = fields->f_id; |
1076 | break; | |
d031aafb | 1077 | case MT_OPERAND_IMM16 : |
ac188222 DB |
1078 | value = fields->f_imm16s; |
1079 | break; | |
d031aafb | 1080 | case MT_OPERAND_IMM16L : |
6f84a2a6 NS |
1081 | value = fields->f_imm16l; |
1082 | break; | |
d031aafb | 1083 | case MT_OPERAND_IMM16O : |
ac188222 DB |
1084 | value = fields->f_imm16s; |
1085 | break; | |
d031aafb | 1086 | case MT_OPERAND_IMM16Z : |
ac188222 DB |
1087 | value = fields->f_imm16u; |
1088 | break; | |
d031aafb | 1089 | case MT_OPERAND_INCAMT : |
ac188222 DB |
1090 | value = fields->f_incamt; |
1091 | break; | |
d031aafb | 1092 | case MT_OPERAND_INCR : |
ac188222 DB |
1093 | value = fields->f_incr; |
1094 | break; | |
d031aafb | 1095 | case MT_OPERAND_LENGTH : |
ac188222 DB |
1096 | value = fields->f_length; |
1097 | break; | |
d031aafb | 1098 | case MT_OPERAND_LOOPSIZE : |
6f84a2a6 NS |
1099 | value = fields->f_loopo; |
1100 | break; | |
d031aafb | 1101 | case MT_OPERAND_MASK : |
ac188222 DB |
1102 | value = fields->f_mask; |
1103 | break; | |
d031aafb | 1104 | case MT_OPERAND_MASK1 : |
ac188222 DB |
1105 | value = fields->f_mask1; |
1106 | break; | |
d031aafb | 1107 | case MT_OPERAND_MODE : |
ac188222 DB |
1108 | value = fields->f_mode; |
1109 | break; | |
d031aafb | 1110 | case MT_OPERAND_PERM : |
ac188222 DB |
1111 | value = fields->f_perm; |
1112 | break; | |
d031aafb | 1113 | case MT_OPERAND_RBBC : |
ac188222 DB |
1114 | value = fields->f_rbbc; |
1115 | break; | |
d031aafb | 1116 | case MT_OPERAND_RC : |
ac188222 DB |
1117 | value = fields->f_rc; |
1118 | break; | |
d031aafb | 1119 | case MT_OPERAND_RC1 : |
ac188222 DB |
1120 | value = fields->f_rc1; |
1121 | break; | |
d031aafb | 1122 | case MT_OPERAND_RC2 : |
ac188222 DB |
1123 | value = fields->f_rc2; |
1124 | break; | |
d031aafb | 1125 | case MT_OPERAND_RC3 : |
6f84a2a6 NS |
1126 | value = fields->f_rc3; |
1127 | break; | |
d031aafb | 1128 | case MT_OPERAND_RCNUM : |
ac188222 DB |
1129 | value = fields->f_rcnum; |
1130 | break; | |
d031aafb | 1131 | case MT_OPERAND_RDA : |
ac188222 DB |
1132 | value = fields->f_rda; |
1133 | break; | |
d031aafb | 1134 | case MT_OPERAND_ROWNUM : |
ac188222 DB |
1135 | value = fields->f_rownum; |
1136 | break; | |
d031aafb | 1137 | case MT_OPERAND_ROWNUM1 : |
ac188222 DB |
1138 | value = fields->f_rownum1; |
1139 | break; | |
d031aafb | 1140 | case MT_OPERAND_ROWNUM2 : |
ac188222 DB |
1141 | value = fields->f_rownum2; |
1142 | break; | |
d031aafb | 1143 | case MT_OPERAND_SIZE : |
ac188222 DB |
1144 | value = fields->f_size; |
1145 | break; | |
d031aafb | 1146 | case MT_OPERAND_TYPE : |
ac188222 DB |
1147 | value = fields->f_type; |
1148 | break; | |
d031aafb | 1149 | case MT_OPERAND_WR : |
ac188222 DB |
1150 | value = fields->f_wr; |
1151 | break; | |
d031aafb | 1152 | case MT_OPERAND_XMODE : |
ac188222 DB |
1153 | value = fields->f_xmode; |
1154 | break; | |
1155 | ||
1156 | default : | |
1157 | /* xgettext:c-format */ | |
1158 | fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), | |
1159 | opindex); | |
1160 | abort (); | |
1161 | } | |
1162 | ||
1163 | return value; | |
1164 | } | |
1165 | ||
1166 | bfd_vma | |
d031aafb | 1167 | mt_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
47b0e7ad NC |
1168 | int opindex, |
1169 | const CGEN_FIELDS * fields) | |
ac188222 DB |
1170 | { |
1171 | bfd_vma value; | |
1172 | ||
1173 | switch (opindex) | |
1174 | { | |
d031aafb | 1175 | case MT_OPERAND_A23 : |
ac188222 DB |
1176 | value = fields->f_a23; |
1177 | break; | |
d031aafb | 1178 | case MT_OPERAND_BALL : |
ac188222 DB |
1179 | value = fields->f_ball; |
1180 | break; | |
d031aafb | 1181 | case MT_OPERAND_BALL2 : |
ac188222 DB |
1182 | value = fields->f_ball2; |
1183 | break; | |
d031aafb | 1184 | case MT_OPERAND_BANKADDR : |
ac188222 DB |
1185 | value = fields->f_bankaddr; |
1186 | break; | |
d031aafb | 1187 | case MT_OPERAND_BRC : |
ac188222 DB |
1188 | value = fields->f_brc; |
1189 | break; | |
d031aafb | 1190 | case MT_OPERAND_BRC2 : |
ac188222 DB |
1191 | value = fields->f_brc2; |
1192 | break; | |
d031aafb | 1193 | case MT_OPERAND_CB1INCR : |
6f84a2a6 NS |
1194 | value = fields->f_cb1incr; |
1195 | break; | |
d031aafb | 1196 | case MT_OPERAND_CB1SEL : |
6f84a2a6 NS |
1197 | value = fields->f_cb1sel; |
1198 | break; | |
d031aafb | 1199 | case MT_OPERAND_CB2INCR : |
6f84a2a6 NS |
1200 | value = fields->f_cb2incr; |
1201 | break; | |
d031aafb | 1202 | case MT_OPERAND_CB2SEL : |
6f84a2a6 NS |
1203 | value = fields->f_cb2sel; |
1204 | break; | |
d031aafb | 1205 | case MT_OPERAND_CBRB : |
ac188222 DB |
1206 | value = fields->f_cbrb; |
1207 | break; | |
d031aafb | 1208 | case MT_OPERAND_CBS : |
ac188222 DB |
1209 | value = fields->f_cbs; |
1210 | break; | |
d031aafb | 1211 | case MT_OPERAND_CBX : |
ac188222 DB |
1212 | value = fields->f_cbx; |
1213 | break; | |
d031aafb | 1214 | case MT_OPERAND_CCB : |
ac188222 DB |
1215 | value = fields->f_ccb; |
1216 | break; | |
d031aafb | 1217 | case MT_OPERAND_CDB : |
ac188222 DB |
1218 | value = fields->f_cdb; |
1219 | break; | |
d031aafb | 1220 | case MT_OPERAND_CELL : |
ac188222 DB |
1221 | value = fields->f_cell; |
1222 | break; | |
d031aafb | 1223 | case MT_OPERAND_COLNUM : |
ac188222 DB |
1224 | value = fields->f_colnum; |
1225 | break; | |
d031aafb | 1226 | case MT_OPERAND_CONTNUM : |
ac188222 DB |
1227 | value = fields->f_contnum; |
1228 | break; | |
d031aafb | 1229 | case MT_OPERAND_CR : |
ac188222 DB |
1230 | value = fields->f_cr; |
1231 | break; | |
d031aafb | 1232 | case MT_OPERAND_CTXDISP : |
ac188222 DB |
1233 | value = fields->f_ctxdisp; |
1234 | break; | |
d031aafb | 1235 | case MT_OPERAND_DUP : |
ac188222 DB |
1236 | value = fields->f_dup; |
1237 | break; | |
d031aafb | 1238 | case MT_OPERAND_FBDISP : |
ac188222 DB |
1239 | value = fields->f_fbdisp; |
1240 | break; | |
d031aafb | 1241 | case MT_OPERAND_FBINCR : |
ac188222 DB |
1242 | value = fields->f_fbincr; |
1243 | break; | |
d031aafb | 1244 | case MT_OPERAND_FRDR : |
ac188222 DB |
1245 | value = fields->f_dr; |
1246 | break; | |
d031aafb | 1247 | case MT_OPERAND_FRDRRR : |
ac188222 DB |
1248 | value = fields->f_drrr; |
1249 | break; | |
d031aafb | 1250 | case MT_OPERAND_FRSR1 : |
ac188222 DB |
1251 | value = fields->f_sr1; |
1252 | break; | |
d031aafb | 1253 | case MT_OPERAND_FRSR2 : |
ac188222 DB |
1254 | value = fields->f_sr2; |
1255 | break; | |
d031aafb | 1256 | case MT_OPERAND_ID : |
ac188222 DB |
1257 | value = fields->f_id; |
1258 | break; | |
d031aafb | 1259 | case MT_OPERAND_IMM16 : |
ac188222 DB |
1260 | value = fields->f_imm16s; |
1261 | break; | |
d031aafb | 1262 | case MT_OPERAND_IMM16L : |
6f84a2a6 NS |
1263 | value = fields->f_imm16l; |
1264 | break; | |
d031aafb | 1265 | case MT_OPERAND_IMM16O : |
ac188222 DB |
1266 | value = fields->f_imm16s; |
1267 | break; | |
d031aafb | 1268 | case MT_OPERAND_IMM16Z : |
ac188222 DB |
1269 | value = fields->f_imm16u; |
1270 | break; | |
d031aafb | 1271 | case MT_OPERAND_INCAMT : |
ac188222 DB |
1272 | value = fields->f_incamt; |
1273 | break; | |
d031aafb | 1274 | case MT_OPERAND_INCR : |
ac188222 DB |
1275 | value = fields->f_incr; |
1276 | break; | |
d031aafb | 1277 | case MT_OPERAND_LENGTH : |
ac188222 DB |
1278 | value = fields->f_length; |
1279 | break; | |
d031aafb | 1280 | case MT_OPERAND_LOOPSIZE : |
6f84a2a6 NS |
1281 | value = fields->f_loopo; |
1282 | break; | |
d031aafb | 1283 | case MT_OPERAND_MASK : |
ac188222 DB |
1284 | value = fields->f_mask; |
1285 | break; | |
d031aafb | 1286 | case MT_OPERAND_MASK1 : |
ac188222 DB |
1287 | value = fields->f_mask1; |
1288 | break; | |
d031aafb | 1289 | case MT_OPERAND_MODE : |
ac188222 DB |
1290 | value = fields->f_mode; |
1291 | break; | |
d031aafb | 1292 | case MT_OPERAND_PERM : |
ac188222 DB |
1293 | value = fields->f_perm; |
1294 | break; | |
d031aafb | 1295 | case MT_OPERAND_RBBC : |
ac188222 DB |
1296 | value = fields->f_rbbc; |
1297 | break; | |
d031aafb | 1298 | case MT_OPERAND_RC : |
ac188222 DB |
1299 | value = fields->f_rc; |
1300 | break; | |
d031aafb | 1301 | case MT_OPERAND_RC1 : |
ac188222 DB |
1302 | value = fields->f_rc1; |
1303 | break; | |
d031aafb | 1304 | case MT_OPERAND_RC2 : |
ac188222 DB |
1305 | value = fields->f_rc2; |
1306 | break; | |
d031aafb | 1307 | case MT_OPERAND_RC3 : |
6f84a2a6 NS |
1308 | value = fields->f_rc3; |
1309 | break; | |
d031aafb | 1310 | case MT_OPERAND_RCNUM : |
ac188222 DB |
1311 | value = fields->f_rcnum; |
1312 | break; | |
d031aafb | 1313 | case MT_OPERAND_RDA : |
ac188222 DB |
1314 | value = fields->f_rda; |
1315 | break; | |
d031aafb | 1316 | case MT_OPERAND_ROWNUM : |
ac188222 DB |
1317 | value = fields->f_rownum; |
1318 | break; | |
d031aafb | 1319 | case MT_OPERAND_ROWNUM1 : |
ac188222 DB |
1320 | value = fields->f_rownum1; |
1321 | break; | |
d031aafb | 1322 | case MT_OPERAND_ROWNUM2 : |
ac188222 DB |
1323 | value = fields->f_rownum2; |
1324 | break; | |
d031aafb | 1325 | case MT_OPERAND_SIZE : |
ac188222 DB |
1326 | value = fields->f_size; |
1327 | break; | |
d031aafb | 1328 | case MT_OPERAND_TYPE : |
ac188222 DB |
1329 | value = fields->f_type; |
1330 | break; | |
d031aafb | 1331 | case MT_OPERAND_WR : |
ac188222 DB |
1332 | value = fields->f_wr; |
1333 | break; | |
d031aafb | 1334 | case MT_OPERAND_XMODE : |
ac188222 DB |
1335 | value = fields->f_xmode; |
1336 | break; | |
1337 | ||
1338 | default : | |
1339 | /* xgettext:c-format */ | |
1340 | fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), | |
1341 | opindex); | |
1342 | abort (); | |
1343 | } | |
1344 | ||
1345 | return value; | |
1346 | } | |
1347 | ||
d031aafb NS |
1348 | void mt_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); |
1349 | void mt_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); | |
ac188222 DB |
1350 | |
1351 | /* Stuffing values in cgen_fields is handled by a collection of functions. | |
1352 | They are distinguished by the type of the VALUE argument they accept. | |
1353 | TODO: floating point, inlining support, remove cases where argument type | |
1354 | not appropriate. */ | |
1355 | ||
1356 | void | |
d031aafb | 1357 | mt_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
47b0e7ad NC |
1358 | int opindex, |
1359 | CGEN_FIELDS * fields, | |
1360 | int value) | |
ac188222 DB |
1361 | { |
1362 | switch (opindex) | |
1363 | { | |
d031aafb | 1364 | case MT_OPERAND_A23 : |
ac188222 DB |
1365 | fields->f_a23 = value; |
1366 | break; | |
d031aafb | 1367 | case MT_OPERAND_BALL : |
ac188222 DB |
1368 | fields->f_ball = value; |
1369 | break; | |
d031aafb | 1370 | case MT_OPERAND_BALL2 : |
ac188222 DB |
1371 | fields->f_ball2 = value; |
1372 | break; | |
d031aafb | 1373 | case MT_OPERAND_BANKADDR : |
ac188222 DB |
1374 | fields->f_bankaddr = value; |
1375 | break; | |
d031aafb | 1376 | case MT_OPERAND_BRC : |
ac188222 DB |
1377 | fields->f_brc = value; |
1378 | break; | |
d031aafb | 1379 | case MT_OPERAND_BRC2 : |
ac188222 DB |
1380 | fields->f_brc2 = value; |
1381 | break; | |
d031aafb | 1382 | case MT_OPERAND_CB1INCR : |
6f84a2a6 NS |
1383 | fields->f_cb1incr = value; |
1384 | break; | |
d031aafb | 1385 | case MT_OPERAND_CB1SEL : |
6f84a2a6 NS |
1386 | fields->f_cb1sel = value; |
1387 | break; | |
d031aafb | 1388 | case MT_OPERAND_CB2INCR : |
6f84a2a6 NS |
1389 | fields->f_cb2incr = value; |
1390 | break; | |
d031aafb | 1391 | case MT_OPERAND_CB2SEL : |
6f84a2a6 NS |
1392 | fields->f_cb2sel = value; |
1393 | break; | |
d031aafb | 1394 | case MT_OPERAND_CBRB : |
ac188222 DB |
1395 | fields->f_cbrb = value; |
1396 | break; | |
d031aafb | 1397 | case MT_OPERAND_CBS : |
ac188222 DB |
1398 | fields->f_cbs = value; |
1399 | break; | |
d031aafb | 1400 | case MT_OPERAND_CBX : |
ac188222 DB |
1401 | fields->f_cbx = value; |
1402 | break; | |
d031aafb | 1403 | case MT_OPERAND_CCB : |
ac188222 DB |
1404 | fields->f_ccb = value; |
1405 | break; | |
d031aafb | 1406 | case MT_OPERAND_CDB : |
ac188222 DB |
1407 | fields->f_cdb = value; |
1408 | break; | |
d031aafb | 1409 | case MT_OPERAND_CELL : |
ac188222 DB |
1410 | fields->f_cell = value; |
1411 | break; | |
d031aafb | 1412 | case MT_OPERAND_COLNUM : |
ac188222 DB |
1413 | fields->f_colnum = value; |
1414 | break; | |
d031aafb | 1415 | case MT_OPERAND_CONTNUM : |
ac188222 DB |
1416 | fields->f_contnum = value; |
1417 | break; | |
d031aafb | 1418 | case MT_OPERAND_CR : |
ac188222 DB |
1419 | fields->f_cr = value; |
1420 | break; | |
d031aafb | 1421 | case MT_OPERAND_CTXDISP : |
ac188222 DB |
1422 | fields->f_ctxdisp = value; |
1423 | break; | |
d031aafb | 1424 | case MT_OPERAND_DUP : |
ac188222 DB |
1425 | fields->f_dup = value; |
1426 | break; | |
d031aafb | 1427 | case MT_OPERAND_FBDISP : |
ac188222 DB |
1428 | fields->f_fbdisp = value; |
1429 | break; | |
d031aafb | 1430 | case MT_OPERAND_FBINCR : |
ac188222 DB |
1431 | fields->f_fbincr = value; |
1432 | break; | |
d031aafb | 1433 | case MT_OPERAND_FRDR : |
ac188222 DB |
1434 | fields->f_dr = value; |
1435 | break; | |
d031aafb | 1436 | case MT_OPERAND_FRDRRR : |
ac188222 DB |
1437 | fields->f_drrr = value; |
1438 | break; | |
d031aafb | 1439 | case MT_OPERAND_FRSR1 : |
ac188222 DB |
1440 | fields->f_sr1 = value; |
1441 | break; | |
d031aafb | 1442 | case MT_OPERAND_FRSR2 : |
ac188222 DB |
1443 | fields->f_sr2 = value; |
1444 | break; | |
d031aafb | 1445 | case MT_OPERAND_ID : |
ac188222 DB |
1446 | fields->f_id = value; |
1447 | break; | |
d031aafb | 1448 | case MT_OPERAND_IMM16 : |
ac188222 DB |
1449 | fields->f_imm16s = value; |
1450 | break; | |
d031aafb | 1451 | case MT_OPERAND_IMM16L : |
6f84a2a6 NS |
1452 | fields->f_imm16l = value; |
1453 | break; | |
d031aafb | 1454 | case MT_OPERAND_IMM16O : |
ac188222 DB |
1455 | fields->f_imm16s = value; |
1456 | break; | |
d031aafb | 1457 | case MT_OPERAND_IMM16Z : |
ac188222 DB |
1458 | fields->f_imm16u = value; |
1459 | break; | |
d031aafb | 1460 | case MT_OPERAND_INCAMT : |
ac188222 DB |
1461 | fields->f_incamt = value; |
1462 | break; | |
d031aafb | 1463 | case MT_OPERAND_INCR : |
ac188222 DB |
1464 | fields->f_incr = value; |
1465 | break; | |
d031aafb | 1466 | case MT_OPERAND_LENGTH : |
ac188222 DB |
1467 | fields->f_length = value; |
1468 | break; | |
d031aafb | 1469 | case MT_OPERAND_LOOPSIZE : |
6f84a2a6 NS |
1470 | fields->f_loopo = value; |
1471 | break; | |
d031aafb | 1472 | case MT_OPERAND_MASK : |
ac188222 DB |
1473 | fields->f_mask = value; |
1474 | break; | |
d031aafb | 1475 | case MT_OPERAND_MASK1 : |
ac188222 DB |
1476 | fields->f_mask1 = value; |
1477 | break; | |
d031aafb | 1478 | case MT_OPERAND_MODE : |
ac188222 DB |
1479 | fields->f_mode = value; |
1480 | break; | |
d031aafb | 1481 | case MT_OPERAND_PERM : |
ac188222 DB |
1482 | fields->f_perm = value; |
1483 | break; | |
d031aafb | 1484 | case MT_OPERAND_RBBC : |
ac188222 DB |
1485 | fields->f_rbbc = value; |
1486 | break; | |
d031aafb | 1487 | case MT_OPERAND_RC : |
ac188222 DB |
1488 | fields->f_rc = value; |
1489 | break; | |
d031aafb | 1490 | case MT_OPERAND_RC1 : |
ac188222 DB |
1491 | fields->f_rc1 = value; |
1492 | break; | |
d031aafb | 1493 | case MT_OPERAND_RC2 : |
ac188222 DB |
1494 | fields->f_rc2 = value; |
1495 | break; | |
d031aafb | 1496 | case MT_OPERAND_RC3 : |
6f84a2a6 NS |
1497 | fields->f_rc3 = value; |
1498 | break; | |
d031aafb | 1499 | case MT_OPERAND_RCNUM : |
ac188222 DB |
1500 | fields->f_rcnum = value; |
1501 | break; | |
d031aafb | 1502 | case MT_OPERAND_RDA : |
ac188222 DB |
1503 | fields->f_rda = value; |
1504 | break; | |
d031aafb | 1505 | case MT_OPERAND_ROWNUM : |
ac188222 DB |
1506 | fields->f_rownum = value; |
1507 | break; | |
d031aafb | 1508 | case MT_OPERAND_ROWNUM1 : |
ac188222 DB |
1509 | fields->f_rownum1 = value; |
1510 | break; | |
d031aafb | 1511 | case MT_OPERAND_ROWNUM2 : |
ac188222 DB |
1512 | fields->f_rownum2 = value; |
1513 | break; | |
d031aafb | 1514 | case MT_OPERAND_SIZE : |
ac188222 DB |
1515 | fields->f_size = value; |
1516 | break; | |
d031aafb | 1517 | case MT_OPERAND_TYPE : |
ac188222 DB |
1518 | fields->f_type = value; |
1519 | break; | |
d031aafb | 1520 | case MT_OPERAND_WR : |
ac188222 DB |
1521 | fields->f_wr = value; |
1522 | break; | |
d031aafb | 1523 | case MT_OPERAND_XMODE : |
ac188222 DB |
1524 | fields->f_xmode = value; |
1525 | break; | |
1526 | ||
1527 | default : | |
1528 | /* xgettext:c-format */ | |
1529 | fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), | |
1530 | opindex); | |
1531 | abort (); | |
1532 | } | |
1533 | } | |
1534 | ||
1535 | void | |
d031aafb | 1536 | mt_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
47b0e7ad NC |
1537 | int opindex, |
1538 | CGEN_FIELDS * fields, | |
1539 | bfd_vma value) | |
ac188222 DB |
1540 | { |
1541 | switch (opindex) | |
1542 | { | |
d031aafb | 1543 | case MT_OPERAND_A23 : |
ac188222 DB |
1544 | fields->f_a23 = value; |
1545 | break; | |
d031aafb | 1546 | case MT_OPERAND_BALL : |
ac188222 DB |
1547 | fields->f_ball = value; |
1548 | break; | |
d031aafb | 1549 | case MT_OPERAND_BALL2 : |
ac188222 DB |
1550 | fields->f_ball2 = value; |
1551 | break; | |
d031aafb | 1552 | case MT_OPERAND_BANKADDR : |
ac188222 DB |
1553 | fields->f_bankaddr = value; |
1554 | break; | |
d031aafb | 1555 | case MT_OPERAND_BRC : |
ac188222 DB |
1556 | fields->f_brc = value; |
1557 | break; | |
d031aafb | 1558 | case MT_OPERAND_BRC2 : |
ac188222 DB |
1559 | fields->f_brc2 = value; |
1560 | break; | |
d031aafb | 1561 | case MT_OPERAND_CB1INCR : |
6f84a2a6 NS |
1562 | fields->f_cb1incr = value; |
1563 | break; | |
d031aafb | 1564 | case MT_OPERAND_CB1SEL : |
6f84a2a6 NS |
1565 | fields->f_cb1sel = value; |
1566 | break; | |
d031aafb | 1567 | case MT_OPERAND_CB2INCR : |
6f84a2a6 NS |
1568 | fields->f_cb2incr = value; |
1569 | break; | |
d031aafb | 1570 | case MT_OPERAND_CB2SEL : |
6f84a2a6 NS |
1571 | fields->f_cb2sel = value; |
1572 | break; | |
d031aafb | 1573 | case MT_OPERAND_CBRB : |
ac188222 DB |
1574 | fields->f_cbrb = value; |
1575 | break; | |
d031aafb | 1576 | case MT_OPERAND_CBS : |
ac188222 DB |
1577 | fields->f_cbs = value; |
1578 | break; | |
d031aafb | 1579 | case MT_OPERAND_CBX : |
ac188222 DB |
1580 | fields->f_cbx = value; |
1581 | break; | |
d031aafb | 1582 | case MT_OPERAND_CCB : |
ac188222 DB |
1583 | fields->f_ccb = value; |
1584 | break; | |
d031aafb | 1585 | case MT_OPERAND_CDB : |
ac188222 DB |
1586 | fields->f_cdb = value; |
1587 | break; | |
d031aafb | 1588 | case MT_OPERAND_CELL : |
ac188222 DB |
1589 | fields->f_cell = value; |
1590 | break; | |
d031aafb | 1591 | case MT_OPERAND_COLNUM : |
ac188222 DB |
1592 | fields->f_colnum = value; |
1593 | break; | |
d031aafb | 1594 | case MT_OPERAND_CONTNUM : |
ac188222 DB |
1595 | fields->f_contnum = value; |
1596 | break; | |
d031aafb | 1597 | case MT_OPERAND_CR : |
ac188222 DB |
1598 | fields->f_cr = value; |
1599 | break; | |
d031aafb | 1600 | case MT_OPERAND_CTXDISP : |
ac188222 DB |
1601 | fields->f_ctxdisp = value; |
1602 | break; | |
d031aafb | 1603 | case MT_OPERAND_DUP : |
ac188222 DB |
1604 | fields->f_dup = value; |
1605 | break; | |
d031aafb | 1606 | case MT_OPERAND_FBDISP : |
ac188222 DB |
1607 | fields->f_fbdisp = value; |
1608 | break; | |
d031aafb | 1609 | case MT_OPERAND_FBINCR : |
ac188222 DB |
1610 | fields->f_fbincr = value; |
1611 | break; | |
d031aafb | 1612 | case MT_OPERAND_FRDR : |
ac188222 DB |
1613 | fields->f_dr = value; |
1614 | break; | |
d031aafb | 1615 | case MT_OPERAND_FRDRRR : |
ac188222 DB |
1616 | fields->f_drrr = value; |
1617 | break; | |
d031aafb | 1618 | case MT_OPERAND_FRSR1 : |
ac188222 DB |
1619 | fields->f_sr1 = value; |
1620 | break; | |
d031aafb | 1621 | case MT_OPERAND_FRSR2 : |
ac188222 DB |
1622 | fields->f_sr2 = value; |
1623 | break; | |
d031aafb | 1624 | case MT_OPERAND_ID : |
ac188222 DB |
1625 | fields->f_id = value; |
1626 | break; | |
d031aafb | 1627 | case MT_OPERAND_IMM16 : |
ac188222 DB |
1628 | fields->f_imm16s = value; |
1629 | break; | |
d031aafb | 1630 | case MT_OPERAND_IMM16L : |
6f84a2a6 NS |
1631 | fields->f_imm16l = value; |
1632 | break; | |
d031aafb | 1633 | case MT_OPERAND_IMM16O : |
ac188222 DB |
1634 | fields->f_imm16s = value; |
1635 | break; | |
d031aafb | 1636 | case MT_OPERAND_IMM16Z : |
ac188222 DB |
1637 | fields->f_imm16u = value; |
1638 | break; | |
d031aafb | 1639 | case MT_OPERAND_INCAMT : |
ac188222 DB |
1640 | fields->f_incamt = value; |
1641 | break; | |
d031aafb | 1642 | case MT_OPERAND_INCR : |
ac188222 DB |
1643 | fields->f_incr = value; |
1644 | break; | |
d031aafb | 1645 | case MT_OPERAND_LENGTH : |
ac188222 DB |
1646 | fields->f_length = value; |
1647 | break; | |
d031aafb | 1648 | case MT_OPERAND_LOOPSIZE : |
6f84a2a6 NS |
1649 | fields->f_loopo = value; |
1650 | break; | |
d031aafb | 1651 | case MT_OPERAND_MASK : |
ac188222 DB |
1652 | fields->f_mask = value; |
1653 | break; | |
d031aafb | 1654 | case MT_OPERAND_MASK1 : |
ac188222 DB |
1655 | fields->f_mask1 = value; |
1656 | break; | |
d031aafb | 1657 | case MT_OPERAND_MODE : |
ac188222 DB |
1658 | fields->f_mode = value; |
1659 | break; | |
d031aafb | 1660 | case MT_OPERAND_PERM : |
ac188222 DB |
1661 | fields->f_perm = value; |
1662 | break; | |
d031aafb | 1663 | case MT_OPERAND_RBBC : |
ac188222 DB |
1664 | fields->f_rbbc = value; |
1665 | break; | |
d031aafb | 1666 | case MT_OPERAND_RC : |
ac188222 DB |
1667 | fields->f_rc = value; |
1668 | break; | |
d031aafb | 1669 | case MT_OPERAND_RC1 : |
ac188222 DB |
1670 | fields->f_rc1 = value; |
1671 | break; | |
d031aafb | 1672 | case MT_OPERAND_RC2 : |
ac188222 DB |
1673 | fields->f_rc2 = value; |
1674 | break; | |
d031aafb | 1675 | case MT_OPERAND_RC3 : |
6f84a2a6 NS |
1676 | fields->f_rc3 = value; |
1677 | break; | |
d031aafb | 1678 | case MT_OPERAND_RCNUM : |
ac188222 DB |
1679 | fields->f_rcnum = value; |
1680 | break; | |
d031aafb | 1681 | case MT_OPERAND_RDA : |
ac188222 DB |
1682 | fields->f_rda = value; |
1683 | break; | |
d031aafb | 1684 | case MT_OPERAND_ROWNUM : |
ac188222 DB |
1685 | fields->f_rownum = value; |
1686 | break; | |
d031aafb | 1687 | case MT_OPERAND_ROWNUM1 : |
ac188222 DB |
1688 | fields->f_rownum1 = value; |
1689 | break; | |
d031aafb | 1690 | case MT_OPERAND_ROWNUM2 : |
ac188222 DB |
1691 | fields->f_rownum2 = value; |
1692 | break; | |
d031aafb | 1693 | case MT_OPERAND_SIZE : |
ac188222 DB |
1694 | fields->f_size = value; |
1695 | break; | |
d031aafb | 1696 | case MT_OPERAND_TYPE : |
ac188222 DB |
1697 | fields->f_type = value; |
1698 | break; | |
d031aafb | 1699 | case MT_OPERAND_WR : |
ac188222 DB |
1700 | fields->f_wr = value; |
1701 | break; | |
d031aafb | 1702 | case MT_OPERAND_XMODE : |
ac188222 DB |
1703 | fields->f_xmode = value; |
1704 | break; | |
1705 | ||
1706 | default : | |
1707 | /* xgettext:c-format */ | |
1708 | fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), | |
1709 | opindex); | |
1710 | abort (); | |
1711 | } | |
1712 | } | |
1713 | ||
1714 | /* Function to call before using the instruction builder tables. */ | |
1715 | ||
1716 | void | |
d031aafb | 1717 | mt_cgen_init_ibld_table (CGEN_CPU_DESC cd) |
ac188222 | 1718 | { |
d031aafb NS |
1719 | cd->insert_handlers = & mt_cgen_insert_handlers[0]; |
1720 | cd->extract_handlers = & mt_cgen_extract_handlers[0]; | |
ac188222 | 1721 | |
d031aafb NS |
1722 | cd->insert_operand = mt_cgen_insert_operand; |
1723 | cd->extract_operand = mt_cgen_extract_operand; | |
ac188222 | 1724 | |
d031aafb NS |
1725 | cd->get_int_operand = mt_cgen_get_int_operand; |
1726 | cd->set_int_operand = mt_cgen_set_int_operand; | |
1727 | cd->get_vma_operand = mt_cgen_get_vma_operand; | |
1728 | cd->set_vma_operand = mt_cgen_set_vma_operand; | |
ac188222 | 1729 | } |