1 /* Instruction building/extraction support for m32r. -*- C -*-
3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
4 - the resultant file is machine generated, cgen-ibld.in isn't
6 Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
8 This file is part of the GNU Binutils and GDB, the GNU debugger.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation, Inc.,
22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
34 #include "m32r-desc.h"
39 #define min(a,b) ((a) < (b) ? (a) : (b))
41 #define max(a,b) ((a) > (b) ? (a) : (b))
43 /* Used by the ifield rtx function. */
44 #define FLD(f) (fields->f)
46 static const char * insert_normal
47 PARAMS ((CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
48 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR));
49 static const char * insert_insn_normal
50 PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *,
51 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma));
53 static int extract_normal
54 PARAMS ((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 PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
59 CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma));
61 /* Operand insertion. */
65 /* Subroutine of insert_normal. */
67 static CGEN_INLINE void
68 insert_1 (cd, value, start, length, word_length, bufp)
71 int start,length,word_length;
76 int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
85 x = bfd_getb16 (bufp);
87 x = bfd_getl16 (bufp);
90 /* ??? This may need reworking as these cases don't necessarily
91 want the first byte and the last two bytes handled like this. */
93 x = (bufp[0] << 16) | bfd_getb16 (bufp + 1);
95 x = bfd_getl16 (bufp) | (bufp[2] << 16);
99 x = bfd_getb32 (bufp);
101 x = bfd_getl32 (bufp);
107 /* Written this way to avoid undefined behaviour. */
108 mask = (((1L << (length - 1)) - 1) << 1) | 1;
109 if (CGEN_INSN_LSB0_P)
110 shift = (start + 1) - length;
112 shift = (word_length - (start + length));
113 x = (x & ~(mask << shift)) | ((value & mask) << shift);
122 bfd_putb16 (x, bufp);
124 bfd_putl16 (x, bufp);
127 /* ??? This may need reworking as these cases don't necessarily
128 want the first byte and the last two bytes handled like this. */
132 bfd_putb16 (x, bufp + 1);
136 bfd_putl16 (x, bufp);
142 bfd_putb32 (x, bufp);
144 bfd_putl32 (x, bufp);
151 #endif /* ! CGEN_INT_INSN_P */
153 /* Default insertion routine.
155 ATTRS is a mask of the boolean attributes.
156 WORD_OFFSET is the offset in bits from the start of the insn of the value.
157 WORD_LENGTH is the length of the word in bits in which the value resides.
158 START is the starting bit number in the word, architecture origin.
159 LENGTH is the length of VALUE in bits.
160 TOTAL_LENGTH is the total length of the insn in bits.
162 The result is an error message or NULL if success. */
164 /* ??? This duplicates functionality with bfd's howto table and
165 bfd_install_relocation. */
166 /* ??? This doesn't handle bfd_vma's. Create another function when
170 insert_normal (cd, value, attrs, word_offset, start, length, word_length,
171 total_length, buffer)
175 unsigned int word_offset, start, length, word_length, total_length;
176 CGEN_INSN_BYTES_PTR buffer;
178 static char errbuf[100];
179 /* Written this way to avoid undefined behaviour. */
180 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
182 /* If LENGTH is zero, this operand doesn't contribute to the value. */
190 if (word_length > 32)
193 /* For architectures with insns smaller than the base-insn-bitsize,
194 word_length may be too big. */
195 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
198 && word_length > total_length)
199 word_length = total_length;
202 /* Ensure VALUE will fit. */
203 if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
205 unsigned long maxval = mask;
207 if ((unsigned long) value > maxval)
209 /* xgettext:c-format */
211 _("operand out of range (%lu not between 0 and %lu)"),
218 if (! cgen_signed_overflow_ok_p (cd))
220 long minval = - (1L << (length - 1));
221 long maxval = (1L << (length - 1)) - 1;
223 if (value < minval || value > maxval)
226 /* xgettext:c-format */
227 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
228 value, minval, maxval);
239 if (CGEN_INSN_LSB0_P)
240 shift = (start + 1) - length;
242 shift = word_length - (start + length);
243 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
246 #else /* ! CGEN_INT_INSN_P */
249 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
251 insert_1 (cd, value, start, length, word_length, bufp);
254 #endif /* ! CGEN_INT_INSN_P */
259 /* Default insn builder (insert handler).
260 The instruction is recorded in CGEN_INT_INSN_P byte order
261 (meaning that if CGEN_INT_INSN_P BUFFER is an int * and thus the value is
262 recorded in host byte order, otherwise BUFFER is an array of bytes and the
263 value is recorded in target byte order).
264 The result is an error message or NULL if success. */
267 insert_insn_normal (cd, insn, fields, buffer, pc)
269 const CGEN_INSN * insn;
270 CGEN_FIELDS * fields;
271 CGEN_INSN_BYTES_PTR buffer;
274 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
276 const unsigned char * syn;
278 CGEN_INIT_INSERT (cd);
279 value = CGEN_INSN_BASE_VALUE (insn);
281 /* If we're recording insns as numbers (rather than a string of bytes),
282 target byte order handling is deferred until later. */
290 cgen_put_insn_value (cd, buffer, min (cd->base_insn_bitsize,
291 CGEN_FIELDS_BITSIZE (fields)),
294 #endif /* ! CGEN_INT_INSN_P */
296 /* ??? It would be better to scan the format's fields.
297 Still need to be able to insert a value based on the operand though;
298 e.g. storing a branch displacement that got resolved later.
299 Needs more thought first. */
301 for (syn = CGEN_SYNTAX_STRING (syntax); * syn != '\0'; ++ syn)
305 if (CGEN_SYNTAX_CHAR_P (* syn))
308 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
317 /* Operand extraction. */
319 #if ! CGEN_INT_INSN_P
321 /* Subroutine of extract_normal.
322 Ensure sufficient bytes are cached in EX_INFO.
323 OFFSET is the offset in bytes from the start of the insn of the value.
324 BYTES is the length of the needed value.
325 Returns 1 for success, 0 for failure. */
327 static CGEN_INLINE int
328 fill_cache (cd, ex_info, offset, bytes, pc)
330 CGEN_EXTRACT_INFO *ex_info;
334 /* It's doubtful that the middle part has already been fetched so
335 we don't optimize that case. kiss. */
337 disassemble_info *info = (disassemble_info *) ex_info->dis_info;
339 /* First do a quick check. */
340 mask = (1 << bytes) - 1;
341 if (((ex_info->valid >> offset) & mask) == mask)
344 /* Search for the first byte we need to read. */
345 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
346 if (! (mask & ex_info->valid))
354 status = (*info->read_memory_func)
355 (pc, ex_info->insn_bytes + offset, bytes, info);
359 (*info->memory_error_func) (status, pc, info);
363 ex_info->valid |= ((1 << bytes) - 1) << offset;
369 /* Subroutine of extract_normal. */
371 static CGEN_INLINE long
372 extract_1 (cd, ex_info, start, length, word_length, bufp, pc)
374 CGEN_EXTRACT_INFO *ex_info;
375 int start,length,word_length;
379 unsigned long x,mask;
381 int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
390 x = bfd_getb16 (bufp);
392 x = bfd_getl16 (bufp);
395 /* ??? This may need reworking as these cases don't necessarily
396 want the first byte and the last two bytes handled like this. */
398 x = (bufp[0] << 16) | bfd_getb16 (bufp + 1);
400 x = bfd_getl16 (bufp) | (bufp[2] << 16);
404 x = bfd_getb32 (bufp);
406 x = bfd_getl32 (bufp);
412 /* Written this way to avoid undefined behaviour. */
413 mask = (((1L << (length - 1)) - 1) << 1) | 1;
414 if (CGEN_INSN_LSB0_P)
415 shift = (start + 1) - length;
417 shift = (word_length - (start + length));
418 return (x >> shift) & mask;
421 #endif /* ! CGEN_INT_INSN_P */
423 /* Default extraction routine.
425 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
426 or sometimes less for cases like the m32r where the base insn size is 32
427 but some insns are 16 bits.
428 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
429 but for generality we take a bitmask of all of them.
430 WORD_OFFSET is the offset in bits from the start of the insn of the value.
431 WORD_LENGTH is the length of the word in bits in which the value resides.
432 START is the starting bit number in the word, architecture origin.
433 LENGTH is the length of VALUE in bits.
434 TOTAL_LENGTH is the total length of the insn in bits.
436 Returns 1 for success, 0 for failure. */
438 /* ??? The return code isn't properly used. wip. */
440 /* ??? This doesn't handle bfd_vma's. Create another function when
444 extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length,
445 word_length, total_length, pc, valuep)
447 CGEN_EXTRACT_INFO *ex_info;
448 CGEN_INSN_INT insn_value;
450 unsigned int word_offset, start, length, word_length, total_length;
456 /* If LENGTH is zero, this operand doesn't contribute to the value
457 so give it a standard value of zero. */
468 if (word_length > 32)
471 /* For architectures with insns smaller than the insn-base-bitsize,
472 word_length may be too big. */
473 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
476 && word_length > total_length)
477 word_length = total_length;
480 /* Does the value reside in INSN_VALUE? */
482 if (word_offset == 0)
484 /* Written this way to avoid undefined behaviour. */
485 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
487 if (CGEN_INSN_LSB0_P)
488 value = insn_value >> ((start + 1) - length);
490 value = insn_value >> (word_length - (start + length));
493 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
494 && (value & (1L << (length - 1))))
498 #if ! CGEN_INT_INSN_P
502 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
504 if (word_length > 32)
507 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
510 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
513 #endif /* ! CGEN_INT_INSN_P */
520 /* Default insn extractor.
522 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
523 The extracted fields are stored in FIELDS.
524 EX_INFO is used to handle reading variable length insns.
525 Return the length of the insn in bits, or 0 if no match,
526 or -1 if an error occurs fetching data (memory_error_func will have
530 extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc)
532 const CGEN_INSN *insn;
533 CGEN_EXTRACT_INFO *ex_info;
534 CGEN_INSN_INT insn_value;
538 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
539 const unsigned char *syn;
541 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
543 CGEN_INIT_EXTRACT (cd);
545 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
549 if (CGEN_SYNTAX_CHAR_P (*syn))
552 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
553 ex_info, insn_value, fields, pc);
558 /* We recognized and successfully extracted this insn. */
559 return CGEN_INSN_BITSIZE (insn);
562 /* machine generated code added here */
564 /* Main entry point for operand insertion.
566 This function is basically just a big switch statement. Earlier versions
567 used tables to look up the function to use, but
568 - if the table contains both assembler and disassembler functions then
569 the disassembler contains much of the assembler and vice-versa,
570 - there's a lot of inlining possibilities as things grow,
571 - using a switch statement avoids the function call overhead.
573 This function could be moved into `parse_insn_normal', but keeping it
574 separate makes clear the interface between `parse_insn_normal' and each of
575 the handlers. It's also needed by GAS to insert operands that couldn't be
576 resolved during parsing.
580 m32r_cgen_insert_operand (cd, opindex, fields, buffer, pc)
583 CGEN_FIELDS * fields;
584 CGEN_INSN_BYTES_PTR buffer;
587 const char * errmsg = NULL;
588 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
592 case M32R_OPERAND_ACC :
593 errmsg = insert_normal (cd, fields->f_acc, 0, 0, 8, 1, 32, total_length, buffer);
595 case M32R_OPERAND_ACCD :
596 errmsg = insert_normal (cd, fields->f_accd, 0, 0, 4, 2, 32, total_length, buffer);
598 case M32R_OPERAND_ACCS :
599 errmsg = insert_normal (cd, fields->f_accs, 0, 0, 12, 2, 32, total_length, buffer);
601 case M32R_OPERAND_DCR :
602 errmsg = insert_normal (cd, fields->f_r1, 0, 0, 4, 4, 32, total_length, buffer);
604 case M32R_OPERAND_DISP16 :
606 long value = fields->f_disp16;
607 value = ((int) (((value) - (pc))) >> (2));
608 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, buffer);
611 case M32R_OPERAND_DISP24 :
613 long value = fields->f_disp24;
614 value = ((int) (((value) - (pc))) >> (2));
615 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 24, 32, total_length, buffer);
618 case M32R_OPERAND_DISP8 :
620 long value = fields->f_disp8;
621 value = ((int) (((value) - (((pc) & (-4))))) >> (2));
622 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 32, total_length, buffer);
625 case M32R_OPERAND_DR :
626 errmsg = insert_normal (cd, fields->f_r1, 0, 0, 4, 4, 32, total_length, buffer);
628 case M32R_OPERAND_HASH :
630 case M32R_OPERAND_HI16 :
631 errmsg = insert_normal (cd, fields->f_hi16, 0|(1<<CGEN_IFLD_SIGN_OPT), 0, 16, 16, 32, total_length, buffer);
633 case M32R_OPERAND_IMM1 :
635 long value = fields->f_imm1;
636 value = ((value) - (1));
637 errmsg = insert_normal (cd, value, 0, 0, 15, 1, 32, total_length, buffer);
640 case M32R_OPERAND_SCR :
641 errmsg = insert_normal (cd, fields->f_r2, 0, 0, 12, 4, 32, total_length, buffer);
643 case M32R_OPERAND_SIMM16 :
644 errmsg = insert_normal (cd, fields->f_simm16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
646 case M32R_OPERAND_SIMM8 :
647 errmsg = insert_normal (cd, fields->f_simm8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, buffer);
649 case M32R_OPERAND_SLO16 :
650 errmsg = insert_normal (cd, fields->f_simm16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
652 case M32R_OPERAND_SR :
653 errmsg = insert_normal (cd, fields->f_r2, 0, 0, 12, 4, 32, total_length, buffer);
655 case M32R_OPERAND_SRC1 :
656 errmsg = insert_normal (cd, fields->f_r1, 0, 0, 4, 4, 32, total_length, buffer);
658 case M32R_OPERAND_SRC2 :
659 errmsg = insert_normal (cd, fields->f_r2, 0, 0, 12, 4, 32, total_length, buffer);
661 case M32R_OPERAND_UIMM16 :
662 errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 16, 16, 32, total_length, buffer);
664 case M32R_OPERAND_UIMM24 :
665 errmsg = insert_normal (cd, fields->f_uimm24, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 8, 24, 32, total_length, buffer);
667 case M32R_OPERAND_UIMM4 :
668 errmsg = insert_normal (cd, fields->f_uimm4, 0, 0, 12, 4, 32, total_length, buffer);
670 case M32R_OPERAND_UIMM5 :
671 errmsg = insert_normal (cd, fields->f_uimm5, 0, 0, 11, 5, 32, total_length, buffer);
673 case M32R_OPERAND_ULO16 :
674 errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 16, 16, 32, total_length, buffer);
678 /* xgettext:c-format */
679 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
687 /* Main entry point for operand extraction.
688 The result is <= 0 for error, >0 for success.
689 ??? Actual values aren't well defined right now.
691 This function is basically just a big switch statement. Earlier versions
692 used tables to look up the function to use, but
693 - if the table contains both assembler and disassembler functions then
694 the disassembler contains much of the assembler and vice-versa,
695 - there's a lot of inlining possibilities as things grow,
696 - using a switch statement avoids the function call overhead.
698 This function could be moved into `print_insn_normal', but keeping it
699 separate makes clear the interface between `print_insn_normal' and each of
704 m32r_cgen_extract_operand (cd, opindex, ex_info, insn_value, fields, pc)
707 CGEN_EXTRACT_INFO *ex_info;
708 CGEN_INSN_INT insn_value;
709 CGEN_FIELDS * fields;
712 /* Assume success (for those operands that are nops). */
714 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
718 case M32R_OPERAND_ACC :
719 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_acc);
721 case M32R_OPERAND_ACCD :
722 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 2, 32, total_length, pc, & fields->f_accd);
724 case M32R_OPERAND_ACCS :
725 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 2, 32, total_length, pc, & fields->f_accs);
727 case M32R_OPERAND_DCR :
728 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_r1);
730 case M32R_OPERAND_DISP16 :
733 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, pc, & value);
734 value = ((((value) << (2))) + (pc));
735 fields->f_disp16 = value;
738 case M32R_OPERAND_DISP24 :
741 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 24, 32, total_length, pc, & value);
742 value = ((((value) << (2))) + (pc));
743 fields->f_disp24 = value;
746 case M32R_OPERAND_DISP8 :
749 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 32, total_length, pc, & value);
750 value = ((((value) << (2))) + (((pc) & (-4))));
751 fields->f_disp8 = value;
754 case M32R_OPERAND_DR :
755 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_r1);
757 case M32R_OPERAND_HASH :
759 case M32R_OPERAND_HI16 :
760 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGN_OPT), 0, 16, 16, 32, total_length, pc, & fields->f_hi16);
762 case M32R_OPERAND_IMM1 :
765 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & value);
766 value = ((value) + (1));
767 fields->f_imm1 = value;
770 case M32R_OPERAND_SCR :
771 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_r2);
773 case M32R_OPERAND_SIMM16 :
774 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_simm16);
776 case M32R_OPERAND_SIMM8 :
777 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, pc, & fields->f_simm8);
779 case M32R_OPERAND_SLO16 :
780 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_simm16);
782 case M32R_OPERAND_SR :
783 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_r2);
785 case M32R_OPERAND_SRC1 :
786 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_r1);
788 case M32R_OPERAND_SRC2 :
789 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_r2);
791 case M32R_OPERAND_UIMM16 :
792 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_uimm16);
794 case M32R_OPERAND_UIMM24 :
795 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 8, 24, 32, total_length, pc, & fields->f_uimm24);
797 case M32R_OPERAND_UIMM4 :
798 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_uimm4);
800 case M32R_OPERAND_UIMM5 :
801 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 5, 32, total_length, pc, & fields->f_uimm5);
803 case M32R_OPERAND_ULO16 :
804 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_uimm16);
808 /* xgettext:c-format */
809 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
817 cgen_insert_fn * const m32r_cgen_insert_handlers[] =
822 cgen_extract_fn * const m32r_cgen_extract_handlers[] =
827 /* Getting values from cgen_fields is handled by a collection of functions.
828 They are distinguished by the type of the VALUE argument they return.
829 TODO: floating point, inlining support, remove cases where result type
833 m32r_cgen_get_int_operand (cd, opindex, fields)
836 const CGEN_FIELDS * fields;
842 case M32R_OPERAND_ACC :
843 value = fields->f_acc;
845 case M32R_OPERAND_ACCD :
846 value = fields->f_accd;
848 case M32R_OPERAND_ACCS :
849 value = fields->f_accs;
851 case M32R_OPERAND_DCR :
852 value = fields->f_r1;
854 case M32R_OPERAND_DISP16 :
855 value = fields->f_disp16;
857 case M32R_OPERAND_DISP24 :
858 value = fields->f_disp24;
860 case M32R_OPERAND_DISP8 :
861 value = fields->f_disp8;
863 case M32R_OPERAND_DR :
864 value = fields->f_r1;
866 case M32R_OPERAND_HASH :
869 case M32R_OPERAND_HI16 :
870 value = fields->f_hi16;
872 case M32R_OPERAND_IMM1 :
873 value = fields->f_imm1;
875 case M32R_OPERAND_SCR :
876 value = fields->f_r2;
878 case M32R_OPERAND_SIMM16 :
879 value = fields->f_simm16;
881 case M32R_OPERAND_SIMM8 :
882 value = fields->f_simm8;
884 case M32R_OPERAND_SLO16 :
885 value = fields->f_simm16;
887 case M32R_OPERAND_SR :
888 value = fields->f_r2;
890 case M32R_OPERAND_SRC1 :
891 value = fields->f_r1;
893 case M32R_OPERAND_SRC2 :
894 value = fields->f_r2;
896 case M32R_OPERAND_UIMM16 :
897 value = fields->f_uimm16;
899 case M32R_OPERAND_UIMM24 :
900 value = fields->f_uimm24;
902 case M32R_OPERAND_UIMM4 :
903 value = fields->f_uimm4;
905 case M32R_OPERAND_UIMM5 :
906 value = fields->f_uimm5;
908 case M32R_OPERAND_ULO16 :
909 value = fields->f_uimm16;
913 /* xgettext:c-format */
914 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
923 m32r_cgen_get_vma_operand (cd, opindex, fields)
926 const CGEN_FIELDS * fields;
932 case M32R_OPERAND_ACC :
933 value = fields->f_acc;
935 case M32R_OPERAND_ACCD :
936 value = fields->f_accd;
938 case M32R_OPERAND_ACCS :
939 value = fields->f_accs;
941 case M32R_OPERAND_DCR :
942 value = fields->f_r1;
944 case M32R_OPERAND_DISP16 :
945 value = fields->f_disp16;
947 case M32R_OPERAND_DISP24 :
948 value = fields->f_disp24;
950 case M32R_OPERAND_DISP8 :
951 value = fields->f_disp8;
953 case M32R_OPERAND_DR :
954 value = fields->f_r1;
956 case M32R_OPERAND_HASH :
959 case M32R_OPERAND_HI16 :
960 value = fields->f_hi16;
962 case M32R_OPERAND_IMM1 :
963 value = fields->f_imm1;
965 case M32R_OPERAND_SCR :
966 value = fields->f_r2;
968 case M32R_OPERAND_SIMM16 :
969 value = fields->f_simm16;
971 case M32R_OPERAND_SIMM8 :
972 value = fields->f_simm8;
974 case M32R_OPERAND_SLO16 :
975 value = fields->f_simm16;
977 case M32R_OPERAND_SR :
978 value = fields->f_r2;
980 case M32R_OPERAND_SRC1 :
981 value = fields->f_r1;
983 case M32R_OPERAND_SRC2 :
984 value = fields->f_r2;
986 case M32R_OPERAND_UIMM16 :
987 value = fields->f_uimm16;
989 case M32R_OPERAND_UIMM24 :
990 value = fields->f_uimm24;
992 case M32R_OPERAND_UIMM4 :
993 value = fields->f_uimm4;
995 case M32R_OPERAND_UIMM5 :
996 value = fields->f_uimm5;
998 case M32R_OPERAND_ULO16 :
999 value = fields->f_uimm16;
1003 /* xgettext:c-format */
1004 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1012 /* Stuffing values in cgen_fields is handled by a collection of functions.
1013 They are distinguished by the type of the VALUE argument they accept.
1014 TODO: floating point, inlining support, remove cases where argument type
1018 m32r_cgen_set_int_operand (cd, opindex, fields, value)
1021 CGEN_FIELDS * fields;
1026 case M32R_OPERAND_ACC :
1027 fields->f_acc = value;
1029 case M32R_OPERAND_ACCD :
1030 fields->f_accd = value;
1032 case M32R_OPERAND_ACCS :
1033 fields->f_accs = value;
1035 case M32R_OPERAND_DCR :
1036 fields->f_r1 = value;
1038 case M32R_OPERAND_DISP16 :
1039 fields->f_disp16 = value;
1041 case M32R_OPERAND_DISP24 :
1042 fields->f_disp24 = value;
1044 case M32R_OPERAND_DISP8 :
1045 fields->f_disp8 = value;
1047 case M32R_OPERAND_DR :
1048 fields->f_r1 = value;
1050 case M32R_OPERAND_HASH :
1052 case M32R_OPERAND_HI16 :
1053 fields->f_hi16 = value;
1055 case M32R_OPERAND_IMM1 :
1056 fields->f_imm1 = value;
1058 case M32R_OPERAND_SCR :
1059 fields->f_r2 = value;
1061 case M32R_OPERAND_SIMM16 :
1062 fields->f_simm16 = value;
1064 case M32R_OPERAND_SIMM8 :
1065 fields->f_simm8 = value;
1067 case M32R_OPERAND_SLO16 :
1068 fields->f_simm16 = value;
1070 case M32R_OPERAND_SR :
1071 fields->f_r2 = value;
1073 case M32R_OPERAND_SRC1 :
1074 fields->f_r1 = value;
1076 case M32R_OPERAND_SRC2 :
1077 fields->f_r2 = value;
1079 case M32R_OPERAND_UIMM16 :
1080 fields->f_uimm16 = value;
1082 case M32R_OPERAND_UIMM24 :
1083 fields->f_uimm24 = value;
1085 case M32R_OPERAND_UIMM4 :
1086 fields->f_uimm4 = value;
1088 case M32R_OPERAND_UIMM5 :
1089 fields->f_uimm5 = value;
1091 case M32R_OPERAND_ULO16 :
1092 fields->f_uimm16 = value;
1096 /* xgettext:c-format */
1097 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1104 m32r_cgen_set_vma_operand (cd, opindex, fields, value)
1107 CGEN_FIELDS * fields;
1112 case M32R_OPERAND_ACC :
1113 fields->f_acc = value;
1115 case M32R_OPERAND_ACCD :
1116 fields->f_accd = value;
1118 case M32R_OPERAND_ACCS :
1119 fields->f_accs = value;
1121 case M32R_OPERAND_DCR :
1122 fields->f_r1 = value;
1124 case M32R_OPERAND_DISP16 :
1125 fields->f_disp16 = value;
1127 case M32R_OPERAND_DISP24 :
1128 fields->f_disp24 = value;
1130 case M32R_OPERAND_DISP8 :
1131 fields->f_disp8 = value;
1133 case M32R_OPERAND_DR :
1134 fields->f_r1 = value;
1136 case M32R_OPERAND_HASH :
1138 case M32R_OPERAND_HI16 :
1139 fields->f_hi16 = value;
1141 case M32R_OPERAND_IMM1 :
1142 fields->f_imm1 = value;
1144 case M32R_OPERAND_SCR :
1145 fields->f_r2 = value;
1147 case M32R_OPERAND_SIMM16 :
1148 fields->f_simm16 = value;
1150 case M32R_OPERAND_SIMM8 :
1151 fields->f_simm8 = value;
1153 case M32R_OPERAND_SLO16 :
1154 fields->f_simm16 = value;
1156 case M32R_OPERAND_SR :
1157 fields->f_r2 = value;
1159 case M32R_OPERAND_SRC1 :
1160 fields->f_r1 = value;
1162 case M32R_OPERAND_SRC2 :
1163 fields->f_r2 = value;
1165 case M32R_OPERAND_UIMM16 :
1166 fields->f_uimm16 = value;
1168 case M32R_OPERAND_UIMM24 :
1169 fields->f_uimm24 = value;
1171 case M32R_OPERAND_UIMM4 :
1172 fields->f_uimm4 = value;
1174 case M32R_OPERAND_UIMM5 :
1175 fields->f_uimm5 = value;
1177 case M32R_OPERAND_ULO16 :
1178 fields->f_uimm16 = value;
1182 /* xgettext:c-format */
1183 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
1189 /* Function to call before using the instruction builder tables. */
1192 m32r_cgen_init_ibld_table (cd)
1195 cd->insert_handlers = & m32r_cgen_insert_handlers[0];
1196 cd->extract_handlers = & m32r_cgen_extract_handlers[0];
1198 cd->insert_operand = m32r_cgen_insert_operand;
1199 cd->extract_operand = m32r_cgen_extract_operand;
1201 cd->get_int_operand = m32r_cgen_get_int_operand;
1202 cd->set_int_operand = m32r_cgen_set_int_operand;
1203 cd->get_vma_operand = m32r_cgen_get_vma_operand;
1204 cd->set_vma_operand = m32r_cgen_set_vma_operand;