https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114617

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <ga...@gcc.gnu.org>:

https://gcc.gnu.org/g:4e3c8257304c55f2ebfb24bd6de3236bda0f054e

commit r14-9823-g4e3c8257304c55f2ebfb24bd6de3236bda0f054e
Author: Gaius Mulley <gaiusm...@gmail.com>
Date:   Sat Apr 6 23:45:35 2024 +0100

    PR modula2/114617 gm2 unable to resolve const expressions using relop ICE

    This patch allows cc1gm2 to resolve constant expressions which use
    relative operators.  Previous to the patch the result of a relop
    was stored in a temporary variable set by an if then else quadruple
    sequence.  This patch marks a const expression in the quadruples
    and then reduces this sequence of quadruples into a single
    assignment to an internal constant.

    gcc/m2/ChangeLog:

            PR modula2/114617
            * gm2-compiler/M2GenGCC.mod (CodeStatememt): Add quad trace.
            (ResolveConstantExpressions): Add parameter p to FoldIfLess,
            FoldIfGre, FoldIfLessEqu, FoldIfGreEqu, FoldIfEqu, FoldIfNotEqu,
            FoldIfIn and FoldIfNotIn.
            (CodeInline): Add constExpr variable and pass it to GetQuadOtok.
            (CodeReturnValue): Ditto.
            (CodeParam): Ditto.
            (FoldStringLength): Ditto.
            (FoldStringConvertM2nul): Ditto.
            (FoldStringConvertCnul): Ditto.
            (DeclaredOperandsBecomes): Ditto.
            (TypeCheckBecomes): Ditto.
            (PerformFoldBecomes): Ditto.
            (CodeBecomes): Ditto.
            (CheckElementSetTypes): Ditto.
            (CodeBinarySet): Ditto.
            (PerformCodeIfLess): Ditto.
            (PerformCodeIfGre): Ditto.
            (PerformCodeIfLessEqu): Ditto.
            (PerformCodeIfGreEqu): Ditto.
            (PerformCodeIfEqu): Ditto.
            (PerformCodeIfNotEqu): Ditto.
            (IsValidExpressionRelOp): Ditto.
            (PerformCodeIfIn): Ditto.
            (PerformCodeIfNotIn): Ditto.
            (CodeXIndr): Ditto.
            (QuadCondition): New procedure function.
            (IsBooleanRelOpPattern): Ditto.
            (FoldBooleanRelopPattern): Ditto.
            (FoldIfGre): Check for boolean relop constant expression and
            add parameter p.
            (FoldIfLessEqu): Ditto.
            (FoldIfIn): Ditto.
            (FoldIfEqu): Ditto.
            (FoldIfNotIn): Ditto.
            (FoldIfGreEqu): New procedure.
            (FoldIfNotEqu): Ditto.
            * gm2-compiler/M2Optimize.mod (ReduceBranch): Add constExpr
            variable and pass it to GetQuadOtok.
            * gm2-compiler/M2Quads.def (IsBecomes): New procedure function.
            (IsDummy): Ditto.
            (IsQuadConstExpr): Ditto.
            (SetQuadConstExpr): Ditto.
            (GetQuadDest): New procedure.
            (GetQuadOp1): New procedure.
            (GetQuadOp2): New procedure.
            (GetQuadOp3): New procedure.
            (GetQuadOtok): New procedure.
            (GetQuadOTypetok): New procedure.
            (PutQuadOtok): New procedure.
            (IsInConstParameters): New procedure function.
            * gm2-compiler/M2Quads.mod (IsBecomes): New procedure function.
            (IsDummy): Ditto.
            (IsQuadConstExpr): Ditto.
            (SetQuadConstExpr): Ditto.
            (GetQuadDest): New procedure.
            (GetQuadOp1): New procedure.
            (GetQuadOp2): New procedure.
            (GetQuadOp3): New procedure.
            (GetQuadOtok): New procedure.
            (GetQuadOTypetok): New procedure.
            (PutQuadOtok): New procedure.
            (IsInConstParameters): New procedure function.
            (ConstStack): Remove to ...
            (ConstExprStack): ... this.
            (ConstParamStack): New variable and initialize.
            (QuadFrame): New field ConstExpr.
            (GetQuadOtok): Add parameter constExpr and assign.
            (PutQuadOtok): Add constExpr parameter and assign.
            (PutQuadOType): Ditto.
            (GetQuadOTypetok): Ditto.
            (EraseQuad): Assign ConstExpr to FALSE.
            (FoldSubrange): Set ConstExpr to FALSE in BecomesOp.
            (PushInConstParameters): New procedure.
            (PopInConstParameters): New procedure.
            (IsInConstParameters): New procedure function.
            * gm2-compiler/M2SymInit.mod (IssueConditional): Add
            constExpr boolean variable.
            (CheckReadBeforeInitQuad): Ditto.
            (trashParam): Ditto.
            * gm2-compiler/P3Build.bnf (ConstExpression): Call
            PushInConstExpression and PopInConstExpression.
            (ConstSetOrQualidentOrFunction): Call
            PushInConstParameters and PopInConstParameters.
            * gm2-compiler/PCBuild.bnf (ConstExpression): Call
            PushInConstExpression and PopInConstExpression.
            * gm2-compiler/PHBuild.bnf: Ditto
            * gm2-gcc/m2expr.cc (m2expr_BuildCondIfExpression): New
            function.
            * gm2-gcc/m2expr.def (BuildCondIfExpression): New prototype.
            * gm2-gcc/m2expr.h (m2expr_BuildCondIfExpression): New function.

    gcc/testsuite/ChangeLog:

            PR modula2/114617
            * gm2/iso/const/pass/iso-const-pass.exp: New test.

    Signed-off-by: Gaius Mulley <gaiusm...@gmail.com>

Reply via email to