1 /* Streamer hooks. Support for adding streamer-specific callbacks to
2 generic streaming routines.
4 Copyright 2011 Free Software Foundation, Inc.
5 Contributed by Diego Novillo <dnovillo@google.com>
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 #ifndef GCC_STREAMER_HOOKS_H
24 #define GCC_STREAMER_HOOKS_H
28 /* Forward declarations to avoid including unnecessary headers. */
30 struct lto_input_block
;
33 struct lto_streamer_cache_d
;
35 /* Streamer hooks. These functions do additional processing as
36 needed by the module. There are two types of callbacks, those that
37 replace the default behavior and those that supplement it.
39 Hooks marked [REQ] are required to be set. Those marked [OPT] may
40 be NULL, if the streamer does not need to implement them. */
41 struct streamer_hooks
{
42 /* [REQ] Called by every tree streaming routine that needs to write
43 a tree node. The arguments are: output_block where to write the
44 node, the tree node to write and a boolean flag that should be true
45 if the caller wants to write a reference to the tree, instead of the
46 tree itself. The referencing mechanism is up to each streamer to
48 void (*write_tree
) (struct output_block
*, tree
, bool);
50 /* [REQ] Called by every tree streaming routine that needs to read
51 a tree node. It takes two arguments: an lto_input_block pointing
52 to the buffer where to read from and a data_in instance with tables
53 and descriptors needed by the unpickling routines. It returns the
54 tree instantiated from the stream. */
55 tree (*read_tree
) (struct lto_input_block
*, struct data_in
*);
58 #define stream_write_tree(OB, EXPR, REF_P) \
59 streamer_hooks.write_tree(OB, EXPR, REF_P)
61 #define stream_read_tree(IB, DATA_IN) \
62 streamer_hooks.read_tree(IB, DATA_IN)
65 extern struct streamer_hooks streamer_hooks
;
67 /* In streamer-hooks.c. */
68 void streamer_hooks_init (void);
70 #endif /* GCC_STREAMER_HOOKS_H */