aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.h
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-07-03 15:25:38 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-07-03 17:33:23 +0200
commit3ae9def08565c36af2dc0bff495545ee1e9db642 (patch)
tree2dc04b1d77cc6cf291fa183a0c6a74deea50708b /gcc/value-range.h
parent17f2e2b77b6610afb8fafd41d0537d3e4429efe0 (diff)
downloadgcc-3ae9def08565c36af2dc0bff495545ee1e9db642.zip
gcc-3ae9def08565c36af2dc0bff495545ee1e9db642.tar.gz
gcc-3ae9def08565c36af2dc0bff495545ee1e9db642.tar.bz2
Move range allocator code to value-range-storage.*
Now that vrange_storage is in its own file, I think it's prudent to move all the vrange allocator code there since it's all related. The users of value-range.h do not need to know the implementation details of the storage facilities. Tested and benchmarked on x86-64 Linux. gcc/ChangeLog: * gimple-range-cache.cc: Include value-range-storage.h. * gimple-range-cache.h (class block_range_cache): Add "class" to m_range_allocator. * gimple-range-edge.cc (gimple_outgoing_range::gimple_outgoing_range): Allocate allocator. (gimple_outgoing_range::~gimple_outgoing_range): Free allocator. (gimple_outgoing_range::calc_switch_ranges): Dereference allocator. * gimple-range-edge.h: Add "class" to m_range_allocator. * gimple-range-infer.cc (infer_range_manager::infer_range_manager): Allocate allocator. (infer_range_manager::~infer_range_manager): Free allocator. (infer_range_manager::get_nonzero): Dereference allocator. (infer_range_manager::add_range): Same. * gimple-range-infer.h (class vrange_allocator): Add "class" to m_range_allocator. * value-range-storage.h (class vrange_allocator): Move from value-range.h. (class obstack_vrange_allocator): Same. (class ggc_vrange_allocator): Same. (vrange_allocator::alloc_vrange): Same. (vrange_allocator::alloc_irange): Same. * value-range.h (class vrange_allocator): Move to value-range-storage.h. (class obstack_vrange_allocator): Same. (class ggc_vrange_allocator): Same.
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r--gcc/value-range.h109
1 files changed, 0 insertions, 109 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 627d221..8ee7793 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -896,113 +896,4 @@ vrp_val_min (const_tree type)
return NULL_TREE;
}
-// This is the range storage class. It is used to allocate the
-// minimum amount of storage needed for a given range. Storage is
-// automatically freed at destruction of the class.
-
-class vrange_allocator
-{
-public:
- vrange_allocator () { }
- virtual ~vrange_allocator () { }
- // Allocate a range of TYPE.
- vrange *alloc_vrange (tree type);
- // Allocate a memory block of BYTES.
- virtual void *alloc (unsigned bytes) = 0;
- virtual void free (void *p) = 0;
- // Return a clone of SRC.
- template <typename T> T *clone (const T &src);
-private:
- irange *alloc_irange (unsigned pairs);
- void operator= (const vrange_allocator &) = delete;
-};
-
-class obstack_vrange_allocator : public vrange_allocator
-{
-public:
- obstack_vrange_allocator ()
- {
- obstack_init (&m_obstack);
- }
- virtual ~obstack_vrange_allocator () final override
- {
- obstack_free (&m_obstack, NULL);
- }
- virtual void *alloc (unsigned bytes) final override
- {
- return obstack_alloc (&m_obstack, bytes);
- }
- virtual void free (void *) final override { }
-private:
- obstack m_obstack;
-};
-
-class ggc_vrange_allocator : public vrange_allocator
-{
-public:
- ggc_vrange_allocator () { }
- virtual ~ggc_vrange_allocator () final override { }
- virtual void *alloc (unsigned bytes) final override
- {
- return ggc_internal_alloc (bytes);
- }
- virtual void free (void *p) final override
- {
- return ggc_free (p);
- }
-};
-
-// Return a new range to hold ranges of TYPE. The newly allocated
-// range is initialized to VR_UNDEFINED.
-
-inline vrange *
-vrange_allocator::alloc_vrange (tree type)
-{
- if (irange::supports_p (type))
- return alloc_irange (2);
-
- gcc_unreachable ();
-}
-
-// Return a new range with NUM_PAIRS.
-
-inline irange *
-vrange_allocator::alloc_irange (unsigned num_pairs)
-{
- // Never allocate 0 pairs.
- // Don't allocate 1 either, or we get legacy value_range's.
- if (num_pairs < 2)
- num_pairs = 2;
-
- size_t nbytes = sizeof (tree) * 2 * num_pairs;
-
- // Allocate the irange and required memory for the vector.
- void *r = alloc (sizeof (irange));
- tree *mem = static_cast <tree *> (alloc (nbytes));
- return new (r) irange (mem, num_pairs);
-}
-
-// Return a clone of an irange.
-
-template <>
-inline irange *
-vrange_allocator::clone <irange> (const irange &src)
-{
- irange *r = alloc_irange (src.num_pairs ());
- *r = src;
- return r;
-}
-
-// Return a clone of a vrange.
-
-template <>
-inline vrange *
-vrange_allocator::clone <vrange> (const vrange &src)
-{
- if (is_a <irange> (src))
- return clone <irange> (as_a <irange> (src));
-
- gcc_unreachable ();
-}
-
#endif // GCC_VALUE_RANGE_H