diff options
author | Gabriel Charette <gchare@google.com> | 2011-10-13 15:40:29 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2011-10-13 11:40:29 -0400 |
commit | a22286c349fb54b55562312c1a5fa0f6e00720e0 (patch) | |
tree | 85421770432a8e88feb71769de2ba639ea6ac0c5 /gcc | |
parent | d8228b30349a52da10b35dfaf6fae311bc29c3a5 (diff) | |
download | gcc-a22286c349fb54b55562312c1a5fa0f6e00720e0.zip gcc-a22286c349fb54b55562312c1a5fa0f6e00720e0.tar.gz gcc-a22286c349fb54b55562312c1a5fa0f6e00720e0.tar.bz2 |
streamer-hooks.h (struct streamer_hooks): Add hooks input_location and output_location.
2011-10-12 Gabriel Charette <gchare@google.com>
Diego Novillo <dnovillo@google.com>
* streamer-hooks.h (struct streamer_hooks): Add hooks
input_location and output_location.
* lto-streamer-in.c (lto_input_location): Use
streamer_hooks.input_location, if set.
* lto-streamer-out.c (lto_output_location): Use
streamer_hooks.output_location, if set.
Co-Authored-By: Diego Novillo <dnovillo@google.com>
From-SVN: r179927
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/lto-streamer-in.c | 17 | ||||
-rw-r--r-- | gcc/lto-streamer-out.c | 14 | ||||
-rw-r--r-- | gcc/streamer-hooks.h | 10 |
4 files changed, 43 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6b0423a..bc917ae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2011-10-13 Gabriel Charette <gchare@google.com> + Diego Novillo <dnovillo@google.com> + + * streamer-hooks.h (struct streamer_hooks): Add hooks + input_location and output_location. + * lto-streamer-in.c (lto_input_location): Use + streamer_hooks.input_location, if set. + * lto-streamer-out.c (lto_output_location): Use + streamer_hooks.output_location, if set. + 2011-10-13 Richard Guenther <rguenther@suse.de> PR tree-optimization/50712 diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index d4e80c7..f18b944 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "lto-streamer.h" #include "tree-streamer.h" #include "tree-pass.h" +#include "streamer-hooks.h" /* The table to hold the file names. */ static htab_t file_name_hash_table; @@ -180,15 +181,23 @@ lto_input_location_bitpack (struct data_in *data_in, struct bitpack_d *bp) } -/* Read a location from input block IB. */ +/* Read a location from input block IB. + If the input_location streamer hook exists, call it. + Otherwise, proceed with reading the location from the + expanded location bitpack. */ location_t lto_input_location (struct lto_input_block *ib, struct data_in *data_in) { - struct bitpack_d bp; + if (streamer_hooks.input_location) + return streamer_hooks.input_location (ib, data_in); + else + { + struct bitpack_d bp; - bp = streamer_read_bitpack (ib); - return lto_input_location_bitpack (data_in, &bp); + bp = streamer_read_bitpack (ib); + return lto_input_location_bitpack (data_in, &bp); + } } diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index c14b3a9..4d88f62 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -172,15 +172,21 @@ lto_output_location_bitpack (struct bitpack_d *bp, /* Emit location LOC to output block OB. - When bitpack is handy, it is more space effecient to call + If the output_location streamer hook exists, call it. + Otherwise, when bitpack is handy, it is more space efficient to call lto_output_location_bitpack with existing bitpack. */ void lto_output_location (struct output_block *ob, location_t loc) { - struct bitpack_d bp = bitpack_create (ob->main_stream); - lto_output_location_bitpack (&bp, ob, loc); - streamer_write_bitpack (&bp); + if (streamer_hooks.output_location) + streamer_hooks.output_location (ob, loc); + else + { + struct bitpack_d bp = bitpack_create (ob->main_stream); + lto_output_location_bitpack (&bp, ob, loc); + streamer_write_bitpack (&bp); + } } diff --git a/gcc/streamer-hooks.h b/gcc/streamer-hooks.h index b4c6562..0c1d483 100644 --- a/gcc/streamer-hooks.h +++ b/gcc/streamer-hooks.h @@ -51,6 +51,16 @@ struct streamer_hooks { and descriptors needed by the unpickling routines. It returns the tree instantiated from the stream. */ tree (*read_tree) (struct lto_input_block *, struct data_in *); + + /* [OPT] Called by lto_input_location to retrieve the source location of the + tree currently being read. If this hook returns NULL, lto_input_location + defaults to calling lto_input_location_bitpack. */ + location_t (*input_location) (struct lto_input_block *, struct data_in *); + + /* [OPT] Called by lto_output_location to write the source_location of the + tree currently being written. If this hook returns NULL, + lto_output_location defaults to calling lto_output_location_bitpack. */ + void (*output_location) (struct output_block *, location_t); }; #define stream_write_tree(OB, EXPR, REF_P) \ |