]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Unify GT_EXPR range operator
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 9 Jun 2023 17:32:25 +0000 (13:32 -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_gt): Remove.  Move prototypes
to range-op-mixed.h
(operator_gt::fold_range): Rename from foperator_gt.
(operator_gt::op1_range): Ditto.
(float_table::float_table): Remove GT_EXPR.
* range-op-mixed.h (class operator_gt): Combined from integer
and float files.
* range-op.cc (op_gt): New object.
(unified_table::unified_table): Add GT_EXPR.
(class operator_gt): Move to range-op-mixed.h.
(gt_op1_op2_relation): Fold into
operator_gt::op1_op2_relation.
(integral_table::integral_table): Remove GT_EXPR.
(pointer_table::pointer_table): Remove GT_EXPR.
* range-op.h (gt_op1_op2_relation): Delete.

gcc/range-op-float.cc
gcc/range-op-mixed.h
gcc/range-op.cc
gcc/range-op.h

index a480f1641d22a39f2bc6f3822b5b63025e5329d2..2f090e752458acb62b4632b6b77518664ae55e99 100644 (file)
@@ -961,32 +961,10 @@ operator_le::op2_range (frange &r,
   return true;
 }
 
-class foperator_gt : public range_operator
-{
-  using range_operator::fold_range;
-  using range_operator::op1_range;
-  using range_operator::op2_range;
-  using range_operator::op1_op2_relation;
-public:
-  bool fold_range (irange &r, tree type,
-                  const frange &op1, const frange &op2,
-                  relation_trio = TRIO_VARYING) const final override;
-  relation_kind op1_op2_relation (const irange &lhs) const final override
-  {
-    return gt_op1_op2_relation (lhs);
-  }
-  bool op1_range (frange &r, tree type,
-                 const irange &lhs, const frange &op2,
-                 relation_trio = TRIO_VARYING) const final override;
-  bool op2_range (frange &r, tree type,
-                 const irange &lhs, const frange &op1,
-                 relation_trio = TRIO_VARYING) const final override;
-} fop_gt;
-
 bool
-foperator_gt::fold_range (irange &r, tree type,
-                         const frange &op1, const frange &op2,
-                         relation_trio rel) const
+operator_gt::fold_range (irange &r, tree type,
+                        const frange &op1, const frange &op2,
+                        relation_trio rel) const
 {
   if (frelop_early_resolve (r, type, op1, op2, rel, VREL_GT))
     return true;
@@ -1004,11 +982,11 @@ foperator_gt::fold_range (irange &r, tree type,
 }
 
 bool
-foperator_gt::op1_range (frange &r,
-                        tree type,
-                        const irange &lhs,
-                        const frange &op2,
-                        relation_trio) const
+operator_gt::op1_range (frange &r,
+                       tree type,
+                       const irange &lhs,
+                       const frange &op2,
+                       relation_trio) const
 {
   switch (get_bool_state (r, lhs, type))
     {
@@ -1043,11 +1021,11 @@ foperator_gt::op1_range (frange &r,
 }
 
 bool
-foperator_gt::op2_range (frange &r,
-                        tree type,
-                        const irange &lhs,
-                        const frange &op1,
-                        relation_trio) const
+operator_gt::op2_range (frange &r,
+                       tree type,
+                       const irange &lhs,
+                       const frange &op1,
+                       relation_trio) const
 {
   switch (get_bool_state (r, lhs, type))
     {
@@ -1723,7 +1701,8 @@ public:
       op1_no_nan.clear_nan ();
     if (op2.maybe_isnan ())
       op2_no_nan.clear_nan ();
-    if (!fop_gt.fold_range (r, type, op1_no_nan, op2_no_nan, rel))
+    if (!range_op_handler (GT_EXPR).fold_range (r, type, op1_no_nan,
+                                               op2_no_nan, rel))
       return false;
     // The result is the same as the ordered version when the
     // comparison is true or when the operands cannot be NANs.
@@ -2744,7 +2723,6 @@ float_table::float_table ()
   // All the relational operators are expected to work, because the
   // calculation of ranges on outgoing edges expect the handlers to be
   // present.
-  set (GT_EXPR, fop_gt);
   set (GE_EXPR, fop_ge);
 
   set (ABS_EXPR, fop_abs);
index dd42d98ca4986d3eaa5c6c52dc24be3e776b5d05..1c68d54b0851f359d4cb05e7c4aa29a4874ae5e0 100644 (file)
@@ -204,4 +204,35 @@ public:
   void update_bitmask (irange &r, const irange &lh,
                       const irange &rh) const final override;
 };
+
+class operator_gt :  public range_operator
+{
+public:
+  using range_operator::fold_range;
+  using range_operator::op1_range;
+  using range_operator::op2_range;
+  using range_operator::op1_op2_relation;
+  bool fold_range (irange &r, tree type,
+                  const irange &op1, const irange &op2,
+                  relation_trio = TRIO_VARYING) const;
+  bool fold_range (irange &r, tree type,
+                  const frange &op1, const frange &op2,
+                  relation_trio = TRIO_VARYING) const final override;
+
+  bool op1_range (irange &r, tree type,
+                 const irange &lhs, const irange &op2,
+                 relation_trio = TRIO_VARYING) const;
+  bool op1_range (frange &r, tree type,
+                 const irange &lhs, const frange &op2,
+                 relation_trio = TRIO_VARYING) const final override;
+
+  bool op2_range (irange &r, tree type,
+                 const irange &lhs, const irange &op1,
+                 relation_trio = TRIO_VARYING) const;
+  bool op2_range (frange &r, tree type,
+                 const irange &lhs, const frange &op1,
+                 relation_trio = TRIO_VARYING) const final override;
+  relation_kind op1_op2_relation (const irange &lhs) const final override;
+  void update_bitmask (irange &r, const irange &lh, const irange &rh) const;
+};
 #endif // GCC_RANGE_OP_MIXED_H
index c2e9927e774d2b71efbe16176ee0222e536abf24..e971bf4cd33c1883ae0f19c21984c28be518553e 100644 (file)
@@ -66,6 +66,7 @@ operator_equal op_equal;
 operator_not_equal op_not_equal;
 operator_lt op_lt;
 operator_le op_le;
+operator_gt op_gt;
 
 // Invoke the initialization routines for each class of range.
 
@@ -79,6 +80,7 @@ unified_table::unified_table ()
   set (NE_EXPR, op_not_equal);
   set (LT_EXPR, op_lt);
   set (LE_EXPR, op_le);
+  set (GT_EXPR, op_gt);
 }
 
 // The tables are hidden and accessed via a simple extern function.
@@ -1291,34 +1293,17 @@ operator_le::op2_range (irange &r, tree type,
 }
 
 
-class operator_gt :  public range_operator
+void
+operator_gt::update_bitmask (irange &r, const irange &lh,
+                            const irange &rh) const
 {
-  using range_operator::fold_range;
-  using range_operator::op1_range;
-  using range_operator::op2_range;
-  using range_operator::op1_op2_relation;
-public:
-  virtual bool fold_range (irange &r, tree type,
-                          const irange &op1,
-                          const irange &op2,
-                          relation_trio = TRIO_VARYING) const;
-  virtual bool op1_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op2,
-                         relation_trio = TRIO_VARYING) const;
-  virtual bool op2_range (irange &r, tree type,
-                         const irange &lhs,
-                         const irange &op1,
-                         relation_trio = TRIO_VARYING) const;
-  virtual relation_kind op1_op2_relation (const irange &lhs) const;
-  void update_bitmask (irange &r, const irange &lh, const irange &rh) const
-    { update_known_bitmask (r, GT_EXPR, lh, rh); }
-} op_gt;
+  update_known_bitmask (r, GT_EXPR, lh, rh);
+}
 
 // Check if the LHS range indicates a relation between OP1 and OP2.
 
 relation_kind
-gt_op1_op2_relation (const irange &lhs)
+operator_gt::op1_op2_relation (const irange &lhs) const
 {
   if (lhs.undefined_p ())
     return VREL_UNDEFINED;
@@ -1333,13 +1318,6 @@ gt_op1_op2_relation (const irange &lhs)
   return VREL_VARYING;
 }
 
-relation_kind
-operator_gt::op1_op2_relation (const irange &lhs) const
-{
-  return gt_op1_op2_relation (lhs);
-}
-
-
 bool
 operator_gt::fold_range (irange &r, tree type,
                         const irange &op1, const irange &op2,
@@ -4805,7 +4783,6 @@ pointer_or_operator::wi_fold (irange &r, tree type,
 \f
 integral_table::integral_table ()
 {
-  set (GT_EXPR, op_gt);
   set (GE_EXPR, op_ge);
   set (PLUS_EXPR, op_plus);
   set (MINUS_EXPR, op_minus);
@@ -4855,7 +4832,6 @@ pointer_table::pointer_table ()
   set (MIN_EXPR, op_ptr_min_max);
   set (MAX_EXPR, op_ptr_min_max);
 
-  set (GT_EXPR, op_gt);
   set (GE_EXPR, op_ge);
   set (SSA_NAME, op_ident);
   set (INTEGER_CST, op_integer_cst);
index 7d24b43a80e619dbb952269d8852b1f6af2744a1..411ab5e4a0af1ce731ee211ca00257e58fc8a5dc 100644 (file)
@@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type,
                                      wide_int &mustbe_nonzero);
 
 // op1_op2_relation methods that are the same across irange and frange.
-relation_kind gt_op1_op2_relation (const irange &lhs);
 relation_kind ge_op1_op2_relation (const irange &lhs);
 
 // This implements the range operator tables as local objects.