* [PATCH 1/3] sim: cgen: unify the genmloop logic a bit
@ 2023-12-20 1:23 Mike Frysinger
2023-12-20 1:23 ` [PATCH 2/3] sim: common: add $LINENO rewriting support to genmloop scripts Mike Frysinger
2023-12-20 1:23 ` [PATCH 3/3] sim: mloop: add #line pragmas everywhere Mike Frysinger
0 siblings, 2 replies; 3+ messages in thread
From: Mike Frysinger @ 2023-12-20 1:23 UTC (permalink / raw)
To: gdb-patches
Pull out the common parts of the genmloop invocation into the common
code. This will make it easier to add more, and make the per-port
differences a little more obvious.
---
sim/Makefile.in | 68 +++++++++++++++++++++------------------------
sim/common/local.mk | 5 ++++
sim/cris/local.mk | 14 ++++------
sim/frv/local.mk | 7 ++---
sim/iq2000/local.mk | 7 ++---
sim/lm32/local.mk | 7 ++---
sim/m32r/local.mk | 21 ++++++--------
sim/or1k/local.mk | 7 ++---
8 files changed, 64 insertions(+), 72 deletions(-)
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 08da2275b7dc..8124910ea182 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -232,3 +232,8 @@ CGEN_GEN_CPU_DESC = \
$(CGEN) $(cgendir) "$(CGENFLAGS)" \
$(@D) "$$FLAGS" $$cpu "$$isa" $$mach "$$SUFFIX" \
$(CGEN_ARCHFILE) ignored $$opcfile
+
+CGEN_GEN_MLOOP = \
+ $(SHELL) $(srccom)/genmloop.sh \
+ -shell $(SHELL) \
+ -infile $< -outfile-prefix $(@D)/
diff --git a/sim/cris/local.mk b/sim/cris/local.mk
index 66ebc99376c4..011f8029e49f 100644
--- a/sim/cris/local.mk
+++ b/sim/cris/local.mk
@@ -91,11 +91,10 @@ BUILT_SOURCES += \
## FIXME: What is mono and what does "Use of `mono' is wip" mean (other
## than the apparent; some "mono" feature is work in progress)?
%D%/mloopv10f.c %D%/engv10.h: %D%/stamp-mloop-v10f ; @true
-%D%/stamp-mloop-v10f: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop-v10f: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -no-fast -pbb -switch semcrisv10f-switch.c \
- -cpu crisv10f \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/ -outfile-suffix -v10f
+ -cpu crisv10f -outfile-suffix -v10f
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-v10f.hin %D%/engv10.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-v10f.cin %D%/mloopv10f.c
$(AM_V_at)touch $@
@@ -103,11 +102,10 @@ BUILT_SOURCES += \
## FIXME: What is mono and what does "Use of `mono' is wip" mean (other
## than the apparent; some "mono" feature is work in progress)?
%D%/mloopv32f.c %D%/engv32.h: %D%/stamp-mloop-v32f ; @true
-%D%/stamp-mloop-v32f: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop-v32f: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -no-fast -pbb -switch semcrisv32f-switch.c \
- -cpu crisv32f \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/ -outfile-suffix -v32f
+ -cpu crisv32f -outfile-suffix -v32f
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng-v32f.hin %D%/engv32.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop-v32f.cin %D%/mloopv32f.c
$(AM_V_at)touch $@
diff --git a/sim/frv/local.mk b/sim/frv/local.mk
index e4940398fd76..287633b4f4c9 100644
--- a/sim/frv/local.mk
+++ b/sim/frv/local.mk
@@ -91,11 +91,10 @@ BUILT_SOURCES += %D%/eng.h
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
-%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -scache -parallel-generic-write -parallel-only \
- -cpu frvbf \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+ -cpu frvbf
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
$(AM_V_at)touch $@
diff --git a/sim/iq2000/local.mk b/sim/iq2000/local.mk
index 99649ec7ad0c..9ed30f3a9bcf 100644
--- a/sim/iq2000/local.mk
+++ b/sim/iq2000/local.mk
@@ -67,11 +67,10 @@ BUILT_SOURCES += %D%/eng.h
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
-%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -fast -pbb -switch sem-switch.c \
- -cpu iq2000bf \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+ -cpu iq2000bf
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
$(AM_V_at)touch $@
diff --git a/sim/lm32/local.mk b/sim/lm32/local.mk
index 917e6bb42ea6..11c6b10ff0c5 100644
--- a/sim/lm32/local.mk
+++ b/sim/lm32/local.mk
@@ -72,11 +72,10 @@ BUILT_SOURCES += %D%/eng.h
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
-%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -fast -pbb -switch sem-switch.c \
- -cpu lm32bf \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+ -cpu lm32bf
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
$(AM_V_at)touch $@
diff --git a/sim/m32r/local.mk b/sim/m32r/local.mk
index 13f6ea5f9570..3bec547cb253 100644
--- a/sim/m32r/local.mk
+++ b/sim/m32r/local.mk
@@ -94,33 +94,30 @@ BUILT_SOURCES += \
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
-%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -fast -pbb -switch sem-switch.c \
- -cpu m32rbf \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+ -cpu m32rbf
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
$(AM_V_at)touch $@
## FIXME: Use of `mono' is wip.
%D%/mloopx.c %D%/engx.h: %D%/stamp-mloop-x ; @true
-%D%/stamp-mloop-x: $(srccom)/genmloop.sh %D%/mloopx.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop-x: %D%/mloopx.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -no-fast -pbb -parallel-write -switch semx-switch.c \
- -cpu m32rxf \
- -infile $(srcdir)/%D%/mloopx.in -outfile-prefix %D%/ -outfile-suffix x
+ -cpu m32rxf -outfile-suffix x
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/engx.hin %D%/engx.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloopx.cin %D%/mloopx.c
$(AM_V_at)touch $@
## FIXME: Use of `mono' is wip.
%D%/mloop2.c %D%/eng2.h: %D%/stamp-mloop-2 ; @true
-%D%/stamp-mloop-2: $(srccom)/genmloop.sh %D%/mloop2.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop-2: %D%/mloop2.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -no-fast -pbb -parallel-write -switch sem2-switch.c \
- -cpu m32r2f \
- -infile $(srcdir)/%D%/mloop2.in -outfile-prefix %D%/ -outfile-suffix 2
+ -cpu m32r2f -outfile-suffix 2
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng2.hin %D%/eng2.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop2.cin %D%/mloop2.c
$(AM_V_at)touch $@
diff --git a/sim/or1k/local.mk b/sim/or1k/local.mk
index cb48f821dcf1..979e0e349043 100644
--- a/sim/or1k/local.mk
+++ b/sim/or1k/local.mk
@@ -74,11 +74,10 @@ BUILT_SOURCES += %D%/eng.h
## FIXME: Use of `mono' is wip.
%D%/mloop.c %D%/eng.h: %D%/stamp-mloop ; @true
-%D%/stamp-mloop: $(srccom)/genmloop.sh %D%/mloop.in
- $(AM_V_GEN)$(SHELL) $(srccom)/genmloop.sh -shell $(SHELL) \
+%D%/stamp-mloop: %D%/mloop.in $(srccom)/genmloop.sh
+ $(AM_V_GEN)$(CGEN_GEN_MLOOP) \
-mono -fast -pbb -switch sem-switch.c \
- -cpu or1k32bf \
- -infile $(srcdir)/%D%/mloop.in -outfile-prefix %D%/
+ -cpu or1k32bf
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/eng.hin %D%/eng.h
$(AM_V_at)$(SHELL) $(srcroot)/move-if-change %D%/mloop.cin %D%/mloop.c
$(AM_V_at)touch $@
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] sim: common: add $LINENO rewriting support to genmloop scripts
2023-12-20 1:23 [PATCH 1/3] sim: cgen: unify the genmloop logic a bit Mike Frysinger
@ 2023-12-20 1:23 ` Mike Frysinger
2023-12-20 1:23 ` [PATCH 3/3] sim: mloop: add #line pragmas everywhere Mike Frysinger
1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2023-12-20 1:23 UTC (permalink / raw)
To: gdb-patches
The generated mloop files can trigger compile time warnings. It can
be difficult to see/understand where the original code is coming from
as all the diagnostics point to the generated output. Using #line
pragmas, we can point people to the original source files.
Unfortunately, this code is written in POSIX shell, and that lacks
support for line number tracking. The $LINENO variable, even when
available, can just be plain wrong. For example, when using dash
and subshells, $LINENO can end up having negative values. Add a
wrapper script that will uses awk to rewrite the $LINENO variable
to the right value to avoid all that.
Basically lineno.sh takes an input script, rewrites all uses of
$LINENO into the actual line number (and $0 into the original file
name), and then executes the temporary script.
This commit doesn't actually add #line pragmas to any files. That
comes next.
---
sim/Makefile.in | 6 ++++--
sim/common/genmloop.sh | 49 ++++++++++++++++++++++++++----------------
sim/common/lineno.sh | 44 +++++++++++++++++++++++++++++++++++++
sim/common/local.mk | 6 ++++--
4 files changed, 83 insertions(+), 22 deletions(-)
create mode 100755 sim/common/lineno.sh
diff --git a/sim/common/genmloop.sh b/sim/common/genmloop.sh
index e6683def4637..73ff2fdc100e 100755
--- a/sim/common/genmloop.sh
+++ b/sim/common/genmloop.sh
@@ -142,6 +142,7 @@ infile=""
prefix="unknown"
outprefix=""
outsuffix=""
+lineno=""
while test $# -gt 0
do
@@ -166,6 +167,8 @@ do
-cpu) shift ; cpu=$1 ;;
-infile) shift ; infile=$1 ;;
-shell) shift ; SHELL=$1 ;;
+ -awk) shift ; AWK=$1 ; export AWK ;;
+ -lineno) shift ; lineno=$1 ;;
*) echo "unknown option: $1" >&2 ; exit 1 ;;
esac
shift
@@ -199,6 +202,16 @@ PREFIX=`echo ${prefix} | tr "${lowercase}" "${uppercase}"`
##########################################################################
+load_infile_section() {
+ if [ -n "${lineno}" ]; then
+ ${SHELL} ${lineno} \
+ "${infile}" "${outprefix}mloop${outsuffix}.tmp" \
+ "$@"
+ else
+ ${SHELL} ${infile} "$@"
+ fi
+}
+
rm -f ${outprefix}eng${outsuffix}.hin
exec 1>${outprefix}eng${outsuffix}.hin
@@ -380,7 +393,7 @@ ATTRIBUTE_UNUSED static INLINE void
EOF
-${SHELL} $infile support
+load_infile_section support
##########################################################################
@@ -425,7 +438,7 @@ esac
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
if [ x$parallel = xread ] ; then
cat << EOF
@@ -466,7 +479,7 @@ cat << EOF
/* begin full-exec-simple */
EOF
-${SHELL} $infile full-exec-simple
+load_infile_section full-exec-simple
cat << EOF
/* end full-exec-simple */
@@ -527,7 +540,7 @@ static INLINE SCACHE *
/* begin extract-scache */
EOF
-${SHELL} $infile extract-scache
+load_infile_section extract-scache
cat << EOF
/* end extract-scache */
@@ -557,7 +570,7 @@ EOF
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
cat << EOF
@@ -580,7 +593,7 @@ cat << EOF
/* begin full-exec-scache */
EOF
-${SHELL} $infile full-exec-scache
+load_infile_section full-exec-scache
cat << EOF
/* end full-exec-scache */
@@ -618,7 +631,7 @@ EOF
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
cat << EOF
@@ -647,7 +660,7 @@ cat << EOF
/* begin fast-exec-scache */
EOF
-${SHELL} $infile fast-exec-scache
+load_infile_section fast-exec-scache
cat << EOF
/* end fast-exec-scache */
@@ -695,7 +708,7 @@ static INLINE SCACHE *
/* begin extract-scache */
EOF
-${SHELL} $infile extract-scache
+load_infile_section extract-scache
cat << EOF
/* end extract-scache */
@@ -726,7 +739,7 @@ EOF
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
if [ x$parallel = xread ] ; then
cat << EOF
@@ -762,7 +775,7 @@ cat << EOF
/* begin full-exec-scache */
EOF
-${SHELL} $infile full-exec-scache
+load_infile_section full-exec-scache
cat << EOF
/* end full-exec-scache */
@@ -798,7 +811,7 @@ EOF
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
if [ x$parallel = xread ] ; then
cat << EOF
@@ -841,7 +854,7 @@ cat << EOF
/* begin fast-exec-scache */
EOF
-${SHELL} $infile fast-exec-scache
+load_infile_section fast-exec-scache
cat << EOF
/* end fast-exec-scache */
@@ -948,7 +961,7 @@ INLINE SEM_PC
/* begin extract-pbb */
EOF
-${SHELL} $infile extract-pbb
+load_infile_section extract-pbb
cat << EOF
/* end extract-pbb */
@@ -1183,7 +1196,7 @@ esac
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
cat << EOF
@@ -1226,7 +1239,7 @@ cat << EOF
/* begin full-exec-pbb */
EOF
-${SHELL} $infile full-exec-pbb
+load_infile_section full-exec-pbb
cat << EOF
/* end full-exec-pbb */
@@ -1275,7 +1288,7 @@ esac
# Any initialization code before looping starts.
# Note that this code may declare some locals.
-${SHELL} $infile init
+load_infile_section init
cat << EOF
@@ -1318,7 +1331,7 @@ cat << EOF
/* begin fast-exec-pbb */
EOF
-${SHELL} $infile fast-exec-pbb
+load_infile_section fast-exec-pbb
cat << EOF
/* end fast-exec-pbb */
diff --git a/sim/common/lineno.sh b/sim/common/lineno.sh
new file mode 100755
index 000000000000..3332f375287f
--- /dev/null
+++ b/sim/common/lineno.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Replace $LINENO on the fly.
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# 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 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, see <http://www.gnu.org/licenses/>.
+
+# Since $LINENO is not reliable in shells/subshells, generate it on the fly.
+
+if [ $# -lt 2 ]; then
+ cat <<EOF >&2
+Usage: $0 <script> <tempfile> [script args]
+
+Rewrite the $LINENO usage in <script> with the line number. The temp script is
+written to <tempfile>, and then removed when done.
+EOF
+ exit 1
+fi
+
+input=$1
+shift
+output=$1
+shift
+
+${AWK:-awk} '{
+ gsub("[$]LINENO", NR + 1)
+ gsub("\"[$]0\"", "\"" FILENAME "\"")
+ print
+}' "${input}" >"${output}"
+${SHELL} "${output}" "$@"
+
+rm -f "${output}"
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 8124910ea182..6414ad1132f2 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -234,6 +234,8 @@ CGEN_GEN_CPU_DESC = \
$(CGEN_ARCHFILE) ignored $$opcfile
CGEN_GEN_MLOOP = \
- $(SHELL) $(srccom)/genmloop.sh \
- -shell $(SHELL) \
+ $(SHELL) $(srccom)/lineno.sh \
+ $(srccom)/genmloop.sh \
+ $@.lineno.sh \
+ -shell $(SHELL) -awk $(AWK) -lineno $(srccom)/lineno.sh \
-infile $< -outfile-prefix $(@D)/
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] sim: mloop: add #line pragmas everywhere
2023-12-20 1:23 [PATCH 1/3] sim: cgen: unify the genmloop logic a bit Mike Frysinger
2023-12-20 1:23 ` [PATCH 2/3] sim: common: add $LINENO rewriting support to genmloop scripts Mike Frysinger
@ 2023-12-20 1:23 ` Mike Frysinger
1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2023-12-20 1:23 UTC (permalink / raw)
To: gdb-patches
This will make compiler diagnostics much better with generated code
so people can understand the original source file.
---
sim/common/genmloop.sh | 32 ++++++++++++++++++++++++++++++++
sim/cris/mloop.in | 5 +++++
sim/frv/mloop.in | 4 ++++
sim/iq2000/mloop.in | 4 ++++
sim/lm32/mloop.in | 4 ++++
sim/m32r/mloop.in | 4 ++++
sim/m32r/mloop2.in | 3 +++
sim/m32r/mloopx.in | 3 +++
sim/or1k/mloop.in | 4 ++++
9 files changed, 63 insertions(+)
diff --git a/sim/common/genmloop.sh b/sim/common/genmloop.sh
index 73ff2fdc100e..8c42f8f21bf6 100755
--- a/sim/common/genmloop.sh
+++ b/sim/common/genmloop.sh
@@ -314,6 +314,7 @@ exec 1>${outprefix}tmp-mloop-$$.cin
# here.
cat << EOF
+#line $LINENO "$0"
/* This file is generated by the genmloop script. DO NOT EDIT! */
/* This must come before any other includes. */
@@ -410,6 +411,7 @@ load_infile_section support
if [ x$scache != xyes -a x$pbb != xyes ] ; then
cat << EOF
+#line $LINENO "$0"
#define FAST_P 0
@@ -429,6 +431,7 @@ EOF
case x$parallel in
xread | xwrite)
cat << EOF
+#line $LINENO "$0"
PAREXEC pbufs[MAX_PARALLEL_INSNS];
PAREXEC *par_exec;
@@ -442,6 +445,7 @@ load_infile_section init
if [ x$parallel = xread ] ; then
cat << EOF
+#line $LINENO "$0"
#if defined (__GNUC__)
{
@@ -459,6 +463,7 @@ EOF
fi
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -482,6 +487,7 @@ EOF
load_infile_section full-exec-simple
cat << EOF
+#line $LINENO "$0"
/* end full-exec-simple */
++ CPU_INSN_COUNT (current_cpu);
@@ -501,6 +507,7 @@ EOF
if [ x$fast = xyes ] ; then
cat << EOF
+#line $LINENO "$0"
#define FAST_P 1
@@ -522,6 +529,7 @@ fi # simple engine
if [ x$scache = xyes -a x$parallel = xno ] ; then
cat << EOF
+#line $LINENO "$0"
static INLINE SCACHE *
@prefix@_scache_lookup (SIM_CPU *current_cpu, PCADDR vpc, SCACHE *scache,
@@ -543,6 +551,7 @@ EOF
load_infile_section extract-scache
cat << EOF
+#line $LINENO "$0"
/* end extract-scache */
}
else if (! FAST_P)
@@ -573,6 +582,7 @@ EOF
load_infile_section init
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -596,6 +606,7 @@ EOF
load_infile_section full-exec-scache
cat << EOF
+#line $LINENO "$0"
/* end full-exec-scache */
SET_H_PC (vpc);
@@ -616,6 +627,7 @@ EOF
if [ x$fast = xyes ] ; then
cat << EOF
+#line $LINENO "$0"
#define FAST_P 1
@@ -634,6 +646,7 @@ EOF
load_infile_section init
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -663,6 +676,7 @@ EOF
load_infile_section fast-exec-scache
cat << EOF
+#line $LINENO "$0"
/* end fast-exec-scache */
SET_H_PC (vpc);
@@ -689,6 +703,7 @@ fi # -scache && ! parallel
if [ x$scache = xyes -a x$parallel != xno ] ; then
cat << EOF
+#line $LINENO "$0"
static INLINE SCACHE *
@prefix@_scache_lookup (SIM_CPU *current_cpu, PCADDR vpc, SCACHE *scache,
@@ -711,6 +726,7 @@ EOF
load_infile_section extract-scache
cat << EOF
+#line $LINENO "$0"
/* end extract-scache */
#undef SET_LAST_INSN_P
}
@@ -743,6 +759,7 @@ load_infile_section init
if [ x$parallel = xread ] ; then
cat << EOF
+#line $LINENO "$0"
#if defined (__GNUC__)
{
if (! CPU_IDESC_READ_INIT_P (current_cpu))
@@ -759,6 +776,7 @@ EOF
fi
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -778,6 +796,7 @@ EOF
load_infile_section full-exec-scache
cat << EOF
+#line $LINENO "$0"
/* end full-exec-scache */
}
while (0 /*CPU_RUNNING_P (current_cpu)*/);
@@ -794,6 +813,7 @@ EOF
if [ x$fast = xyes ] ; then
cat << EOF
+#line $LINENO "$0"
#define FAST_P 1
@@ -815,6 +835,7 @@ load_infile_section init
if [ x$parallel = xread ] ; then
cat << EOF
+#line $LINENO "$0"
#if defined (__GNUC__)
{
@@ -832,6 +853,7 @@ EOF
fi
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -857,6 +879,7 @@ EOF
load_infile_section fast-exec-scache
cat << EOF
+#line $LINENO "$0"
/* end fast-exec-scache */
}
while (0 /*CPU_RUNNING_P (current_cpu)*/);
@@ -881,6 +904,7 @@ fi # -scache && parallel
if [ x$pbb = xyes ] ; then
cat << EOF
+#line $LINENO "$0"
/* Record address of cti terminating a pbb. */
#define SET_CTI_VPC(sc) do { _cti_sc = (sc); } while (0)
@@ -964,6 +988,7 @@ EOF
load_infile_section extract-pbb
cat << EOF
+#line $LINENO "$0"
/* end extract-pbb */
/* The last one is a pseudo-insn to link to the next chain.
@@ -1187,6 +1212,7 @@ EOF
case x$parallel in
xread | xwrite)
cat << EOF
+#line $LINENO "$0"
PAREXEC pbufs[MAX_PARALLEL_INSNS];
PAREXEC *par_exec = &pbufs[0];
@@ -1199,6 +1225,7 @@ esac
load_infile_section init
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -1242,6 +1269,7 @@ EOF
load_infile_section full-exec-pbb
cat << EOF
+#line $LINENO "$0"
/* end full-exec-pbb */
}
while (CPU_RUNNING_P (current_cpu));
@@ -1258,6 +1286,7 @@ EOF
if [ x$fast = xyes ] ; then
cat << EOF
+#line $LINENO "$0"
#define FAST_P 1
@@ -1279,6 +1308,7 @@ EOF
case x$parallel in
xread | xwrite)
cat << EOF
+#line $LINENO "$0"
PAREXEC pbufs[MAX_PARALLEL_INSNS];
PAREXEC *par_exec = &pbufs[0];
@@ -1291,6 +1321,7 @@ esac
load_infile_section init
cat << EOF
+#line $LINENO "$0"
if (! CPU_IDESC_SEM_INIT_P (current_cpu))
{
@@ -1334,6 +1365,7 @@ EOF
load_infile_section fast-exec-pbb
cat << EOF
+#line $LINENO "$0"
/* end fast-exec-pbb */
}
while (CPU_RUNNING_P (current_cpu));
diff --git a/sim/cris/mloop.in b/sim/cris/mloop.in
index 21cbb6923baa..d0f3ee534167 100644
--- a/sim/cris/mloop.in
+++ b/sim/cris/mloop.in
@@ -42,6 +42,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
#include <stdlib.h>
/* It seems we don't have a templated header file corresponding to
@@ -142,6 +143,7 @@ EOF
xinit)
cat <<EOF
+#line $LINENO "$0"
/* This seemed the only sane location to emit a call to a
model-specific init function. It may not work for all simulator
types. FIXME: Introduce a model-init hook. */
@@ -160,6 +162,7 @@ xextract-simple | xextract-scache)
# Outputs: sc filled in
cat <<EOF
+#line $LINENO "$0"
{
CGEN_INSN_INT insn = GETIMEMUHI (current_cpu, vpc);
extract (current_cpu, vpc, insn, SEM_ARGBUF (sc), FAST_P);
@@ -179,6 +182,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -276,6 +280,7 @@ xfull-exec-* | xfast-exec-*)
# vpc contains the address of the next insn to execute
cat <<EOF
+#line $LINENO "$0"
{
#if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
#define DEFINE_SWITCH
diff --git a/sim/frv/mloop.in b/sim/frv/mloop.in
index dc77f06651dc..9429bf05d72e 100644
--- a/sim/frv/mloop.in
+++ b/sim/frv/mloop.in
@@ -39,6 +39,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
static INLINE const IDESC *
extract (SIM_CPU *current_cpu, PCADDR pc, CGEN_INSN_INT insn, ARGBUF *abuf,
@@ -411,6 +412,7 @@ EOF
xinit)
cat <<EOF
+#line $LINENO "$0"
/*xxxinit*/
/* If the timer is enabled, then we will enable model profiling during
execution. This is because the timer needs accurate cycles counts to
@@ -428,6 +430,7 @@ xextract-simple | xextract-scache)
# SET_LAST_INSN_P(last_p) called to indicate whether insn is last one
cat <<EOF
+#line $LINENO "$0"
{
CGEN_INSN_INT insn = frvbf_read_imem_USI (current_cpu, vpc);
extract (current_cpu, vpc, insn, SEM_ARGBUF (sc), FAST_P);
@@ -449,6 +452,7 @@ xfull-exec-* | xfast-exec-*)
# scache lookup.
cat <<EOF
+#line $LINENO "$0"
{
FRV_VLIW *vliw;
int first_insn_p = 1;
diff --git a/sim/iq2000/mloop.in b/sim/iq2000/mloop.in
index e0ec847ada9d..1d3df32ee777 100644
--- a/sim/iq2000/mloop.in
+++ b/sim/iq2000/mloop.in
@@ -40,6 +40,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
#include <stdlib.h>
static INLINE const IDESC *
@@ -139,6 +140,7 @@ xextract-simple | xextract-scache)
# Outputs: sc filled in
cat <<EOF
+#line $LINENO "$0"
{
CGEN_INSN_INT insn = GETIMEMUSI (current_cpu, CPU2INSN(vpc));
extract (current_cpu, vpc, insn, SEM_ARGBUF (sc), FAST_P);
@@ -159,6 +161,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -224,6 +227,7 @@ xfull-exec-* | xfast-exec-*)
# vpc contains the address of the next insn to execute
cat <<EOF
+#line $LINENO "$0"
{
#if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
#define DEFINE_SWITCH
diff --git a/sim/lm32/mloop.in b/sim/lm32/mloop.in
index 574f00a51193..d5dc1ed959a5 100644
--- a/sim/lm32/mloop.in
+++ b/sim/lm32/mloop.in
@@ -32,6 +32,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
#include <stdlib.h>
static INLINE const IDESC *
@@ -130,6 +131,7 @@ xinit)
xextract-simple | xextract-scache)
cat <<EOF
+#line $LINENO "$0"
{
CGEN_INSN_INT insn = GETIMEMUSI (current_cpu, vpc);
extract (current_cpu, vpc, insn, SEM_ARGBUF (sc), FAST_P);
@@ -149,6 +151,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -183,6 +186,7 @@ xfull-exec-* | xfast-exec-*)
# Outputs: vpc
cat <<EOF
+#line $LINENO "$0"
/* Update cycle counter */
SET_H_CSR (LM32_CSR_CC, GET_H_CSR (LM32_CSR_CC) + 1);
#if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
diff --git a/sim/m32r/mloop.in b/sim/m32r/mloop.in
index 1d4d51b90071..cec2190b28c2 100644
--- a/sim/m32r/mloop.in
+++ b/sim/m32r/mloop.in
@@ -42,6 +42,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
#include <stdlib.h>
static INLINE const IDESC *
@@ -157,6 +158,7 @@ xinit)
xextract-simple | xextract-scache)
cat <<EOF
+#line $LINENO "$0"
{
if ((pc & 3) != 0)
{
@@ -199,6 +201,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -302,6 +305,7 @@ xfull-exec-* | xfast-exec-*)
# vpc is the virtual program counter.
cat <<EOF
+#line $LINENO "$0"
#if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
#define DEFINE_SWITCH
#include "sem-switch.c"
diff --git a/sim/m32r/mloop2.in b/sim/m32r/mloop2.in
index e7982fc9e419..462c8be9267e 100644
--- a/sim/m32r/mloop2.in
+++ b/sim/m32r/mloop2.in
@@ -41,6 +41,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
/* Emit insns to write back the results of insns executed in parallel.
SC points to a sufficient number of scache entries for the writeback
@@ -206,6 +207,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -517,6 +519,7 @@ xfull-exec-pbb)
# vpc is the virtual program counter.
cat <<EOF
+#line $LINENO "$0"
#define DEFINE_SWITCH
#include "sem2-switch.c"
EOF
diff --git a/sim/m32r/mloopx.in b/sim/m32r/mloopx.in
index e601dcad446b..a7371ed2fbe8 100644
--- a/sim/m32r/mloopx.in
+++ b/sim/m32r/mloopx.in
@@ -41,6 +41,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
/* Emit insns to write back the results of insns executed in parallel.
SC points to a sufficient number of scache entries for the writeback
@@ -206,6 +207,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -517,6 +519,7 @@ xfull-exec-pbb)
# vpc is the virtual program counter.
cat <<EOF
+#line $LINENO "$0"
#define DEFINE_SWITCH
#include "semx-switch.c"
EOF
diff --git a/sim/or1k/mloop.in b/sim/or1k/mloop.in
index a1cb117dc61d..0b707ea0766f 100644
--- a/sim/or1k/mloop.in
+++ b/sim/or1k/mloop.in
@@ -42,6 +42,7 @@ case "x$1" in
xsupport)
cat <<EOF
+#line $LINENO "$0"
#include <stdlib.h>
static INLINE const IDESC *
@@ -144,6 +145,7 @@ xinit)
xextract-simple | xextract-scache)
cat <<EOF
+#line $LINENO "$0"
{
USI insn = GETIMEMUSI (current_cpu, pc);
extract (current_cpu, pc, insn, sc, FAST_P);
@@ -164,6 +166,7 @@ xextract-pbb)
# SET_INSN_COUNT(n) must be called to record number of real insns.
cat <<EOF
+#line $LINENO "$0"
{
const IDESC *idesc;
int icount = 0;
@@ -222,6 +225,7 @@ xfull-exec-* | xfast-exec-*)
# vpc is the virtual program counter.
cat <<EOF
+#line $LINENO "$0"
#if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
#define DEFINE_SWITCH
#ifdef WANT_CPU_OR1K32BF
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-20 1:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-20 1:23 [PATCH 1/3] sim: cgen: unify the genmloop logic a bit Mike Frysinger
2023-12-20 1:23 ` [PATCH 2/3] sim: common: add $LINENO rewriting support to genmloop scripts Mike Frysinger
2023-12-20 1:23 ` [PATCH 3/3] sim: mloop: add #line pragmas everywhere Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).