]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/data-streamer.c
alias.c: Reorder #include statements and remove duplicates.
[thirdparty/gcc.git] / gcc / data-streamer.c
CommitLineData
f0efc7aa
DN
1/* Generic streaming support for basic data types.
2
5624e564 3 Copyright (C) 2011-2015 Free Software Foundation, Inc.
f0efc7aa
DN
4 Contributed by Diego Novillo <dnovillo@google.com>
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22#include "config.h"
23#include "system.h"
24#include "coretypes.h"
c7131fb2 25#include "backend.h"
957060b5 26#include "hard-reg-set.h"
40e23961 27#include "tree.h"
c7131fb2 28#include "gimple.h"
c582198b 29#include "cgraph.h"
f0efc7aa 30#include "data-streamer.h"
957060b5
AM
31#include "alias.h"
32#include "fold-const.h"
33#include "internal-fn.h"
f0efc7aa
DN
34
35/* Pack WORK into BP in a variant of uleb format. */
36
37void
38bp_pack_var_len_unsigned (struct bitpack_d *bp, unsigned HOST_WIDE_INT work)
39{
40 do
41 {
42 unsigned int half_byte = (work & 0x7);
43 work >>= 3;
44 if (work != 0)
45 /* More half_bytes to follow. */
46 half_byte |= 0x8;
47
48 bp_pack_value (bp, half_byte, 4);
49 }
50 while (work != 0);
51}
52
53
54/* Pack WORK into BP in a variant of sleb format. */
55
56void
57bp_pack_var_len_int (struct bitpack_d *bp, HOST_WIDE_INT work)
58{
59 int more, half_byte;
60
61 do
62 {
63 half_byte = (work & 0x7);
64 /* arithmetic shift */
65 work >>= 3;
66 more = !((work == 0 && (half_byte & 0x4) == 0)
67 || (work == -1 && (half_byte & 0x4) != 0));
68 if (more)
69 half_byte |= 0x8;
70
71 bp_pack_value (bp, half_byte, 4);
72 }
73 while (more);
74}
75
76
77/* Unpack VAL from BP in a variant of uleb format. */
78
79unsigned HOST_WIDE_INT
80bp_unpack_var_len_unsigned (struct bitpack_d *bp)
81{
82 unsigned HOST_WIDE_INT result = 0;
83 int shift = 0;
84 unsigned HOST_WIDE_INT half_byte;
85
86 while (true)
87 {
88 half_byte = bp_unpack_value (bp, 4);
89 result |= (half_byte & 0x7) << shift;
90 shift += 3;
91 if ((half_byte & 0x8) == 0)
92 return result;
93 }
94}
95
96
97/* Unpack VAL from BP in a variant of sleb format. */
98
99HOST_WIDE_INT
100bp_unpack_var_len_int (struct bitpack_d *bp)
101{
102 HOST_WIDE_INT result = 0;
103 int shift = 0;
104 unsigned HOST_WIDE_INT half_byte;
105
106 while (true)
107 {
108 half_byte = bp_unpack_value (bp, 4);
109 result |= (half_byte & 0x7) << shift;
110 shift += 3;
111 if ((half_byte & 0x8) == 0)
112 {
113 if ((shift < HOST_BITS_PER_WIDE_INT) && (half_byte & 0x4))
4176084b 114 result |= - (HOST_WIDE_INT_1U << shift);
f0efc7aa
DN
115
116 return result;
117 }
118 }
119}