From fd4cf7a092bb2ce21c0d8246c17c0b7f82de440c Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Thu, 22 Feb 2024 09:18:46 +0100 Subject: Move bitmask routines to vrange base class. Any range can theoretically have a bitmask of set bits. This patch moves the bitmask accessors to the base class. This cleans up some users in IPA*, and will provide a cleaner interface when prange is in place. gcc/ChangeLog: * ipa-cp.cc (propagate_bits_across_jump_function): Access bitmask through base class. (ipcp_store_vr_results): Same. * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same. (ipcp_get_parm_bits): Same. (ipcp_update_vr): Same. * range-op-mixed.h (update_known_bitmask): Change argument to vrange. * range-op.cc (update_known_bitmask): Same. * value-range.cc (vrange::update_bitmask): New. (irange::set_nonzero_bits): Move to vrange class. (irange::get_nonzero_bits): Same. * value-range.h (class vrange): Add update_bitmask, get_bitmask, get_nonzero_bits, and set_nonzero_bits. (class irange): Make bitmask methods virtual overrides. (class Value_Range): Add get_bitmask and update_bitmask. --- gcc/value-range.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'gcc/value-range.cc') diff --git a/gcc/value-range.cc b/gcc/value-range.cc index ccac517..926f7b7 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -68,6 +68,18 @@ unsupported_range::accept (const vrange_visitor &v) const v.visit (*this); } +void +vrange::update_bitmask (const class irange_bitmask &) +{ +} + +irange_bitmask +vrange::get_bitmask () const +{ + // Return all unknown bits for the given precision. + return irange_bitmask (TYPE_PRECISION (type ())); +} + bool unsupported_range::contains_p (tree) const { @@ -2010,7 +2022,7 @@ irange::get_bitmask () const // normalize the range if anything changed. void -irange::set_nonzero_bits (const wide_int &bits) +vrange::set_nonzero_bits (const wide_int &bits) { gcc_checking_assert (!undefined_p ()); irange_bitmask bm (wi::zero (TYPE_PRECISION (type ())), bits); @@ -2020,7 +2032,7 @@ irange::set_nonzero_bits (const wide_int &bits) // Return the nonzero bits in R. wide_int -irange::get_nonzero_bits () const +vrange::get_nonzero_bits () const { gcc_checking_assert (!undefined_p ()); irange_bitmask bm = get_bitmask (); -- cgit v1.1