public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Gaius Mulley <gaius@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5176] Bugfix to allow testsuite/gm2/pim/pass/arraybool.mod to compile on ppc64le Date: Sun, 15 Jan 2023 13:14:01 +0000 (GMT) [thread overview] Message-ID: <20230115131401.CBAD73858D32@sourceware.org> (raw) https://gcc.gnu.org/g:c8f2be5d437e2fb1d91b3ef6a8ca2093ba7e2091 commit r13-5176-gc8f2be5d437e2fb1d91b3ef6a8ca2093ba7e2091 Author: Gaius Mulley <gaiusmod2@gmail.com> Date: Sun Jan 15 13:13:40 2023 +0000 Bugfix to allow testsuite/gm2/pim/pass/arraybool.mod to compile on ppc64le This bug is exposed on the ppc64le platform. The expression parser P3Build.bnf (and PHBuild.bnf) BuiltNot omitted to record the current token position on the quad stack. The patch changes all occurances of NEW to newBoolFrame to ensure that the tokenno recorded in the bool frame is set to a sensible value. BuildNot is fixed and improved to generate a virtual token recording the position of the subexpression. gcc/m2/ChangeLog: * gm2-compiler/M2LexBuf.mod (isSrcToken): Add block comment. Remove dead code. * gm2-compiler/M2Quads.def (BuildNot): Add notTokPos parameter. * gm2-compiler/M2Quads.mod (BuildNot): Add notTokPos parameter. Create and push virtual token. (PopBooltok): New procedure. (PushBooltok): New procedure. (PushBool): Re-implement using PushBooltok. (PopBool): Re-implement using PopBooltok. * gm2-compiler/P3Build.bnf (ConstFactor): Record token position of NOT. (Factor): Record token position of NOT. * gm2-compiler/PHBuild.bnf (ConstFactor): Record token position of NOT. (Relation): Push token position. (UnaryOrConstTerm): Push token position. (AddOperator): Push token position. (MulOperator): Push token position. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com> Diff: --- gcc/m2/gm2-compiler/M2LexBuf.mod | 7 ++--- gcc/m2/gm2-compiler/M2Quads.def | 2 +- gcc/m2/gm2-compiler/M2Quads.mod | 63 +++++++++++++++++++++++++++++----------- gcc/m2/gm2-compiler/P3Build.bnf | 15 ++++++---- gcc/m2/gm2-compiler/PHBuild.bnf | 49 ++++++++++++++++--------------- 5 files changed, 85 insertions(+), 51 deletions(-) diff --git a/gcc/m2/gm2-compiler/M2LexBuf.mod b/gcc/m2/gm2-compiler/M2LexBuf.mod index ffdcb674d43..eaf938c9a32 100644 --- a/gcc/m2/gm2-compiler/M2LexBuf.mod +++ b/gcc/m2/gm2-compiler/M2LexBuf.mod @@ -1117,7 +1117,8 @@ END PrintTokenNo ; (* - isSrcToken - + isSrcToken - returns TRUE if tokenno is associated with + program source code. *) PROCEDURE isSrcToken (tokenno: CARDINAL) : BOOLEAN ; @@ -1138,10 +1139,6 @@ VAR bufLeft, bufRight: TokenBucket ; lc, ll, lr : location_t ; BEGIN - IF FALSE - THEN - RETURN caret - END ; IF isSrcToken (caret) AND isSrcToken (left) AND isSrcToken (right) THEN lc := TokenToLocation (caret) ; diff --git a/gcc/m2/gm2-compiler/M2Quads.def b/gcc/m2/gm2-compiler/M2Quads.def index bc84c24e758..797d5fca8b7 100644 --- a/gcc/m2/gm2-compiler/M2Quads.def +++ b/gcc/m2/gm2-compiler/M2Quads.def @@ -2064,7 +2064,7 @@ PROCEDURE PopConstructor ; |------------| |------------| *) -PROCEDURE BuildNot ; +PROCEDURE BuildNot (notTokPos: CARDINAL) ; (* diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index cbd4a975374..9006f30bb0b 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -12872,13 +12872,16 @@ END BuildRelOp ; |------------| |------------| *) -PROCEDURE BuildNot ; +PROCEDURE BuildNot (notTokPos: CARDINAL) ; VAR - t, f: CARDINAL ; + combinedTok, + exprTokPos : CARDINAL ; + t, f : CARDINAL ; BEGIN CheckBooleanId ; - PopBool (t, f) ; - PushBool (f, t) + PopBooltok (t, f, exprTokPos) ; + combinedTok := MakeVirtualTok (notTokPos, notTokPos, exprTokPos) ; + PushBooltok (f, t, combinedTok) END BuildNot ; @@ -13662,11 +13665,11 @@ END OperandTtok ; (* - PopBool - Pops a True and a False exit quad number from the True/False - stack. + PopBooltok - Pops a True and a False exit quad number from the True/False + stack. *) -PROCEDURE PopBool (VAR True, False: CARDINAL) ; +PROCEDURE PopBooltok (VAR True, False: CARDINAL; VAR tokno: CARDINAL) ; VAR f: BoolFrame ; BEGIN @@ -13674,32 +13677,58 @@ BEGIN WITH f^ DO True := TrueExit ; False := FalseExit ; + tokno := tokenno ; Assert (BooleanOp) END ; DISPOSE (f) -END PopBool ; +END PopBooltok ; (* - PushBool - Push a True and a False exit quad numbers onto the - True/False stack. + PushBooltok - Push a True and a False exit quad numbers onto the + True/False stack. *) -PROCEDURE PushBool (True, False: CARDINAL) ; +PROCEDURE PushBooltok (True, False: CARDINAL; tokno: CARDINAL) ; VAR f: BoolFrame ; BEGIN - Assert(True<=NextQuad) ; - Assert(False<=NextQuad) ; - NEW(f) ; + Assert (True<=NextQuad) ; + Assert (False<=NextQuad) ; + f := newBoolFrame () ; WITH f^ DO TrueExit := True ; FalseExit := False ; BooleanOp := TRUE ; + tokenno := tokno ; Annotation := NIL END ; PushAddress (BoolStack, f) ; Annotate ('<q%1d>|<q%2d>||true quad|false quad') +END PushBooltok ; + + +(* + PopBool - Pops a True and a False exit quad number from the True/False + stack. +*) + +PROCEDURE PopBool (VAR True, False: CARDINAL) ; +VAR + tokno: CARDINAL ; +BEGIN + PopBooltok (True, False, tokno) +END PopBool ; + + +(* + PushBool - Push a True and a False exit quad numbers onto the + True/False stack. +*) + +PROCEDURE PushBool (True, False: CARDINAL) ; +BEGIN + PushBooltok (True, False, UnknownTokenNo) END PushBool ; @@ -14571,7 +14600,7 @@ PROCEDURE newBoolFrame () : BoolFrame ; VAR f: BoolFrame ; BEGIN - NEW(f) ; + NEW (f) ; WITH f^ DO TrueExit := 0 ; FalseExit := 0 ; @@ -14618,7 +14647,7 @@ BEGIN WITH f^ DO TrueExit := True END ; - PushAddress(BoolStack, f) + PushAddress (BoolStack, f) END PushT ; @@ -14630,7 +14659,7 @@ PROCEDURE PopT (VAR True: WORD) ; VAR f: BoolFrame ; BEGIN - f := PopAddress(BoolStack) ; + f := PopAddress (BoolStack) ; WITH f^ DO True := TrueExit ; Assert(NOT BooleanOp) diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf index 8ccc4d604a3..9b2e8421a26 100644 --- a/gcc/m2/gm2-compiler/P3Build.bnf +++ b/gcc/m2/gm2-compiler/P3Build.bnf @@ -723,8 +723,10 @@ MulOperator := "*" % Pus RecordOp % =: -ConstFactor := Number | ConstString | ConstSetOrQualidentOrFunction | - "(" ConstExpression ")" | "NOT" ConstFactor % BuildNot % +ConstFactor := % VAR tokpos: CARDINAL ; % + Number | ConstString | ConstSetOrQualidentOrFunction | + "(" ConstExpression ")" | "NOT" % tokpos := GetTokenNo() -1 % + ConstFactor % BuildNot (tokpos) % | ConstAttribute =: -- to help satisfy LL1 @@ -1087,11 +1089,14 @@ UnaryOrTerm := "+" % Pus Term % BuildUnaryOp % | Term =: -Term := Factor { MulOperator Factor % BuildBinaryOp % +Term := Factor + { MulOperator Factor % BuildBinaryOp % } =: -Factor := Number | string | SetOrDesignatorOrFunction | - "(" Expression ")" | "NOT" ( Factor % BuildNot % +Factor := % VAR tokpos: CARDINAL ; % + Number | string | SetOrDesignatorOrFunction | + "(" Expression ")" | "NOT" % tokpos := GetTokenNo ()-1 % + ( Factor % BuildNot (tokpos) % | ConstAttribute ) =: diff --git a/gcc/m2/gm2-compiler/PHBuild.bnf b/gcc/m2/gm2-compiler/PHBuild.bnf index 7cb97421956..1abcec46f34 100644 --- a/gcc/m2/gm2-compiler/PHBuild.bnf +++ b/gcc/m2/gm2-compiler/PHBuild.bnf @@ -53,7 +53,8 @@ FROM M2Printf IMPORT printf0 ; FROM M2Debug IMPORT Assert ; FROM P2SymBuild IMPORT BuildString, BuildNumber ; -FROM M2Quads IMPORT PushT, PopT, PushTF, PopTF, PopNothing, PushTFtok, PopTFtok, PopTtok, +FROM M2Quads IMPORT PushT, PopT, PushTF, PopTF, PopNothing, Annotate, + PushTtok, PushTFtok, PopTtok, PopTFtok, OperandTok, StartBuildDefFile, StartBuildModFile, BuildModuleStart, EndBuildFile, @@ -630,56 +631,58 @@ ConstExpression := % VAR ] % PopAuto % =: -Relation := "=" % PushT(EqualTok) % - | "#" % PushT(HashTok) % - | "<>" % PushT(LessGreaterTok) % - | "<" % PushT(LessTok) % - | "<=" % PushT(LessEqualTok) % - | ">" % PushT(GreaterTok) % - | ">=" % PushT(GreaterEqualTok) % - | "IN" % PushT(InTok) % +Relation := "=" % PushTtok(EqualTok, GetTokenNo() -1) % + | "#" % PushTtok(HashTok, GetTokenNo() -1) % + | "<>" % PushTtok(LessGreaterTok, GetTokenNo() -1) % + | "<" % PushTtok(LessTok, GetTokenNo() -1) % + | "<=" % PushTtok(LessEqualTok, GetTokenNo() -1) % + | ">" % PushTtok(GreaterTok, GetTokenNo() -1) % + | ">=" % PushTtok(GreaterEqualTok, GetTokenNo() -1) % + | "IN" % PushTtok(InTok, GetTokenNo() -1) % =: SimpleConstExpr := UnaryOrConstTerm { AddOperator ConstTerm % BuildBinaryOp % } =: -UnaryOrConstTerm := "+" % PushT(PlusTok) % +UnaryOrConstTerm := "+" % PushTtok(PlusTok, GetTokenNo() -1) % ConstTerm % BuildUnaryOp % | - "-" % PushT(MinusTok) % + "-" % PushTtok(MinusTok, GetTokenNo() -1) % ConstTerm % BuildUnaryOp % | ConstTerm =: -AddOperator := "+" % PushT(PlusTok) ; +AddOperator := "+" % PushTtok(PlusTok, GetTokenNo() -1) ; RecordOp % - | "-" % PushT(MinusTok) ; + | "-" % PushTtok(MinusTok, GetTokenNo() -1) ; RecordOp % - | "OR" % PushT(OrTok) ; + | "OR" % PushTtok(OrTok, GetTokenNo() -1) ; RecordOp % =: ConstTerm := ConstFactor { MulOperator ConstFactor % BuildBinaryOp % } =: -MulOperator := "*" % PushT(TimesTok) ; +MulOperator := "*" % PushTtok(TimesTok, GetTokenNo() -1) ; RecordOp % - | "/" % PushT(DivideTok) ; + | "/" % PushTtok(DivideTok, GetTokenNo() -1) ; RecordOp % - | "DIV" % PushT(DivTok) ; + | "DIV" % PushTtok(DivTok, GetTokenNo() -1) ; RecordOp % - | "MOD" % PushT(ModTok) ; + | "MOD" % PushTtok(ModTok, GetTokenNo() -1) ; RecordOp % - | "REM" % PushT(RemTok) ; + | "REM" % PushTtok(RemTok, GetTokenNo() -1) ; RecordOp % - | "AND" % PushT(AndTok) ; + | "AND" % PushTtok(AndTok, GetTokenNo() -1) ; RecordOp % - | "&" % PushT(AmbersandTok) ; + | "&" % PushTtok(AmbersandTok, GetTokenNo() -1) ; RecordOp % =: -ConstFactor := Number | ConstString | ConstSetOrQualidentOrFunction | - "(" ConstExpression ")" | "NOT" ConstFactor % BuildNot % +ConstFactor := % VAR tokpos: CARDINAL ; % + Number | ConstString | ConstSetOrQualidentOrFunction | + "(" ConstExpression ")" | "NOT" % tokpos := GetTokenNo() -1 % + ConstFactor % BuildNot (tokpos) % | ConstAttribute =: -- to help satisfy LL1
reply other threads:[~2023-01-15 13:14 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230115131401.CBAD73858D32@sourceware.org \ --to=gaius@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).