From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1499) id CBAD73858D32; Sun, 15 Jan 2023 13:14:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBAD73858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673788441; bh=to+9ehthmfzGGKkuEE0Pg/D+csc+iwhHfG9hRgKdtIk=; h=From:To:Subject:Date:From; b=tgGSjSsztMSIBsQcxlXgdLGi+2uuWW1Xb7plpVYz6ijutZ3U6dzQKA/yDWVaLM2U2 aEIJHwX8hZNO+/WizjhgTrR767klGNYkbg9qu2YSRg/7qepjQ11SW43/Q8No/1u1XK vC8bVCk1I8d5Vfgp0bBODvft6TbXbHi6cbHHIuns= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Gaius Mulley To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5176] Bugfix to allow testsuite/gm2/pim/pass/arraybool.mod to compile on ppc64le X-Act-Checkin: gcc X-Git-Author: Gaius Mulley X-Git-Refname: refs/heads/master X-Git-Oldrev: 4dc4584b6079ac801ed5f0c79d335891821dbb3b X-Git-Newrev: c8f2be5d437e2fb1d91b3ef6a8ca2093ba7e2091 Message-Id: <20230115131401.CBAD73858D32@sourceware.org> Date: Sun, 15 Jan 2023 13:14:01 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c8f2be5d437e2fb1d91b3ef6a8ca2093ba7e2091 commit r13-5176-gc8f2be5d437e2fb1d91b3ef6a8ca2093ba7e2091 Author: Gaius Mulley 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 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 ('|||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