This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch][commit] Re: CGEN simulators now brokenly require CGEN disassemblers...
- From: Dave Brolley <brolley at redhat dot com>
- To: Dave Brolley <brolley at redhat dot com>
- Cc: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>, binutils at sourceware dot org, gdb-patches at sourceware dot org
- Date: Fri, 02 Dec 2005 15:12:16 -0500
- Subject: [patch][commit] Re: CGEN simulators now brokenly require CGEN disassemblers...
- References: <200512020402.jB242Det026048@ignucius.se.axis.com> <43909D18.9090906@redhat.com>
I've committed the attached patch.
Dave Brolley wrote:
Once again, my apologies. I'll prepare a proper patch for this.
Dave
Hans-Peter Nilsson wrote:
I'd prefer not to commit this, but instead break out the CGEN
bitset operators into a separate file, say, cgen-bitops.c. (I
think that would arguably be covered by the "obvious" rule, but
solicit feedback anyway). As a stopgap I need like the
following to build a re-generated CRIS sim (once the CGEN
breakage is fixed; see recent post there), as simulators now
refer to some new bitset operators defined in
opcodes/cgen-opc.c. For CRIS, only the simulator is
CGEN-generated; the disassembler and everything else is
"manual".
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.
? opcodes/cgen-bitset.c
Index: opcodes/Makefile.am
===================================================================
RCS file: /cvs/src/src/opcodes/Makefile.am,v
retrieving revision 1.92
diff -c -p -r1.92 Makefile.am
*** opcodes/Makefile.am 30 Oct 2005 17:40:28 -0000 1.92
--- opcodes/Makefile.am 2 Dec 2005 20:00:39 -0000
*************** CFILES = \
*** 56,61 ****
--- 56,62 ----
avr-dis.c \
bfin-dis.c \
cgen-asm.c \
+ cgen-bitset.c \
cgen-dis.c \
cgen-opc.c \
cris-dis.c \
*************** ALL_MACHINES = \
*** 192,197 ****
--- 193,199 ----
avr-dis.lo \
bfin-dis.lo \
cgen-asm.lo \
+ cgen-bitset.lo \
cgen-dis.lo \
cgen-opc.lo \
cris-dis.lo \
*************** cgen-asm.lo: cgen-asm.c sysdep.h config.
*** 612,617 ****
--- 614,623 ----
$(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 \
Index: opcodes/Makefile.in
===================================================================
RCS file: /cvs/src/src/opcodes/Makefile.in,v
retrieving revision 1.103
diff -c -p -r1.103 Makefile.in
*** opcodes/Makefile.in 30 Oct 2005 17:40:28 -0000 1.103
--- opcodes/Makefile.in 2 Dec 2005 20:00:39 -0000
*************** CFILES = \
*** 278,283 ****
--- 278,284 ----
avr-dis.c \
bfin-dis.c \
cgen-asm.c \
+ cgen-bitset.c \
cgen-dis.c \
cgen-opc.c \
cris-dis.c \
*************** ALL_MACHINES = \
*** 414,419 ****
--- 415,421 ----
avr-dis.lo \
bfin-dis.lo \
cgen-asm.lo \
+ cgen-bitset.lo \
cgen-dis.lo \
cgen-opc.lo \
cris-dis.lo \
*************** cgen-asm.lo: cgen-asm.c sysdep.h config.
*** 1154,1159 ****
--- 1156,1165 ----
$(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 \
Index: opcodes/cgen-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/cgen-opc.c,v
retrieving revision 1.16
diff -c -p -r1.16 cgen-opc.c
*** opcodes/cgen-opc.c 28 Oct 2005 19:49:21 -0000 1.16
--- opcodes/cgen-opc.c 2 Dec 2005 20:00:39 -0000
*************** cgen_signed_overflow_ok_p (CGEN_CPU_DESC
*** 613,763 ****
{
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];
- }
--- 613,615 ----
Index: opcodes/configure
===================================================================
RCS file: /cvs/src/src/opcodes/configure,v
retrieving revision 1.83
diff -c -p -r1.83 configure
*** opcodes/configure 7 Nov 2005 22:21:48 -0000 1.83
--- opcodes/configure 2 Dec 2005 20:00:41 -0000
*************** done
*** 8685,8691 ****
# Utility var, documents generic cgen support files.
! cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo"
# We don't do any links based on the target system, just makefile config.
--- 8685,8691 ----
# Utility var, documents generic cgen support files.
! 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.
*************** if test x${all_targets} = xfalse ; then
*** 8704,8710 ****
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_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" ;;
--- 8704,8710 ----
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 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" ;;
Index: opcodes/configure.in
===================================================================
RCS file: /cvs/src/src/opcodes/configure.in,v
retrieving revision 1.64
diff -c -p -r1.64 configure.in
*** opcodes/configure.in 25 Oct 2005 17:40:16 -0000 1.64
--- opcodes/configure.in 2 Dec 2005 20:00:41 -0000
*************** done
*** 139,145 ****
# Utility var, documents generic cgen support files.
! cgen_files="cgen-opc.lo cgen-asm.lo cgen-dis.lo"
# We don't do any links based on the target system, just makefile config.
--- 139,145 ----
# Utility var, documents generic cgen support files.
! 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.
*************** if test x${all_targets} = xfalse ; then
*** 158,164 ****
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_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" ;;
--- 158,164 ----
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 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" ;;
/* 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];
}