diff options
Diffstat (limited to 'opcodes/frv-opc.c')
-rw-r--r-- | opcodes/frv-opc.c | 277 |
1 files changed, 126 insertions, 151 deletions
diff --git a/opcodes/frv-opc.c b/opcodes/frv-opc.c index d88cd7d..293ae61 100644 --- a/opcodes/frv-opc.c +++ b/opcodes/frv-opc.c @@ -34,132 +34,120 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "elf/frv.h" #include <stdio.h> -static int match_unit - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, CGEN_ATTR_VALUE_TYPE)); -static int match_vliw - PARAMS ((VLIW_COMBO *, VLIW_COMBO *, int)); -static VLIW_COMBO * add_next_to_vliw - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE)); -static int find_major_in_vliw - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE)); -static int fr400_check_insn_major_constraints - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE)); -static int fr450_check_insn_major_constraints - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE)); -static int fr500_check_insn_major_constraints - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE)); -static int fr550_check_insn_major_constraints - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, const CGEN_INSN *)); -static int check_insn_major_constraints - PARAMS ((FRV_VLIW *, CGEN_ATTR_VALUE_TYPE, const CGEN_INSN *)); +/* Returns TRUE if {MAJOR,MACH} is a major branch of the FRV + development tree. */ -int +bfd_boolean frv_is_branch_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach) { switch (mach) { case bfd_mach_fr400: if (major >= FR400_MAJOR_B_1 && major <= FR400_MAJOR_B_6) - return 1; /* is a branch */ + return TRUE; break; case bfd_mach_fr450: if (major >= FR450_MAJOR_B_1 && major <= FR450_MAJOR_B_6) - return 1; /* is a branch */ + return TRUE; break; default: if (major >= FR500_MAJOR_B_1 && major <= FR500_MAJOR_B_6) - return 1; /* is a branch */ + return TRUE; break; } - return 0; /* not a branch */ + return FALSE; } -int +/* Returns TRUE if {MAJOR,MACH} supports floating point insns. */ + +bfd_boolean frv_is_float_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach) { switch (mach) { case bfd_mach_fr400: case bfd_mach_fr450: - return 0; /* No float insns */ + return FALSE; default: if (major >= FR500_MAJOR_F_1 && major <= FR500_MAJOR_F_8) - return 1; /* is a float insn */ + return TRUE; break; } - return 0; /* not a branch */ + return FALSE; } -int +/* Returns TRUE if {MAJOR,MACH} supports media insns. */ + +bfd_boolean frv_is_media_major (CGEN_ATTR_VALUE_TYPE major, unsigned long mach) { switch (mach) { case bfd_mach_fr400: if (major >= FR400_MAJOR_M_1 && major <= FR400_MAJOR_M_2) - return 1; /* is a media insn */ + return TRUE; break; case bfd_mach_fr450: if (major >= FR450_MAJOR_M_1 && major <= FR450_MAJOR_M_6) - return 1; /* is a media insn */ + return TRUE; break; default: if (major >= FR500_MAJOR_M_1 && major <= FR500_MAJOR_M_8) - return 1; /* is a media insn */ + return TRUE; break; } - return 0; /* not a branch */ + return FALSE; } -int +bfd_boolean frv_is_branch_insn (const CGEN_INSN *insn) { if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR), bfd_mach_fr400)) - return 1; + return TRUE; if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR), bfd_mach_fr450)) - return 1; + return TRUE; if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR), bfd_mach_fr500)) - return 1; + return TRUE; - return 0; + return FALSE; } -int +bfd_boolean frv_is_float_insn (const CGEN_INSN *insn) { if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR), bfd_mach_fr400)) - return 1; + return TRUE; if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR), bfd_mach_fr450)) - return 1; + return TRUE; if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR), bfd_mach_fr500)) - return 1; + return TRUE; - return 0; + return FALSE; } -int +bfd_boolean frv_is_media_insn (const CGEN_INSN *insn) { if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR), bfd_mach_fr400)) - return 1; + return TRUE; if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR), bfd_mach_fr450)) - return 1; + return TRUE; if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR), bfd_mach_fr500)) - return 1; + return TRUE; - return 0; + return FALSE; } /* This table represents the allowable packing for vliw insns for the fr400. @@ -397,10 +385,10 @@ frv_vliw_reset (FRV_VLIW *vliw, unsigned long mach, unsigned long elf_flags) } } -/* Return 1 if unit1 is a match for unit2. +/* Return TRUE if unit1 is a match for unit2. Unit1 comes from the insn's UNIT attribute. unit2 comes from one of the *_allowed_vliw tables above. */ -static int +static bfd_boolean match_unit (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit1, CGEN_ATTR_VALUE_TYPE unit2) { @@ -408,9 +396,9 @@ match_unit (FRV_VLIW *vliw, unit1 = vliw->unit_mapping[unit1]; if (unit1 == unit2) - return 1; + return TRUE; if (unit1 < unit2) - return 0; + return FALSE; switch (unit1) { @@ -420,36 +408,34 @@ match_unit (FRV_VLIW *vliw, /* The 01 versions of these units are within 2 enums of the 0 or 1 versions. */ if (unit1 - unit2 <= 2) - return 1; + return TRUE; break; case UNIT_IALL: case UNIT_FMALL: /* The ALL versions of these units are within 5 enums of the 0, 1, 2 or 3 versions. */ if (unit1 - unit2 <= 5) - return 1; + return TRUE; break; default: break; } - return 0; + return FALSE; } -/* Return 1 if the vliws match, 0 otherwise. */ +/* Return TRUE if the vliws match, FALSE otherwise. */ -static int +static bfd_boolean match_vliw (VLIW_COMBO *vliw1, VLIW_COMBO *vliw2, int vliw_size) { int i; for (i = 0; i < vliw_size; ++i) - { - if ((*vliw1)[i] != (*vliw2)[i]) - return 0; - } + if ((*vliw1)[i] != (*vliw2)[i]) + return FALSE; - return 1; + return TRUE; } /* Find the next vliw vliw in the table that can accomodate the new insn. @@ -466,7 +452,7 @@ add_next_to_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit) { fprintf (stderr, "frv-opc.c line %d: bad vliw->next_slot value.\n", __LINE__); - abort (); /* Should never happen */ + abort (); /* Should never happen. */ } /* The table is sorted by units allowed within slots, so vliws with @@ -483,28 +469,26 @@ add_next_to_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit) return NULL; } -/* Look for the given major insn type in the given vliw. Return 1 if found, - return 0 otherwise. */ +/* Look for the given major insn type in the given vliw. + Returns TRUE if found, FALSE otherwise. */ -static int +static bfd_boolean find_major_in_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major) { int i; for (i = 0; i < vliw->next_slot; ++i) if (vliw->major[i] == major) - return 1; + return TRUE; - return 0; + return FALSE; } /* Check for constraints between the insns in the vliw due to major insn types. */ -static int -fr400_check_insn_major_constraints ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major -) +static bfd_boolean +fr400_check_insn_major_constraints (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major) { /* In the cpu file, all media insns are represented as being allowed in both media units. This makes it easier since this is the case for fr500. @@ -516,17 +500,15 @@ fr400_check_insn_major_constraints ( return ! find_major_in_vliw (vliw, FR400_MAJOR_M_1) && ! find_major_in_vliw (vliw, FR400_MAJOR_M_2); case FR400_MAJOR_M_1: - return !find_major_in_vliw (vliw, FR400_MAJOR_M_2); + return ! find_major_in_vliw (vliw, FR400_MAJOR_M_2); default: break; } - return 1; + return TRUE; } -static int -fr450_check_insn_major_constraints ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major -) +static bfd_boolean +fr450_check_insn_major_constraints (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major) { CGEN_ATTR_VALUE_TYPE other_major; @@ -536,7 +518,7 @@ fr450_check_insn_major_constraints ( /* (M4, M5) and (M4, M6) are allowed. */ if (other_major == FR450_MAJOR_M_4) if (major == FR450_MAJOR_M_5 || major == FR450_MAJOR_M_6) - return 1; + return TRUE; /* Otherwise, instructions in even-numbered media categories cannot be executed in parallel with other media instructions. */ @@ -556,38 +538,37 @@ fr450_check_insn_major_constraints ( || other_major == FR450_MAJOR_M_6); default: - return 1; + return TRUE; } } -static int -find_unit_in_vliw ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit -) +static bfd_boolean +find_unit_in_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE unit) { int i; + for (i = 0; i < vliw->next_slot; ++i) if (CGEN_INSN_ATTR_VALUE (vliw->insn[i], CGEN_INSN_UNIT) == unit) - return 1; + return TRUE; - return 0; /* not found */ + return FALSE; /* Not found. */ } -static int -find_major_in_slot ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major, CGEN_ATTR_VALUE_TYPE slot -) +static bfd_boolean +find_major_in_slot (FRV_VLIW *vliw, + CGEN_ATTR_VALUE_TYPE major, + CGEN_ATTR_VALUE_TYPE slot) { int i; for (i = 0; i < vliw->next_slot; ++i) if (vliw->major[i] == major && (*vliw->current_vliw)[i] == slot) - return 1; + return TRUE; - return 0; + return FALSE; } -static int +static bfd_boolean fr550_find_media_in_vliw (FRV_VLIW *vliw) { int i; @@ -603,13 +584,13 @@ fr550_find_media_in_vliw (FRV_VLIW *vliw) || CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MCLRACC_1) continue; - return 1; /* found one */ + return TRUE; /* Found one. */ } - return 0; + return FALSE; } -static int +static bfd_boolean fr550_find_float_in_vliw (FRV_VLIW *vliw) { int i; @@ -623,16 +604,16 @@ fr550_find_float_in_vliw (FRV_VLIW *vliw) if (CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_FNOP) continue; - return 1; /* found one */ + return TRUE; /* Found one. */ } - return 0; + return FALSE; } -static int -fr550_check_insn_major_constraints ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major, const CGEN_INSN *insn -) +static bfd_boolean +fr550_check_insn_major_constraints (FRV_VLIW *vliw, + CGEN_ATTR_VALUE_TYPE major, + const CGEN_INSN *insn) { CGEN_ATTR_VALUE_TYPE unit; CGEN_ATTR_VALUE_TYPE slot = (*vliw->current_vliw)[vliw->next_slot]; @@ -646,8 +627,8 @@ fr550_check_insn_major_constraints ( break; case UNIT_FM2: case UNIT_FM3: - /* Floating point insns other than FNOP in slot f2 or f3 cannot coexist with - media insns. */ + /* Floating point insns other than FNOP in slot f2 or f3 cannot coexist + with media insns. */ if (major >= FR550_MAJOR_F_1 && major <= FR550_MAJOR_F_4 && CGEN_INSN_NUM (insn) != FRV_INSN_FNOP) return ! fr550_find_media_in_vliw (vliw); @@ -657,30 +638,31 @@ fr550_check_insn_major_constraints ( && CGEN_INSN_NUM (insn) != FRV_INSN_MNOP) return ! fr550_find_float_in_vliw (vliw); /* F-2 in slot f2 or f3 cannot coexist with F-2 or F-4 in slot f1 or f2 - respectively. - */ + respectively. */ if (major == FR550_MAJOR_F_2) - return ! find_major_in_slot (vliw, FR550_MAJOR_F_2, slot - (UNIT_FM2 - UNIT_FM0)) - && ! find_major_in_slot (vliw, FR550_MAJOR_F_4, slot - (UNIT_FM2 - UNIT_FM0)); + return ! find_major_in_slot (vliw, FR550_MAJOR_F_2, + slot - (UNIT_FM2 - UNIT_FM0)) + && ! find_major_in_slot (vliw, FR550_MAJOR_F_4, + slot - (UNIT_FM2 - UNIT_FM0)); /* M-2 or M-5 in slot m2 or m3 cannot coexist with M-2 in slot m1 or m2 respectively. */ if (major == FR550_MAJOR_M_2 || major == FR550_MAJOR_M_5) - return ! find_major_in_slot (vliw, FR550_MAJOR_M_2, slot - (UNIT_FM2 - UNIT_FM0)); + return ! find_major_in_slot (vliw, FR550_MAJOR_M_2, + slot - (UNIT_FM2 - UNIT_FM0)); /* M-4 in slot m2 or m3 cannot coexist with M-4 in slot m1 or m2 respectively. */ if (major == FR550_MAJOR_M_4) - return ! find_major_in_slot (vliw, FR550_MAJOR_M_4, slot - (UNIT_FM2 - UNIT_FM0)); + return ! find_major_in_slot (vliw, FR550_MAJOR_M_4, + slot - (UNIT_FM2 - UNIT_FM0)); break; default: break; } - return 1; /* all ok */ + return TRUE; /* All OK. */ } -static int -fr500_check_insn_major_constraints ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major -) +static bfd_boolean +fr500_check_insn_major_constraints (FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major) { /* TODO: A table might be faster for some of the more complex instances here. */ @@ -699,7 +681,7 @@ fr500_check_insn_major_constraints ( case FR500_MAJOR_F_4: case FR500_MAJOR_F_8: case FR500_MAJOR_M_8: - return 1; /* OK */ + return TRUE; /* OK */ case FR500_MAJOR_I_2: /* Cannot coexist with I-3 insn. */ return ! find_major_in_vliw (vliw, FR500_MAJOR_I_3); @@ -783,35 +765,33 @@ fr500_check_insn_major_constraints ( abort (); break; } - return 1; + return TRUE; } -static int -check_insn_major_constraints ( - FRV_VLIW *vliw, CGEN_ATTR_VALUE_TYPE major, const CGEN_INSN *insn -) +static bfd_boolean +check_insn_major_constraints (FRV_VLIW *vliw, + CGEN_ATTR_VALUE_TYPE major, + const CGEN_INSN *insn) { - int rc; switch (vliw->mach) { case bfd_mach_fr400: - rc = fr400_check_insn_major_constraints (vliw, major); - break; + return fr400_check_insn_major_constraints (vliw, major); + case bfd_mach_fr450: - rc = fr450_check_insn_major_constraints (vliw, major); - break; + return fr450_check_insn_major_constraints (vliw, major); + case bfd_mach_fr550: - rc = fr550_check_insn_major_constraints (vliw, major, insn); - break; + return fr550_check_insn_major_constraints (vliw, major, insn); + default: - rc = fr500_check_insn_major_constraints (vliw, major); - break; + return fr500_check_insn_major_constraints (vliw, major); } - return rc; } -/* Add in insn to the VLIW vliw if possible. Return 0 if successful, - non-zero otherwise. */ +/* Add in insn to the VLIW vliw if possible. + Return 0 if successful, non-zero otherwise. */ + int frv_vliw_add_insn (FRV_VLIW *vliw, const CGEN_INSN *insn) { @@ -832,7 +812,7 @@ frv_vliw_add_insn (FRV_VLIW *vliw, const CGEN_INSN *insn) { fprintf (stderr, "frv-opc.c line %d: bad insn unit.\n", __LINE__); - abort (); /* no UNIT specified for this insn in frv.cpu */ + abort (); /* No UNIT specified for this insn in frv.cpu. */ } switch (vliw->mach) @@ -888,22 +868,21 @@ frv_vliw_add_insn (FRV_VLIW *vliw, const CGEN_INSN *insn) return 1; } -int -spr_valid (regno) - long regno; +bfd_boolean +spr_valid (long regno) { - if (regno < 0) return 0; - if (regno <= 4095) return 1; - return 0; + if (regno < 0) return FALSE; + if (regno <= 4095) return TRUE; + return FALSE; } /* -- */ /* The hash functions are recorded here to help keep assembler code out of the disassembler and vice versa. */ -static int asm_hash_insn_p PARAMS ((const CGEN_INSN *)); -static unsigned int asm_hash_insn PARAMS ((const char *)); -static int dis_hash_insn_p PARAMS ((const CGEN_INSN *)); -static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT)); +static int asm_hash_insn_p (const CGEN_INSN *); +static unsigned int asm_hash_insn (const char *); +static int dis_hash_insn_p (const CGEN_INSN *); +static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT); /* Instruction formats. */ @@ -6223,14 +6202,10 @@ dis_hash_insn (buf, value) return CGEN_DIS_HASH (buf, value); } -static void set_fields_bitsize PARAMS ((CGEN_FIELDS *, int)); - /* Set the recorded length of the insn in the CGEN_FIELDS struct. */ static void -set_fields_bitsize (fields, size) - CGEN_FIELDS *fields; - int size; +set_fields_bitsize (CGEN_FIELDS *fields, int size) { CGEN_FIELDS_BITSIZE (fields) = size; } @@ -6239,15 +6214,15 @@ set_fields_bitsize (fields, size) This plugs the opcode entries and macro instructions into the cpu table. */ void -frv_cgen_init_opcode_table (cd) - CGEN_CPU_DESC cd; +frv_cgen_init_opcode_table (CGEN_CPU_DESC cd) { int i; int num_macros = (sizeof (frv_cgen_macro_insn_table) / sizeof (frv_cgen_macro_insn_table[0])); const CGEN_IBASE *ib = & frv_cgen_macro_insn_table[0]; const CGEN_OPCODE *oc = & frv_cgen_macro_insn_opcode_table[0]; - CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN)); + CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN)); + memset (insns, 0, num_macros * sizeof (CGEN_INSN)); for (i = 0; i < num_macros; ++i) { |