1 /* Fujitsu FRV opcode support, for GNU Binutils. -*- C -*-
3 Copyright 2003 Free Software Foundation, Inc.
5 Contributed by Red Hat Inc; developed under contract from Fujitsu.
7 This file is part of the GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /* This file is an addendum to frv.cpu. Heavy use of C code isn't
26 appropriate in .cpu files, so it resides here. This especially applies
27 to assembly/disassembly where parsing/printing can be quite involved.
28 Such things aren't really part of the specification of the cpu, per se,
29 so .cpu files provide the general framework and .opc files handle the
30 nitty-gritty details as necessary.
32 Each section is delimited with start and end markers.
34 <arch>-opc.h additions use: "-- opc.h"
35 <arch>-opc.c additions use: "-- opc.c"
36 <arch>-asm.c additions use: "-- asm.c"
37 <arch>-dis.c additions use: "-- dis.c"
38 <arch>-ibd.h additions use: "-- ibd.h"
43 #undef CGEN_DIS_HASH_SIZE
44 #define CGEN_DIS_HASH_SIZE 128
46 #define CGEN_DIS_HASH(buffer, value) (((value) >> 18) & 127)
49 #define FRV_VLIW_SIZE 4 /* fr500 has largest vliw size of 4. */
50 typedef CGEN_ATTR_VALUE_TYPE VLIW_COMBO[FRV_VLIW_SIZE];
55 int constraint_violation;
57 unsigned long elf_flags;
58 CGEN_ATTR_VALUE_TYPE *unit_mapping;
59 VLIW_COMBO *current_vliw;
60 CGEN_ATTR_VALUE_TYPE major[FRV_VLIW_SIZE];
63 int frv_is_branch_major PARAMS ((CGEN_ATTR_VALUE_TYPE, unsigned long));
64 int frv_is_float_major PARAMS ((CGEN_ATTR_VALUE_TYPE, unsigned long));
65 int frv_is_media_major PARAMS ((CGEN_ATTR_VALUE_TYPE, unsigned long));
66 int frv_is_branch_insn PARAMS ((const CGEN_INSN *));
67 int frv_is_float_insn PARAMS ((const CGEN_INSN *));
68 int frv_is_media_insn PARAMS ((const CGEN_INSN *));
69 void frv_vliw_reset PARAMS ((FRV_VLIW *, unsigned long mach, unsigned long elf_flags));
70 int frv_vliw_add_insn PARAMS ((FRV_VLIW *, const CGEN_INSN *));
71 int spr_valid PARAMS ((long));
78 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, CGEN_ATTR_VALUE_TYPE));
80 PARAMS ((VLIW_COMBO *, VLIW_COMBO *, int));
81 static VLIW_COMBO * add_next_to_vliw
82 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
83 static int find_major_in_vliw
84 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
85 static int fr400_check_insn_major_constraints
86 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
87 static int fr500_check_insn_major_constraints
88 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
89 static int check_insn_major_constraints
90 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
93 frv_is_branch_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach)
98 if (major >= FR400_MAJOR_B_1 && major <= FR400_MAJOR_B_6)
99 return 1; /* is a branch */
102 if (major >= FR500_MAJOR_B_1 && major <= FR500_MAJOR_B_6)
103 return 1; /* is a branch */
107 return 0; /* not a branch */
111 frv_is_float_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach)
116 return 0; /* No float insns */
118 if (major >= FR500_MAJOR_F_1 && major <= FR500_MAJOR_F_8)
119 return 1; /* is a float insn */
123 return 0; /* not a branch */
127 frv_is_media_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach)
132 if (major >= FR400_MAJOR_M_1 && major <= FR400_MAJOR_M_2)
133 return 1; /* is a media insn */
136 if (major >= FR500_MAJOR_M_1 && major <= FR500_MAJOR_M_8)
137 return 1; /* is a media insn */
141 return 0; /* not a branch */
145 frv_is_branch_insn (const CGEN_INSN *insn)
147 if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
150 if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
158 frv_is_float_insn (const CGEN_INSN *insn)
160 if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
163 if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
171 frv_is_media_insn (const CGEN_INSN *insn)
173 if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
176 if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
183 /* This table represents the allowable packing for vliw insns for the fr400.
184 The fr400 has only 2 vliw slots. Represent this by not allowing any insns
186 Subsets of any given row are also allowed. */
187 static VLIW_COMBO fr400_allowed_vliw[] =
189 /* slot0 slot1 slot2 slot3 */
190 { UNIT_I0, UNIT_I1, UNIT_NIL, UNIT_NIL },
191 { UNIT_I0, UNIT_FM0, UNIT_NIL, UNIT_NIL },
192 { UNIT_I0, UNIT_B0, UNIT_NIL, UNIT_NIL },
193 { UNIT_FM0, UNIT_FM1, UNIT_NIL, UNIT_NIL },
194 { UNIT_FM0, UNIT_B0, UNIT_NIL, UNIT_NIL },
195 { UNIT_B0, UNIT_NIL, UNIT_NIL, UNIT_NIL },
196 { UNIT_C, UNIT_NIL, UNIT_NIL, UNIT_NIL },
197 { UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL }
200 /* This table represents the allowable packing for vliw insns for the fr500.
201 Subsets of any given row are also allowed. */
202 static VLIW_COMBO fr500_allowed_vliw[] =
204 /* slot0 slot1 slot2 slot3 */
205 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1 },
206 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_B0 },
207 { UNIT_I0, UNIT_FM0, UNIT_FM1, UNIT_B0 },
208 { UNIT_I0, UNIT_FM0, UNIT_B0, UNIT_B1 },
209 { UNIT_I0, UNIT_I1, UNIT_B0, UNIT_B1 },
210 { UNIT_I0, UNIT_B0, UNIT_B1, UNIT_NIL },
211 { UNIT_FM0, UNIT_FM1, UNIT_B0, UNIT_B1 },
212 { UNIT_FM0, UNIT_B0, UNIT_B1, UNIT_NIL },
213 { UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL },
214 { UNIT_C, UNIT_NIL, UNIT_NIL, UNIT_NIL },
215 { UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL }
218 /* Some insns are assigned specialized implementation units which map to
219 different actual implementation units on different machines. These
220 tables perform that mapping. */
221 static CGEN_ATTR_VALUE_TYPE fr400_unit_mapping[] =
223 /* unit in insn actual unit */
230 /* FM01 */ UNIT_FM01,
231 /* B0 */ UNIT_B0, /* branches only in B0 unit. */
235 /* MULT-DIV */ UNIT_I0, /* multiply and divide only in I0 unit. */
236 /* LOAD */ UNIT_I0 /* load only in I0 unit. */
239 static CGEN_ATTR_VALUE_TYPE fr500_unit_mapping[] =
241 /* unit in insn actual unit */
248 /* FM01 */ UNIT_FM01,
253 /* MULT-DIV */ UNIT_I01, /* multiply and divide in I0 or I1 unit. */
254 /* LOAD */ UNIT_I01 /* load in I0 or I1 unit. */
258 frv_vliw_reset (FRV_VLIW *vliw, unsigned long mach, unsigned long elf_flags)
261 vliw->constraint_violation = 0;
263 vliw->elf_flags = elf_flags;
268 vliw->current_vliw = fr400_allowed_vliw;
269 vliw->unit_mapping = fr400_unit_mapping;
272 vliw->current_vliw = fr500_allowed_vliw;
273 vliw->unit_mapping = fr500_unit_mapping;
278 /* Return 1 if unit1 is a match for unit2.
279 Unit1 comes from the insn's UNIT attribute. unit2 comes from one of the
280 *_allowed_vliw tables above. */
282 match_unit (FRV_VLIW *vliw,
283 CGEN_ATTR_VALUE_TYPE unit1, CGEN_ATTR_VALUE_TYPE unit2)
285 /* Map any specialized implementation units to actual ones. */
286 unit1 = vliw->unit_mapping[unit1];
298 /* The 01 versions of these units are within 2 enums of the 0 or 1
300 if (unit1 - unit2 <= 2)
310 /* Return 1 if the vliws match, 0 otherwise. */
313 match_vliw (VLIW_COMBO *vliw1, VLIW_COMBO *vliw2, int vliw_size)
317 for (i = 0; i < vliw_size; ++i)
319 if ((*vliw1)[i] != (*vliw2)[i])
326 /* Find the next vliw vliw in the table that can accomodate the new insn.
327 If one is found then return it. Otherwise return NULL. */
330 add_next_to_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit)
332 int next = vliw->next_slot;
333 VLIW_COMBO *current = vliw->current_vliw;
334 VLIW_COMBO *potential;
337 abort (); /* Should never happen */
339 /* The table is sorted by units allowed within slots, so vliws with
340 identical starting sequences are together. */
344 if (match_unit (vliw, unit, (*potential)[next]))
348 while (match_vliw (potential, current, next));
353 /* Look for the given major insn type in the given vliw. Return 1 if found,
354 return 0 otherwise. */
357 find_major_in_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major)
361 for (i = 0; i < vliw->next_slot; ++i)
362 if (vliw->major[i] == major)
368 /* Check for constraints between the insns in the vliw due to major insn
372 fr400_check_insn_major_constraints (
373 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major
376 /* In the cpu file, all media insns are represented as being allowed in
377 both media units. This makes it easier since this is the case for fr500.
378 Catch the invalid combinations here. Insns of major class FR400_MAJOR_M_2
379 cannot coexist with any other media insn in a vliw. */
382 case FR400_MAJOR_M_2:
383 return ! find_major_in_vliw (vliw, FR400_MAJOR_M_1)
384 && ! find_major_in_vliw (vliw, FR400_MAJOR_M_2);
392 fr500_check_insn_major_constraints (
393 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major
396 /* TODO: A table might be faster for some of the more complex instances
400 case FR500_MAJOR_I_1:
401 case FR500_MAJOR_I_4:
402 case FR500_MAJOR_I_5:
403 case FR500_MAJOR_I_6:
404 case FR500_MAJOR_B_1:
405 case FR500_MAJOR_B_2:
406 case FR500_MAJOR_B_3:
407 case FR500_MAJOR_B_4:
408 case FR500_MAJOR_B_5:
409 case FR500_MAJOR_B_6:
410 case FR500_MAJOR_F_4:
411 case FR500_MAJOR_F_8:
412 case FR500_MAJOR_M_8:
414 case FR500_MAJOR_I_2:
415 /* Cannot coexist with I-3 insn. */
416 return ! find_major_in_vliw (vliw, FR500_MAJOR_I_3);
417 case FR500_MAJOR_I_3:
418 /* Cannot coexist with I-2 insn. */
419 return ! find_major_in_vliw (vliw, FR500_MAJOR_I_2);
420 case FR500_MAJOR_F_1:
421 case FR500_MAJOR_F_2:
422 /* Cannot coexist with F-5, F-6, or M-7 insn. */
423 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
424 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
425 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
426 case FR500_MAJOR_F_3:
427 /* Cannot coexist with F-7, or M-7 insn. */
428 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
429 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
430 case FR500_MAJOR_F_5:
431 /* Cannot coexist with F-1, F-2, F-6, F-7, or M-7 insn. */
432 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
433 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
434 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
435 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
436 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
437 case FR500_MAJOR_F_6:
438 /* Cannot coexist with F-1, F-2, F-5, F-6, or M-7 insn. */
439 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
440 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
441 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
442 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
443 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
444 case FR500_MAJOR_F_7:
445 /* Cannot coexist with F-3, F-5, F-7, or M-7 insn. */
446 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_3)
447 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
448 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
449 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
450 case FR500_MAJOR_M_1:
451 /* Cannot coexist with M-7 insn. */
452 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
453 case FR500_MAJOR_M_2:
454 case FR500_MAJOR_M_3:
455 /* Cannot coexist with M-5, M-6 or M-7 insn. */
456 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
457 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
458 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
459 case FR500_MAJOR_M_4:
460 /* Cannot coexist with M-6 insn. */
461 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_6);
462 case FR500_MAJOR_M_5:
463 /* Cannot coexist with M-2, M-3, M-5, M-6 or M-7 insn. */
464 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
465 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
466 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
467 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
468 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
469 case FR500_MAJOR_M_6:
470 /* Cannot coexist with M-2, M-3, M-4, M-5, M-6 or M-7 insn. */
471 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
472 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
473 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_4)
474 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
475 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
476 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
477 case FR500_MAJOR_M_7:
478 /* Cannot coexist with M-1, M-2, M-3, M-5, M-6 or M-7 insn. */
479 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_1)
480 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
481 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
482 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
483 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
484 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7)
485 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
486 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
487 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_3)
488 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
489 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
490 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_7);
499 check_insn_major_constraints (
500 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major
507 rc = fr400_check_insn_major_constraints (vliw, major);
510 rc = fr500_check_insn_major_constraints (vliw, major);
516 /* Add in insn to the VLIW vliw if possible. Return 0 if successful,
517 non-zero otherwise. */
519 frv_vliw_add_insn (FRV_VLIW *vliw, const CGEN_INSN *insn)
522 CGEN_ATTR_VALUE_TYPE major;
523 CGEN_ATTR_VALUE_TYPE unit;
524 VLIW_COMBO *new_vliw;
526 if (vliw->constraint_violation || CGEN_INSN_INVALID_P (insn))
529 index = vliw->next_slot;
530 if (index >= FRV_VLIW_SIZE)
533 unit = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_UNIT);
534 if (unit == UNIT_NIL)
535 abort (); /* no UNIT specified for this insn in frv.cpu */
537 if (vliw->mach == bfd_mach_fr400)
538 major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR);
540 major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR);
544 /* Any insn can be added to slot 0. */
545 while (! match_unit (vliw, unit, (*vliw->current_vliw)[0]))
546 ++vliw->current_vliw;
547 vliw->major[0] = major;
552 /* If there are already insns in the vliw(s) check to see that
553 this one can be added. Do this by finding an allowable vliw
554 combination that can accept the new insn. */
555 if (! (vliw->elf_flags & EF_FRV_NOPACK))
557 new_vliw = add_next_to_vliw (vliw, unit);
558 if (new_vliw && check_insn_major_constraints (vliw, major))
560 vliw->current_vliw = new_vliw;
561 vliw->major[index] = major;
566 /* The frv machine supports all packing conbinations. If we fail,
567 to add the insn, then it could not be handled as if it was the fr500.
568 Just return as if it was handled ok. */
569 if (vliw->mach == bfd_mach_frv)
573 vliw->constraint_violation = 1;
581 if (regno < 0) return 0;
582 if (regno <= 4095) return 1;
588 static const char * parse_ulo16
589 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
590 static const char * parse_uslo16
591 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
592 static const char * parse_uhi16
593 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
594 static long parse_register_number
595 PARAMS ((const char **));
596 static const char * parse_spr
597 PARAMS ((CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *));
598 static const char * parse_d12
599 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
600 static const char * parse_s12
601 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
602 static const char * parse_u12
603 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
606 parse_ulo16 (cd, strp, opindex, valuep)
610 unsigned long *valuep;
613 enum cgen_parse_operand_result result_type;
616 if (**strp == '#' || **strp == '%')
618 if (strncasecmp (*strp + 1, "lo(", 3) == 0)
621 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_LO16,
622 &result_type, &value);
624 return "missing `)'";
627 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
632 if (strncasecmp (*strp + 1, "gprello(", 8) == 0)
635 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_GPRELLO,
636 &result_type, &value);
638 return "missing ')'";
641 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
647 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
651 parse_uslo16 (cd, strp, opindex, valuep)
655 unsigned long *valuep;
658 enum cgen_parse_operand_result result_type;
661 if (**strp == '#' || **strp == '%')
663 if (strncasecmp (*strp + 1, "lo(", 3) == 0)
666 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_LO16,
667 &result_type, &value);
669 return "missing `)'";
672 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
677 else if (strncasecmp (*strp + 1, "gprello(", 8) == 0)
680 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_GPRELLO,
681 &result_type, &value);
683 return "missing ')'";
686 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
692 return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
696 parse_uhi16 (cd, strp, opindex, valuep)
700 unsigned long *valuep;
703 enum cgen_parse_operand_result result_type;
706 if (**strp == '#' || **strp == '%')
708 if (strncasecmp (*strp + 1, "hi(", 3) == 0)
711 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_HI16,
712 &result_type, &value);
714 return "missing `)'";
717 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
722 else if (strncasecmp (*strp + 1, "gprelhi(", 8) == 0)
725 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_GPRELHI,
726 &result_type, &value);
728 return "missing ')'";
731 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
737 return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
741 parse_register_number (strp)
745 if (**strp < '0' || **strp > '9')
746 return -1; /* error */
748 regno = **strp - '0';
749 for (++*strp; **strp >= '0' && **strp <= '9'; ++*strp)
750 regno = regno * 10 + (**strp - '0');
756 parse_spr (cd, strp, table, valuep)
759 CGEN_KEYWORD * table;
762 const char *save_strp;
765 /* Check for spr index notation. */
766 if (strncasecmp (*strp, "spr[", 4) == 0)
769 regno = parse_register_number (strp);
771 return "missing `]'";
773 if (! spr_valid (regno))
774 return "Special purpose register number is out of range";
780 regno = parse_register_number (strp);
783 if (! spr_valid (regno))
784 return "Special purpose register number is out of range";
790 return cgen_parse_keyword (cd, strp, table, valuep);
794 parse_d12 (cd, strp, opindex, valuep)
801 enum cgen_parse_operand_result result_type;
804 /* Check for small data reference. */
805 if (**strp == '#' || **strp == '%')
807 if (strncasecmp (*strp + 1, "gprel12(", 8) == 0)
810 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_GPREL12,
811 &result_type, &value);
813 return "missing `)'";
819 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
823 parse_s12 (cd, strp, opindex, valuep)
830 enum cgen_parse_operand_result result_type;
833 /* Check for small data reference. */
834 if ((**strp == '#' || **strp == '%')
835 && strncasecmp (*strp + 1, "gprel12(", 8) == 0)
838 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_GPREL12,
839 &result_type, &value);
841 return "missing `)'";
850 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
855 parse_u12 (cd, strp, opindex, valuep)
862 enum cgen_parse_operand_result result_type;
865 /* Check for small data reference. */
866 if ((**strp == '#' || **strp == '%')
867 && strncasecmp (*strp + 1, "gprel12(", 8) == 0)
870 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_GPRELU12,
871 &result_type, &value);
873 return "missing `)'";
882 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
889 static void print_spr
890 PARAMS ((CGEN_CPU_DESC, PTR, CGEN_KEYWORD *, long, unsigned));
892 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int));
894 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int));
897 print_spr (cd, dis_info, names, regno, attrs)
904 /* Use the register index format for any unnamed registers. */
905 if (cgen_keyword_lookup_value (names, regno) == NULL)
907 disassemble_info *info = (disassemble_info *) dis_info;
908 (*info->fprintf_func) (info->stream, "spr[%ld]", regno);
911 print_keyword (cd, dis_info, names, regno, attrs);
915 print_hi (cd, dis_info, value, attrs, pc, length)
916 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
919 unsigned int attrs ATTRIBUTE_UNUSED;
920 bfd_vma pc ATTRIBUTE_UNUSED;
921 int length ATTRIBUTE_UNUSED;
923 disassemble_info *info = (disassemble_info *) dis_info;
925 (*info->fprintf_func) (info->stream, "0x%lx", value);
927 (*info->fprintf_func) (info->stream, "hi(0x%lx)", value);
931 print_lo (cd, dis_info, value, attrs, pc, length)
932 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
935 unsigned int attrs ATTRIBUTE_UNUSED;
936 bfd_vma pc ATTRIBUTE_UNUSED;
937 int length ATTRIBUTE_UNUSED;
939 disassemble_info *info = (disassemble_info *) dis_info;
941 (*info->fprintf_func) (info->stream, "0x%lx", value);
943 (*info->fprintf_func) (info->stream, "lo(0x%lx)", value);