[patch][rfa] Representation of ISA Attribute in CGEN
Dave Brolley <[email protected]>
| Newsgroups | gmane.comp.emulators.sid.devel,gmane.comp.tools.cgen.devel,gmane.comp.gnu.binutils,gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi, These changes have been in our local tree for a few years now and were developed for an internal port which requires *much* more than 32 ISAs or even 64 ISAs. These changes could be of benifit to others, so I would like to submit them for approval. Currently, ISA is represented as an integer, like all the other non-boolean attributes. It is a bit mask with each bit representing whether a particular ISA is supported. Our port requires that there be no fixed limit on the number of ISAs, and so, we developed an open-ended representation for a bitset using a bitstring and a length. It is called CGEN_BITSET and is declared in include/opcode/cgen-bitset.h and supported by several new functions in opcodes/cgen-opc.c. All manipulation of these bitsets is done using these functions which hide the internal representation. See cgen-bitset.h (attached) for a description of the implementation The patch has 3 parts: 1) Extension of CGEN_ATTR_VALUE_TYPE to be a union allowing the use of CGEN_BITSET as well as its supporting macros. 2) Changes to CGEN so that it generates code to correctly access and initialize the new definition of CGEN_ATTR_VALUE_TYPE and to use the proper cover functions when manipulating ISAs. 3) Changes to hand written portions of existing opcodes, sim and sid ports as in 2). Fortunately, the use of existing CGEN macros made these changes minimal. I have also included in the patch the regenerated source for the frv port so that you can see the effect on the generated code. None of the generated code for existing sid ports is affected. One natural extension of this work would be use the same representation for all bitset attributes in CGEN. I believe that MACH is the only other one at this time. Seeking comments and approval to commit. Thanks, Dave
cgen-bitset.ChangeLog
(text/plain, 5 KB)
cgen/ChangeLog: 2005-09-19 Dave Brolley <[email protected]> * attr.scm (gen-value-for-defn-raw): New methods. (gen-value-for-defn): Don't test for 'SID-SIMULATOR. Call gen-value-for-defn-raw. * sid.scm (gen-obj-attr-sid-defn): Call gen-value-for-defn-raw. 2002-12-13 Dave Brolley <[email protected]> * utils-cgen.scm (gen-attr-type): Moved from sid.scm. (-gen-attr-accessors): New function. (gen-obj-attr-defn): Update terminating initializer. (gen-obj-attr-end-defn): New function. * sid.scm (gen-attr-type): Moved to utils-cgen.scm. * sid-cpu.scm (cgen-desc.h): Generate code to include "opcode/cgen-bitset.h" * intrinsics.scm (kept-insn-isas): Correct the extraction of the isa name. * desc.scm ('gen-defn): Update terminating initializer. * desc-cpu.scm (gen-ifld-decls): Call -gen-attr-accessors. Update terminatinig initializer. (gen-hw-decls): Ditto. (gen-operand-decls): Ditto. (gen-insn-decls): Ditto. (-gen-hash-defines): Generate code to include "opcde/cgen-bitset.h" (gen-insn-table): Update terminating initializer. (-gen-cpu-open): Update generation of @arch@_cgen_rebuild_tables, @arch@_cgen_cpu_open, @arch@_cgen_cpu_close. * attr.scm (charmask-bytes): New function. (bitset-attr->charmask): New function. (<bitset-attribute>): Handle isa-attributes specially. Also handle differences for SID-SIMULATOR. (<integer-attribute>): Handle differences for SID-SIMULATOR. (<enum-attribute>): Ditto. include/ChangeLog: 2003-09-29 Dave Brolley <[email protected]> * dis-asm.h (disassemble_info): insn_sets now (void *) to allow for more exotic underlying types to be used. include/opcode/ChangeLog: 2005-02-16 Dave Brolley <[email protected]> * cgen-bitset.h: Rename CGEN_ISA_MASK to CGEN_BITSET. Rename cgen_isa_mask_* to cgen_bitset_*. * cgen.h: Likewise. 2003-10-21 Richard Sandiford <[email protected]> * cgen.h (CGEN_BITSET_ATTR_VALUE): Fix definition. (CGEN_ATTR_ENTRY): Change "value" to type "unsigned". (CGEN_CPU_TABLE): Make isas a ponter. 2003-09-29 Dave Brolley <[email protected]> * cgen.h (CGEN_ATTR_VALUE_BITSET_TYPE): New typedef. (CGEN_ATTR_VALUE_ENUM_TYPE): Ditto. (CGEN_ATTR_VALUE_TYPE): Use these new typedefs. 2002-12-13 Dave Brolley <[email protected]> * cgen.h (symcat.h): #include it. (cgen-bitset.h): #include it. (CGEN_ATTR_VALUE_TYPE): Now a union. (CGEN_ATTR_VALUE): Reference macros generated in opcodes/<arch>-desc.h. (CGEN_ATTR_ENTRY): 'value' now unsigned. (cgen_cpu_desc): 'isas' now (CGEN_ISA_MASK*). * cgen-bitset.h: New file. opcodes/ChangeLog: 2005-09-19 Dave Brolley <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * cgen-dis.in (print_insn_@arch@): Fix comparison with cached isas. * *-dis.c: Regenerate. 2003-06-05 DJ Delorie <[email protected]> * 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 <[email protected]> * 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. sid/component/cgen-cpu/ChangeLog: 2003-10-07 Dave Brolley <[email protected]> * tracedis.cxx (cgen_disassemble): Rename isa_mask to isas. Now (CGEN_ISA_MASK*). * tracedis.h (opcode/cgen-bitset.h): #include it. (cgen_disassemble): Rename isa_mask to isas. Now (CGEN_ISA_MASK*). (cgen_bi_endian_cpu::disassemble): 'isas' now (CGEN_ISA_MASK *). * cgen-cpu.h (opcode/cgen-bitset.h): #include it. (cgen_bi_endian_cpu::disassemble): 'isas' now (CGEN_ISA_MASK *). * compCGEN.cxx (cgen_disassemble): Rename isa_mask to isas. Now (CGEN_ISA_MASK*). cpu/ChangeLog: 2003-09-24 Dave Brolley <[email protected]> * frv.opc: Use CGEN_ATTR_VALUE_ENUM_TYPE in place of CGEN_ATTR_VALUE_TYPE. * m32c.opc (m32c_cgen_insn_supported): Use CGEN_INSN_BITSET_ATTR_VALUE. Use cgen_bitset_intersect_p. gas/ChangeLog: 2005-09-19 Dave Brolley <[email protected]> * config/tc-m32c.c (default_isa): New static variable. (m32c_isa): Now of type CGEN_BITSET. (md_begin): Pass &m32c_isa to m32c_cgen_cpu_open. sim/frv/ChangeLog: 2003-09-29 Dave Brolley <[email protected]> * frv-sim.h: Use CGEN_ATTR_VALUE_ENUM_TYPE in place of CGEN_ATTR_VALUE_TYPE. * mloop.in: Ditto. * pipeline.c: Ditto. * traps.c: Ditto.
cgen-bitset.h
(text/plain, 2 KB)
/* Header file the type CGEN_BITSET.
Copyright 2002, 2005 Free Software Foundation, Inc.
This file is part of GDB, the GNU debugger, and the GNU Binutils.
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 of the License, 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.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef CGEN_BITSET_H
#define CGEN_BITSET_H
#ifdef __cplusplus
extern "C" {
#endif
/* A bitmask represented as a string.
Each member of the set is represented as a bit
in the string. Bytes are indexed from left to right in the string and
bits from most significant to least within each byte.
For example, the bit representing member number 6 is (set->bits[0] & 0x02).
*/
typedef struct cgen_bitset
{
unsigned length;
char *bits;
} CGEN_BITSET;
extern CGEN_BITSET *cgen_bitset_create PARAMS ((unsigned));
extern void cgen_bitset_init PARAMS ((CGEN_BITSET *, unsigned));
extern void cgen_bitset_clear PARAMS ((CGEN_BITSET *));
extern void cgen_bitset_add PARAMS ((CGEN_BITSET *, unsigned));
extern void cgen_bitset_set PARAMS ((CGEN_BITSET *, unsigned));
extern int cgen_bitset_compare PARAMS ((CGEN_BITSET *, CGEN_BITSET *));
extern void cgen_bitset_union PARAMS ((CGEN_BITSET *, CGEN_BITSET *, CGEN_BITSET *));
extern int cgen_bitset_intersect_p PARAMS ((CGEN_BITSET *, CGEN_BITSET *));
extern int cgen_bitset_contains PARAMS ((CGEN_BITSET *, unsigned));
extern CGEN_BITSET *cgen_bitset_copy PARAMS ((CGEN_BITSET *));
#ifdef __cplusplus
} // extern "C"
#endif
#endif
cgen-bitset.patch.txt
(text/plain, 642.5 KB) - not displayed