This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
[RFA] Patch to eliminate FOO_INSN_MAX from sid
- To: cgen at sources dot redhat dot com
- Subject: [RFA] Patch to eliminate FOO_INSN_MAX from sid
- From: Ben Elliston <bje at redhat dot com>
- Date: Mon, 2 Apr 2001 15:27:30 +1000 (EST)
- References: <15047.61111.152757.865497@scooby.apac.redhat.com>
>>>>> "Ben" == Ben Elliston <bje@redhat.com> writes:
Ben> Currently, cgen breaks when handling instruction sets with a "max"
Ben> instruction mnemonic. I've already fixed it properly in opcodes.
Ben> This patch extends the fix into the sim application.
And, likewise, here is the fix for the sid application. Tested on a
few ports, including "the hulk" (ARM7T). Okay to to commit?
2001-04-02 Ben Elliston <bje@redhat.com>
* sid-cpu.scm (-last-insn): New function.
(-gen-sem-switch-engine): Loop through idesc while less than or
equal to the last instruction enum, not less than the MAX enum.
(-gen-sfrag-engine-fn): Clean up frag_label_table initialisation.
* sid-decode.scm (-gen-decode-insn-globals): Define the idesc
table's size to be the last instruction enum plus one, not
@PREFIX@_INSN_MAX.
* sid.scm (gen-cpu-insn-enum-decl): Do not append a dummy `max'
instruction onto the instruction list.
Index: sid-cpu.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid-cpu.scm,v
retrieving revision 1.2
diff -u -r1.2 sid-cpu.scm
--- sid-cpu.scm 2001/01/29 18:56:26 1.2
+++ sid-cpu.scm 2001/04/02 05:25:25
@@ -5,6 +5,10 @@
; ***********
; cgen-desc.h
+(define (-last-insn)
+ (string-upcase (gen-c-symbol (caar (list-take -1
+ (gen-obj-list-enums (non-multi-insns (current-insn-list))))))))
+
; Declare the attributes.
(define (-gen-attr-decls)
@@ -807,7 +811,7 @@
@prefix@_idesc::idesc_table[labels[i].insn].cgoto.label = labels[i].label;
// confirm that table is all filled up
- for (int i=0; i<@PREFIX@_INSN_MAX; i++)
+ for (int i = 0; i <= @PREFIX@_INSN_" (-last-insn) "; i++)
assert (@prefix@_idesc::idesc_table[i].cgoto.label != 0);
// Initialize the compiler virtual insn.
@@ -1049,12 +1053,7 @@
", @PREFIX@_FRAG_LIST_END },\n"))
insn-list frag-usage)
"")
-
- "\
- { @PREFIX@_INSN_MAX }
-};
-\n"
- )
+ "};\n\n")
)
; Return sfrag computed-goto engine.
@@ -1112,20 +1111,18 @@
// Allocate frag label table and point idesc table entries at it.
// FIXME: Temporary hack, to be redone.
static void** frag_label_table;
- frag_label_table = new (void*) [@PREFIX@_INSN_MAX * 4];
- memset (frag_label_table, 0, sizeof (void*) * @PREFIX@_INSN_MAX * 4);
+ int max_insns = @PREFIX@_INSN_" (-last-insn) " + 1;
+ int tabsize = max_insns * 4;
+ frag_label_table = new (void*) [tabsize];
+ memset (frag_label_table, 0, sizeof (void*) * tabsize);
int i;
void** v;
- for (i = 0, v = frag_label_table; i < @PREFIX@_INSN_MAX; ++i)
+ for (i = 0, v = frag_label_table; i < max_insns; ++i)
{
@prefix@_idesc::idesc_table[@prefix@_frag_usage[i].itype].cgoto.frags = v;
for (int j = 0; @prefix@_frag_usage[i].ftype[j] != @PREFIX@_FRAG_LIST_END; ++j)
*v++ = labels[@prefix@_frag_usage[i].ftype[j]].label;
}
-
- // Record frags used by each insn.
- //for (int i = 0; @prefix@_frag_usage[i].itype != @PREFIX@_INSN_MAX; ++i)
- // @prefix@_idesc::idesc_table[@prefix@_frag_usage[i].itype].frags = & @prefix@_frag_usage[i];
// Initialize the compiler virtual insn.
// FIXME: Also needed if !gnuc.
Index: sid-decode.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid-decode.scm,v
retrieving revision 1.3
diff -u -r1.3 sid-decode.scm
--- sid-decode.scm 2001/03/01 19:15:30 1.3
+++ sid-decode.scm 2001/04/02 05:25:25
@@ -11,7 +11,9 @@
; Print the higher detailed stuff at higher verbosity.
(logit 2 "Processing decode insn globals ...\n")
- (let* ((all-attrs (current-insn-attr-list)))
+ (let* ((all-attrs (current-insn-attr-list))
+ (last-insn (string-upcase (gen-c-symbol (caar (list-take -1
+ (gen-obj-list-enums (non-multi-insns (current-insn-list)))))))))
(string-write
"
@@ -27,7 +29,7 @@
"")
"\
-@prefix@_idesc @prefix@_idesc::idesc_table[@PREFIX@_INSN_MAX] =
+@prefix@_idesc @prefix@_idesc::idesc_table[@PREFIX@_INSN_" last-insn " + 1] =
{\n"
(string-map
Index: sid.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid.scm,v
retrieving revision 1.3
diff -u -r1.3 sid.scm
--- sid.scm 2001/03/01 19:15:30 1.3
+++ sid.scm 2001/04/02 05:25:27
@@ -1320,8 +1320,7 @@
(cons '-
(atlist-attrs (obj-atlist i))))))
(parallel-insns insn-list)))
- nil)
- '((max))))
+ nil)))
)
; Return the enum of INSN in cpu family CPU.