public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1718] PR modula2/110126 variables are reported as unused when referenced by ASM fix
@ 2023-06-12 14:26 Gaius Mulley
  0 siblings, 0 replies; only message in thread
From: Gaius Mulley @ 2023-06-12 14:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bf470895905e9152424076d1630a9d2c60de023b

commit r14-1718-gbf470895905e9152424076d1630a9d2c60de023b
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Mon Jun 12 15:25:39 2023 +0100

    PR modula2/110126 variables are reported as unused when referenced by ASM fix
    
    This patch fixes the trash list of the asm statement.  It introduces a
    separate build procedure for trashed elements.
    
    gcc/m2/ChangeLog:
    
            PR modula2/110126
            * gm2-compiler/M2Quads.def (BuildAsmElement): Remove
            trash parameter.
            (BuildAsmTrash): New procedure.
            * gm2-compiler/M2Quads.mod (BuildAsmTrash): New procedure.
            (BuildAsmElement): Remove trash parameter.
            * gm2-compiler/P3Build.bnf (AsmTrashList): Rewrite.
    
    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

Diff:
---
 gcc/m2/gm2-compiler/M2Quads.def | 26 ++++++++++++++++++++--
 gcc/m2/gm2-compiler/M2Quads.mod | 48 ++++++++++++++++++++++++++++++++++++-----
 gcc/m2/gm2-compiler/P3Build.bnf | 24 ++++++---------------
 3 files changed, 73 insertions(+), 25 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Quads.def b/gcc/m2/gm2-compiler/M2Quads.def
index 493111e7c1b..fcb59bbcf49 100644
--- a/gcc/m2/gm2-compiler/M2Quads.def
+++ b/gcc/m2/gm2-compiler/M2Quads.def
@@ -144,7 +144,7 @@ EXPORT QUALIFIED StartBuildDefFile, StartBuildModFile, EndBuildFile,
                  IsAutoPushOn, PushAutoOn, PushAutoOff, PopAuto,
                  PushInConstExpression, PopInConstExpression,
                  IsInConstExpression,
-                 MustCheckOverflow, BuildAsmElement ;
+                 MustCheckOverflow, BuildAsmElement, BuildAsmTrash ;
 
 
 TYPE
@@ -2734,7 +2734,29 @@ PROCEDURE IsInConstExpression () : BOOLEAN ;
                         |------------------|       |------------------|
 *)
 
-PROCEDURE BuildAsmElement (input, output, trash: BOOLEAN) ;
+PROCEDURE BuildAsmElement (input, output: BOOLEAN) ;
+
+
+(*
+   BuildAsmTrash - the stack is expected to contain:
+
+
+                        Entry                      Exit
+                        =====                      ====
+
+                 Ptr ->
+                        +------------------+
+                        | expr | tokpos    |
+                        |------------------|       +------------------+
+                        | CurrentInterface |       | CurrentInterface |
+                        |------------------|       |------------------|
+                        | CurrentAsm       |       | CurrentAsm       |
+                        |------------------|       |------------------|
+                        | n                |       | n                |
+                        |------------------|       |------------------|
+*)
+
+PROCEDURE BuildAsmTrash ;
 
 
 END M2Quads.
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index 8639d5e5807..081e9311ae8 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -14421,7 +14421,7 @@ END AddVarientEquality ;
                         |------------------|       |------------------|
 *)
 
-PROCEDURE BuildAsmElement (input, output, trash: BOOLEAN) ;
+PROCEDURE BuildAsmElement (input, output: BOOLEAN) ;
 VAR
    n, str, expr, tokpos,
    CurrentInterface,
@@ -14449,15 +14449,53 @@ BEGIN
       PutRegInterface (tokpos, CurrentInterface, n, name, str, expr,
                        0, NextQuad)
    END ;
-   IF trash
+   PushT (n) ;
+   PushT (CurrentAsm) ;
+   PushT (CurrentInterface)
+END BuildAsmElement ;
+
+
+(*
+   BuildAsmTrash - the stack is expected to contain:
+
+
+                        Entry                      Exit
+                        =====                      ====
+
+                 Ptr ->
+                        +------------------+
+                        | expr | tokpos    |
+                        |------------------|       +------------------+
+                        | CurrentInterface |       | CurrentInterface |
+                        |------------------|       |------------------|
+                        | CurrentAsm       |       | CurrentAsm       |
+                        |------------------|       |------------------|
+                        | n                |       | n                |
+                        |------------------|       |------------------|
+*)
+
+PROCEDURE BuildAsmTrash ;
+VAR
+   n, expr, tokpos,
+   CurrentInterface,
+   CurrentAsm      : CARDINAL ;
+BEGIN
+   PopTtok (expr, tokpos) ;
+   PopT (CurrentInterface) ;
+   PopT (CurrentAsm) ;
+   Assert (IsGnuAsm (CurrentAsm) OR IsGnuAsmVolatile (CurrentAsm)) ;
+   PopT (n) ;
+   INC (n) ;
+   IF CurrentInterface = NulSym
    THEN
-      PutRegInterface (tokpos, CurrentInterface, n, name, str, expr,
-                       0, NextQuad)
+      CurrentInterface := MakeRegInterface ()
    END ;
+   PutRegInterface (tokpos, CurrentInterface, n, NulName, NulSym, expr,
+                    0, NextQuad) ;
    PushT (n) ;
    PushT (CurrentAsm) ;
    PushT (CurrentInterface)
-END BuildAsmElement ;
+END BuildAsmTrash ;
 
 
 (*
diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf
index 8fbe19111b6..e3cf96f5b42 100644
--- a/gcc/m2/gm2-compiler/P3Build.bnf
+++ b/gcc/m2/gm2-compiler/P3Build.bnf
@@ -126,7 +126,7 @@ FROM M2Quads IMPORT PushT, PopT, PushTF, PopTF, PopNothing, Annotate,
                     BuildRetry,
                     DisplayStack,
                     AddVarientRange, AddVarientEquality,
-                    BuildAsmElement,
+                    BuildAsmElement, BuildAsmTrash,
                     BeginVarient, EndVarient, BeginVarientList, EndVarientList,
                     PushInConstExpression, PopInConstExpression, IsInConstExpression,
                     BuildDefaultFieldAlignment, BuildPragmaField,
@@ -1587,7 +1587,7 @@ AsmOperandName :=  ( NamedOperand
 AsmInputElement := AsmOperandName
                    ConstExpression '(' Expression                          % IF Pass3
                                                                              THEN
-                                                                                BuildAsmElement (TRUE, FALSE, FALSE)
+                                                                                BuildAsmElement (TRUE, FALSE)
                                                                              END
                                                                            %
                                    ')'
@@ -1596,34 +1596,22 @@ AsmInputElement := AsmOperandName
 AsmOutputElement := AsmOperandName
                     ConstExpression '(' Expression                         % IF Pass3
                                                                              THEN
-                                                                                BuildAsmElement (FALSE, TRUE, FALSE)
+                                                                                BuildAsmElement (FALSE, TRUE)
                                                                              END
                                                                            %
                                     ')'
                   =:
 
-AsmTrashList :=                                                            % VAR expr, tokpos  : CARDINAL ; %
+AsmTrashList :=                                                            % VAR expr, tokpos: CARDINAL ; %
                  [ ConstExpression                                         % IF Pass3
                                                                              THEN
-                                                                                PopTtok (expr, tokpos) ;
-                                                                                PushT (NulSym) ;
-                                                                                PushTtok (expr, tokpos) ;
-                                                                                BuildAsmElement (FALSE, FALSE, TRUE) ;
-                                                                                PopTtok (expr, tokpos) ;
-                                                                                PopNothing ;
-                                                                                PushTtok (expr, tokpos) ;
+                                                                                BuildAsmTrash
                                                                              END
 
                                                                            %
                  ] { ',' ConstExpression                                   % IF Pass3
                                                                              THEN
-                                                                                PopTtok (expr, tokpos) ;
-                                                                                PushT (NulSym) ;
-                                                                                PushTtok (expr, tokpos) ;
-                                                                                BuildAsmElement (FALSE, FALSE, TRUE) ;
-                                                                                PopTtok (expr, tokpos) ;
-                                                                                PopNothing ;
-                                                                                PushTtok (expr, tokpos) ;
+                                                                                BuildAsmTrash
                                                                              END
                                                                            %
                    } =:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-12 14:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 14:26 [gcc r14-1718] PR modula2/110126 variables are reported as unused when referenced by ASM fix Gaius Mulley

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).