aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-06-09 13:35:24 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-06-09 20:33:02 -0400
commitb073d8af944119c4429b243c09eac612f22d1e83 (patch)
tree030e4acfb48d4ee9fe64b6ce8ac3b90b7373f0a9
parenta0a8f1c735d0ab5af9ecbbf21a783bba78496939 (diff)
downloadgcc-b073d8af944119c4429b243c09eac612f22d1e83.zip
gcc-b073d8af944119c4429b243c09eac612f22d1e83.tar.gz
gcc-b073d8af944119c4429b243c09eac612f22d1e83.tar.bz2
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.
-rw-r--r--gcc/range-op-float.cc40
-rw-r--r--gcc/range-op-mixed.h24
-rw-r--r--gcc/range-op.cc29
3 files changed, 44 insertions, 49 deletions
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 4faca62..bc8ecc6 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 d6cd368..f30f7d0 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 a127da2..70684b4 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);