]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Unify Identity range operator
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 9 Jun 2023 17:35:24 +0000 (13:35 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Sat, 10 Jun 2023 00:33:02 +0000 (20:33 -0400)
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
gcc/range-op-mixed.h
gcc/range-op.cc

index 4faca62c48fa11eb6c3c792848166c675e094ec2..bc8ecc61bce2ce9b5053087248031e5ca8b2407a 100644 (file)
@@ -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);
index d6cd368393278b8b1913c23bb3f83d09860bd793..f30f7d019ee62060a78d427293a082c223c407d8 100644 (file)
@@ -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
index a127da22006b94ec45509512fed96de0fa9fa0af..70684b4c7f72103c9b6a16e4470d6f2a0d4cd463 100644 (file)
@@ -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);