aboutsummaryrefslogtreecommitdiff
path: root/gcc/range-op.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-06-10 16:59:38 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-06-12 10:51:06 -0400
commit1b1de36ac83eff7ab8bd9fc379516d723f620a2e (patch)
treea4605f6f9697fcf055d73659a3326840b38c02bd /gcc/range-op.cc
parent1c0aae69a760c7ec3ee436d4c36bb01be6bc0951 (diff)
downloadgcc-1b1de36ac83eff7ab8bd9fc379516d723f620a2e.zip
gcc-1b1de36ac83eff7ab8bd9fc379516d723f620a2e.tar.gz
gcc-1b1de36ac83eff7ab8bd9fc379516d723f620a2e.tar.bz2
Provide a default range_operator via range_op_handler.
range_op_handler now provides a default range_operator for any opcode, so there is no longer a need to check for a valid operator. * gimple-range-op.cc (gimple_range_op_handler): Set m_operator manually as there is no access to the default operator. (cfn_copysign::fold_range): Don't check for validity. (cfn_ubsan::fold_range): Ditto. (gimple_range_op_handler::maybe_builtin_call): Don't set to NULL. * range-op.cc (default_operator): New. (range_op_handler::range_op_handler): Use default_operator instead of NULL. (range_op_handler::operator bool): Move from header, compare against default operator. (range_op_handler::range_op): New. * range-op.h (range_op_handler::operator bool): Move.
Diffstat (limited to 'gcc/range-op.cc')
-rw-r--r--gcc/range-op.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 382f5d5..a271e00 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -121,16 +121,44 @@ range_op_table::range_op_table ()
// set (MAX_EXPR, op_max);
}
+// Instantiate a default range operator for opcodes with no entry.
+
+range_operator default_operator;
+
+// Create a default range_op_handler.
+
range_op_handler::range_op_handler ()
{
- m_operator = NULL;
+ m_operator = &default_operator;
}
-// Constructing without a type must come from the unified table.
+// Create a range_op_handler for CODE. Use a default operatoer if CODE
+// does not have an entry.
range_op_handler::range_op_handler (tree_code code)
{
m_operator = operator_table[code];
+ if (!m_operator)
+ m_operator = &default_operator;
+}
+
+// Return TRUE if this handler has a non-default operator.
+
+range_op_handler::operator bool () const
+{
+ return m_operator != &default_operator;
+}
+
+// Return a pointer to the range operator assocaited with this handler.
+// If it is a default operator, return NULL.
+// This is the equivalent of indexing the range table.
+
+range_operator *
+range_op_handler::range_op () const
+{
+ if (m_operator != &default_operator)
+ return m_operator;
+ return NULL;
}
// Create a dispatch pattern for value range discriminators LHS, OP1, and OP2.