]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: igen: do not reindent literal semantics output
authorMike Frysinger <vapier@gentoo.org>
Fri, 15 Dec 2023 03:29:56 +0000 (22:29 -0500)
committerMike Frysinger <vapier@gentoo.org>
Fri, 15 Dec 2023 03:33:47 +0000 (22:33 -0500)
When generating semantics.c from .igen source files, indenting the code
makes it more readable, but confuses compiler diagnostics.  The latter
is a bit more important than the former, so bias towards that.

For example, with an introduced error, we can see w/gcc-13:

(before this change)
  CC       mn10300/semantics.o
../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
../../../sim/mn10300/am33-2.igen:11:5: error: ‘srcreg’ undeclared (first use in this function)
   11 |   srcreg = translate_rreg (SD_, RN2);
      |     ^~~~~~

(with this change)
  CC       mn10300/semantics.o
../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
../../../sim/mn10300/am33-2.igen:11:3: error: ‘srcreg’ undeclared (first use in this function)
   11 |   srcreg = translate_rreg (SD_, RN2);
      |   ^~~~~~

sim/igen/gen-semantics.c

index 54d83d61eccdd2f270a88c155182b181ac8b17fe..455702973e4b201206f8657a861e0cdfa49158ab 100644 (file)
@@ -262,10 +262,17 @@ print_semantic_body (lf *file,
     {
       /* true code */
       lf_printf (file, "{\n");
-      lf_indent (file, +2);
+      /* NB: Do not indent the code.  If the .igen source files cause a compiler
+        warning, the diagnostics can read the line from the original source,
+        but use column offsets from the generated files, causing columns to be
+        misaligned.  It makes the generated code slightly more difficult to
+        read, but accurate compiler diagnostics relative to the original source
+        are more important here.
+      lf_indent (file, +2); */
       lf_print__line_ref (file, instruction->code->line);
       table_print_code (file, instruction->code);
-      lf_indent (file, -2);
+      /* NB: Disabled -- see above.
+      lf_indent (file, -2); */
       lf_printf (file, "}\n");
       lf_print__internal_ref (file);
     }