diff mbox series

[COMMITTED,8/15] Unify Identity range operator

Message ID 15aa449a-aa1f-10cd-783f-23295f77d4e2@redhat.com
State New
Headers show
Series [COMMITTED,1/15] - Provide a unified range-op table. | expand

Commit Message

Andrew MacLeod June 10, 2023, 12:35 a.m. UTC
This unifies the identity operation, which is used by SSA_NAME, 
PAREN_EXPR, OBJ_TYPE_REF and REAL_CST.

REAL_CST is using it incorrectly, but preserves current functionality.  
There will not be an SSA_NAME in the op1 position, so there is no point 
in having an op1_range routine.  That will be corrected in the next patch.

Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed.

Andrew
diff mbox series

Patch

From 60b00c6f187450e1f3ffac1b64986ae74b8b948b Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Fri, 9 Jun 2023 13:35:24 -0400
Subject: [PATCH 08/31] 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.
---
 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);
-- 
2.40.1