This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA: opcodes,include patch for cgen


Hi -

The following patch aims to work around a bug in cgen-generated opcodes
libraries.  Some data structures are sized with macros that are inconsistently
overridden in some target-specific headers (opcodes/*-desc.h).  The patch
below removes the inconsistency and adds some compile-time error checking.

May I commit this?

- FChE

[opcodes/ChangeLog]
2000-05-15  Frank Ch. Eigler  <fche@redhat.com>

	* fr30-desc.h: Partially regenerated to account for changed
	CGEN_MAX_* -> CGEN_ACTUAL_MAX_* macros.
	* m32r-desc.h: Ditto.

[include/opcode/ChangeLog]
2000-05-15  Frank Ch. Eigler  <fche@redhat.com>

	* cgen.h (CGEN_MAX_SYNTAX_BYTES): Increase to 32.  Check that
	it exceeds CGEN_ACTUAL_MAX_SYNTAX_BYTES, if set.
	(CGEN_MAX_IFMT_OPERANDS): Increase to 16.  Check that it exceeds
	CGEN_ACTUAL_MAX_IFMT_OPERANDS, if set.


Index: opcodes/fr30-desc.h
===================================================================
RCS file: /cvs/src/src/opcodes/fr30-desc.h,v
retrieving revision 1.3
diff -p -u -r1.3 fr30-desc.h
--- fr30-desc.h	1999/10/05 00:05:52	1.3
+++ fr30-desc.h	2000/05/15 14:59:03
@@ -43,18 +43,16 @@ with this program; if not, write to the 
 
 #define CGEN_INT_INSN_P 0
 
-/* FIXME: Need to compute CGEN_MAX_SYNTAX_BYTES.  */
+/* Maximum number of syntax bytes in an instruction.  */
+#define CGEN_ACTUAL_MAX_SYNTAX_BYTES 15
 
 /* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands.
    e.g. In "b,a foo" the ",a" is an operand.  If mnemonics have operands
    we can't hash on everything up to the space.  */
 #define CGEN_MNEMONIC_OPERANDS
 
-/* Maximum number of operands any insn or macro-insn has.  */
-#define CGEN_MAX_INSN_OPERANDS 16
-
 /* Maximum number of fields in an instruction.  */
-#define CGEN_MAX_IFMT_OPERANDS 7
+#define CGEN_ACTUAL_MAX_IFMT_OPERANDS 7
 
 /* Enums.  */
 
Index: opcodes/m32r-desc.h
===================================================================
RCS file: /cvs/src/src/opcodes/m32r-desc.h,v
retrieving revision 1.4
diff -p -u -r1.4 m32r-desc.h
--- m32r-desc.h	2000/02/24 16:19:36	1.4
+++ m32r-desc.h	2000/05/15 14:59:03
@@ -44,18 +44,16 @@ with this program; if not, write to the 
 
 #define CGEN_INT_INSN_P 1
 
-/* FIXME: Need to compute CGEN_MAX_SYNTAX_BYTES.  */
+/* Maximum number of syntax bytes in an instruction.  */
+#define CGEN_ACTUAL_MAX_SYNTAX_BYTES 15
 
 /* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands.
    e.g. In "b,a foo" the ",a" is an operand.  If mnemonics have operands
    we can't hash on everything up to the space.  */
 #define CGEN_MNEMONIC_OPERANDS
 
-/* Maximum number of operands any insn or macro-insn has.  */
-#define CGEN_MAX_INSN_OPERANDS 16
-
 /* Maximum number of fields in an instruction.  */
-#define CGEN_MAX_IFMT_OPERANDS 7
+#define CGEN_ACTUAL_MAX_IFMT_OPERANDS 7
 
 /* Enums.  */
 

Index: include/opcode/cgen.h
===================================================================
RCS file: /cvs/src/src/include/opcode/cgen.h,v
retrieving revision 1.4
diff -p -u -r1.4 cgen.h
--- cgen.h	2000/02/24 23:57:23	1.4
+++ cgen.h	2000/05/15 14:59:05
@@ -735,10 +735,18 @@ typedef struct
    into the operand table.  The operand table doesn't exist in C, per se, as
    the data is recorded in the parse/insert/extract/print switch statements. */
 
-#ifndef CGEN_MAX_SYNTAX_BYTES
-#define CGEN_MAX_SYNTAX_BYTES 16
+/* This should be at least as large as necessary for any target. */
+#define CGEN_MAX_SYNTAX_BYTES 32
+
+/* A target may know its own precise maximum.  Assert that it falls below
+   the above limit. */
+#ifdef CGEN_ACTUAL_MAX_SYNTAX_BYTES
+#if CGEN_ACTUAL_MAX_SYNTAX_BYTES > CGEN_MAX_SYNTAX_BYTES
+#error "CGEN_ACTUAL_MAX_SYNTAX_BYTES too high - enlarge CGEN_MAX_SYNTAX_BYTES"
+#endif
 #endif
 
+
 typedef struct
 {
   unsigned char syntax[CGEN_MAX_SYNTAX_BYTES];
@@ -824,9 +832,17 @@ typedef struct {
 #define CGEN_IFMT_IFLD_IFLD(ii) ((ii)->ifld)
 } CGEN_IFMT_IFLD;
 
-#ifndef CGEN_MAX_IFMT_OPERANDS
-#define CGEN_MAX_IFMT_OPERANDS 1
+/* This should be at least as large as necessary for any target. */
+#define CGEN_MAX_IFMT_OPERANDS 16
+
+/* A target may know its own precise maximum.  Assert that it falls below
+   the above limit. */
+#ifdef CGEN_ACTUAL_MAX_IFMT_OPERANDS
+#if CGEN_ACTUAL_MAX_IFMT_OPERANDS > CGEN_MAX_IFMT_OPERANDS
+#error "CGEN_ACTUAL_MAX_IFMT_OPERANDS too high - enlarge CGEN_MAX_IFMT_OPERANDS"
+#endif
 #endif
+
 
 typedef struct
 {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]