2005-12-02 Dave Brolley <brolley@redhat.com>

* configure.in (cgen_files): Add cgen-bitset.lo.
        (ta): Add cgen-bitset.lo when arch==bfd_cris_arch.
        * Makefile.am (CFILES): Add cgen-bitset.c.
        (ALL_MACHINES): Add cgen-bitset.lo.
        (cgen-bitset.lo): New target.
        * cgen-opc.c (cgen_bitset_create, cgen_bitset_init, cgen_bitset_clear)
        (cgen_bitset_add, cgen_bitset_set, cgen_bitset_contains)
        (cgen_bitset_compare, cgen_bitset_intersect_p, cgen_bitset_copy)
        (cgen_bitset_union): Moved from here ...
        * cgen-bitset.c: ... to here. New file.
        * Makefile.in: Regenerated.
        * configure: Regenerated.
This commit is contained in:
Dave Brolley 2005-12-02 20:09:42 +00:00
parent 31e2b00f59
commit 3609e0feb6
7 changed files with 204 additions and 152 deletions

View File

@ -1,3 +1,18 @@
2005-12-02 Dave Brolley <brolley@redhat.com>
* configure.in (cgen_files): Add cgen-bitset.lo.
(ta): Add cgen-bitset.lo when arch==bfd_cris_arch.
* Makefile.am (CFILES): Add cgen-bitset.c.
(ALL_MACHINES): Add cgen-bitset.lo.
(cgen-bitset.lo): New target.
* cgen-opc.c (cgen_bitset_create, cgen_bitset_init, cgen_bitset_clear)
(cgen_bitset_add, cgen_bitset_set, cgen_bitset_contains)
(cgen_bitset_compare, cgen_bitset_intersect_p, cgen_bitset_copy)
(cgen_bitset_union): Moved from here ...
* cgen-bitset.c: ... to here. New file.
* Makefile.in: Regenerated.
* configure: Regenerated.
2005-11-22 James E Wilson <wilson@specifix.com>
* ia64-gen.c (_opcode_int64_low, _opcode_int64_high,

View File

@ -56,6 +56,7 @@ CFILES = \
avr-dis.c \
bfin-dis.c \
cgen-asm.c \
cgen-bitset.c \
cgen-dis.c \
cgen-opc.c \
cris-dis.c \
@ -192,6 +193,7 @@ ALL_MACHINES = \
avr-dis.lo \
bfin-dis.lo \
cgen-asm.lo \
cgen-bitset.lo \
cgen-dis.lo \
cgen-opc.lo \
cris-dis.lo \
@ -612,6 +614,10 @@ cgen-asm.lo: cgen-asm.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/symcat.h \
$(INCDIR)/opcode/cgen.h $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen-bitset.h \
opintl.h
cgen-bitset.lo: cgen-bitset.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h \
$(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/symcat.h \
$(INCDIR)/opcode/cgen.h $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen-bitset.h
cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(BFD_H) \
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/symcat.h \

View File

@ -278,6 +278,7 @@ CFILES = \
avr-dis.c \
bfin-dis.c \
cgen-asm.c \
cgen-bitset.c \
cgen-dis.c \
cgen-opc.c \
cris-dis.c \
@ -414,6 +415,7 @@ ALL_MACHINES = \
avr-dis.lo \
bfin-dis.lo \
cgen-asm.lo \
cgen-bitset.lo \
cgen-dis.lo \
cgen-opc.lo \
cris-dis.lo \
@ -1154,6 +1156,10 @@ cgen-asm.lo: cgen-asm.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/symcat.h \
$(INCDIR)/opcode/cgen.h $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen-bitset.h \
opintl.h
cgen-bitset.lo: cgen-bitset.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h \
$(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/symcat.h \
$(INCDIR)/opcode/cgen.h $(INCDIR)/symcat.h $(INCDIR)/opcode/cgen-bitset.h
cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h $(BFD_H) \
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/symcat.h \

173
opcodes/cgen-bitset.c Normal file
View File

@ -0,0 +1,173 @@
/* CGEN generic opcode support.
Copyright 2002, 2005
Free Software Foundation, Inc.
This file is part of the GNU Binutils and GDB, the GNU debugger.
This program 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)
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.
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. */
/* Functions for manipulating CGEN_BITSET. */
#include "libiberty.h"
#include "opcode/cgen-bitset.h"
#include <string.h>
/* 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];
}

View File

@ -613,151 +613,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];
}

4
opcodes/configure vendored
View File

@ -8685,7 +8685,7 @@ done
# Utility var, documents generic cgen support files.
cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo"
cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo cgen-bitset.lo"
# We don't do any links based on the target system, just makefile config.
@ -8704,7 +8704,7 @@ if test x${all_targets} = xfalse ; then
bfd_arm_arch) ta="$ta arm-dis.lo" ;;
bfd_avr_arch) ta="$ta avr-dis.lo" ;;
bfd_bfin_arch) ta="$ta bfin-dis.lo" ;;
bfd_cris_arch) ta="$ta cris-dis.lo cris-opc.lo" ;;
bfd_cris_arch) ta="$ta cris-dis.lo cris-opc.lo cgen-bitset.lo" ;;
bfd_crx_arch) ta="$ta crx-dis.lo crx-opc.lo" ;;
bfd_d10v_arch) ta="$ta d10v-dis.lo d10v-opc.lo" ;;
bfd_d30v_arch) ta="$ta d30v-dis.lo d30v-opc.lo" ;;

View File

@ -139,7 +139,7 @@ done
# Utility var, documents generic cgen support files.
cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo"
cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo cgen-bitset.lo"
# We don't do any links based on the target system, just makefile config.
@ -158,7 +158,7 @@ if test x${all_targets} = xfalse ; then
bfd_arm_arch) ta="$ta arm-dis.lo" ;;
bfd_avr_arch) ta="$ta avr-dis.lo" ;;
bfd_bfin_arch) ta="$ta bfin-dis.lo" ;;
bfd_cris_arch) ta="$ta cris-dis.lo cris-opc.lo" ;;
bfd_cris_arch) ta="$ta cris-dis.lo cris-opc.lo cgen-bitset.lo" ;;
bfd_crx_arch) ta="$ta crx-dis.lo crx-opc.lo" ;;
bfd_d10v_arch) ta="$ta d10v-dis.lo d10v-opc.lo" ;;
bfd_d30v_arch) ta="$ta d30v-dis.lo d30v-opc.lo" ;;