Fix autoconf breakage + commit target.c, omitted in previous delta
[deliverable/binutils-gdb.git] / opcodes / cgen-opc.c
index 56840a6a6f9f100706312e9d243313368504962a..7e958e7779a07c34f6f84bc24a2c8b0486e62b15 100644 (file)
@@ -1,6 +1,7 @@
 /* CGEN generic opcode support.
 
-   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils and GDB, the GNU debugger.
 
 #include "symcat.h"
 #include "opcode/cgen.h"
 
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
 static unsigned int hash_keyword_name
   PARAMS ((const CGEN_KEYWORD *, const char *, int));
 static unsigned int hash_keyword_value
@@ -263,7 +268,7 @@ cgen_hw_lookup_by_name (cd, name)
      CGEN_CPU_DESC cd;
      const char *name;
 {
-  int i;
+  unsigned int i;
   const CGEN_HW_ENTRY **hw = cd->hw_table.entries;
 
   for (i = 0; i < cd->hw_table.num_entries; ++i)
@@ -281,9 +286,9 @@ cgen_hw_lookup_by_name (cd, name)
 const CGEN_HW_ENTRY *
 cgen_hw_lookup_by_num (cd, hwnum)
      CGEN_CPU_DESC cd;
-     int hwnum;
+     unsigned int hwnum;
 {
-  int i;
+  unsigned int i;
   const CGEN_HW_ENTRY **hw = cd->hw_table.entries;
 
   /* ??? This can be speeded up.  */
@@ -305,7 +310,7 @@ cgen_operand_lookup_by_name (cd, name)
      CGEN_CPU_DESC cd;
      const char *name;
 {
-  int i;
+  unsigned int i;
   const CGEN_OPERAND **op = cd->operand_table.entries;
 
   for (i = 0; i < cd->operand_table.num_entries; ++i)
@@ -370,30 +375,7 @@ cgen_get_insn_value (cd, buf, length)
      unsigned char *buf;
      int length;
 {
-  CGEN_INSN_INT value;
-
-  switch (length)
-    {
-    case 8:
-      value = *buf;
-      break;
-    case 16:
-      if (cd->insn_endian == CGEN_ENDIAN_BIG)
-       value = bfd_getb16 (buf);
-      else
-       value = bfd_getl16 (buf);
-      break;
-    case 32:
-      if (cd->insn_endian == CGEN_ENDIAN_BIG)
-       value = bfd_getb32 (buf);
-      else
-       value = bfd_getl32 (buf);
-      break;
-    default:
-      abort ();
-    }
-
-  return value;
+  return bfd_get_bits (buf, length, cd->insn_endian == CGEN_ENDIAN_BIG);
 }
 
 /* Cover function to store an insn value properly byteswapped.  */
@@ -405,26 +387,8 @@ cgen_put_insn_value (cd, buf, length, value)
      int length;
      CGEN_INSN_INT value;
 {
-  switch (length)
-    {
-    case 8:
-      buf[0] = value;
-      break;
-    case 16:
-      if (cd->insn_endian == CGEN_ENDIAN_BIG)
-       bfd_putb16 (value, buf);
-      else
-       bfd_putl16 (value, buf);
-      break;
-    case 32:
-      if (cd->insn_endian == CGEN_ENDIAN_BIG)
-       bfd_putb32 (value, buf);
-      else
-       bfd_putl32 (value, buf);
-      break;
-    default:
-      abort ();
-    }
+  bfd_put_bits ((bfd_vma) value, buf, length,
+               cd->insn_endian == CGEN_ENDIAN_BIG);
 }
 \f
 /* Look up instruction INSN_*_VALUE and extract its fields.
@@ -595,3 +559,27 @@ cgen_lookup_get_insn_operands (cd, insn, insn_int_value, insn_bytes_value,
   cgen_get_insn_operands (cd, insn, fields, indices);
   return insn;
 }
+
+/* Allow signed overflow of instruction fields.  */
+void
+cgen_set_signed_overflow_ok (cd)
+     CGEN_CPU_DESC cd;
+{
+  cd->signed_overflow_ok_p = 1;
+}
+
+/* Generate an error message if a signed field in an instruction overflows.  */
+void
+cgen_clear_signed_overflow_ok (cd)
+     CGEN_CPU_DESC cd;
+{
+  cd->signed_overflow_ok_p = 0;
+}
+
+/* Will an error message be generated if a signed field in an instruction overflows ? */
+unsigned int
+cgen_signed_overflow_ok_p (cd)
+     CGEN_CPU_DESC cd;
+{
+  return cd->signed_overflow_ok_p;
+}
This page took 0.041667 seconds and 4 git commands to generate.