aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-06-09 13:32:25 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-06-09 20:33:02 -0400
commitf544e7e8a1897b4ddf2ae21c53f9284356373618 (patch)
tree6171590064f2872b0cfc2eb183c0eff62412a23c
parentd251d14ccd2814920f817a96b691e38c10cc8854 (diff)
downloadgcc-f544e7e8a1897b4ddf2ae21c53f9284356373618.zip
gcc-f544e7e8a1897b4ddf2ae21c53f9284356373618.tar.gz
gcc-f544e7e8a1897b4ddf2ae21c53f9284356373618.tar.bz2
Unify GT_EXPR 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_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.
-rw-r--r--gcc/range-op-float.cc52
-rw-r--r--gcc/range-op-mixed.h31
-rw-r--r--gcc/range-op.cc40
-rw-r--r--gcc/range-op.h1
4 files changed, 54 insertions, 70 deletions
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index a480f16..2f090e7 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -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);
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index dd42d98..1c68d54 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -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
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index c2e9927..e971bf4 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -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,
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);
diff --git a/gcc/range-op.h b/gcc/range-op.h
index 7d24b43..411ab5e 100644
--- a/gcc/range-op.h
+++ b/gcc/range-op.h
@@ -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.