This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem w/ igen, multiple -M models, and -G gen-multi-sim.


> what's happening is that make_gen_semantics_list() is calling
> insn_list_insert() to insert the DMxC1_COP1Sb on to the semantics list
> (OK), but insn_list_insert finds that all of the keys it cares about
> are the same, thinks it's a duplicate of DMxC1_COP1Sa, and merges it
> into DMxC1_COP1Sa (not so OK), and as a result no semantic function is
> generated for DMxC1_COP1Sb.

Sounds like another key is needed (I keep adding them :-).

> I don't know what the right solution here is, but I figured others
> might want to be aware of the problem and might have comments.
> 
> Having talked w/ Andrew a bit about the future of the MIPS sim, it's
> going to move away from using -M like this, and instead use multiple
> igen runs to generate simulators for different machines.  So, this
> isn't something that I need a solution to.
> 
> I just wanted people who might care in the future to have a reference
> in the list archives.  If a solution comes out of this, well, that'd
> be fine by me, too.  8-)

Turns out that such instructions need to be given unique field-names as 
they would otherwise generate functions with the same name.  Just explot it.

See attached.  It works for your example.

	Andrew
2002-03-14  Andrew Cagney  <ac131313@redhat.com>

	* gen.c (format_name_cmp): New function.
	(insn_list_insert): Use the instruction field name as an
	additional key.  Different field names indicate different
	semantics.

Index: gen.c
===================================================================
RCS file: /cvs/src/src/sim/igen/gen.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 gen.c
--- gen.c	1999/04/16 01:35:04	1.1.1.1
+++ gen.c	2002/03/15 02:41:39
@@ -308,7 +308,18 @@
     }
 }
 
-
+/* Same as strcmp().  */
+static int
+format_name_cmp (const char *l, const char *r)
+{
+  if (l == NULL && r == NULL)
+    return 0;
+  if (l != NULL && r == NULL)
+    return -1;
+  if (l == NULL && r != NULL)
+    return +1;
+  return strcmp (l, r);
+}
 
 
 typedef enum {
@@ -346,6 +357,18 @@
 
       /* key#3 sort according to the non-constant fields of each instruction */
       cmp = insn_field_cmp (insn->words, (*cur_insn_ptr)->insn->words);
+      if (cmp < 0)
+	break;
+      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)

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