| 1 |
/* Streamer hooks. Support for adding streamer-specific callbacks to |
| 2 |
generic streaming routines. |
| 3 |
|
| 4 |
Copyright (C) 2011-2025 Free Software Foundation, Inc. |
| 5 |
Contributed by Diego Novillo <[email protected]> |
| 6 |
|
| 7 |
This file is part of GCC. |
| 8 |
|
| 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 |
| 12 |
version. |
| 13 |
|
| 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 |
| 17 |
for more details. |
| 18 |
|
| 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/>. */ |
| 22 |
|
| 23 |
#ifndef GCC_STREAMER_HOOKS_H |
| 24 |
#define GCC_STREAMER_HOOKS_H |
| 25 |
|
| 26 |
/* Forward declarations to avoid including unnecessary headers. */ |
| 27 |
struct output_block; |
| 28 |
class lto_input_block; |
| 29 |
class data_in; |
| 30 |
|
| 31 |
/* Streamer hooks. These functions do additional processing as |
| 32 |
needed by the module. There are two types of callbacks, those that |
| 33 |
replace the default behavior and those that supplement it. |
| 34 |
|
| 35 |
Hooks marked [REQ] are required to be set. Those marked [OPT] may |
| 36 |
be NULL, if the streamer does not need to implement them. */ |
| 37 |
struct streamer_hooks { |
| 38 |
/* [REQ] Called by every tree streaming routine that needs to write |
| 39 |
a tree node. The arguments are: output_block where to write the |
| 40 |
node, the tree node to write and a boolean flag that should be true |
| 41 |
if the caller wants to write a reference to the tree, instead of the |
| 42 |
tree itself. The second boolean parameter specifies this for |
| 43 |
the tree itself, the first for all siblings that are streamed. |
| 44 |
The referencing mechanism is up to each streamer to implement. */ |
| 45 |
void (*write_tree) (struct output_block *, tree, bool, bool); |
| 46 |
|
| 47 |
/* [REQ] Called by every tree streaming routine that needs to read |
| 48 |
a tree node. It takes two arguments: an lto_input_block pointing |
| 49 |
to the buffer where to read from and a data_in instance with tables |
| 50 |
and descriptors needed by the unpickling routines. It returns the |
| 51 |
tree instantiated from the stream. */ |
| 52 |
tree (*read_tree) (class lto_input_block *, class data_in *); |
| 53 |
|
| 54 |
/* [REQ] Called by every streaming routine that needs to read a location. */ |
| 55 |
void (*input_location) (location_t *, struct bitpack_d *, class data_in *); |
| 56 |
|
| 57 |
/* [REQ] Called by every streaming routine that needs to write a |
| 58 |
location. */ |
| 59 |
void (*output_location) (struct output_block *, struct bitpack_d *, |
| 60 |
location_t); |
| 61 |
|
| 62 |
/* [REQ] Called by every streaming routine that needs to write a |
| 63 |
location, both LOCATION_LOCUS and LOCATION_BLOCK. */ |
| 64 |
void (*output_location_and_block) (struct output_block *, struct bitpack_d *, |
| 65 |
location_t); |
| 66 |
}; |
| 67 |
|
| 68 |
#define stream_write_tree(OB, EXPR, REF_P) \ |
| 69 |
streamer_hooks.write_tree (OB, EXPR, REF_P, REF_P) |
| 70 |
|
| 71 |
#define stream_write_tree_shallow_non_ref(OB, EXPR, REF_P) \ |
| 72 |
streamer_hooks.write_tree (OB, EXPR, REF_P, false) |
| 73 |
|
| 74 |
#define stream_read_tree(IB, DATA_IN) \ |
| 75 |
streamer_hooks.read_tree (IB, DATA_IN) |
| 76 |
|
| 77 |
#define stream_input_location(LOCPTR, BP, DATA_IN) \ |
| 78 |
streamer_hooks.input_location (LOCPTR, BP, DATA_IN) |
| 79 |
|
| 80 |
#define stream_output_location(OB, BP, LOC) \ |
| 81 |
streamer_hooks.output_location (OB, BP, LOC) |
| 82 |
|
| 83 |
#define stream_output_location_and_block(OB, BP, LOC) \ |
| 84 |
streamer_hooks.output_location_and_block (OB, BP, LOC) |
| 85 |
|
| 86 |
/* Streamer hooks. */ |
| 87 |
extern struct streamer_hooks streamer_hooks; |
| 88 |
|
| 89 |
/* In streamer-hooks.cc. */ |
| 90 |
void streamer_hooks_init (void); |
| 91 |
|
| 92 |
#endif /* GCC_STREAMER_HOOKS_H */ |