PowerPC64 .branch_lt address
[binutils-gdb.git] / sim / common / genmloop.sh
old mode 100644 (file)
new mode 100755 (executable)
index dddd1a1..1bbeb61
@@ -1,22 +1,21 @@
 # Generate the main loop of the simulator.
-# Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright (C) 1996-2022 Free Software Foundation, Inc.
 # Contributed by Cygnus Support.
 #
 # This file is part of the GNU simulators.
 #
 # 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, or (at your option)
-# any later version.
+# the Free Software Foundation; either version 3 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.
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 # This file creates two files: eng.hin and mloop.cin.
 # eng.hin defines a few macros that specify what kind of engine was selected
 #
 #      Specify the suffix to append to output files.
 #
+# -shell <shell>
+#
+#      Specify the shell to use to execute <input-file>
+#
 # Only one of -scache/-pbb may be selected.
 # -simple is the default.
 #
@@ -137,6 +140,7 @@ switch=
 cpu="unknown"
 infile=""
 prefix="unknown"
+outprefix=""
 outsuffix=""
 
 while test $# -gt 0
@@ -151,6 +155,7 @@ do
        -scache) scache=yes ;;
        -pbb) pbb=yes ;;
        -no-parallel) ;;
+       -outfile-prefix) shift ; outprefix=$1 ;;
        -outfile-suffix) shift ; outsuffix=$1 ;;
        -parallel-read) parallel=read ;;
        -parallel-write) parallel=write ;;
@@ -160,6 +165,7 @@ do
        -switch) shift ; switch=$1 ;;
        -cpu) shift ; cpu=$1 ;;
        -infile) shift ; infile=$1 ;;
+       -shell) shift ; SHELL=$1 ;;
        *) echo "unknown option: $1" >&2 ; exit 1 ;;
        esac
        shift
@@ -193,8 +199,8 @@ PREFIX=`echo ${prefix} | tr "${lowercase}" "${uppercase}"`
 
 ##########################################################################
 
-rm -f eng${outsuffix}.hin
-exec 1>eng${outsuffix}.hin
+rm -f ${outprefix}eng${outsuffix}.hin
+exec 1>${outprefix}eng${outsuffix}.hin
 
 echo "/* engine configuration for ${cpu} */"
 echo ""
@@ -287,8 +293,8 @@ fi
 
 ##########################################################################
 
-rm -f tmp-mloop-$$.cin mloop${outsuffix}.cin
-exec 1>tmp-mloop-$$.cin
+rm -f ${outprefix}tmp-mloop-$$.cin ${outprefix}mloop${outsuffix}.cin
+exec 1>${outprefix}tmp-mloop-$$.cin
 
 # We use @cpu@ instead of ${cpu} because we still need to run sed to handle
 # transformation of @cpu@ for mainloop.in, so there's no need to use ${cpu}
@@ -297,14 +303,19 @@ exec 1>tmp-mloop-$$.cin
 cat << EOF
 /* This file is generated by the genmloop script.  DO NOT EDIT! */
 
+/* This must come before any other includes.  */
+#include "defs.h"
+
 /* Enable switch() support in cgen headers.  */
 #define SEM_IN_SWITCH
 
 #define WANT_CPU @cpu@
 #define WANT_CPU_@CPU@
 
-#include "sim-main.h"
+#include "ansidecl.h"
 #include "bfd.h"
+
+#include "sim-main.h"
 #include "cgen-mem.h"
 #include "cgen-ops.h"
 #include "sim-assert.h"
@@ -340,7 +351,7 @@ static INLINE void
    This is as opposed to x-after which is only emitted at the end of a group
    of parallel insns.  */
 
-static INLINE void
+ATTRIBUTE_UNUSED static INLINE void
 @prefix@_emit_before (SIM_CPU *current_cpu, SCACHE *sc, PCADDR pc, int first_p)
 {
   ARGBUF *abuf = &sc[0].argbuf;
@@ -355,7 +366,7 @@ static INLINE void
    x-after is emitted after a serial insn or at the end of a group of
    parallel insns.  */
 
-static INLINE void
+ATTRIBUTE_UNUSED static INLINE void
 @prefix@_emit_after (SIM_CPU *current_cpu, SCACHE *sc, PCADDR pc)
 {
   ARGBUF *abuf = &sc[0].argbuf;
@@ -1108,7 +1119,7 @@ void
            }
        }
 
-      TRACE_INSN_FINI (current_cpu, cur_abuf, 0 /*last_p*/);
+      CGEN_TRACE_INSN_FINI (current_cpu, cur_abuf, 0 /*last_p*/);
     }
 
   /* FIXME: Later make cover macros: PROFILE_INSN_{INIT,FINI}.  */
@@ -1116,8 +1127,8 @@ void
       && ARGBUF_PROFILE_P (cur_abuf))
     @prefix@_model_insn_before (current_cpu, first_p);
 
-  TRACE_INSN_INIT (current_cpu, cur_abuf, first_p);
-  TRACE_INSN (current_cpu, cur_idesc->idata, cur_abuf, pc);
+  CGEN_TRACE_INSN_INIT (current_cpu, cur_abuf, first_p);
+  CGEN_TRACE_INSN (current_cpu, cur_idesc->idata, cur_abuf, pc);
 }
 
 /* x-after handler.
@@ -1142,7 +1153,7 @@ void
       cycles = (*prev_idesc->timing->model_fn) (current_cpu, prev_sem_arg);
       @prefix@_model_insn_after (current_cpu, 1 /*last_p*/, cycles);
     }
-  TRACE_INSN_FINI (current_cpu, prev_abuf, 1 /*last_p*/);
+  CGEN_TRACE_INSN_FINI (current_cpu, prev_abuf, 1 /*last_p*/);
 }
 
 #define FAST_P 0
@@ -1327,8 +1338,9 @@ fi # -pbb
 # Expand @..@ macros appearing in tmp-mloop-{pid}.cin.
 sed \
   -e "s/@cpu@/$cpu/g" -e "s/@CPU@/$CPU/g" \
-  -e "s/@prefix@/$prefix/g" -e "s/@PREFIX@/$PREFIX/g" < tmp-mloop-$$.cin > mloop${outsuffix}.cin
+  -e "s/@prefix@/$prefix/g" -e "s/@PREFIX@/$PREFIX/g" \
+  < ${outprefix}tmp-mloop-$$.cin > ${outprefix}mloop${outsuffix}.cin
 rc=$?
-rm -f tmp-mloop-$$.cin
+rm -f ${outprefix}tmp-mloop-$$.cin
 
 exit $rc