From 1b1de36ac83eff7ab8bd9fc379516d723f620a2e Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:59:38 -0400 Subject: 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. --- gcc/range-op.cc | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'gcc/range-op.cc') 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. -- cgit v1.1