aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-06-12 15:25:39 +0100
committerGaius Mulley <gaiusmod2@gmail.com>2023-06-12 15:25:39 +0100
commitbf470895905e9152424076d1630a9d2c60de023b (patch)
treea0f749a7fb752092a2c93a32fbbe33a630a34473 /gcc
parent7a4794af9aa2d7621b67ea026f29a771590f61a1 (diff)
downloadgcc-bf470895905e9152424076d1630a9d2c60de023b.zip
gcc-bf470895905e9152424076d1630a9d2c60de023b.tar.gz
gcc-bf470895905e9152424076d1630a9d2c60de023b.tar.bz2
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/m2/gm2-compiler/M2Quads.def26
-rw-r--r--gcc/m2/gm2-compiler/M2Quads.mod48
-rw-r--r--gcc/m2/gm2-compiler/P3Build.bnf24
3 files changed, 73 insertions, 25 deletions
diff --git a/gcc/m2/gm2-compiler/M2Quads.def b/gcc/m2/gm2-compiler/M2Quads.def
index 493111e..fcb59bb 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 8639d5e..081e931 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 8fbe191..e3cf96f 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
%
} =: