aboutsummaryrefslogtreecommitdiff
path: root/opcodes/cgen-opc.in
diff options
context:
space:
mode:
Diffstat (limited to 'opcodes/cgen-opc.in')
-rw-r--r--opcodes/cgen-opc.in98
1 files changed, 15 insertions, 83 deletions
diff --git a/opcodes/cgen-opc.in b/opcodes/cgen-opc.in
index 014d9a3..2bb47a1 100644
--- a/opcodes/cgen-opc.in
+++ b/opcodes/cgen-opc.in
@@ -36,72 +36,7 @@ along with this program; if not, write to the Free Software Foundation, Inc.,
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 *, unsigned long));
-
-/* Cover function to read and properly byteswap an insn value. */
-
-CGEN_INSN_INT
-cgen_get_insn_value (od, buf, length)
- CGEN_OPCODE_DESC od;
- unsigned char *buf;
- int length;
-{
- CGEN_INSN_INT value;
-
- switch (length)
- {
- case 8:
- value = *buf;
- break;
- case 16:
- if (CGEN_OPCODE_INSN_ENDIAN (od) == CGEN_ENDIAN_BIG)
- value = bfd_getb16 (buf);
- else
- value = bfd_getl16 (buf);
- break;
- case 32:
- if (CGEN_OPCODE_INSN_ENDIAN (od) == CGEN_ENDIAN_BIG)
- value = bfd_getb32 (buf);
- else
- value = bfd_getl32 (buf);
- break;
- default:
- abort ();
- }
-
- return value;
-}
-
-/* Cover function to store an insn value properly byteswapped. */
-
-void
-cgen_put_insn_value (od, buf, length, value)
- CGEN_OPCODE_DESC od;
- unsigned char *buf;
- int length;
- CGEN_INSN_INT value;
-{
- switch (length)
- {
- case 8:
- buf[0] = value;
- break;
- case 16:
- if (CGEN_OPCODE_INSN_ENDIAN (od) == CGEN_ENDIAN_BIG)
- bfd_putb16 (value, buf);
- else
- bfd_putl16 (value, buf);
- break;
- case 32:
- if (CGEN_OPCODE_INSN_ENDIAN (od) == CGEN_ENDIAN_BIG)
- bfd_putb32 (value, buf);
- else
- bfd_putl32 (value, buf);
- break;
- default:
- abort ();
- }
-}
+static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT));
/* Look up instruction INSN_VALUE and extract its fields.
INSN, if non-null, is the insn table entry.
@@ -111,7 +46,7 @@ cgen_put_insn_value (od, buf, length, value)
If INSN != NULL, LENGTH must be valid.
ALIAS_P is non-zero if alias insns are to be included in the search.
- The result a pointer to the insn table entry, or NULL if the instruction
+ The result is a pointer to the insn table entry, or NULL if the instruction
wasn't recognized. */
const CGEN_INSN *
@@ -123,9 +58,9 @@ const CGEN_INSN *
CGEN_FIELDS *fields;
int alias_p;
{
- unsigned char buf[16];
+ unsigned char buf[CGEN_MAX_INSN_SIZE];
unsigned char *bufp;
- unsigned int base_insn;
+ CGEN_INSN_INT base_insn;
#if CGEN_INT_INSN_P
CGEN_EXTRACT_INFO *info = NULL;
#else
@@ -133,25 +68,22 @@ const CGEN_INSN *
CGEN_EXTRACT_INFO *info = &ex_info;
#endif
-#if ! CGEN_INT_INSN_P
+#if CGEN_INT_INSN_P
+ cgen_put_insn_value (od, buf, length, insn_value);
+ bufp = buf;
+ base_insn = insn_value; /*???*/
+#else
ex_info.dis_info = NULL;
- ex_info.bytes = insn_value;
+ ex_info.insn_bytes = insn_value;
ex_info.valid = -1;
+ base_insn = cgen_get_insn_value (od, buf, length);
+ bufp = insn_value;
#endif
if (!insn)
{
const CGEN_INSN_LIST *insn_list;
-#if CGEN_INT_INSN_P
- cgen_put_insn_value (od, buf, length, insn_value);
- bufp = buf;
- base_insn = insn_value; /*???*/
-#else
- base_insn = cgen_get_insn_value (od, buf, length);
- bufp = insn_value;
-#endif
-
/* The instructions are stored in hash lists.
Pick the first one and keep trying until we find the right one. */
@@ -166,11 +98,11 @@ const CGEN_INSN *
/* Basic bit mask must be correct. */
/* ??? May wish to allow target to defer this check until the
extract handler. */
- if ((insn_value & CGEN_INSN_MASK (insn)) == CGEN_INSN_VALUE (insn))
+ if ((base_insn & CGEN_INSN_MASK (insn)) == CGEN_INSN_VALUE (insn))
{
/* ??? 0 is passed for `pc' */
int elength = (*CGEN_EXTRACT_FN (insn)) (od, insn, info,
- insn_value, fields,
+ base_insn, fields,
(bfd_vma) 0);
if (elength > 0)
{
@@ -196,7 +128,7 @@ const CGEN_INSN *
abort ();
/* ??? 0 is passed for `pc' */
- length = (*CGEN_EXTRACT_FN (insn)) (od, insn, info, insn_value, fields,
+ length = (*CGEN_EXTRACT_FN (insn)) (od, insn, info, base_insn, fields,
(bfd_vma) 0);
/* Sanity check: must succeed.
Could relax this later if it ever proves useful. */