This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Implementing a new API for value_range
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 3 Oct 2018 11:20:02 +0300
- Subject: Re: RFC: Implementing a new API for value_range
- References: <e0333cf0-d384-9097-b5cc-440519e7d788@redhat.com>
Sorry, I meant to say it only builds tree-vrp.o.
On Wed, Oct 3, 2018, 09:36 Aldy Hernandez <aldyh@redhat.com> wrote:
> Hi Richard. Hi folks.
>
> I'd like to implement a clean API that disallows direct access to any of
> the value_range internals. My aim is a clean API with no change in
> functionality.
>
> This is mostly a clean-up, but could also pave the way for possibly
> changing the underlying implementation in the future so we can unite VPR
> and the on-demand work with a single common code base.
>
> I am quoting the main structure below to give an idea where I'd like to
> head, and am also attaching a proof-of-concept patch to tree-vrp.[hc].
> It is untested and only builds cc1.
>
> Ideally I'd like to evolve this to include other methods that make the
> VRP / vr-values code more readable.
>
> Note: I have added a tree type field (m_type) to make it easy to
> determine the tree type of the range. Right now a value_range looses
> the range type if UNDEFINED or VARYING, as both min/max are NULL. If
> there is strong objection to the extra word, we could set min/max to
> integer_zero_node in the type if UNDEFINED/VARYING. But really, all
> this will be hidden in the API, so we could change the underlying
> representation at will.
>
> Would you be ok with this if I continue down this path?
>
> Thanks.
> Aldy
>
> struct GTY((for_user)) value_range
> {
> value_range ();
> value_range (tree type);
> value_range (tree type, value_range_type, tree, tree, bitmap = NULL);
> value_range (const value_range &);
> bool operator== (const value_range &) const;
> bool operator!= (const value_range &) const;
> void intersect (const value_range *);
> void union_ (const value_range *);
>
> /* Types of value ranges. */
> bool undefined_p () const;
> bool varying_p () const;
> bool symbolic_p () const;
> bool numeric_p () const;
> void set_undefined ();
> void set_varying ();
>
> /* Equivalence bitmap methods. */
> bitmap equiv () const;
> void set_equiv (bitmap);
> void equiv_free ();
> void equiv_copy (const value_range *);
> void equiv_clear ();
> void equiv_and (const value_range *);
> void equiv_ior (const value_range *);
>
> /* Misc methods. */
> tree type () const;
> bool null_p () const;
> bool may_contain_p (tree) const;
> tree singleton () const;
> void canonicalize ();
> void copy_with_equiv_update (const value_range *);
> void dump () const;
>
> /* Temporary accessors that should eventually be removed. */
> enum value_range_type vrtype () const;
> tree min () const;
> tree max () const;
>
> /* private: These are public because of GTY stupidity. */
> enum value_range_type m_vrtype;
> tree m_min;
> tree m_max;
> tree m_type;
> /* Set of SSA names whose value ranges are equivalent to this one.
> This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */
> bitmap m_equiv;
>
> private:
> void init (tree type, value_range_type, tree, tree, bitmap);
> void check ();
> };
>