]> Git Repo - binutils.git/blobdiff - opcodes/cgen-opc.in
This commit was generated by cvs2svn to track changes on a CVS vendor
[binutils.git] / opcodes / cgen-opc.in
index 014d9a352221788a18cbf6c55f9a18ff094d86b1..44a187dd80fa5331d72d6cffbeb553e02010b6cf 100644 (file)
@@ -30,78 +30,16 @@ along with this program; if not, write to the Free Software Foundation, Inc.,
 #include "@[email protected]"
 #include "opintl.h"
 
+/* Used by the ifield rtx function.  */
+#define FLD(f) (fields->f)
+
 /* 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 *, 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 +49,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 +61,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 +71,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 +101,12 @@ 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_BASE_MASK (insn))
+                 == CGEN_INSN_BASE_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 +132,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.  */
This page took 0.029582 seconds and 4 git commands to generate.