diff options
author | Dave Brolley <brolley@redhat.com> | 2005-10-28 19:49:22 +0000 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2005-10-28 19:49:22 +0000 |
commit | fb53f5a81a23dd5fc2eac009274e90b9753e1f22 (patch) | |
tree | 9f8008d9c42d53829f5300448a1b57f87013b6db /opcodes/cgen-opc.c | |
parent | 16175d96a0fd067a57f340015061292a5d8c3ee3 (diff) | |
download | gdb-fb53f5a81a23dd5fc2eac009274e90b9753e1f22.zip gdb-fb53f5a81a23dd5fc2eac009274e90b9753e1f22.tar.gz gdb-fb53f5a81a23dd5fc2eac009274e90b9753e1f22.tar.bz2 |
2005-10-28 Dave Brolley <brolley@redhat.com>
* All CGEN-generated sources: Regenerate.
Contribute the following changes:
2005-09-19 Dave Brolley <brolley@redhat.com>
* disassemble.c (disassemble_init_for_target): Add 'break' to case for
bfd_arch_tic4x. Use cgen_bitset_create and cgen_bitset_set for
bfd_arch_m32c case.
2005-02-16 Dave Brolley <brolley@redhat.com>
* cgen-dis.in: Rename CGEN_ISA_MASK to CGEN_BITSET. Rename
cgen_isa_mask_* to cgen_bitset_*.
* cgen-opc.c: Likewise.
2003-11-28 Richard Sandiford <rsandifo@redhat.com>
* cgen-dis.in (print_insn_@arch@): Fix comparison with cached isas.
* *-dis.c: Regenerate.
2003-06-05 DJ Delorie <dj@redhat.com>
* cgen-dis.in (print_insn_@arch@): Copy prev_isas, don't assign
it, as it may point to a reused buffer. Set prev_isas when we
change cpus.
2002-12-13 Dave Brolley <brolley@redhat.com>
* cgen-opc.c (cgen_isa_mask_create): New support function for
CGEN_ISA_MASK.
(cgen_isa_mask_init): Ditto.
(cgen_isa_mask_clear): Ditto.
(cgen_isa_mask_add): Ditto.
(cgen_isa_mask_set): Ditto.
(cgen_isa_supported): Ditto.
(cgen_isa_mask_compare): Ditto.
(cgen_isa_mask_intersection): Ditto.
(cgen_isa_mask_copy): Ditto.
(cgen_isa_mask_combine): Ditto.
* cgen-dis.in (libiberty.h): #include it.
(isas): Renamed from 'isa' and now (CGEN_ISA_MASK *).
(print_insn_@arch@): Use CGEN_ISA_MASK and support functions.
* Makefile.am (CGENDEPS): Add utils-cgen.scm and attrs.scm.
* Makefile.in: Regenerated.
Diffstat (limited to 'opcodes/cgen-opc.c')
-rw-r--r-- | opcodes/cgen-opc.c | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/opcodes/cgen-opc.c b/opcodes/cgen-opc.c index d34aac8..dbc5175 100644 --- a/opcodes/cgen-opc.c +++ b/opcodes/cgen-opc.c @@ -613,3 +613,151 @@ 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]; +} |