From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 77925385696B; Sat, 10 Jun 2023 00:34:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77925385696B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357250; bh=0iCvPhv1jfehpkQZWB/10ty1FVwVklfZ3ssFl8muPkg=; h=From:To:Subject:Date:From; b=w9Oon7GN2pLY5ZwJvJ3P6Txts70ncvrer6gDq7xO5cbqZTOVTRB/kZuoXeCUVopGk DNrEErhS68xRp1b1IkwDWcJdn1YN0h23umf0Y/t+wnfup4lNtpB6KJ/KUeDpJjFlwz vHx5ya55vK+y5oK7P7wWCjcjW65GyqOUCgRkRfro= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Macleod To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1674] Unify Identity range operator X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: a0a8f1c735d0ab5af9ecbbf21a783bba78496939 X-Git-Newrev: b073d8af944119c4429b243c09eac612f22d1e83 Message-Id: <20230610003410.77925385696B@sourceware.org> Date: Sat, 10 Jun 2023 00:34:10 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b073d8af944119c4429b243c09eac612f22d1e83 commit r14-1674-gb073d8af944119c4429b243c09eac612f22d1e83 Author: Andrew MacLeod Date: Fri Jun 9 13:35:24 2023 -0400 Unify Identity range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_identity): Remove. Move prototypes to range-op-mixed.h (operator_identity::fold_range): Rename from foperator_identity. (operator_identity::op1_range): Ditto. (float_table::float_table): Remove fop_identity. * range-op-mixed.h (class operator_identity): Combined from integer and float files. * range-op.cc (op_identity): New object. (unified_table::unified_table): Add op_identity. (class operator_identity): Move to range-op-mixed.h. (integral_table::integral_table): Remove identity. (pointer_table::pointer_table): Remove identity. Diff: --- gcc/range-op-float.cc | 40 +++++++++++++++------------------------- gcc/range-op-mixed.h | 24 ++++++++++++++++++++++++ gcc/range-op.cc | 29 +++++------------------------ 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 4faca62c48f..bc8ecc61bce 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -541,27 +541,22 @@ build_gt (frange &r, tree type, const frange &val) } -class foperator_identity : public range_operator +bool +operator_identity::fold_range (frange &r, tree, const frange &op1, + const frange &, relation_trio) const { - using range_operator::fold_range; - using range_operator::op1_range; -public: - bool fold_range (frange &r, tree type ATTRIBUTE_UNUSED, - const frange &op1, const frange &op2 ATTRIBUTE_UNUSED, - relation_trio = TRIO_VARYING) const final override - { - r = op1; - return true; - } - bool op1_range (frange &r, tree type ATTRIBUTE_UNUSED, - const frange &lhs, const frange &op2 ATTRIBUTE_UNUSED, - relation_trio = TRIO_VARYING) const final override - { - r = lhs; - return true; - } -public: -} fop_identity; + r = op1; + return true; +} + +bool +operator_identity::op1_range (frange &r, tree, const frange &lhs, + const frange &, relation_trio) const +{ + r = lhs; + return true; +} + bool operator_equal::op2_range (frange &r, tree type, @@ -2694,11 +2689,6 @@ private: float_table::float_table () { - set (SSA_NAME, fop_identity); - set (PAREN_EXPR, fop_identity); - set (OBJ_TYPE_REF, fop_identity); - set (REAL_CST, fop_identity); - set (ABS_EXPR, fop_abs); set (NEGATE_EXPR, fop_negate); set (PLUS_EXPR, fop_plus); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index d6cd3683932..f30f7d019ee 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -268,4 +268,28 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_identity : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::lhs_op1_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool fold_range (frange &r, tree type ATTRIBUTE_UNUSED, + const frange &op1, const frange &op2 ATTRIBUTE_UNUSED, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type ATTRIBUTE_UNUSED, + const frange &lhs, const frange &op2 ATTRIBUTE_UNUSED, + relation_trio = TRIO_VARYING) const final override; + relation_kind lhs_op1_relation (const irange &lhs, + const irange &op1, const irange &op2, + relation_kind rel) const final override; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index a127da22006..70684b4c7f7 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -68,6 +68,7 @@ operator_lt op_lt; operator_le op_le; operator_gt op_gt; operator_ge op_ge; +operator_identity op_ident; // Invoke the initialization routines for each class of range. @@ -83,6 +84,10 @@ unified_table::unified_table () set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); + set (SSA_NAME, op_ident); + set (PAREN_EXPR, op_ident); + set (OBJ_TYPE_REF, op_ident); + set (REAL_CST, op_ident); } // The tables are hidden and accessed via a simple extern function. @@ -4240,26 +4245,6 @@ operator_cst::fold_range (irange &r, tree type ATTRIBUTE_UNUSED, } -class operator_identity : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::lhs_op1_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual relation_kind lhs_op1_relation (const irange &lhs, - const irange &op1, - const irange &op2, - relation_kind rel) const; -} op_ident; - // Determine if there is a relationship between LHS and OP1. relation_kind @@ -4774,9 +4759,6 @@ integral_table::integral_table () set (BIT_XOR_EXPR, op_bitwise_xor); set (BIT_NOT_EXPR, op_bitwise_not); set (INTEGER_CST, op_integer_cst); - set (SSA_NAME, op_ident); - set (PAREN_EXPR, op_ident); - set (OBJ_TYPE_REF, op_ident); set (ABS_EXPR, op_abs); set (NEGATE_EXPR, op_negate); set (ADDR_EXPR, op_addr); @@ -4810,7 +4792,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (SSA_NAME, op_ident); set (INTEGER_CST, op_integer_cst); set (ADDR_EXPR, op_addr); set (NOP_EXPR, op_cast);