Skip to content
Snippets Groups Projects
Commit cf5bea76 authored by Aldy Hernandez's avatar Aldy Hernandez
Browse files

Convert range-op.* to vrange.

This patch provides the infrastructure to make range-ops type agnostic.

First, the range_op_handler function has been replaced with an object
of the same name.  It's coded in such a way to minimize changes to the
code base, and to encapsulate the dispatch code.

Instead of:

	range_operator *op = range_op_handler (code, type);
	if (op)
	  op->fold_range (...);

We now do:
	range_op_handler op (code, type);
	if (op)
	  op->fold_range (...);

I've folded gimple_range_handler into the range_op_handler class,
since it's also a query into the range operators.

Instead of:

	range_operator *handler = gimple_range_handler (stmt);

We now do:

	range_op_handler handler (stmt);

This all has the added benefit of moving all the dispatch code into an
independent class and avoid polluting range_operator (which we'll
further split later when frange and prange come live).

There's this annoying "using" keyword that's been added to each
operator due to hiding rules in C++.  The issue is that we will have
different virtual versions of fold_range() for each combination of
operands.  For example:

	// Traditional binary op on irange's.
	fold_range (irange &lhs, const irange &op1, const irange &op2);
	// For POINTER_DIFF_EXPR:
	fold_range (irange &lhs, const prange &op1, const prange &op2);
	// Cast from irange to prange.
	fold_range (prange &lhs, const irange &op1, const irange &op2);

Overloading virtuals when there are multiple same named methods causes
hidden virtuals warnings from -Woverloaded-virtual, thus the using
keyword.  An alternative would be to have different names:
fold_range_III, fold_range_IPP, fold_range_PII, but that's uglier
still.

Tested on x86-64 & ppc64le Linux.

gcc/ChangeLog:

	* gimple-range-edge.cc (gimple_outgoing_range_stmt_p): Adjust for
	vrange and convert range_op_handler function calls to use the
	identically named object.
	* gimple-range-fold.cc (gimple_range_operand1): Same.
	(gimple_range_operand2): Same.
	(fold_using_range::fold_stmt): Same.
	(fold_using_range::range_of_range_op): Same.
	(fold_using_range::range_of_builtin_ubsan_call): Same.
	(fold_using_range::relation_fold_and_or): Same.
	(fur_source::register_outgoing_edges): Same.
	* gimple-range-fold.h (gimple_range_handler): Remove.
	* gimple-range-gori.cc (gimple_range_calc_op1): Adjust for vrange.
	(gimple_range_calc_op2): Same.
	(range_def_chain::get_def_chain): Same.
	(gori_compute::compute_operand_range): Same.
	(gori_compute::condexpr_adjust): Same.
	* gimple-range.cc (gimple_ranger::prefill_name): Same.
	(gimple_ranger::prefill_stmt_dependencies): Same.
	* range-op.cc (get_bool_state): Same.
	(class operator_equal): Add using clause.
	(class operator_not_equal): Same.
	(class operator_lt): Same.
	(class operator_le): Same.
	(class operator_gt): Same.
	(class operator_ge): Same.
	(class operator_plus): Same.
	(class operator_minus): Same.
	(class operator_mult): Same.
	(class operator_exact_divide): Same.
	(class operator_lshift): Same.
	(class operator_rshift): Same.
	(class operator_cast): Same.
	(class operator_logical_and): Same.
	(class operator_bitwise_and): Same.
	(class operator_logical_or): Same.
	(class operator_bitwise_or): Same.
	(class operator_bitwise_xor): Same.
	(class operator_trunc_mod): Same.
	(class operator_logical_not): Same.
	(class operator_bitwise_not): Same.
	(class operator_cst): Same.
	(class operator_identity): Same.
	(class operator_unknown): Same.
	(class operator_abs): Same.
	(class operator_negate): Same.
	(class operator_addr_expr): Same.
	(class pointer_or_operator): Same.
	(operator_plus::op1_range): Adjust for vrange.
	(operator_minus::op1_range): Same.
	(operator_mult::op1_range): Same.
	(operator_cast::op1_range): Same.
	(operator_bitwise_not::fold_range): Same.
	(operator_negate::fold_range): Same.
	(range_op_handler): Rename to...
	(get_handler): ...this.
	(range_op_handler::range_op_handler): New.
	(range_op_handler::fold_range): New.
	(range_op_handler::op1_range): New.
	(range_op_handler::op2_range): New.
	(range_op_handler::lhs_op1_relation): New.
	(range_op_handler::lhs_op2_relation): New.
	(range_op_handler::op1_op2_relation): New.
	(range_cast): Adjust for vrange.
	* range-op.h (range_op_handler): Remove function.
	(range_cast): Adjust for vrange.
	(class range_op_handler): New.
	(get_bool_state): Adjust for vrange.
	(empty_range_varying): Same.
	(relop_early_resolve): Same.
	* tree-data-ref.cc (compute_distributive_range): Same.
	* tree-vrp.cc (get_range_op_handler): Remove.
	(range_fold_binary_symbolics_p): Use range_op_handler class
	instead of get_range_op_handler.
	(range_fold_unary_symbolics_p): Same.
	(range_fold_binary_expr): Same.
	(range_fold_unary_expr): Same.
	* value-query.cc (range_query::get_tree_range): Adjust for vrange.
parent 59c8e96d
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment