From 9a2f0d152d98dd55efc9accd07ea507b929c3516 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 19 Mar 2024 17:17:53 +0100 Subject: Accept a vrange in get_legacy_range. In preparation for prange, make get_legacy_range take a generic vrange, not just an irange. gcc/ChangeLog: * value-range.cc (get_legacy_range): Make static and add another version of get_legacy_range that takes a vrange. * value-range.h (class irange): Remove unnecessary friendship with get_legacy_range. (get_legacy_range): Accept a vrange. --- gcc/value-range.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'gcc/value-range.cc') diff --git a/gcc/value-range.cc b/gcc/value-range.cc index b901c86..44929b2 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1004,7 +1004,7 @@ irange::operator= (const irange &src) return *this; } -value_range_kind +static value_range_kind get_legacy_range (const irange &r, tree &min, tree &max) { if (r.undefined_p ()) @@ -1041,6 +1041,21 @@ get_legacy_range (const irange &r, tree &min, tree &max) return VR_RANGE; } +// Given a range in V, return an old-style legacy range consisting of +// a value_range_kind with a MIN/MAX. This is to maintain +// compatibility with passes that still depend on VR_ANTI_RANGE, and +// only works for integers and pointers. + +value_range_kind +get_legacy_range (const vrange &v, tree &min, tree &max) +{ + if (is_a (v)) + return get_legacy_range (as_a (v), min, max); + + gcc_unreachable (); + return VR_UNDEFINED; +} + /* Set value range to the canonical form of {VRTYPE, MIN, MAX, EQUIV}. This means adjusting VRTYPE, MIN and MAX representing the case of a wrapping range with MAX < MIN covering [MIN, type_max] U [type_min, MAX] -- cgit v1.1