xref: /dflybsd-src/contrib/gcc-4.7/gcc/streamer-hooks.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Streamer hooks.  Support for adding streamer-specific callbacks to
2*e4b17023SJohn Marino    generic streaming routines.
3*e4b17023SJohn Marino 
4*e4b17023SJohn Marino    Copyright 2011 Free Software Foundation, Inc.
5*e4b17023SJohn Marino    Contributed by Diego Novillo <dnovillo@google.com>
6*e4b17023SJohn Marino 
7*e4b17023SJohn Marino This file is part of GCC.
8*e4b17023SJohn Marino 
9*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
10*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
11*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
12*e4b17023SJohn Marino version.
13*e4b17023SJohn Marino 
14*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
16*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17*e4b17023SJohn Marino for more details.
18*e4b17023SJohn Marino 
19*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
20*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
21*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
22*e4b17023SJohn Marino 
23*e4b17023SJohn Marino #ifndef GCC_STREAMER_HOOKS_H
24*e4b17023SJohn Marino #define GCC_STREAMER_HOOKS_H
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino #include "tree.h"
27*e4b17023SJohn Marino 
28*e4b17023SJohn Marino /* Forward declarations to avoid including unnecessary headers.  */
29*e4b17023SJohn Marino struct output_block;
30*e4b17023SJohn Marino struct lto_input_block;
31*e4b17023SJohn Marino struct data_in;
32*e4b17023SJohn Marino 
33*e4b17023SJohn Marino /* Streamer hooks.  These functions do additional processing as
34*e4b17023SJohn Marino    needed by the module.  There are two types of callbacks, those that
35*e4b17023SJohn Marino    replace the default behavior and those that supplement it.
36*e4b17023SJohn Marino 
37*e4b17023SJohn Marino    Hooks marked [REQ] are required to be set.  Those marked [OPT] may
38*e4b17023SJohn Marino    be NULL, if the streamer does not need to implement them.  */
39*e4b17023SJohn Marino struct streamer_hooks {
40*e4b17023SJohn Marino   /* [REQ] Called by every tree streaming routine that needs to write
41*e4b17023SJohn Marino      a tree node.  The arguments are: output_block where to write the
42*e4b17023SJohn Marino      node, the tree node to write and a boolean flag that should be true
43*e4b17023SJohn Marino      if the caller wants to write a reference to the tree, instead of the
44*e4b17023SJohn Marino      tree itself.  The second boolean parameter specifies this for
45*e4b17023SJohn Marino      the tree itself, the first for all siblings that are streamed.
46*e4b17023SJohn Marino      The referencing mechanism is up to each streamer to implement.  */
47*e4b17023SJohn Marino   void (*write_tree) (struct output_block *, tree, bool, bool);
48*e4b17023SJohn Marino 
49*e4b17023SJohn Marino   /* [REQ] Called by every tree streaming routine that needs to read
50*e4b17023SJohn Marino      a tree node.  It takes two arguments: an lto_input_block pointing
51*e4b17023SJohn Marino      to the buffer where to read from and a data_in instance with tables
52*e4b17023SJohn Marino      and descriptors needed by the unpickling routines.  It returns the
53*e4b17023SJohn Marino      tree instantiated from the stream.  */
54*e4b17023SJohn Marino   tree (*read_tree) (struct lto_input_block *, struct data_in *);
55*e4b17023SJohn Marino 
56*e4b17023SJohn Marino   /* [OPT] Called by lto_input_location to retrieve the source location of the
57*e4b17023SJohn Marino      tree currently being read. If this hook returns NULL, lto_input_location
58*e4b17023SJohn Marino      defaults to calling lto_input_location_bitpack.  */
59*e4b17023SJohn Marino   location_t (*input_location) (struct lto_input_block *, struct data_in *);
60*e4b17023SJohn Marino 
61*e4b17023SJohn Marino   /* [OPT] Called by lto_output_location to write the source_location of the
62*e4b17023SJohn Marino      tree currently being written. If this hook returns NULL,
63*e4b17023SJohn Marino      lto_output_location defaults to calling lto_output_location_bitpack.  */
64*e4b17023SJohn Marino   void (*output_location) (struct output_block *, location_t);
65*e4b17023SJohn Marino };
66*e4b17023SJohn Marino 
67*e4b17023SJohn Marino #define stream_write_tree(OB, EXPR, REF_P) \
68*e4b17023SJohn Marino     streamer_hooks.write_tree(OB, EXPR, REF_P, REF_P)
69*e4b17023SJohn Marino 
70*e4b17023SJohn Marino #define stream_write_tree_shallow_non_ref(OB, EXPR, REF_P) \
71*e4b17023SJohn Marino     streamer_hooks.write_tree(OB, EXPR, REF_P, false)
72*e4b17023SJohn Marino 
73*e4b17023SJohn Marino #define stream_read_tree(IB, DATA_IN) \
74*e4b17023SJohn Marino     streamer_hooks.read_tree(IB, DATA_IN)
75*e4b17023SJohn Marino 
76*e4b17023SJohn Marino /* Streamer hooks.  */
77*e4b17023SJohn Marino extern struct streamer_hooks streamer_hooks;
78*e4b17023SJohn Marino 
79*e4b17023SJohn Marino /* In streamer-hooks.c.  */
80*e4b17023SJohn Marino void streamer_hooks_init (void);
81*e4b17023SJohn Marino 
82*e4b17023SJohn Marino #endif  /* GCC_STREAMER_HOOKS_H  */
83