add packaging
[platform/upstream/binutils.git] / opcodes / cgen-opc.c
index dbc5175..e086a66 100644 (file)
@@ -1,25 +1,25 @@
 /* CGEN generic opcode support.
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005
-   Free Software Foundation, Inc.
+   Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
-   This file is part of the GNU Binutils and GDB, the GNU debugger.
+   This file is part of libopcodes.
 
-   This program is free software; you can redistribute it and/or modify
+   This library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   It is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
 
    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "sysdep.h"
+#include "alloca-conf.h"
 #include <stdio.h>
 #include "ansidecl.h"
 #include "libiberty.h"
 #include "symcat.h"
 #include "opcode/cgen.h"
 
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
 static unsigned int hash_keyword_name
   (const CGEN_KEYWORD *, const char *, int);
 static unsigned int hash_keyword_value
@@ -379,10 +375,11 @@ cgen_get_insn_value (CGEN_CPU_DESC cd, unsigned char *buf, int length)
 
       for (i = 0; i < length; i += insn_chunk_bitsize) /* NB: i == bits */
        {
-         int index;
+         int bit_index;
          bfd_vma this_value;
-         index = i; /* NB: not dependent on endianness; opposite of cgen_put_insn_value! */
-         this_value = bfd_get_bits (& buf[index / 8], insn_chunk_bitsize, big_p);
+
+         bit_index = i; /* NB: not dependent on endianness; opposite of cgen_put_insn_value! */
+         this_value = bfd_get_bits (& buf[bit_index / 8], insn_chunk_bitsize, big_p);
          value = (value << insn_chunk_bitsize) | this_value;
        }
     }
@@ -417,9 +414,10 @@ cgen_put_insn_value (CGEN_CPU_DESC cd,
 
       for (i = 0; i < length; i += insn_chunk_bitsize) /* NB: i == bits */
        {
-         int index;
-         index = (length - insn_chunk_bitsize - i); /* NB: not dependent on endianness! */
-         bfd_put_bits ((bfd_vma) value, & buf[index / 8], insn_chunk_bitsize, big_p);
+         int bit_index;
+
+         bit_index = (length - insn_chunk_bitsize - i); /* NB: not dependent on endianness! */
+         bfd_put_bits ((bfd_vma) value, & buf[bit_index / 8], insn_chunk_bitsize, big_p);
          value >>= insn_chunk_bitsize;
        }
     }
@@ -613,151 +611,3 @@ cgen_signed_overflow_ok_p (CGEN_CPU_DESC cd)
 {
   return cd->signed_overflow_ok_p;
 }
-/* Functions for manipulating CGEN_BITSET.  */
-
-/* Create a bit mask.  */
-CGEN_BITSET *
-cgen_bitset_create (unsigned bit_count)
-{
-  CGEN_BITSET * mask = xmalloc (sizeof (* mask));
-  cgen_bitset_init (mask, bit_count);
-  return mask;
-}
-
-/* Initialize an existing bit mask.  */
-
-void
-cgen_bitset_init (CGEN_BITSET * mask, unsigned bit_count)
-{
-  if (! mask)
-    return;
-  mask->length = (bit_count / 8) + 1;
-  mask->bits = xmalloc (mask->length);
-  cgen_bitset_clear (mask);
-}
-
-/* Clear the bits of a bit mask.  */
-
-void
-cgen_bitset_clear (CGEN_BITSET * mask)
-{
-  unsigned i;
-
-  if (! mask)
-    return;
-
-  for (i = 0; i < mask->length; ++i)
-    mask->bits[i] = 0;
-}
-
-/* Add a bit to a bit mask.  */
-
-void
-cgen_bitset_add (CGEN_BITSET * mask, unsigned bit_num)
-{
-  int byte_ix, bit_ix;
-  int bit_mask;
-
-  if (! mask)
-    return;
-  byte_ix = bit_num / 8;
-  bit_ix = bit_num % 8;
-  bit_mask = 1 << (7 - bit_ix);
-  mask->bits[byte_ix] |= bit_mask;
-}
-
-/* Set a bit mask.  */
-
-void
-cgen_bitset_set (CGEN_BITSET * mask, unsigned bit_num)
-{
-  if (! mask)
-    return;
-  cgen_bitset_clear (mask);
-  cgen_bitset_add (mask, bit_num);
-}
-
-/* Test for a bit in a bit mask.
-   Returns 1 if the bit is found  */
-
-int
-cgen_bitset_contains (CGEN_BITSET * mask, unsigned bit_num)
-{
-  int byte_ix, bit_ix;
-  int bit_mask;
-
-  if (! mask)
-    return 1; /* No bit restrictions.  */
-
-  byte_ix = bit_num / 8;
-  bit_ix = 7 - (bit_num % 8);
-  bit_mask = 1 << bit_ix;
-  return (mask->bits[byte_ix] & bit_mask) >> bit_ix;
-}
-
-/* Compare two bit masks for equality.
-   Returns 0 if they are equal.  */
-
-int
-cgen_bitset_compare (CGEN_BITSET * mask1, CGEN_BITSET * mask2)
-{
-  if (mask1 == mask2)
-    return 0;
-  if (! mask1 || ! mask2)
-    return 1;
-  if (mask1->length != mask2->length)
-    return 1;
-  return memcmp (mask1->bits, mask2->bits, mask1->length);
-}
-
-/* Test two bit masks for common bits.
-   Returns 1 if a common bit is found.  */
-
-int
-cgen_bitset_intersect_p (CGEN_BITSET * mask1, CGEN_BITSET * mask2)
-{
-  unsigned i, limit;
-
-  if (mask1 == mask2)
-    return 1;
-  if (! mask1 || ! mask2)
-    return 0;
-  limit = mask1->length < mask2->length ? mask1->length : mask2->length;
-
-  for (i = 0; i < limit; ++i)
-    if ((mask1->bits[i] & mask2->bits[i]))
-      return 1;
-
-  return 0;
-}
-
-/* Make a copy of a bit mask.  */
-
-CGEN_BITSET *
-cgen_bitset_copy (CGEN_BITSET * mask)
-{
-  CGEN_BITSET* newmask;
-
-  if (! mask)
-    return NULL;
-  newmask = cgen_bitset_create ((mask->length * 8) - 1);
-  memcpy (newmask->bits, mask->bits, mask->length);
-  return newmask;
-}
-
-/* Combine two bit masks.  */
-
-void
-cgen_bitset_union (CGEN_BITSET * mask1, CGEN_BITSET * mask2,
-                  CGEN_BITSET * result)
-{
-  unsigned i;
-
-  if (! mask1 || ! mask2 || ! result
-      || mask1->length != mask2->length
-      || mask1->length != result->length)
-    return;
-
-  for (i = 0; i < result->length; ++i)
-    result->bits[i] = mask1->bits[i] | mask2->bits[i];
-}