aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-section-out.h
blob: 001f2c93c836107e0a80d65e18cdc39307c56171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* LTO output code.
   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
   Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#ifndef GCC_LTO_SECTION_OUT_H
#define GCC_LTO_SECTION_OUT_H

#ifdef LTO_STREAM_DEBUGGING
void lto_debug_out_fun (struct lto_debug_context *, char);
#endif

struct lto_char_ptr_base
{
  char *ptr;
};

/* An incore byte stream to buffer the various parts of the
function. The entire structure should be zeroed when created.  The
record consists of a set of blocks.  The first sizeof (ptr) bytes are
used as a chain, and the rest store the bytes to be written.  */

struct lto_output_stream
{
  /* The pointer to the first block in the stream.  */
  struct lto_char_ptr_base * first_block;
  /* The pointer to the last and current block in the stream.  */
  struct lto_char_ptr_base * current_block;
  /* The pointer to where the next char should be written.  */
  char * current_pointer;
  /* The number of characters left in the current block.  */
  unsigned int left_in_block;
  /* The block size of the last block allocated.  */
  unsigned int block_size;
  /* The total number of characters written.  */
  unsigned int total_size;
};

#ifdef LTO_STREAM_DEBUGGING
#define LTO_SET_DEBUGGING_STREAM(STREAM,CONTEXT)	\
do { \
  ob-> STREAM = xcalloc (1, sizeof (struct lto_output_stream)); \
  lto_debug_context. CONTEXT = ob-> STREAM; \
  lto_debug_context.current_data = ob-> STREAM; \
  lto_debug_context.stream_name = #CONTEXT; \
  gcc_assert (lto_debug_context.indent == 0);  \
} while (0)
#define LTO_CLEAR_DEBUGGING_STREAM(STREAM) \
  free (ob-> STREAM)
#else
#define LTO_SET_DEBUGGING_STREAM(STREAM,CONTEXT)
#define LTO_CLEAR_DEBUGGING_STREAM(STREAM)  (void)0
#endif

struct lto_decl_slot {
  tree t;
  int slot_num;
};


/* The structure that holds all of the vectors of global types and
   decls used in lto serialization for this file.  */

struct lto_out_decl_state
{
  /* The hash table that contains the set of field_decls we have
     seen so far and the indexes assigned to them.  */
  htab_t field_decl_hash_table;
  unsigned int next_field_decl_index;
  VEC(tree,heap) *field_decls;

  /* The hash table that contains the set of function_decls we have
     seen so far and the indexes assigned to them.  */
  htab_t fn_decl_hash_table;
  unsigned int next_fn_decl_index;
  VEC(tree,heap) *fn_decls;

  /* The hash table that contains the set of var_decls we have
     seen so far and the indexes assigned to them.  */
  htab_t var_decl_hash_table;
  unsigned int next_var_decl_index;
  VEC(tree,heap) *var_decls;

  /* The hash table that contains the set of type_decls we have
     seen so far and the indexes assigned to them.  */
  htab_t type_decl_hash_table;
  unsigned int next_type_decl_index;
  VEC(tree,heap) *type_decls;

  /* The hash table that contains the set of namespace_decls we have
     seen so far and the indexes assigned to them.  */
  htab_t namespace_decl_hash_table;
  unsigned int next_namespace_decl_index;
  VEC(tree,heap) *namespace_decls;

  /* The hash table that contains the set of type we have seen so far
     and the indexes assigned to them.  */
  htab_t type_hash_table;
  unsigned int next_type_index;
  VEC(tree,heap) *types;
};

hashval_t lto_hash_decl_slot_node (const void *);
int lto_eq_decl_slot_node (const void *, const void *);
hashval_t lto_hash_type_slot_node (const void *);
int lto_eq_type_slot_node (const void *, const void *);

struct lto_out_decl_state *lto_get_out_decl_state (void);
void lto_write_stream (struct lto_output_stream *);
void lto_output_1_stream (struct lto_output_stream *, char);
void lto_output_uleb128_stream (struct lto_output_stream *, unsigned HOST_WIDE_INT);
void lto_output_widest_uint_uleb128_stream (struct lto_output_stream *,
					    unsigned HOST_WIDEST_INT);
void lto_output_sleb128_stream (struct lto_output_stream *, HOST_WIDE_INT);
void lto_output_integer_stream (struct lto_output_stream *, tree);
bool lto_output_decl_index (struct lto_output_stream *, htab_t, unsigned int *, tree, unsigned int *);
bool gate_lto_out (void);
#endif  /* GCC_LTO_SECTION_OUT_H  */