[3/3] sim: mloop: add #line pragmas everywhere

Message ID 20231220012354.15032-3-vapier@gentoo.org
State New
Headers
Series [1/3] sim: cgen: unify the genmloop logic a bit |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Mike Frysinger Dec. 20, 2023, 1:23 a.m. UTC
  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(+)
  

Patch

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