1 /* Fujitsu FRV opcode support, for GNU Binutils. -*- C -*-
3 Copyright 2000, 2001, 2003, 2004 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)
48 /* Allows reason codes to be output when assembler errors occur. */
49 #define CGEN_VERBOSE_ASSEMBLER_ERRORS
52 #define FRV_VLIW_SIZE 8 /* fr550 has largest vliw size of 8. */
53 #define PAD_VLIW_COMBO ,UNIT_NIL,UNIT_NIL,UNIT_NIL,UNIT_NIL
54 typedef CGEN_ATTR_VALUE_TYPE VLIW_COMBO[FRV_VLIW_SIZE];
59 int constraint_violation;
61 unsigned long elf_flags;
62 CGEN_ATTR_VALUE_TYPE *unit_mapping;
63 VLIW_COMBO *current_vliw;
64 CGEN_ATTR_VALUE_TYPE major[FRV_VLIW_SIZE];
65 const CGEN_INSN* insn[FRV_VLIW_SIZE];
68 int frv_is_branch_major PARAMS ((CGEN_ATTR_VALUE_TYPE, unsigned long));
69 int frv_is_float_major PARAMS ((CGEN_ATTR_VALUE_TYPE, unsigned long));
70 int frv_is_media_major PARAMS ((CGEN_ATTR_VALUE_TYPE, unsigned long));
71 int frv_is_branch_insn PARAMS ((const CGEN_INSN *));
72 int frv_is_float_insn PARAMS ((const CGEN_INSN *));
73 int frv_is_media_insn PARAMS ((const CGEN_INSN *));
74 void frv_vliw_reset PARAMS ((FRV_VLIW *, unsigned long mach, unsigned long elf_flags));
75 int frv_vliw_add_insn PARAMS ((FRV_VLIW *, const CGEN_INSN *));
76 int spr_valid PARAMS ((long));
84 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, CGEN_ATTR_VALUE_TYPE));
86 PARAMS ((VLIW_COMBO *, VLIW_COMBO *, int));
87 static VLIW_COMBO * add_next_to_vliw
88 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
89 static int find_major_in_vliw
90 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
91 static int fr400_check_insn_major_constraints
92 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
93 static int fr450_check_insn_major_constraints
94 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
95 static int fr500_check_insn_major_constraints
96 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE));
97 static int fr550_check_insn_major_constraints
98 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, const CGEN_INSN *));
99 static int check_insn_major_constraints
100 PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, const CGEN_INSN *));
103 frv_is_branch_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach)
108 if (major >= FR400_MAJOR_B_1 && major <= FR400_MAJOR_B_6)
109 return 1; /* is a branch */
112 if (major >= FR450_MAJOR_B_1 && major <= FR450_MAJOR_B_6)
113 return 1; /* is a branch */
116 if (major >= FR500_MAJOR_B_1 && major <= FR500_MAJOR_B_6)
117 return 1; /* is a branch */
121 return 0; /* not a branch */
125 frv_is_float_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach)
131 return 0; /* No float insns */
133 if (major >= FR500_MAJOR_F_1 && major <= FR500_MAJOR_F_8)
134 return 1; /* is a float insn */
138 return 0; /* not a branch */
142 frv_is_media_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach)
147 if (major >= FR400_MAJOR_M_1 && major <= FR400_MAJOR_M_2)
148 return 1; /* is a media insn */
151 if (major >= FR450_MAJOR_M_1 && major <= FR450_MAJOR_M_6)
152 return 1; /* is a media insn */
155 if (major >= FR500_MAJOR_M_1 && major <= FR500_MAJOR_M_8)
156 return 1; /* is a media insn */
160 return 0; /* not a branch */
164 frv_is_branch_insn (const CGEN_INSN *insn)
166 if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
169 if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR),
172 if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
180 frv_is_float_insn (const CGEN_INSN *insn)
182 if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
185 if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR),
188 if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
196 frv_is_media_insn (const CGEN_INSN *insn)
198 if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
201 if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR),
204 if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
211 /* This table represents the allowable packing for vliw insns for the fr400.
212 The fr400 has only 2 vliw slots. Represent this by not allowing any insns
214 Subsets of any given row are also allowed. */
215 static VLIW_COMBO fr400_allowed_vliw[] =
217 /* slot0 slot1 slot2 slot3 */
218 { UNIT_I0, UNIT_I1, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
219 { UNIT_I0, UNIT_FM0, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
220 { UNIT_I0, UNIT_B0, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
221 { UNIT_FM0, UNIT_FM1, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
222 { UNIT_FM0, UNIT_B0, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
223 { UNIT_B0, UNIT_NIL, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
224 { UNIT_C, UNIT_NIL, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
225 { UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO }
228 /* This table represents the allowable packing for vliw insns for the fr500.
229 The fr500 has only 4 vliw slots. Represent this by not allowing any insns
231 Subsets of any given row are also allowed. */
232 static VLIW_COMBO fr500_allowed_vliw[] =
234 /* slot0 slot1 slot2 slot3 */
235 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1 PAD_VLIW_COMBO },
236 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_B0 PAD_VLIW_COMBO },
237 { UNIT_I0, UNIT_FM0, UNIT_FM1, UNIT_B0 PAD_VLIW_COMBO },
238 { UNIT_I0, UNIT_FM0, UNIT_B0, UNIT_B1 PAD_VLIW_COMBO },
239 { UNIT_I0, UNIT_I1, UNIT_B0, UNIT_B1 PAD_VLIW_COMBO },
240 { UNIT_I0, UNIT_B0, UNIT_B1, UNIT_NIL PAD_VLIW_COMBO },
241 { UNIT_FM0, UNIT_FM1, UNIT_B0, UNIT_B1 PAD_VLIW_COMBO },
242 { UNIT_FM0, UNIT_B0, UNIT_B1, UNIT_NIL PAD_VLIW_COMBO },
243 { UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
244 { UNIT_C, UNIT_NIL, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO },
245 { UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL PAD_VLIW_COMBO }
248 /* This table represents the allowable packing for vliw insns for the fr550.
249 Subsets of any given row are also allowed. */
250 static VLIW_COMBO fr550_allowed_vliw[] =
252 /* slot0 slot1 slot2 slot3 slot4 slot5 slot6 slot7 */
253 { UNIT_I0, UNIT_I1, UNIT_I2, UNIT_I3, UNIT_B0, UNIT_B1 , UNIT_NIL, UNIT_NIL },
254 { UNIT_I0, UNIT_I1, UNIT_I2, UNIT_B0, UNIT_B1 , UNIT_NIL, UNIT_NIL, UNIT_NIL },
255 { UNIT_I0, UNIT_I1, UNIT_B0, UNIT_B1 , UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
256 { UNIT_I0, UNIT_B0, UNIT_B1 , UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
257 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_I2, UNIT_FM2, UNIT_I3, UNIT_FM3 },
258 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_I2, UNIT_FM2, UNIT_I3, UNIT_B0 },
259 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_I2, UNIT_FM2, UNIT_FM3, UNIT_B0 },
260 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_I2, UNIT_FM2, UNIT_B0, UNIT_B1 },
261 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_I2, UNIT_I3, UNIT_B0, UNIT_B1 },
262 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_I2, UNIT_B0, UNIT_B1, UNIT_NIL },
263 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_FM2, UNIT_FM3, UNIT_B0, UNIT_B1 },
264 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_FM2, UNIT_FM3, UNIT_B0, UNIT_B1 },
265 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_FM2, UNIT_B0, UNIT_B1, UNIT_NIL },
266 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_FM1, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL },
267 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_I2, UNIT_I3, UNIT_B0, UNIT_B1, UNIT_NIL },
268 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_I2, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL },
269 { UNIT_I0, UNIT_FM0, UNIT_I1, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL },
270 { UNIT_I0, UNIT_FM0, UNIT_FM1, UNIT_FM2, UNIT_FM3, UNIT_B0, UNIT_B1, UNIT_NIL },
271 { UNIT_I0, UNIT_FM0, UNIT_FM1, UNIT_FM2, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL },
272 { UNIT_I0, UNIT_FM0, UNIT_FM1, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL },
273 { UNIT_I0, UNIT_FM0, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
274 { UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
275 { UNIT_C, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
276 { UNIT_FM0, UNIT_FM1, UNIT_FM2, UNIT_FM3, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL },
277 { UNIT_FM0, UNIT_FM1, UNIT_FM2, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL },
278 { UNIT_FM0, UNIT_FM1, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
279 { UNIT_FM0, UNIT_B0, UNIT_B1, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL },
280 { UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL, UNIT_NIL }
283 /* Some insns are assigned specialized implementation units which map to
284 different actual implementation units on different machines. These
285 tables perform that mapping. */
286 static CGEN_ATTR_VALUE_TYPE fr400_unit_mapping[] =
288 /* unit in insn actual unit */
293 /* I2 */ UNIT_NIL, /* no I2 or I3 unit */
295 /* IALL */ UNIT_I01, /* only I0 and I1 units */
298 /* FM01 */ UNIT_FM01,
299 /* FM2 */ UNIT_NIL, /* no F2 or M2 units */
300 /* FM3 */ UNIT_NIL, /* no F3 or M3 units */
301 /* FMALL */ UNIT_FM01,/* Only F0,F1,M0,M1 units */
302 /* FMLOW */ UNIT_FM0, /* Only F0,M0 units */
303 /* B0 */ UNIT_B0, /* branches only in B0 unit. */
307 /* MULT-DIV */ UNIT_I0, /* multiply and divide only in I0 unit. */
308 /* IACC */ UNIT_I01, /* iacc multiply in I0 or I1 unit. */
309 /* LOAD */ UNIT_I0, /* load only in I0 unit. */
310 /* STORE */ UNIT_I0, /* store only in I0 unit. */
311 /* SCAN */ UNIT_I0, /* scan only in I0 unit. */
312 /* DCPL */ UNIT_C, /* dcpl only in C unit. */
313 /* MDUALACC */ UNIT_FM0, /* media dual acc insn only in FM0 unit. */
314 /* MDCUTSSI */ UNIT_FM0, /* mdcutssi only in FM0 unit. */
315 /* MCLRACC-1*/ UNIT_FM0 /* mclracc,A==1 insn only in FM0 unit. */
318 /* Some insns are assigned specialized implementation units which map to
319 different actual implementation units on different machines. These
320 tables perform that mapping. */
321 static CGEN_ATTR_VALUE_TYPE fr450_unit_mapping[] =
323 /* unit in insn actual unit */
328 /* I2 */ UNIT_NIL, /* no I2 or I3 unit */
330 /* IALL */ UNIT_I01, /* only I0 and I1 units */
333 /* FM01 */ UNIT_FM01,
334 /* FM2 */ UNIT_NIL, /* no F2 or M2 units */
335 /* FM3 */ UNIT_NIL, /* no F3 or M3 units */
336 /* FMALL */ UNIT_FM01,/* Only F0,F1,M0,M1 units */
337 /* FMLOW */ UNIT_FM0, /* Only F0,M0 units */
338 /* B0 */ UNIT_B0, /* branches only in B0 unit. */
342 /* MULT-DIV */ UNIT_I0, /* multiply and divide only in I0 unit. */
343 /* IACC */ UNIT_I01, /* iacc multiply in I0 or I1 unit. */
344 /* LOAD */ UNIT_I0, /* load only in I0 unit. */
345 /* STORE */ UNIT_I0, /* store only in I0 unit. */
346 /* SCAN */ UNIT_I0, /* scan only in I0 unit. */
347 /* DCPL */ UNIT_I0, /* dcpl only in I0 unit. */
348 /* MDUALACC */ UNIT_FM0, /* media dual acc insn only in FM0 unit. */
349 /* MDCUTSSI */ UNIT_FM01, /* mdcutssi in FM0 or FM1. */
350 /* MCLRACC-1*/ UNIT_FM0 /* mclracc,A==1 insn only in FM0 unit. */
353 static CGEN_ATTR_VALUE_TYPE fr500_unit_mapping[] =
355 /* unit in insn actual unit */
360 /* I2 */ UNIT_NIL, /* no I2 or I3 unit */
362 /* IALL */ UNIT_I01, /* only I0 and I1 units */
365 /* FM01 */ UNIT_FM01,
366 /* FM2 */ UNIT_NIL, /* no F2 or M2 units */
367 /* FM3 */ UNIT_NIL, /* no F3 or M2 units */
368 /* FMALL */ UNIT_FM01,/* Only F0,F1,M0,M1 units */
369 /* FMLOW */ UNIT_FM0, /* Only F0,M0 units */
374 /* MULT-DIV */ UNIT_I01, /* multiply and divide in I0 or I1 unit. */
375 /* IACC */ UNIT_NIL, /* iacc multiply not implemented */
376 /* LOAD */ UNIT_I01, /* load in I0 or I1 unit. */
377 /* STORE */ UNIT_I0, /* store only in I0 unit. */
378 /* SCAN */ UNIT_I01, /* scan in I0 or I1 unit. */
379 /* DCPL */ UNIT_C, /* dcpl only in C unit. */
380 /* MDUALACC */ UNIT_FM0, /* media dual acc insn only in FM0 unit. */
381 /* MDCUTSSI */ UNIT_FM0, /* mdcutssi only in FM0 unit. */
382 /* MCLRACC-1*/ UNIT_FM01 /* mclracc,A==1 in FM0 or FM1 unit. */
385 static CGEN_ATTR_VALUE_TYPE fr550_unit_mapping[] =
387 /* unit in insn actual unit */
394 /* IALL */ UNIT_IALL,
397 /* FM01 */ UNIT_FM01,
400 /* FMALL */ UNIT_FMALL,
401 /* FMLOW */ UNIT_FM01, /* Only F0,F1,M0,M1 units */
406 /* MULT-DIV */ UNIT_I01, /* multiply and divide in I0 or I1 unit. */
407 /* IACC */ UNIT_NIL, /* iacc multiply not implemented. */
408 /* LOAD */ UNIT_I01, /* load in I0 or I1 unit. */
409 /* STORE */ UNIT_I01, /* store in I0 or I1 unit. */
410 /* SCAN */ UNIT_IALL, /* scan in any integer unit. */
411 /* DCPL */ UNIT_I0, /* dcpl only in I0 unit. */
412 /* MDUALACC */ UNIT_FMALL,/* media dual acc insn in all media units */
413 /* MDCUTSSI */ UNIT_FM01, /* mdcutssi in FM0 or FM1 unit. */
414 /* MCLRACC-1*/ UNIT_FM01 /* mclracc,A==1 in FM0 or FM1 unit. */
418 frv_vliw_reset (FRV_VLIW *vliw, unsigned long mach, unsigned long elf_flags)
421 vliw->constraint_violation = 0;
423 vliw->elf_flags = elf_flags;
428 vliw->current_vliw = fr400_allowed_vliw;
429 vliw->unit_mapping = fr400_unit_mapping;
432 vliw->current_vliw = fr400_allowed_vliw;
433 vliw->unit_mapping = fr450_unit_mapping;
436 vliw->current_vliw = fr550_allowed_vliw;
437 vliw->unit_mapping = fr550_unit_mapping;
440 vliw->current_vliw = fr500_allowed_vliw;
441 vliw->unit_mapping = fr500_unit_mapping;
446 /* Return 1 if unit1 is a match for unit2.
447 Unit1 comes from the insn's UNIT attribute. unit2 comes from one of the
448 *_allowed_vliw tables above. */
450 match_unit (FRV_VLIW *vliw,
451 CGEN_ATTR_VALUE_TYPE unit1, CGEN_ATTR_VALUE_TYPE unit2)
453 /* Map any specialized implementation units to actual ones. */
454 unit1 = vliw->unit_mapping[unit1];
466 /* The 01 versions of these units are within 2 enums of the 0 or 1
468 if (unit1 - unit2 <= 2)
473 /* The ALL versions of these units are within 5 enums of the 0, 1, 2 or 3
475 if (unit1 - unit2 <= 5)
485 /* Return 1 if the vliws match, 0 otherwise. */
488 match_vliw (VLIW_COMBO *vliw1, VLIW_COMBO *vliw2, int vliw_size)
492 for (i = 0; i < vliw_size; ++i)
494 if ((*vliw1)[i] != (*vliw2)[i])
501 /* Find the next vliw vliw in the table that can accomodate the new insn.
502 If one is found then return it. Otherwise return NULL. */
505 add_next_to_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit)
507 int next = vliw->next_slot;
508 VLIW_COMBO *current = vliw->current_vliw;
509 VLIW_COMBO *potential;
513 fprintf (stderr, "frv-opc.c line %d: bad vliw->next_slot value.\n",
515 abort (); /* Should never happen */
518 /* The table is sorted by units allowed within slots, so vliws with
519 identical starting sequences are together. */
523 if (match_unit (vliw, unit, (*potential)[next]))
527 while (match_vliw (potential, current, next));
532 /* Look for the given major insn type in the given vliw. Return 1 if found,
533 return 0 otherwise. */
536 find_major_in_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major)
540 for (i = 0; i < vliw->next_slot; ++i)
541 if (vliw->major[i] == major)
547 /* Check for constraints between the insns in the vliw due to major insn
551 fr400_check_insn_major_constraints (
552 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major
555 /* In the cpu file, all media insns are represented as being allowed in
556 both media units. This makes it easier since this is the case for fr500.
557 Catch the invalid combinations here. Insns of major class FR400_MAJOR_M_2
558 cannot coexist with any other media insn in a vliw. */
561 case FR400_MAJOR_M_2:
562 return ! find_major_in_vliw (vliw, FR400_MAJOR_M_1)
563 && ! find_major_in_vliw (vliw, FR400_MAJOR_M_2);
564 case FR400_MAJOR_M_1:
565 return !find_major_in_vliw (vliw, FR400_MAJOR_M_2);
573 fr450_check_insn_major_constraints (
574 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major
577 CGEN_ATTR_VALUE_TYPE other_major;
579 /* Our caller guarantees there's at least one other instruction. */
580 other_major = CGEN_INSN_ATTR_VALUE (vliw->insn[0], CGEN_INSN_FR450_MAJOR);
582 /* (M4, M5) and (M4, M6) are allowed. */
583 if (other_major == FR450_MAJOR_M_4)
584 if (major == FR450_MAJOR_M_5 || major == FR450_MAJOR_M_6)
587 /* Otherwise, instructions in even-numbered media categories cannot be
588 executed in parallel with other media instructions. */
591 case FR450_MAJOR_M_2:
592 case FR450_MAJOR_M_4:
593 case FR450_MAJOR_M_6:
594 return !(other_major >= FR450_MAJOR_M_1
595 && other_major <= FR450_MAJOR_M_6);
597 case FR450_MAJOR_M_1:
598 case FR450_MAJOR_M_3:
599 case FR450_MAJOR_M_5:
600 return !(other_major == FR450_MAJOR_M_2
601 || other_major == FR450_MAJOR_M_4
602 || other_major == FR450_MAJOR_M_6);
611 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit
615 for (i = 0; i < vliw->next_slot; ++i)
616 if (CGEN_INSN_ATTR_VALUE (vliw->insn[i], CGEN_INSN_UNIT) == unit)
619 return 0; /* not found */
624 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major, CGEN_ATTR_VALUE_TYPE slot
629 for (i = 0; i < vliw->next_slot; ++i)
630 if (vliw->major[i] == major && (*vliw->current_vliw)[i] == slot)
637 fr550_find_media_in_vliw (FRV_VLIW *vliw)
641 for (i = 0; i < vliw->next_slot; ++i)
643 if (vliw->major[i] < FR550_MAJOR_M_1 || vliw->major[i] > FR550_MAJOR_M_5)
646 /* Found a media insn, however, MNOP and MCLRACC don't count. */
647 if (CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MNOP
648 || CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MCLRACC_0
649 || CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MCLRACC_1)
652 return 1; /* found one */
659 fr550_find_float_in_vliw (FRV_VLIW *vliw)
663 for (i = 0; i < vliw->next_slot; ++i)
665 if (vliw->major[i] < FR550_MAJOR_F_1 || vliw->major[i] > FR550_MAJOR_F_4)
668 /* Found a floating point insn, however, FNOP doesn't count. */
669 if (CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_FNOP)
672 return 1; /* found one */
679 fr550_check_insn_major_constraints (
680 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major, const CGEN_INSN *insn
683 CGEN_ATTR_VALUE_TYPE unit;
684 CGEN_ATTR_VALUE_TYPE slot = (*vliw->current_vliw)[vliw->next_slot];
688 /* If it's a store, then there must be another store in I1 */
689 unit = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_UNIT);
690 if (unit == UNIT_STORE)
691 return find_unit_in_vliw (vliw, UNIT_STORE);
695 /* Floating point insns other than FNOP in slot f2 or f3 cannot coexist with
697 if (major >= FR550_MAJOR_F_1 && major <= FR550_MAJOR_F_4
698 && CGEN_INSN_NUM (insn) != FRV_INSN_FNOP)
699 return ! fr550_find_media_in_vliw (vliw);
700 /* Media insns other than MNOP in slot m2 or m3 cannot coexist with
701 floating point insns. */
702 if (major >= FR550_MAJOR_M_1 && major <= FR550_MAJOR_M_5
703 && CGEN_INSN_NUM (insn) != FRV_INSN_MNOP)
704 return ! fr550_find_float_in_vliw (vliw);
705 /* F-2 in slot f2 or f3 cannot coexist with F-2 or F-4 in slot f1 or f2
708 if (major == FR550_MAJOR_F_2)
709 return ! find_major_in_slot (vliw, FR550_MAJOR_F_2, slot - (UNIT_FM2 - UNIT_FM0))
710 && ! find_major_in_slot (vliw, FR550_MAJOR_F_4, slot - (UNIT_FM2 - UNIT_FM0));
711 /* M-2 or M-5 in slot m2 or m3 cannot coexist with M-2 in slot m1 or m2
713 if (major == FR550_MAJOR_M_2 || major == FR550_MAJOR_M_5)
714 return ! find_major_in_slot (vliw, FR550_MAJOR_M_2, slot - (UNIT_FM2 - UNIT_FM0));
715 /* M-4 in slot m2 or m3 cannot coexist with M-4 in slot m1 or m2
717 if (major == FR550_MAJOR_M_4)
718 return ! find_major_in_slot (vliw, FR550_MAJOR_M_4, slot - (UNIT_FM2 - UNIT_FM0));
723 return 1; /* all ok */
727 fr500_check_insn_major_constraints (
728 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major
731 /* TODO: A table might be faster for some of the more complex instances
735 case FR500_MAJOR_I_1:
736 case FR500_MAJOR_I_4:
737 case FR500_MAJOR_I_5:
738 case FR500_MAJOR_I_6:
739 case FR500_MAJOR_B_1:
740 case FR500_MAJOR_B_2:
741 case FR500_MAJOR_B_3:
742 case FR500_MAJOR_B_4:
743 case FR500_MAJOR_B_5:
744 case FR500_MAJOR_B_6:
745 case FR500_MAJOR_F_4:
746 case FR500_MAJOR_F_8:
747 case FR500_MAJOR_M_8:
749 case FR500_MAJOR_I_2:
750 /* Cannot coexist with I-3 insn. */
751 return ! find_major_in_vliw (vliw, FR500_MAJOR_I_3);
752 case FR500_MAJOR_I_3:
753 /* Cannot coexist with I-2 insn. */
754 return ! find_major_in_vliw (vliw, FR500_MAJOR_I_2);
755 case FR500_MAJOR_F_1:
756 case FR500_MAJOR_F_2:
757 /* Cannot coexist with F-5, F-6, or M-7 insn. */
758 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
759 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
760 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
761 case FR500_MAJOR_F_3:
762 /* Cannot coexist with F-7, or M-7 insn. */
763 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
764 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
765 case FR500_MAJOR_F_5:
766 /* Cannot coexist with F-1, F-2, F-6, F-7, or M-7 insn. */
767 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
768 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
769 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
770 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
771 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
772 case FR500_MAJOR_F_6:
773 /* Cannot coexist with F-1, F-2, F-5, F-6, or M-7 insn. */
774 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
775 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
776 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
777 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
778 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
779 case FR500_MAJOR_F_7:
780 /* Cannot coexist with F-3, F-5, F-7, or M-7 insn. */
781 return ! find_major_in_vliw (vliw, FR500_MAJOR_F_3)
782 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
783 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
784 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
785 case FR500_MAJOR_M_1:
786 /* Cannot coexist with M-7 insn. */
787 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
788 case FR500_MAJOR_M_2:
789 case FR500_MAJOR_M_3:
790 /* Cannot coexist with M-5, M-6 or M-7 insn. */
791 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
792 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
793 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
794 case FR500_MAJOR_M_4:
795 /* Cannot coexist with M-6 insn. */
796 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_6);
797 case FR500_MAJOR_M_5:
798 /* Cannot coexist with M-2, M-3, M-5, M-6 or M-7 insn. */
799 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
800 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
801 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
802 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
803 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
804 case FR500_MAJOR_M_6:
805 /* Cannot coexist with M-2, M-3, M-4, M-5, M-6 or M-7 insn. */
806 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
807 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
808 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_4)
809 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
810 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
811 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
812 case FR500_MAJOR_M_7:
813 /* Cannot coexist with M-1, M-2, M-3, M-5, M-6 or M-7 insn. */
814 return ! find_major_in_vliw (vliw, FR500_MAJOR_M_1)
815 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
816 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
817 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
818 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
819 && ! find_major_in_vliw (vliw, FR500_MAJOR_M_7)
820 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
821 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
822 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_3)
823 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
824 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
825 && ! find_major_in_vliw (vliw, FR500_MAJOR_F_7);
827 fprintf (stderr, "frv-opc.c, line %d: bad major code, aborting.\n",
836 check_insn_major_constraints (
837 FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major, const CGEN_INSN *insn
844 rc = fr400_check_insn_major_constraints (vliw, major);
847 rc = fr450_check_insn_major_constraints (vliw, major);
850 rc = fr550_check_insn_major_constraints (vliw, major, insn);
853 rc = fr500_check_insn_major_constraints (vliw, major);
859 /* Add in insn to the VLIW vliw if possible. Return 0 if successful,
860 non-zero otherwise. */
862 frv_vliw_add_insn (FRV_VLIW *vliw, const CGEN_INSN *insn)
865 CGEN_ATTR_VALUE_TYPE major;
866 CGEN_ATTR_VALUE_TYPE unit;
867 VLIW_COMBO *new_vliw;
869 if (vliw->constraint_violation || CGEN_INSN_INVALID_P (insn))
872 index = vliw->next_slot;
873 if (index >= FRV_VLIW_SIZE)
876 unit = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_UNIT);
877 if (unit == UNIT_NIL)
879 fprintf (stderr, "frv-opc.c line %d: bad insn unit.\n",
881 abort (); /* no UNIT specified for this insn in frv.cpu */
887 major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR);
890 major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR);
893 major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR550_MAJOR);
896 major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR);
902 /* Any insn can be added to slot 0. */
903 while (! match_unit (vliw, unit, (*vliw->current_vliw)[0]))
904 ++vliw->current_vliw;
905 vliw->major[0] = major;
906 vliw->insn[0] = insn;
911 /* If there are already insns in the vliw(s) check to see that
912 this one can be added. Do this by finding an allowable vliw
913 combination that can accept the new insn. */
914 if (! (vliw->elf_flags & EF_FRV_NOPACK))
916 new_vliw = add_next_to_vliw (vliw, unit);
917 if (new_vliw && check_insn_major_constraints (vliw, major, insn))
919 vliw->current_vliw = new_vliw;
920 vliw->major[index] = major;
921 vliw->insn[index] = insn;
926 /* The frv machine supports all packing conbinations. If we fail,
927 to add the insn, then it could not be handled as if it was the fr500.
928 Just return as if it was handled ok. */
929 if (vliw->mach == bfd_mach_frv)
933 vliw->constraint_violation = 1;
941 if (regno < 0) return 0;
942 if (regno <= 4095) return 1;
948 static const char * parse_ulo16
949 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
950 static const char * parse_uslo16
951 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
952 static const char * parse_uhi16
953 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
954 static long parse_register_number
955 PARAMS ((const char **));
956 static const char * parse_spr
957 PARAMS ((CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *));
958 static const char * parse_d12
959 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
960 static const char * parse_s12
961 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
962 static const char * parse_u12
963 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
964 static const char * parse_even_register
965 PARAMS ((CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *));
966 static const char * parse_A0
967 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
968 static const char * parse_A1
969 PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
970 static const char * parse_A
971 PARAMS ((CGEN_CPU_DESC, const char **, int, long *, long));
973 inline static const char *
974 parse_symbolic_address (CGEN_CPU_DESC cd,
978 enum cgen_parse_operand_result *resultp,
981 enum cgen_parse_operand_result result_type;
982 const char *errmsg = (* cd->parse_operand_fn)
983 (cd, CGEN_PARSE_OPERAND_SYMBOLIC, strp, opindex, opinfo,
984 &result_type, valuep);
987 && result_type != CGEN_PARSE_OPERAND_RESULT_QUEUED)
988 return "symbolic expression required";
991 *resultp = result_type;
997 parse_ldd_annotation (CGEN_CPU_DESC cd,
1003 enum cgen_parse_operand_result result_type;
1006 if (**strp == '#' || **strp == '%')
1008 if (strncasecmp (*strp + 1, "tlsdesc(", 8) == 0)
1011 errmsg = parse_symbolic_address (cd, strp, opindex,
1012 BFD_RELOC_FRV_TLSDESC_RELAX,
1013 &result_type, &value);
1015 return "missing ')'";
1024 while (**strp == ' ' || **strp == '\t')
1028 return "missing `@'";
1036 parse_call_annotation (CGEN_CPU_DESC cd,
1042 enum cgen_parse_operand_result result_type;
1045 if (**strp == '#' || **strp == '%')
1047 if (strncasecmp (*strp + 1, "gettlsoff(", 10) == 0)
1050 errmsg = parse_symbolic_address (cd, strp, opindex,
1051 BFD_RELOC_FRV_GETTLSOFF_RELAX,
1052 &result_type, &value);
1054 return "missing ')'";
1063 while (**strp == ' ' || **strp == '\t')
1067 return "missing `@'";
1075 parse_ld_annotation (CGEN_CPU_DESC cd,
1081 enum cgen_parse_operand_result result_type;
1084 if (**strp == '#' || **strp == '%')
1086 if (strncasecmp (*strp + 1, "tlsoff(", 7) == 0)
1089 errmsg = parse_symbolic_address (cd, strp, opindex,
1090 BFD_RELOC_FRV_TLSOFF_RELAX,
1091 &result_type, &value);
1093 return "missing ')'";
1102 while (**strp == ' ' || **strp == '\t')
1106 return "missing `@'";
1114 parse_ulo16 (cd, strp, opindex, valuep)
1118 unsigned long *valuep;
1121 enum cgen_parse_operand_result result_type;
1124 if (**strp == '#' || **strp == '%')
1126 if (strncasecmp (*strp + 1, "lo(", 3) == 0)
1129 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_LO16,
1130 &result_type, &value);
1132 return "missing `)'";
1135 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
1140 if (strncasecmp (*strp + 1, "gprello(", 8) == 0)
1143 errmsg = parse_symbolic_address (cd, strp, opindex,
1144 BFD_RELOC_FRV_GPRELLO,
1145 &result_type, &value);
1147 return "missing ')'";
1152 else if (strncasecmp (*strp + 1, "gotlo(", 6) == 0)
1155 errmsg = parse_symbolic_address (cd, strp, opindex,
1156 BFD_RELOC_FRV_GOTLO,
1157 &result_type, &value);
1159 return "missing ')'";
1164 else if (strncasecmp (*strp + 1, "gotfuncdesclo(", 14) == 0)
1167 errmsg = parse_symbolic_address (cd, strp, opindex,
1168 BFD_RELOC_FRV_FUNCDESC_GOTLO,
1169 &result_type, &value);
1171 return "missing ')'";
1176 else if (strncasecmp (*strp + 1, "gotofflo(", 9) == 0)
1179 errmsg = parse_symbolic_address (cd, strp, opindex,
1180 BFD_RELOC_FRV_GOTOFFLO,
1181 &result_type, &value);
1183 return "missing ')'";
1188 else if (strncasecmp (*strp + 1, "gotofffuncdesclo(", 17) == 0)
1191 errmsg = parse_symbolic_address (cd, strp, opindex,
1192 BFD_RELOC_FRV_FUNCDESC_GOTOFFLO,
1193 &result_type, &value);
1195 return "missing ')'";
1200 else if (strncasecmp (*strp + 1, "gottlsdesclo(", 13) == 0)
1203 errmsg = parse_symbolic_address (cd, strp, opindex,
1204 BFD_RELOC_FRV_GOTTLSDESCLO,
1205 &result_type, &value);
1207 return "missing ')'";
1212 else if (strncasecmp (*strp + 1, "tlsmofflo(", 10) == 0)
1215 errmsg = parse_symbolic_address (cd, strp, opindex,
1216 BFD_RELOC_FRV_TLSMOFFLO,
1217 &result_type, &value);
1219 return "missing ')'";
1224 else if (strncasecmp (*strp + 1, "gottlsofflo(", 12) == 0)
1227 errmsg = parse_symbolic_address (cd, strp, opindex,
1228 BFD_RELOC_FRV_GOTTLSOFFLO,
1229 &result_type, &value);
1231 return "missing ')'";
1237 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
1241 parse_uslo16 (cd, strp, opindex, valuep)
1245 unsigned long *valuep;
1248 enum cgen_parse_operand_result result_type;
1251 if (**strp == '#' || **strp == '%')
1253 if (strncasecmp (*strp + 1, "lo(", 3) == 0)
1256 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_LO16,
1257 &result_type, &value);
1259 return "missing `)'";
1262 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
1267 else if (strncasecmp (*strp + 1, "gprello(", 8) == 0)
1270 errmsg = parse_symbolic_address (cd, strp, opindex,
1271 BFD_RELOC_FRV_GPRELLO,
1272 &result_type, &value);
1274 return "missing ')'";
1279 else if (strncasecmp (*strp + 1, "gotlo(", 6) == 0)
1282 errmsg = parse_symbolic_address (cd, strp, opindex,
1283 BFD_RELOC_FRV_GOTLO,
1284 &result_type, &value);
1286 return "missing ')'";
1291 else if (strncasecmp (*strp + 1, "gotfuncdesclo(", 14) == 0)
1294 errmsg = parse_symbolic_address (cd, strp, opindex,
1295 BFD_RELOC_FRV_FUNCDESC_GOTLO,
1296 &result_type, &value);
1298 return "missing ')'";
1303 else if (strncasecmp (*strp + 1, "gotofflo(", 9) == 0)
1306 errmsg = parse_symbolic_address (cd, strp, opindex,
1307 BFD_RELOC_FRV_GOTOFFLO,
1308 &result_type, &value);
1310 return "missing ')'";
1315 else if (strncasecmp (*strp + 1, "gotofffuncdesclo(", 17) == 0)
1318 errmsg = parse_symbolic_address (cd, strp, opindex,
1319 BFD_RELOC_FRV_FUNCDESC_GOTOFFLO,
1320 &result_type, &value);
1322 return "missing ')'";
1327 else if (strncasecmp (*strp + 1, "gottlsdesclo(", 13) == 0)
1330 errmsg = parse_symbolic_address (cd, strp, opindex,
1331 BFD_RELOC_FRV_GOTTLSDESCLO,
1332 &result_type, &value);
1334 return "missing ')'";
1339 else if (strncasecmp (*strp + 1, "tlsmofflo(", 10) == 0)
1342 errmsg = parse_symbolic_address (cd, strp, opindex,
1343 BFD_RELOC_FRV_TLSMOFFLO,
1344 &result_type, &value);
1346 return "missing ')'";
1351 else if (strncasecmp (*strp + 1, "gottlsofflo(", 12) == 0)
1354 errmsg = parse_symbolic_address (cd, strp, opindex,
1355 BFD_RELOC_FRV_GOTTLSOFFLO,
1356 &result_type, &value);
1358 return "missing ')'";
1364 return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
1368 parse_uhi16 (cd, strp, opindex, valuep)
1372 unsigned long *valuep;
1375 enum cgen_parse_operand_result result_type;
1378 if (**strp == '#' || **strp == '%')
1380 if (strncasecmp (*strp + 1, "hi(", 3) == 0)
1383 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_HI16,
1384 &result_type, &value);
1386 return "missing `)'";
1389 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
1391 /* If bfd_vma is wider than 32 bits, but we have a sign-
1392 or zero-extension, truncate it. */
1393 if (value >= - ((bfd_vma)1 << 31)
1394 || value <= ((bfd_vma)1 << 31) - (bfd_vma)1)
1395 value &= (((bfd_vma)1 << 16) << 16) - 1;
1401 else if (strncasecmp (*strp + 1, "gprelhi(", 8) == 0)
1404 errmsg = parse_symbolic_address (cd, strp, opindex,
1405 BFD_RELOC_FRV_GPRELHI,
1406 &result_type, &value);
1408 return "missing ')'";
1413 else if (strncasecmp (*strp + 1, "gothi(", 6) == 0)
1416 errmsg = parse_symbolic_address (cd, strp, opindex,
1417 BFD_RELOC_FRV_GOTHI,
1418 &result_type, &value);
1420 return "missing ')'";
1425 else if (strncasecmp (*strp + 1, "gotfuncdeschi(", 14) == 0)
1428 errmsg = parse_symbolic_address (cd, strp, opindex,
1429 BFD_RELOC_FRV_FUNCDESC_GOTHI,
1430 &result_type, &value);
1432 return "missing ')'";
1437 else if (strncasecmp (*strp + 1, "gotoffhi(", 9) == 0)
1440 errmsg = parse_symbolic_address (cd, strp, opindex,
1441 BFD_RELOC_FRV_GOTOFFHI,
1442 &result_type, &value);
1444 return "missing ')'";
1449 else if (strncasecmp (*strp + 1, "gotofffuncdeschi(", 17) == 0)
1452 errmsg = parse_symbolic_address (cd, strp, opindex,
1453 BFD_RELOC_FRV_FUNCDESC_GOTOFFHI,
1454 &result_type, &value);
1456 return "missing ')'";
1461 else if (strncasecmp (*strp + 1, "gottlsdeschi(", 13) == 0)
1464 errmsg = parse_symbolic_address (cd, strp, opindex,
1465 BFD_RELOC_FRV_GOTTLSDESCHI,
1466 &result_type, &value);
1468 return "missing ')'";
1473 else if (strncasecmp (*strp + 1, "tlsmoffhi(", 10) == 0)
1476 errmsg = parse_symbolic_address (cd, strp, opindex,
1477 BFD_RELOC_FRV_TLSMOFFHI,
1478 &result_type, &value);
1480 return "missing ')'";
1485 else if (strncasecmp (*strp + 1, "gottlsoffhi(", 12) == 0)
1488 errmsg = parse_symbolic_address (cd, strp, opindex,
1489 BFD_RELOC_FRV_GOTTLSOFFHI,
1490 &result_type, &value);
1492 return "missing ')'";
1498 return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
1502 parse_register_number (strp)
1506 if (**strp < '0' || **strp > '9')
1507 return -1; /* error */
1509 regno = **strp - '0';
1510 for (++*strp; **strp >= '0' && **strp <= '9'; ++*strp)
1511 regno = regno * 10 + (**strp - '0');
1517 parse_spr (cd, strp, table, valuep)
1520 CGEN_KEYWORD * table;
1523 const char *save_strp;
1526 /* Check for spr index notation. */
1527 if (strncasecmp (*strp, "spr[", 4) == 0)
1530 regno = parse_register_number (strp);
1532 return "missing `]'";
1534 if (! spr_valid (regno))
1535 return "Special purpose register number is out of range";
1541 regno = parse_register_number (strp);
1544 if (! spr_valid (regno))
1545 return "Special purpose register number is out of range";
1551 return cgen_parse_keyword (cd, strp, table, valuep);
1555 parse_d12 (cd, strp, opindex, valuep)
1562 enum cgen_parse_operand_result result_type;
1565 /* Check for small data reference. */
1566 if (**strp == '#' || **strp == '%')
1568 if (strncasecmp (*strp + 1, "gprel12(", 8) == 0)
1571 errmsg = parse_symbolic_address (cd, strp, opindex,
1572 BFD_RELOC_FRV_GPREL12,
1573 &result_type, &value);
1575 return "missing `)'";
1580 else if (strncasecmp (*strp + 1, "got12(", 6) == 0)
1583 errmsg = parse_symbolic_address (cd, strp, opindex,
1584 BFD_RELOC_FRV_GOT12,
1585 &result_type, &value);
1587 return "missing ')'";
1592 else if (strncasecmp (*strp + 1, "gotfuncdesc12(", 14) == 0)
1595 errmsg = parse_symbolic_address (cd, strp, opindex,
1596 BFD_RELOC_FRV_FUNCDESC_GOT12,
1597 &result_type, &value);
1599 return "missing ')'";
1604 else if (strncasecmp (*strp + 1, "gotoff12(", 9) == 0)
1607 errmsg = parse_symbolic_address (cd, strp, opindex,
1608 BFD_RELOC_FRV_GOTOFF12,
1609 &result_type, &value);
1611 return "missing ')'";
1616 else if (strncasecmp (*strp + 1, "gotofffuncdesc12(", 17) == 0)
1619 errmsg = parse_symbolic_address (cd, strp, opindex,
1620 BFD_RELOC_FRV_FUNCDESC_GOTOFF12,
1621 &result_type, &value);
1623 return "missing ')'";
1628 else if (strncasecmp (*strp + 1, "gottlsdesc12(", 13) == 0)
1631 errmsg = parse_symbolic_address (cd, strp, opindex,
1632 BFD_RELOC_FRV_GOTTLSDESC12,
1633 &result_type, &value);
1635 return "missing ')'";
1640 else if (strncasecmp (*strp + 1, "tlsmoff12(", 10) == 0)
1643 errmsg = parse_symbolic_address (cd, strp, opindex,
1644 BFD_RELOC_FRV_TLSMOFF12,
1645 &result_type, &value);
1647 return "missing ')'";
1652 else if (strncasecmp (*strp + 1, "gottlsoff12(", 12) == 0)
1655 errmsg = parse_symbolic_address (cd, strp, opindex,
1656 BFD_RELOC_FRV_GOTTLSOFF12,
1657 &result_type, &value);
1659 return "missing ')'";
1665 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
1669 parse_s12 (cd, strp, opindex, valuep)
1676 enum cgen_parse_operand_result result_type;
1679 /* Check for small data reference. */
1680 if (**strp == '#' || **strp == '%')
1682 if (strncasecmp (*strp + 1, "gprel12(", 8) == 0)
1685 errmsg = parse_symbolic_address (cd, strp, opindex,
1686 BFD_RELOC_FRV_GPREL12,
1687 &result_type, &value);
1689 return "missing `)'";
1694 else if (strncasecmp (*strp + 1, "got12(", 6) == 0)
1697 errmsg = parse_symbolic_address (cd, strp, opindex,
1698 BFD_RELOC_FRV_GOT12,
1699 &result_type, &value);
1701 return "missing ')'";
1706 else if (strncasecmp (*strp + 1, "gotfuncdesc12(", 14) == 0)
1709 errmsg = parse_symbolic_address (cd, strp, opindex,
1710 BFD_RELOC_FRV_FUNCDESC_GOT12,
1711 &result_type, &value);
1713 return "missing ')'";
1718 else if (strncasecmp (*strp + 1, "gotoff12(", 9) == 0)
1721 errmsg = parse_symbolic_address (cd, strp, opindex,
1722 BFD_RELOC_FRV_GOTOFF12,
1723 &result_type, &value);
1725 return "missing ')'";
1730 else if (strncasecmp (*strp + 1, "gotofffuncdesc12(", 17) == 0)
1733 errmsg = parse_symbolic_address (cd, strp, opindex,
1734 BFD_RELOC_FRV_FUNCDESC_GOTOFF12,
1735 &result_type, &value);
1737 return "missing ')'";
1742 else if (strncasecmp (*strp + 1, "gottlsdesc12(", 13) == 0)
1745 errmsg = parse_symbolic_address (cd, strp, opindex,
1746 BFD_RELOC_FRV_GOTTLSDESC12,
1747 &result_type, &value);
1749 return "missing ')'";
1754 else if (strncasecmp (*strp + 1, "tlsmoff12(", 10) == 0)
1757 errmsg = parse_symbolic_address (cd, strp, opindex,
1758 BFD_RELOC_FRV_TLSMOFF12,
1759 &result_type, &value);
1761 return "missing ')'";
1766 else if (strncasecmp (*strp + 1, "gottlsoff12(", 12) == 0)
1769 errmsg = parse_symbolic_address (cd, strp, opindex,
1770 BFD_RELOC_FRV_GOTTLSOFF12,
1771 &result_type, &value);
1773 return "missing ')'";
1782 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
1786 parse_u12 (cd, strp, opindex, valuep)
1793 enum cgen_parse_operand_result result_type;
1796 /* Check for small data reference. */
1797 if ((**strp == '#' || **strp == '%')
1798 && strncasecmp (*strp + 1, "gprel12(", 8) == 0)
1801 errmsg = parse_symbolic_address (cd, strp, opindex,
1802 BFD_RELOC_FRV_GPRELU12,
1803 &result_type, &value);
1805 return "missing `)'";
1814 return cgen_parse_signed_integer (cd, strp, opindex, valuep);
1819 parse_A (cd, strp, opindex, valuep, A)
1831 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
1836 return "Value of A operand must be 0 or 1";
1842 parse_A0 (cd, strp, opindex, valuep)
1848 return parse_A (cd, strp, opindex, valuep, 0);
1852 parse_A1 (cd, strp, opindex, valuep)
1858 return parse_A (cd, strp, opindex, valuep, 1);
1862 parse_even_register (cd, strP, tableP, valueP)
1865 CGEN_KEYWORD * tableP;
1868 const char * errmsg;
1869 const char * saved_star_strP = * strP;
1871 errmsg = cgen_parse_keyword (cd, strP, tableP, valueP);
1873 if (errmsg == NULL && ((* valueP) & 1))
1875 errmsg = _("register number must be even");
1876 * strP = saved_star_strP;
1883 parse_call_label (CGEN_CPU_DESC cd,
1887 enum cgen_parse_operand_result *resultp,
1893 /* Check for small data reference. */
1894 if (opinfo == 0 && (**strp == '#' || **strp == '%'))
1896 if (strncasecmp (*strp + 1, "gettlsoff(", 10) == 0)
1899 errmsg = parse_symbolic_address (cd, strp, opindex,
1900 BFD_RELOC_FRV_GETTLSOFF,
1903 return "missing `)'";
1910 return cgen_parse_address (cd, strp, opindex, opinfo, resultp, valuep);
1916 static void print_spr
1917 PARAMS ((CGEN_CPU_DESC, PTR, CGEN_KEYWORD *, long, unsigned));
1918 static void print_hi
1919 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int));
1920 static void print_lo
1921 PARAMS ((CGEN_CPU_DESC, PTR, long, unsigned, bfd_vma, int));
1924 print_at (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1926 long reloc_ann ATTRIBUTE_UNUSED,
1927 long value ATTRIBUTE_UNUSED,
1928 bfd_vma pc ATTRIBUTE_UNUSED,
1929 int length ATTRIBUTE_UNUSED
1932 disassemble_info *info = (disassemble_info *) dis_info;
1933 (*info->fprintf_func) (info->stream, "@");
1937 print_spr (cd, dis_info, names, regno, attrs)
1940 CGEN_KEYWORD *names;
1944 /* Use the register index format for any unnamed registers. */
1945 if (cgen_keyword_lookup_value (names, regno) == NULL)
1947 disassemble_info *info = (disassemble_info *) dis_info;
1948 (*info->fprintf_func) (info->stream, "spr[%ld]", regno);
1951 print_keyword (cd, dis_info, names, regno, attrs);
1955 print_hi (cd, dis_info, value, attrs, pc, length)
1956 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1959 unsigned int attrs ATTRIBUTE_UNUSED;
1960 bfd_vma pc ATTRIBUTE_UNUSED;
1961 int length ATTRIBUTE_UNUSED;
1963 disassemble_info *info = (disassemble_info *) dis_info;
1965 (*info->fprintf_func) (info->stream, "0x%lx", value);
1967 (*info->fprintf_func) (info->stream, "hi(0x%lx)", value);
1971 print_lo (cd, dis_info, value, attrs, pc, length)
1972 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1975 unsigned int attrs ATTRIBUTE_UNUSED;
1976 bfd_vma pc ATTRIBUTE_UNUSED;
1977 int length ATTRIBUTE_UNUSED;
1979 disassemble_info *info = (disassemble_info *) dis_info;
1981 (*info->fprintf_func) (info->stream, "0x%lx", value);
1983 (*info->fprintf_func) (info->stream, "lo(0x%lx)", value);