This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/igen] Only sort on format_name when merging
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 22 Nov 2002 18:31:50 -0500
- Subject: [patch/igen] Only sort on format_name when merging
Hello,
The attached is a refinement on an earlier patch related to creating the
list of semantic functions.
Given two instructions:
00000000::::FOO
*isa1
00000000::::BAR
*isa2
then igen was silently dropping the second instruction from the list of
semantic functions that need to be generated - it had concluded that BAR
was a duplicate of FOO.
The attached patch stops this by refining the sort order used when
accumulating semantic instructions:
It sorts on both the format and name fields but only when merging (i.e.,
when two instructions with identical opcodes are allowed).
committed,
Andrew
2002-11-22 Andrew Cagney <cagney@redhat.com>
* gen.c (name_cmp): Rename format_name_cmp.
(insn_list_insert): When a merge, compare the format name and
instruction name. Add trace messages.
Index: gen.c
===================================================================
RCS file: /cvs/src/src/sim/igen/gen.c,v
retrieving revision 1.5
diff -u -r1.5 gen.c
--- gen.c 22 Nov 2002 04:20:49 -0000 1.5
+++ gen.c 22 Nov 2002 23:20:02 -0000
@@ -296,7 +296,7 @@
/* Same as strcmp(). */
static int
-format_name_cmp (const char *l, const char *r)
+name_cmp (const char *l, const char *r)
{
if (l == NULL && r == NULL)
return 0;
@@ -350,19 +350,35 @@
else if (cmp > 0)
continue;
- /* key#4 sort according to the format-name. If two apparently
- identical instructions have unique format-names, then the
- instructions are different. This is because the
- format-name's use is overloaded, it not only indicates the
- format name but also provides a unique semantic name for the
- function. */
- cmp =
- format_name_cmp (insn->format_name,
- (*cur_insn_ptr)->insn->format_name);
- if (cmp < 0)
- break;
- else if (cmp > 0)
- continue;
+ if (duplicate_action == merge_duplicate_insns)
+ {
+ /* key#4: If we're going to merge duplicates, also sort
+ according to the format_name. Two instructions with
+ identical decode patterns, but different names, are
+ considered different when merging. Duplicates are only
+ important when creating a decode table (implied by
+ report_duplicate_insns) as such a table only has the
+ instruction's bit code as a way of differentiating
+ between instructions. */
+ int cmp = name_cmp (insn->format_name,
+ (*cur_insn_ptr)->insn->format_name);
+ if (cmp < 0)
+ break;
+ else if (cmp > 0)
+ continue;
+ }
+
+ if (duplicate_action == merge_duplicate_insns)
+ {
+ /* key#5: If we're going to merge duplicates, also sort
+ according to the name. See comment above for
+ format_name. */
+ int cmp = name_cmp (insn->name, (*cur_insn_ptr)->insn->name);
+ if (cmp < 0)
+ break;
+ else if (cmp > 0)
+ continue;
+ }
/* duplicate keys, report problem */
switch (duplicate_action)
@@ -379,6 +395,15 @@
"Location of duplicate instruction\n");
case merge_duplicate_insns:
/* Add the opcode path to the instructions list */
+ if (options.trace.insn_insertion)
+ {
+ notify ((*cur_insn_ptr)->insn->line,
+ "%s.%s: insert merge %s.%s\n",
+ (*cur_insn_ptr)->insn->format_name,
+ (*cur_insn_ptr)->insn->name,
+ insn->format_name,
+ insn->name);
+ }
if (opcodes != NULL)
{
insn_opcodes **last = &(*cur_insn_ptr)->opcodes;
@@ -400,6 +425,13 @@
/* create a new list entry and insert it */
{
insn_list *new_insn = ZALLOC (insn_list);
+ if (options.trace.insn_insertion)
+ {
+ notify (insn->line,
+ "%s.%s: insert new\n",
+ insn->format_name,
+ insn->name);
+ }
new_insn->insn = insn;
new_insn->expanded_bits = expanded_bits;
new_insn->next = (*cur_insn_ptr);