aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-section-out.h
blob: 4bc4d814c4de6bf1b80e492ce9f4e45cfb31ca7b (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
/* 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; \
  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


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);

#endif  /* GCC_LTO_SECTION_OUT_H  */