This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


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

[RFA] Patch to eliminate FOO_INSN_MAX from sim


Currently, cgen breaks when handling instruction sets with a "max"
instruction mnemonic.  I've already fixed it properly in opcodes.
This patch extends the fix into the sim application.

The code to produce the C symbol in sim-{decode,model}.scm is quite
long-winded.  Is there a better way?

Tested on two ports with expected results.  Okay to commit?


2001-04-02  Ben Elliston  <bje@redhat.com>

	* sim-decode.scm (@prefix@_init_idesc_table): Compute tabsize
	using the size of the table and its elements.
	(-gen-decode-insn-globals): Define the idesc table's size to be
	the last instruction enum plus one, not @PREFIX@_INSN_MAX.
	* sim-model.scm (-gen-mach-defns): Define CPU_MAX_INSNS as the
	last instruction enum plus one, not @CPU@_INSN_MAX.

Index: sim-decode.scm
===================================================================
RCS file: /cvs/src/src/cgen/sim-decode.scm,v
retrieving revision 1.5
diff -u -w -r1.5 sim-decode.scm
--- sim-decode.scm	2001/03/05 15:43:38	1.5
+++ sim-decode.scm	2001/04/02 03:03:56
@@ -32,7 +32,9 @@
    teensy bit of cpu in the decoder.  Moving it to malloc space is trivial
    but won't be done until necessary (we don't currently support the runtime
    addition of instructions nor an SMP machine with different cpus).  */
-static IDESC " IDESC-TABLE-VAR "[@PREFIX@_INSN_MAX];
+static IDESC " IDESC-TABLE-VAR "[@PREFIX@_INSN_"
+   (string-upcase (gen-c-symbol (caar (list-take -1
+       (gen-obj-list-enums (non-multi-insns (current-insn-list))))))) " + 1];
 
 /* Commas between elements are contained in the macros.
    Some of these are conditionally compiled out.  */
@@ -145,7 +147,7 @@
 {
   IDESC *id,*tabend;
   const struct insn_sem *t,*tend;
-  int tabsize = @PREFIX@_INSN_MAX;
+  int tabsize = sizeof (" IDESC-TABLE-VAR ") / sizeof (IDESC);
   IDESC *table = " IDESC-TABLE-VAR ";
 
   memset (table, 0, tabsize * sizeof (IDESC));
Index: sim-model.scm
===================================================================
RCS file: /cvs/src/src/cgen/sim-model.scm,v
retrieving revision 1.1.1.1
diff -u -w -r1.1.1.1 sim-model.scm
--- sim-model.scm	2000/07/28 04:11:52	1.1.1.1
+++ sim-model.scm	2001/04/02 03:03:57
@@ -313,6 +313,8 @@
 ; Return C code to define the machine data.
 
 (define (-gen-mach-defns)
+  (let* ((insns (gen-obj-list-enums (non-multi-insns (current-insn-list))))
+	 (last-insn (string-upcase (gen-c-symbol (caar (list-take -1 insns))))))
   (string-list-map
    (lambda (mach)
      (gen-obj-sanitize
@@ -326,7 +328,7 @@
   CPU_PC_FETCH (cpu) = " (gen-sym (mach-cpu mach)) "_h_pc_get;
   CPU_PC_STORE (cpu) = " (gen-sym (mach-cpu mach)) "_h_pc_set;
   CPU_GET_IDATA (cpu) = @cpu@_get_idata;
-  CPU_MAX_INSNS (cpu) = @CPU@_INSN_MAX;
+  CPU_MAX_INSNS (cpu) = @CPU@_INSN_" last-insn " + 1;
   CPU_INSN_NAME (cpu) = cgen_insn_name;
   CPU_FULL_ENGINE_FN (cpu) = @cpu@_engine_run_full;
 #if WITH_FAST
@@ -352,7 +354,7 @@
 
 ")))
 
-   (current-mach-list))
+   (current-mach-list)))
 )
 
 ; Top level file generators.


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