This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add LTO streaming support for sreal


On Tue, 25 Apr 2017, Jan Hubicka wrote:

> Hi,
> for inliner to use sreals we need to stream them into summaries.  I added them
> as member functions, becuase for streamer_write_sreal/streamer_read_sreal pair
> we would need to access private variables. Does this seem sane?

Bah - stupid C++ ;)

> Bootstrapped/regtested x86_64-linux, OK?

Ok.

Thanks,
Richard.

> Honza
> 
> 	* sreal.c: Include backend.h, tree.h, gimple.h, cgraph.h and
> 	data-streamer.h
> 	(sreal::stream_out, sreal::stream_in): New.
> 	* sreal.h (sreal::stream_out, sreal::stream_in): Declare.
> Index: sreal.c
> ===================================================================
> --- sreal.c	(revision 246970)
> +++ sreal.c	(working copy)
> @@ -53,6 +53,11 @@ along with GCC; see the file COPYING3.
>  #include "coretypes.h"
>  #include "sreal.h"
>  #include "selftest.h"
> +#include "backend.h"
> +#include "tree.h"
> +#include "gimple.h"
> +#include "cgraph.h"
> +#include "data-streamer.h"
>  
>  /* Print the content of struct sreal.  */
>  
> @@ -236,6 +241,26 @@ sreal::operator/ (const sreal &other) co
>    return r;
>  }
>  
> +/* Stream sreal value to OB.  */
> +
> +void
> +sreal::stream_out (struct output_block *ob)
> +{
> +  streamer_write_hwi (ob, m_sig);
> +  streamer_write_hwi (ob, m_exp);
> +}
> +
> +/* Read sreal value from IB.  */
> +
> +sreal
> +sreal::stream_in (struct lto_input_block *ib)
> +{
> +  sreal val;
> +  val.m_sig = streamer_read_hwi (ib);
> +  val.m_exp = streamer_read_hwi (ib);
> +  return val;
> +}
> +
>  #if CHECKING_P
>  
>  namespace selftest {
> Index: sreal.h
> ===================================================================
> --- sreal.h	(revision 246970)
> +++ sreal.h	(working copy)
> @@ -34,6 +34,9 @@ along with GCC; see the file COPYING3.
>  #define SREAL_SIGN(v) (v < 0 ? -1: 1)
>  #define SREAL_ABS(v) (v < 0 ? -v: v)
>  
> +struct output_block;
> +struct lto_input_block;
> +
>  /* Structure for holding a simple real number.  */
>  class sreal
>  {
> @@ -50,6 +53,8 @@ public:
>    void dump (FILE *) const;
>    int64_t to_int () const;
>    double to_double () const;
> +  void stream_out (struct output_block *);
> +  static sreal stream_in (struct lto_input_block *);
>    sreal operator+ (const sreal &other) const;
>    sreal operator- (const sreal &other) const;
>    sreal operator* (const sreal &other) const;
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]