* sid.scm (gen-cpu-insn-enum-decl): Do not append a dummy `max'
instruction onto the instruction list.
+ * 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.
+
2001-03-28 Ben Elliston <bje@redhat.com>
* doc/version.texi (UPDATED, EDITION): Update.
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. */
{
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));
; Return C code to define the machine data.
(define (-gen-mach-defns)
- (string-list-map
- (lambda (mach)
- (gen-obj-sanitize
- mach
- (string-list "\
+ (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
+ mach
+ (string-list "\
static void\n"
(gen-sym mach) "_init_cpu (SIM_CPU *cpu)
{
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
")))
- (current-mach-list))
+ (current-mach-list)))
)
\f
; Top level file generators.