This is the mail archive of the gdb-patches@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: sim/mips patch: add support for more NEC VR targets


At 05 Nov 2002 16:20:00 +0000, Richard Sandiford wrote:
> mips/
> 	* configure.in (mips64vr*): Define TARGET_ENABLE_FR to 1.
> 	(mips64vr-*-*, mips64vrel-*-*): New configurations.
> 	Add a new simulator generator, MULTI.
> 	* configure: Regenerate.
> 	* Makefile.in (SIM_MULTI_OBJ, SIM_EXTRA_DISTCLEAN): New variables.
> 	(multi-run.o): New dependency.
> 	(SIM_MULTI_ALL, SIM_MULTI_CONFIGS): New variables.
> 	(BUILT_SRC_FROM_MULTI): New variable.  Depend on tmp-multi.
> 	(tmp-mach-multi, tmp-itable-multi, tmp-run-multi): New dependencies.
> 	(tmp-multi): Combine them.
> 	(clean-extra): Remove sources in BUILT_SRC_FROM_MULTI.
> 	(distclean-extra): New rule.
> 	* sim-main.h: Include bfd.h.
> 	(MIPS_BFD_MACH): New macro.
> 	* mips.igen (vr4120, vr5400, vr5500): New models.
> 	(check_mf_cycles): Don't enforce mflo and mfhi separation
> 	in vr5500 code.
> 	(clo, clz, dclo, dclz, madd, maddu, msub, msub, mul): Add *vr5500.
> 	* vr.igen: Replace with new version.
> 	* multi-run.c: New file.

My patch, below, drops down on top of yours, with the following
effect:

* no new multi-run.c src.

* multi-run.c generated in its entirety by configure.in, to provide
  functions: sim_engine_run, and mips_mach_multi.

* s/MIPS_BFD_MACH/MIPS_MACH/

* MIPS_MACH either defined to a hard-coded value from configure.in, or
  if MULTI to mips_mach_multi() which returns a supported machine
  type (either the currently selected one).

The generation of multi-run.c is kinda gross, but i didn't feel like
breaking it out into its own script.  For true Rightness, it probably
should be.  8-S


I've not really tested it by running stuff thru the sim, but it does
seem to compile.



chris
==
diff -Nupr -x CVS -x configure mips.rsandifo/Makefile.in mips/Makefile.in
--- mips.rsandifo/Makefile.in	Wed Nov  6 11:39:48 2002
+++ mips/Makefile.in	Wed Nov  6 14:04:39 2002
@@ -76,7 +76,7 @@ cp1.o: $(srcdir)/cp1.c config.h sim-main
 
 mdmx.o: $(srcdir)/mdmx.c $(srcdir)/sim-main.h
 
-multi-run.o: multi-include.h multi-switch.c tmp-mach-multi
+multi-run.o: multi-include.h tmp-mach-multi
 
 ../igen/igen:
 	cd ../igen && $(MAKE)
@@ -391,4 +391,4 @@ clean-extra:
 	rm -f m16*.o m32*.o itable*.o
 
 distclean-extra:
-	rm -f multi-include.h multi-switch.c
+	rm -f multi-include.h multi-run.c
diff -Nupr -x CVS -x configure mips.rsandifo/configure.in mips/configure.in
--- mips.rsandifo/configure.in	Wed Nov  6 11:39:48 2002
+++ mips/configure.in	Wed Nov  6 14:09:07 2002
@@ -101,6 +101,8 @@ sim_igen_machine="-M mipsIV"
 sim_m16_machine="-M mips16"
 sim_igen_filter="32,64,f"
 sim_m16_filter="16"
+sim_mach_default="mips8000"
+
 case "${target}" in
   mips*tx39*)		sim_gen=IGEN
 			sim_igen_filter="32,f"
@@ -108,15 +110,18 @@ case "${target}" in
 			;;
   mips64vr43*-*-*)	sim_gen=IGEN
 			sim_igen_machine="-M mipsIV"
+			sim_mach_default="mips8000"
 			;;
   mips64vr5*-*-*)	sim_gen=IGEN
 			sim_igen_machine="-M vr5000"
+			sim_mach_default="mips5000"
 			;;
   mips64vr41*)		sim_gen=M16
 			sim_igen_machine="-M vr4100"
 			sim_m16_machine="-M vr4100"
 			sim_igen_filter="32,64,f"
 			sim_m16_filter="16"
+			sim_mach_default="mips4100"
                         ;;
   mips64vr-*-* | mips64vrel-*-*)
 			sim_gen=MULTI
@@ -138,20 +143,24 @@ case "${target}" in
   mipsisa32*-*-*)	sim_gen=IGEN
 		        sim_igen_machine="-M mips32"
 			sim_igen_filter="32,f"
+			sim_mach_default="mipsisa32"
 			;;
   mipsisa64sb1*-*-*)	sim_gen=IGEN
 		        sim_igen_machine="-M mips64,sb1"
 			sim_igen_filter="32,64,f"
+			sim_mach_default="mips_sb1"
 			;;
   mipsisa64*-*-*)	sim_gen=IGEN
 		        sim_igen_machine="-M mips64,mips3d"
 			sim_igen_filter="32,64,f"
+			sim_mach_default="mipsisa64"
 			;;
   mips*lsi*)	        sim_gen=M16
 			sim_igen_machine="-M mipsIII,mips16"
 			sim_m16_machine="-M mips16,mipsIII"
 			sim_igen_filter="32,f"
 			sim_m16_filter="16"
+			sim_mach_default="mips4000"
                         ;;
   mips*-*-*)		sim_gen=IGEN
 			sim_igen_filter="32,f"
@@ -190,13 +199,58 @@ if test ${sim_gen} = MULTI; then
   fi
 
   # Start in a known state.
-  rm -f multi-include.h multi-switch.c
+  rm -f multi-include.h multi-run.c
   sim_multi_flags=
   sim_multi_src=
   sim_multi_obj=multi-run.o
   sim_multi_igen_configs=
   sim_seen_default=no
 
+  cat << __EOF__ > multi-run.c
+/* Main entry point for MULTI simulators.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   --
+
+   This file was generated by sim/mips/configure.  */
+
+#include "sim-main.h"
+#include "multi-include.h"
+
+#define SD sd
+#define CPU cpu
+
+void
+sim_engine_run (SIM_DESC sd,
+		int next_cpu_nr,
+		int nr_cpus,
+		int signal) /* ignore */
+{
+  int mach;
+
+  if (STATE_ARCHITECTURE (sd) == NULL)
+    mach = bfd_mach_${sim_multi_default};
+  else
+    mach = STATE_ARCHITECTURE (SD)->mach;
+
+  switch (mach)
+    {
+__EOF__
+
   for fc in ${sim_multi_configs}; do
 
     # Split up the entry.  ${c} contains the first three elements.
@@ -252,17 +306,17 @@ if test ${sim_gen} = MULTI; then
     # top-level foo_engine_run() function.
     echo "#include \"${w}${name}_engine.h\"" >> multi-include.h
 
-    # Add case statements for this engine.
+    # Add case statements for this engine to sim_engine_run().
     for mach in `echo ${bfdmachs} | sed 's/,/ /g'`; do
-      echo "case bfd_mach_${mach}:" >> multi-switch.c
+      echo "    case bfd_mach_${mach}:" >> multi-run.c
       if test ${mach} = ${sim_multi_default}; then
-	echo "default:" >> multi-switch.c
+	echo "    default:" >> multi-run.c
 	sim_seen_default=yes
       fi
     done
-    echo "  ${w}${name}_engine_run (sd, next_cpu_nr, nr_cpus, signal);" \
-      >> multi-switch.c
-    echo "  break;" >> multi-switch.c
+    echo "      ${w}${name}_engine_run (sd, next_cpu_nr, nr_cpus, signal);" \
+      >> multi-run.c
+    echo "      break;" >> multi-run.c
   done
 
   # Check whether we added a 'default:' label.
@@ -270,11 +324,50 @@ if test ${sim_gen} = MULTI; then
     AC_MSG_ERROR(Error in configure.in: \${sim_multi_configs} doesn't have an entry for \${sim_multi_default})
   fi
 
-  # Used to define MIPS_BFD_MACH.
-  SIM_SUBTARGET="$SIM_SUBTARGET -DMULTI_DEFAULT_BFD_MACH=bfd_mach_${sim_multi_default}"
+  cat << __EOF__ >> multi-run.c
+    }
+}
+
+int
+mips_mach_multi (SIM_DESC sd)
+{
+  if (STATE_ARCHITECTURE (sd) == NULL)
+    return bfd_mach_${sim_multi_default};
+
+  switch (STATE_ARCHITECTURE (SD)->mach)
+    {
+__EOF__
+
+  # Add case statements for this engine to mips_mach_multi().
+  for fc in ${sim_multi_configs}; do
+
+    # Split up the entry.  ${c} contains the first three elements.
+    # Note: outer sqaure brackets are m4 quotes.
+    c=`echo ${fc} | sed ['s/:[^:]*$//']`
+    bfdmachs=`echo ${fc} | sed 's/.*://'`
+
+    for mach in `echo ${bfdmachs} | sed 's/,/ /g'`; do
+      echo "    case bfd_mach_${mach}:" >> multi-run.c
+    done
+  done
+
+  cat << __EOF__ >> multi-run.c
+      return (STATE_ARCHITECTURE (SD)->mach);
+    default:
+      return bfd_mach_${sim_multi_default};
+    }
+}
+__EOF__
+
+  SIM_SUBTARGET="$SIM_SUBTARGET -DMIPS_MACH_MULTI"
 else
   # For clean-extra
   sim_multi_src=doesnt-exist.c
+
+  if test x"${sim_mach_default}" = x""; then
+    AC_MSG_ERROR(Error in configure.in: \${sim_mach_default} not defined)
+  fi
+  SIM_SUBTARGET="$SIM_SUBTARGET -DMIPS_MACH_DEFAULT=bfd_mach_${sim_mach_default}"
 fi
 sim_igen_flags="-F ${sim_igen_filter} ${sim_igen_machine} ${sim_igen_smp}"
 sim_m16_flags=" -F ${sim_m16_filter}  ${sim_m16_machine}  ${sim_igen_smp}"
diff -Nupr -x CVS -x configure mips.rsandifo/mips.igen mips/mips.igen
--- mips.rsandifo/mips.igen	Wed Nov  6 11:39:48 2002
+++ mips/mips.igen	Wed Nov  6 14:10:02 2002
@@ -233,7 +233,7 @@
 :function:::int:check_mf_cycles:hilo_history *history, signed64 time, const char *new
 {
   /* There are no timing requirements in vr5500 code.  */
-  if (MIPS_BFD_MACH (SD) == bfd_mach_mips5500)
+  if (MIPS_MACH (SD) == bfd_mach_mips5500)
     return 1;
   if (history->mf.timestamp + 3 > time)
     {
diff -Nupr -x CVS -x configure mips.rsandifo/multi-run.c mips/multi-run.c
--- mips.rsandifo/multi-run.c	Wed Nov  6 11:39:48 2002
+++ mips/multi-run.c	Wed Dec 31 16:00:00 1969
@@ -1,36 +0,0 @@
-/* Main entry point for MULTI simulators.
-   Copyright (C) 2002 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-   */
-
-#include "sim-main.h"
-#include "multi-include.h"
-
-#define SD sd
-#define CPU cpu
-
-void
-sim_engine_run (SIM_DESC sd,
-		int next_cpu_nr,
-		int nr_cpus,
-		int signal) /* ignore */
-{
-  switch (MIPS_BFD_MACH (sd))
-    {
-#include "multi-switch.c"
-    }
-}
diff -Nupr -x CVS -x configure mips.rsandifo/sim-main.h mips/sim-main.h
--- mips.rsandifo/sim-main.h	Wed Nov  6 11:39:48 2002
+++ mips/sim-main.h	Wed Nov  6 14:08:48 2002
@@ -950,15 +950,11 @@ void mips_cpu_exception_trigger(SIM_DESC
 void mips_cpu_exception_suspend(SIM_DESC sd, sim_cpu* cpu, int exception);
 void mips_cpu_exception_resume(SIM_DESC sd, sim_cpu* cpu, int exception);
 
-#ifdef MULTI_DEFAULT_BFD_MACH
-#define MIPS_BFD_MACH(SD) \
-	(STATE_ARCHITECTURE (SD)->mach != 0 \
-	 ? STATE_ARCHITECTURE (SD)->mach \
-	 : MULTI_DEFAULT_BFD_MACH)
-#endif
-
-#ifndef MIPS_BFD_MACH
-#define MIPS_BFD_MACH(SD) 0
+#ifdef MIPS_MACH_MULTI
+extern int mips_mach_multi(SIM_DESC sd);
+#define MIPS_MACH(SD)	mips_mach_multi(SD)
+#else
+#define	MIPS_MACH(SD)	MIPS_MACH_DEFAULT
 #endif
 
 #if H_REVEALS_MODULE_P (SIM_MAIN_INLINE)


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