aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-function-out.c
blob: d13da80888018f323d02b343b940e00cb71b6e5f (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
/* Write the gimple representation of a function and it's local
   variables to a .o file.

   Copyright 2006 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 2, 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 COPYING.  If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.  */

#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "toplev.h"
#include "tree.h"
#include "expr.h"
#include "flags.h"
#include "params.h"
#include "input.h"
#include "varray.h"
#include "hashtab.h"
#include "langhooks.h"
#include "basic-block.h"
#include "tree-iterator.h"
#include "tree-pass.h"
#include "tree-flow.h"
#include "cgraph.h"
#include "function.h"
#include "ggc.h"
#include "diagnostic.h"
#include "except.h"
#include "debug.h"
#include "vec.h"
#include "tree-vectorizer.h"
#include "timevar.h"
#include "dwarf2asm.h"
#include "dwarf2out.h"
#include "output.h"
#include "lto-tags.h"
#include <ctype.h>


sbitmap lto_flags_needed_for;
sbitmap lto_types_needed_for;

#ifdef LTO_STREAM_DEBUGGING
const char *LTO_tag_names[LTO_last_tag];

static struct lto_debug_context lto_debug_context;
static void debug_out_fun (struct lto_debug_context *, char);
#endif


/* The index of the last eh_region seen for an instruction.  The
   eh_region for an instruction is only emitted if it different from
   the last instruction.  */

static int last_eh_region_seen;
static unsigned int expr_to_tag[NUM_TREE_CODES];

struct decl_slot {
  tree t;
  int slot_num;
};

/* Returns a hash code for P.  */

static hashval_t
hash_decl_slot_node (const void *p)
{
  const struct decl_slot *ds = (const struct decl_slot *) p;
  return (hashval_t) DECL_UID (ds->t);
}


/* Returns nonzero if P1 and P2 are equal.  */

static int
eq_decl_slot_node (const void *p1, const void *p2)
{
  const struct decl_slot *ds1 =
    (const struct decl_slot *) p1;
  const struct decl_slot *ds2 =
    (const struct decl_slot *) p2;

  return DECL_UID (ds1->t) == DECL_UID (ds2->t);
}


/* Returns a hash code for P.  */

static hashval_t
hash_type_slot_node (const void *p)
{
  const struct decl_slot *ds = (const struct decl_slot *) p;
  return (hashval_t) TYPE_UID (ds->t);
}


/* Returns nonzero if P1 and P2 are equal.  */

static int
eq_type_slot_node (const void *p1, const void *p2)
{
  const struct decl_slot *ds1 =
    (const struct decl_slot *) p1;
  const struct decl_slot *ds2 =
    (const struct decl_slot *) p2;

  return TYPE_UID (ds1->t) == TYPE_UID (ds2->t);
}


/* Returns a hash code for P.  */

static hashval_t
hash_label_slot_node (const void *p)
{
  const struct decl_slot *ds = (const struct decl_slot *) p;
  return (hashval_t) LABEL_DECL_UID (ds->t);
}


/* Returns nonzero if P1 and P2 are equal.  */

static int
eq_label_slot_node (const void *p1, const void *p2)
{
  const struct decl_slot *ds1 =
    (const struct decl_slot *) p1;
  const struct decl_slot *ds2 =
    (const struct decl_slot *) p2;

  return LABEL_DECL_UID (ds1->t) == LABEL_DECL_UID (ds2->t);
}


struct string_slot {
  const char *s;
  int len;
  unsigned int slot_num;
};


/* Returns a hash code for P.  */

static hashval_t
hash_string_slot_node (const void *p)
{
  const struct string_slot *ds = (const struct string_slot *) p;
  return (hashval_t) htab_hash_string (ds->s);
}


/* Returns nonzero if P1 and P2 are equal.  */

static int
eq_string_slot_node (const void *p1, const void *p2)
{
  const struct string_slot *ds1 =
    (const struct string_slot *) p1;
  const struct string_slot *ds2 =
    (const struct string_slot *) p2;

  if (ds1->len == ds2->len)
    {
      int i;
      for (i=0; i<ds1->len; i++)
	if (ds1->s[i] != ds2->s[i])
	  return 0;
      return 1;
    }
  else return 0;
}


struct 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 output_stream
{
  /* The pointer to the first block in the stream.  */
  struct char_ptr_base * first_block;
  /* The pointer to the last and current block in the stream.  */
  struct 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;
};

struct output_block
{
  /* The stream that the main tree codes are written to.  */
  struct output_stream *main_stream;
  /* The stream that contains the indexes for the local name table.  */
  struct output_stream *local_decl_index_stream;
  /* The stream that contains the local name table.  */
  struct output_stream *local_decl_stream;
  /* The stream that contains the names for the named_labels.  */
  struct output_stream *named_label_stream;
  /* The stream that contains the string table.  */
  struct output_stream *string_stream;
  /* The stream that contains the ssa_names table.  */
  struct output_stream *ssa_names_stream;
  /* The stream that contains the cfg.  */
  struct output_stream *cfg_stream;

#ifdef LTO_STREAM_DEBUGGING
  /* The stream that contains the local decls index debugging information.  */
  struct output_stream *debug_decl_index_stream;
  /* The stream that contains the local decls debugging information.  */
  struct output_stream *debug_decl_stream;
  /* The stream that contains the labels debugging information.  */
  struct output_stream *debug_label_stream;
  /* The stream that contains the ssa_names debugging information.  */
  struct output_stream *debug_ssa_names_stream;
  /* The stream that contains the cfg debugging information.  */
  struct output_stream *debug_cfg_stream;
  /* The stream that contains the gimple debugging information.  */
  struct output_stream *debug_main_stream;
#endif

  /* The hash table that contains the set of labels we have seen so
     far and the indexes assigned to them.  */
  htab_t label_hash_table;
  int next_named_label_index;
  int next_unnamed_label_index;
  VEC(tree,heap) *named_labels;

  /* The hash table that contains the set of local parm and var decls
     we have seen so far and the indexes assigned to them.  */
  htab_t local_decl_hash_table;
  unsigned int next_local_decl_index;
  /* The local_decls_index and the local_decls_index_d are the indexes
     in the local var stream and the local var debugging stream where
     a particular local var is located.  This allows the local vars to
     be read in random order.  */ 
  VEC(int,heap) *local_decls_index;
  /* Index in unexpanded_vars_list so that list can be reconstructed
     properly.  */
  VEC(int,heap) *unexpanded_local_decls_index;
#ifdef LTO_STREAM_DEBUGGING
  VEC(int,heap) *local_decls_index_d;
#endif
  VEC(tree,heap) *local_decls;

  /* 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 strings we have seen so
     far and the indexes assigned to them.  */
  htab_t string_hash_table;
  unsigned int next_string_index;

  /* 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;

  /* These are the last file and line that were seen in the stream.
     If the current node differs from these, it needs to insert
     something into the stream and fix these up.  */
  const char *current_file;
  int current_line;
#ifdef USE_MAPPED_LOCATION  
  int current_col;
#endif
};


/* The output stream that contains the abbrev table for all of the
   functions in this compilation unit.  */
static void output_expr_operand (struct output_block *, tree);


#ifdef LTO_STREAM_DEBUGGING
#define LTO_SET_DEBUGGING_STREAM(STREAM,CONTEXT)	\
do { \
  ob-> STREAM = xcalloc (1, sizeof (struct 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


/* Clear the line info stored in DATA_IN.  */

static void
clear_line_info (struct output_block *ob)
{
  ob->current_file = NULL;
  ob->current_line = 0;
#ifdef USE_MAPPED_LOCATION  
  ob->current_col = 0;
#endif
}


/* Create the output block and return it.  IS_FUNTION is true if this
   is for a function and false for a constructor.  */

static struct output_block *
create_output_block (bool is_function)
{
  struct output_block *ob = xcalloc (1, sizeof (struct output_block));

  ob->main_stream = xcalloc (1, sizeof (struct output_stream));
  ob->string_stream = xcalloc (1, sizeof (struct output_stream));
  if (is_function)
    {
      ob->local_decl_index_stream = xcalloc (1, sizeof (struct output_stream));
      ob->local_decl_stream = xcalloc (1, sizeof (struct output_stream));
      ob->named_label_stream = xcalloc (1, sizeof (struct output_stream));
      ob->ssa_names_stream = xcalloc (1, sizeof (struct output_stream));
      ob->cfg_stream = xcalloc (1, sizeof (struct output_stream));
    }
#ifdef LTO_STREAM_DEBUGGING
  lto_debug_context.out = debug_out_fun;
  lto_debug_context.indent = 0;
#endif

  clear_line_info (ob);

  if (is_function)
    {
      ob->label_hash_table
	= htab_create (37, hash_label_slot_node, eq_label_slot_node, free);
      ob->local_decl_hash_table
	= htab_create (37, hash_decl_slot_node, eq_decl_slot_node, free);
    }

  ob->field_decl_hash_table
    = htab_create (37, hash_decl_slot_node, eq_decl_slot_node, free);
  ob->fn_decl_hash_table
    = htab_create (37, hash_decl_slot_node, eq_decl_slot_node, free);
  ob->var_decl_hash_table
    = htab_create (37, hash_decl_slot_node, eq_decl_slot_node, free);
  ob->type_decl_hash_table
    = htab_create (37, hash_decl_slot_node, eq_decl_slot_node, free);
  ob->string_hash_table
    = htab_create (37, hash_string_slot_node, eq_string_slot_node, free);
  ob->type_hash_table
    = htab_create (37, hash_type_slot_node, eq_type_slot_node, free);

  /* The unnamed labels must all be negative.  */
  ob->next_unnamed_label_index = -1;
  return ob;
}


/* Destroy the output block OB.  IS_FUNTION is true if this is for a
   function and false for a constructor.  */

static void
destroy_output_block (struct output_block * ob, bool is_function)
{
  if (is_function)
    {
      htab_delete (ob->label_hash_table);
      htab_delete (ob->local_decl_hash_table);
    }
  htab_delete (ob->field_decl_hash_table);
  htab_delete (ob->fn_decl_hash_table);
  htab_delete (ob->var_decl_hash_table);
  htab_delete (ob->type_decl_hash_table);
  htab_delete (ob->string_hash_table);
  htab_delete (ob->type_hash_table);

  free (ob->main_stream);
  free (ob->string_stream);
  if (is_function)
    {
      free (ob->local_decl_index_stream);
      free (ob->local_decl_stream);
      free (ob->named_label_stream);
      free (ob->ssa_names_stream);
      free (ob->cfg_stream);
    }

  LTO_CLEAR_DEBUGGING_STREAM (debug_main_stream);
  if (is_function)
    {
      LTO_CLEAR_DEBUGGING_STREAM (debug_label_stream);
      LTO_CLEAR_DEBUGGING_STREAM (debug_ssa_names_stream);
      LTO_CLEAR_DEBUGGING_STREAM (debug_cfg_stream);
      LTO_CLEAR_DEBUGGING_STREAM (debug_decl_stream);
      LTO_CLEAR_DEBUGGING_STREAM (debug_decl_index_stream);
    }

  if (is_function)
    {
      VEC_free (int, heap, ob->local_decls_index);
      VEC_free (int, heap, ob->unexpanded_local_decls_index);
#ifdef LTO_STREAM_DEBUGGING
      VEC_free (int, heap, ob->local_decls_index_d);
#endif
      VEC_free (tree, heap, ob->named_labels);
    }
  VEC_free (tree, heap, ob->local_decls);
  VEC_free (tree, heap, ob->field_decls);
  VEC_free (tree, heap, ob->fn_decls);
  VEC_free (tree, heap, ob->var_decls);
  VEC_free (tree, heap, ob->types);

  free (ob);
}

/* Write all of the chars in OBS to the assembler.  Recycle the blocks
   in obs as this is being done.  */

static void
write_stream (struct output_stream *obs)
{
  unsigned int block_size = 1024;
  unsigned int num_chars;
  struct char_ptr_base *block;
  if (!obs->first_block)
    return;

  block = obs->first_block;
  while (block)
    {
      const char *base = ((char *)block) + sizeof (struct char_ptr_base);
      struct char_ptr_base *old_block = block;
      block = (struct char_ptr_base *)block->ptr;
      /* If there is a next block, then this one is full, if there is
	 not a next block, then the left_in_block field says how many
	 chars there are in this block.  */
      num_chars = block_size - sizeof (struct char_ptr_base);
      if (!block)
	num_chars = num_chars - obs->left_in_block;

      assemble_string (base, num_chars);
      free (old_block);
      block_size *= 2;
    }
}


/* Write a character to the output block.  */

static void
output_1_stream (struct output_stream *obs, char c)
{
  /* No space left.  */
  if (obs->left_in_block == 0)
    {
      struct char_ptr_base *new_block;

      if (obs->first_block == NULL)
	{
	  /* This is the first time the stream has been written
	     into.  */
	  obs->block_size = 1024;
	  new_block = (struct char_ptr_base*) xmalloc (obs->block_size);
	  obs->first_block = new_block;
	}
      else
	{
	  struct char_ptr_base *tptr;
	  /* Get a new block that is twice as big as the last block
	     and link it into the list.  */
	  obs->block_size *= 2;
	  new_block = (struct char_ptr_base*) xmalloc (obs->block_size);
	  /* The first bytes of the block are reserved as a pointer to
	     the next block.  Set the chain of the full block to the
	     pointer to the new block.  */
	  tptr = obs->current_block;
	  tptr->ptr = (char *)new_block;
	}

      /* Set the place for the next char at the first position after the
	 chain to the next block.  */
      obs->current_pointer
	= ((char *)new_block) + sizeof (struct char_ptr_base);
      obs->current_block = new_block;
      /* Null out the newly allocated block's pointer to the next block.  */
      new_block->ptr = NULL;
      obs->left_in_block = obs->block_size - sizeof (struct char_ptr_base);
    }

  /* Write the actual character.  */
  *obs->current_pointer = c;
  obs->current_pointer++;
  obs->total_size++;
  obs->left_in_block--;
}


/* Write a zero to the output stream.  */

static void
output_zero (struct output_block *ob)
{
  LTO_DEBUG_WIDE ("U", 0);
  output_1_stream (ob->main_stream, 0);
}


/* Output an unsigned LEB128 quantity to OBS.  */

static void
output_uleb128_stream (struct output_stream *obs, unsigned HOST_WIDE_INT work)
{
  LTO_DEBUG_WIDE ("U", work);
  do
    {
      unsigned int byte = (work & 0x7f);
      work >>= 7;
      if (work != 0)
	/* More bytes to follow.  */
	byte |= 0x80;

      output_1_stream (obs, byte);
    }
  while (work != 0);
}

/* Identical to output_uleb128_stream above except using unsigned 
   HOST_WIDEST_INT type.  For efficiency on host where unsigned HOST_WIDEST_INT
   is not native, we only use this if we know that HOST_WIDE_INT is not wide
   enough.  */

static void
output_widest_uint_uleb128_stream (struct output_stream *obs,
				   unsigned HOST_WIDEST_INT work)
{
  LTO_DEBUG_WIDE ("U", work);
  do
    {
      unsigned int byte = (work & 0x7f);
      work >>= 7;
      if (work != 0)
	/* More bytes to follow.  */
	byte |= 0x80;

      output_1_stream (obs, byte);
    }
  while (work != 0);
}


/* Output an unsigned LEB128 quantity to OB->main_stream.  */

static void
output_uleb128 (struct output_block *ob, unsigned HOST_WIDE_INT work)
{
  output_uleb128_stream (ob->main_stream, work);
}

/* HOST_WIDEST_INT version of output_uleb128.  OB and WORK are as in
   output_uleb128. */

static void
output_widest_uint_uleb128 (struct output_block *ob,
			    unsigned HOST_WIDEST_INT work)
{
  output_widest_uint_uleb128_stream (ob->main_stream, work);
}

/* Output a signed LEB128 quantity.  */

static void
output_sleb128_stream (struct output_stream *obs, HOST_WIDE_INT work)
{
  int more, byte;
  LTO_DEBUG_WIDE ("S", work);
  do
    {
      byte = (work & 0x7f);
      /* arithmetic shift */
      work >>= 7;
      more = !((work == 0 && (byte & 0x40) == 0)
	       || (work == -1 && (byte & 0x40) != 0));
      if (more)
	byte |= 0x80;

      output_1_stream (obs, byte);
    }
  while (more);
}


/* Output a signed LEB128 quantity to OB->main_stream.  */

static void
output_sleb128 (struct output_block *ob, HOST_WIDE_INT work)
{
  output_sleb128_stream (ob->main_stream, work);
}


/* Output STRING of LEN to the string table in OB.  Then put the index 
   onto the INDEX_STREAM.  */

static void
output_string (struct output_block *ob, 
	       struct output_stream *index_stream,
	       const char *string,
	       unsigned int len)
{
  void **slot;
  struct string_slot s_slot;
  s_slot.s = string;
  s_slot.len = len;

  slot = htab_find_slot (ob->string_hash_table, &s_slot, INSERT);
  if (*slot == NULL)
    {
      struct output_stream *string_stream = ob->string_stream;
      unsigned int start = string_stream->total_size;
      struct string_slot *new_slot
	= xmalloc (sizeof (struct string_slot));
      unsigned int i;

      new_slot->s = string;
      new_slot->slot_num = start;
      *slot = new_slot;
      output_uleb128_stream (index_stream, start);
      output_uleb128_stream (string_stream, len);
      for (i=0; i<len; i++)
	output_1_stream (string_stream, string[i]);
    }
  else
    {
      struct string_slot *old_slot = (struct string_slot *)*slot;
      output_uleb128_stream (index_stream, old_slot->slot_num);

      /* From the debugging protocol's point of view, the entry needs
	 to look the same reguardless of whether this is the first
	 occurence of this string or not.  Thus, we simulate the same
	 debugging info as would be output as if this was a new
	 string.  */
      LTO_DEBUG_WIDE ("U", len);
    }
  LTO_DEBUG_STRING (string, len);
}


/* Put out a real constant.  */

static void
output_real (struct output_block *ob, tree t)
{
  static char real_buffer[1000];
  const REAL_VALUE_TYPE *r = &TREE_REAL_CST (t);

  LTO_DEBUG_TOKEN ("real");
  real_to_hexadecimal (real_buffer, r, 1000, 0, 1);
  output_string (ob, ob->main_stream, real_buffer, strlen (real_buffer));
}


/* Put out a integer constant.  These are stored as two HOST_WIDE_INTS
   so games may have to be played to shift the data from the high to
   the low value.  */

static void
output_integer (struct output_block *ob, tree t)
{
  struct output_stream *obs = ob->main_stream;
  HOST_WIDE_INT low = TREE_INT_CST_LOW (t);
  HOST_WIDE_INT high = TREE_INT_CST_HIGH (t);
  int more, byte;

  /* Of course if the high value is just sign bits for the signed low
     value, we can just punt and call output_sleb128 and be done with
     it.  */
  if (((high == -1) && (low < 0))
      || ((high == 0) && (low >= 0)))
    {
      output_sleb128_stream (obs, low);
      return;
    }

  LTO_DEBUG_INTEGER ("SS", high, low);

  /* This is just a copy of the output_sleb128 code with extra
     operations to transfer the low 7 bits of the high value to the
     top 7 bits of the low value, shift the high down by 7 and then do
     a slightly more complex exit test.  */
  do
    {
      unsigned HOST_WIDE_INT transfer = (high & 0x7f);
      high = ((unsigned HOST_WIDE_INT) high) >> 7;
      transfer <<= (HOST_BITS_PER_WIDE_INT - 7);

      byte = (low & 0x7f);

      /* Logical shift.  */
      low = ((unsigned HOST_WIDE_INT) low) >> 7;
      low |= transfer;
      more = !((high == 0 && low == 0 && (byte & 0x40) == 0)
	       || (high == -1 && low == -1 && (byte & 0x40) != 0));
      if (more)
	byte |= 0x80;

      output_1_stream (obs, byte);
    }
  while (more);
}


/* Lookup NAME in TABLE.  If NAME is not found, create a new entry in
   TABLE for NAME with NEXT_INDEX and increment NEXT_INDEX.  Then
   print the index to OBS.  True is returned if NAME was added to the
   table.  The resulting index is store in THIS_INDEX.

   If OBS is NULL, the only action is to add NAME to the table. */

static bool
output_decl_index (struct output_stream * obs, htab_t table,
		   unsigned int *next_index, tree name, 
		   unsigned int *this_index)
{
  void **slot;
  struct decl_slot d_slot;
  d_slot.t = name;

  slot = htab_find_slot (table, &d_slot, INSERT);
  if (*slot == NULL)
    {
      struct decl_slot *new_slot = xmalloc (sizeof (struct decl_slot));
      int index = (*next_index)++;

      new_slot->t = name;
      new_slot->slot_num = index;
      *this_index = index;
      *slot = new_slot;
      if (obs)
	output_uleb128_stream (obs, index);
      return true;
    }
  else
    {
      struct decl_slot *old_slot = (struct decl_slot *)*slot;
      *this_index = old_slot->slot_num;
      if (obs)
	output_uleb128_stream (obs, old_slot->slot_num);
      return false;
    }
}


/* Build a densely packed word that contains only the flags that are
   used for this type of tree EXPR and write the word in uleb128 to
   the OB.  IF CODE is 0 (ERROR_MARK), put the flags anyway.
   FORCE_LOC forces the line number to be serialized reguardless of
   the type of tree.  */


static void
output_tree_flags (struct output_block *ob, 
		   enum tree_code code, 
		   tree expr, 
		   bool force_loc)
{
  lto_flags_type flags = 0;
  const char *file_to_write = NULL;
  int line_to_write = -1;
#ifdef USE_MAPPED_LOCATION
  int col_to_write = -1;
#endif

  if (code == 0 || TEST_BIT (lto_flags_needed_for, code))
    {

#define START_CLASS_SWITCH()              \
  {                                       \
    enum tree_code code = TREE_CODE (expr); \
                                          \
    switch (TREE_CODE_CLASS (code))       \
    {

#define START_CLASS_CASE(class)    case class:
#define ADD_CLASS_DECL_FLAG(flag_name)    \
      { flags <<= 1; if (expr->decl_common. flag_name ) flags |= 1; }
#define ADD_CLASS_EXPR_FLAG(flag_name)    \
      { flags <<= 1; if (expr->base. flag_name ) flags |= 1; }
#define END_CLASS_CASE(class)      break;
#define END_CLASS_SWITCH()                \
    default:                              \
      gcc_unreachable ();                 \
    }


#define START_EXPR_SWITCH()               \
    switch (code)			  \
    {
#define START_EXPR_CASE(code)    case code:
#define ADD_EXPR_FLAG(flag_name) \
      { flags <<= 1; if (expr->base. flag_name ) flags |= 1; }
#define ADD_DECL_FLAG(flag_name) \
      { flags <<= 1; if (expr->decl_common. flag_name ) flags |= 1; }
#define ADD_VIS_FLAG(flag_name)  \
      { flags <<= 1; if (expr->decl_with_vis. flag_name ) flags |= 1; }
#define ADD_VIS_FLAG_SIZE(flag_name,size)					\
      { flags <<= size; if (expr->decl_with_vis. flag_name ) flags |= expr->decl_with_vis. flag_name; }
#define END_EXPR_CASE(class)      break;
#define END_EXPR_SWITCH()                 \
    default:                              \
      gcc_unreachable ();                 \
    }                                     \
  }

#include "lto-tree-flags.def"

#undef START_CLASS_SWITCH
#undef START_CLASS_CASE
#undef ADD_CLASS_DECL_FLAG
#undef ADD_CLASS_EXPR_FLAG
#undef END_CLASS_CASE
#undef END_CLASS_SWITCH
#undef START_EXPR_SWITCH
#undef START_EXPR_CASE
#undef ADD_EXPR_FLAG
#undef ADD_DECL_FLAG
#undef ADD_VIS_FLAG
#undef ADD_VIS_FLAG_SIZE
#undef END_EXPR_CASE
#undef END_EXPR_SWITCH

      flags <<= LTO_SOURCE_LOC_BITS;
      if (expr)
	{
	  const char *current_file = NULL;
	  int current_line = 0;
#ifdef USE_MAPPED_LOCATION
	  int current_col = 0;
#endif
	  if (EXPR_P (expr) || GIMPLE_STMT_P (expr))
	    {
	      if (EXPR_HAS_LOCATION (expr))
		{
		  expanded_location xloc 
		    = expand_location (EXPR_LOCATION (expr));

		  current_file = xloc.file;
		  current_line = xloc.line;
#ifdef USE_MAPPED_LOCATION
		  current_col = xloc.column;
#endif
		  flags |= LTO_SOURCE_HAS_LOC;
		}
	    }

	  /* We use force_loc here because we only want to put out the
	     line number when we are writing the top level list of var
	     and parm decls, not when we access them inside a
	     function.  */
	  else if (force_loc && DECL_P (expr))
	    {
	      expanded_location xloc 
		= expand_location (DECL_SOURCE_LOCATION (expr));
	      if (xloc.file)
		{
		  current_file = xloc.file;
		  current_line = xloc.line;
#ifdef USE_MAPPED_LOCATION
		  current_col = xloc.column;
#endif
		  flags |= LTO_SOURCE_HAS_LOC;
		}
	    }

	  if (current_file
	      && (ob->current_file == NULL
		  || strcmp (ob->current_file, current_file) != 0))
	    {
	      file_to_write = current_file;
	      ob->current_file = current_file;
	      flags |= LTO_SOURCE_FILE;
	    }
	  if (current_line != 0
	      && ob->current_line != current_line)
	    {
	      line_to_write = current_line;
	      ob->current_line = current_line;
	      flags |= LTO_SOURCE_LINE;
	    }
#ifdef USE_MAPPED_LOCATION
	  if (current_col != 0
	      && ob->current_col != current_col)
	    {
	      col_to_write = current_col;
	      ob->current_col = current_col;
	      flags |= LTO_SOURCE_COL;
	    }
#endif
	}

      LTO_DEBUG_TOKEN ("flags");
      output_widest_uint_uleb128 (ob, flags);
      LTO_DEBUG_TREE_FLAGS (code, flags);

      if (file_to_write)
	{
	  LTO_DEBUG_TOKEN ("file");
	  output_string (ob, ob->main_stream, 
			 file_to_write, strlen (file_to_write) + 1);
	}
      if (line_to_write != -1)
	{
	  LTO_DEBUG_TOKEN ("line");
	  output_uleb128 (ob, line_to_write);
	}
#ifdef USE_MAPPED_LOCATION
      if (col_to_write != -1)
	{
	  LTO_DEBUG_TOKEN ("col");
	  output_uleb128 (ob, col_to_write);
	}
#endif
    }
}


/* Look up TYPE in the type table and write the uleb128 index for it.
   This is a hack and will be replaced with a real reference to the
   type.  */

static void
output_type_ref (struct output_block *ob, tree node)
{
  bool new;
  unsigned int index;

  LTO_DEBUG_TOKEN ("type");
  new = output_decl_index (ob->main_stream, ob->type_hash_table,
			   &ob->next_type_index, node, &index);

  if (new)
    VEC_safe_push (tree, heap, ob->types, node);
}


/* Look up NAME in the type table and if WRITE, write the uleb128
   index for it to OB.  */

static unsigned int
output_local_decl_ref (struct output_block *ob, tree name, bool write)
{
  unsigned int index;
  bool new = output_decl_index (write ? ob->main_stream : NULL, 
				ob->local_decl_hash_table,
				&ob->next_local_decl_index, 
				name, &index);
  /* Push the new local var or param onto a vector for later
     processing.  */
  if (new)
    {
      VEC_safe_push (tree, heap, ob->local_decls, name);
      VEC_safe_push (int, heap, ob->local_decls_index, 0);
      VEC_safe_push (int, heap, ob->unexpanded_local_decls_index, -1);
#ifdef LTO_STREAM_DEBUGGING
      VEC_safe_push (int, heap, ob->local_decls_index_d, 0);
#endif
    }
  return index;
}

/* Look up LABEL in the label table and write the uleb128 index for it.  */

static void
output_label_ref (struct output_block *ob, tree label)
{
  void **slot;
  struct decl_slot d_slot;
  d_slot.t = label;

  slot = htab_find_slot (ob->label_hash_table, &d_slot, INSERT);
  if (*slot == NULL)
    {
      struct decl_slot *new_slot = xmalloc (sizeof (struct decl_slot));

      /* Named labels are given positive integers and unnamed labels are 
	 given negative indexes.  */
      bool named = (DECL_NAME (label) != NULL_TREE);
      int index = named
	? ob->next_named_label_index++ : ob->next_unnamed_label_index--;

      new_slot->t = label;
      new_slot->slot_num = index;
      *slot = new_slot;
      output_sleb128 (ob, index);
      if (named)
	VEC_safe_push (tree, heap, ob->named_labels, label);
    }
  else
    {
      struct decl_slot *old_slot = (struct decl_slot *)*slot;
      output_sleb128 (ob, old_slot->slot_num);
    }
}


/* Output the start of a record with TAG and possibly flags for EXPR,
   and the TYPE for VALUE to OB.  */

static void
output_record_start (struct output_block *ob, tree expr,
		     tree value, unsigned int tag)
{
  output_1_stream (ob->main_stream, tag);
  LTO_DEBUG_INDENT (tag);
  if (expr)
    {
      enum tree_code code = TREE_CODE (expr);
      if (value
	  && TEST_BIT (lto_types_needed_for, code)
	  && TREE_TYPE (value))
	output_type_ref (ob, TREE_TYPE (value));
      output_tree_flags (ob, code, expr, false);
    }
}


/* Output a LIST of TYPE_DECLS.  */

static void
output_type_list (struct output_block *ob, tree list)
{
  tree tl;
  int count = 0;
  if (list)
    {
      gcc_assert (TREE_CODE (list) == TREE_LIST);
      for (tl = list; tl; tl = TREE_CHAIN (tl))
	if (TREE_VALUE (tl) != NULL_TREE)
	  count++;

      output_uleb128 (ob, count);
      for (tl = list; tl; tl = TREE_CHAIN (tl))
	if (TREE_VALUE (tl) != NULL_TREE)
	  output_type_ref (ob, TREE_VALUE (tl));
    }
  else
    output_zero (ob);
}


/* Output an eh_cleanup region with REGION_NUMBER.  HAS_INNER is true if
   there are children of this node and HAS_PEER is true if there are
   siblings of this node.  MAY_CONTAIN_THROW and PREV_TRY are the
   fields of the eh_region.  */

static void
output_eh_cleanup (void *obv,
		   int region_number,
		   bool has_inner, bool has_peer,
		   bool may_contain_throw, int prev_try)
{
  struct output_block *ob = (struct output_block*)obv;
  output_record_start (ob, NULL, NULL,
		       LTO_eh_table_cleanup0 +
		     (has_inner ? 1 : 0) + (may_contain_throw ? 2 : 0));
  output_sleb128 (ob, region_number);
  output_sleb128 (ob, prev_try);
  if (!has_peer)
    output_zero (ob);
  LTO_DEBUG_UNDENT ();
}


/* Output an eh_try region with REGION_NUMBER.  HAS_INNER is true if
   there are children of this node and HAS_PEER is true if there are
   siblings of this node.  MAY_CONTAIN_THROW, CATCH and LAST_CATCH are
   the fields of the eh_region.  */

static void
output_eh_try (void *obv,
	       int region_number,
	       bool has_inner, bool has_peer,
	       bool may_contain_throw, int catch,
	       int last_catch)
{
  struct output_block *ob = (struct output_block*)obv;
  output_record_start (ob, NULL, NULL,
		       LTO_eh_table_try0 +
		     (has_inner ? 1 : 0) + (may_contain_throw ? 2 : 0));
  output_sleb128 (ob, region_number);
  output_sleb128 (ob, catch);
  output_sleb128 (ob, last_catch);
  if (!has_peer)
    output_zero (ob);
  LTO_DEBUG_UNDENT ();
}


/* Output an eh_catch region with REGION_NUMBER.  HAS_INNER is true if
   there are children of this node and HAS_PEER is true if there are
   siblings of this node.  MAY_CONTAIN_THROW, NEXT_CATCH and
   PREV_CATCH, and TYPE_LIST are the fields of the eh_region.  */

static void
output_eh_catch (void *obv,
		 int region_number,
		 bool has_inner, bool has_peer,
		 bool may_contain_throw, int next_catch,
		 int prev_catch, tree type_list)
{
  struct output_block *ob = (struct output_block*)obv;
  output_record_start (ob, NULL, NULL,
		       LTO_eh_table_catch0 +
		     (has_inner ? 1 : 0) + (may_contain_throw ? 2 : 0));
  output_sleb128 (ob, region_number);
  output_sleb128 (ob, next_catch);
  output_sleb128 (ob, prev_catch);
  output_type_list (ob, type_list);
  if (!has_peer)
    output_zero (ob);
  LTO_DEBUG_UNDENT ();
}

/* Output an eh_allowed_exceptions region with REGION_NUMBER.
   HAS_INNER is true if there are children of this node and HAS_PEER
   is true if there are siblings of this node.  MAY_CONTAIN_THROW, and
   TYPE_LIST are the fields of the eh_region.  */

static void
output_eh_allowed (void *obv,
		   int region_number,
		   bool has_inner, bool has_peer,
		   bool may_contain_throw, tree type_list)
{
  struct output_block *ob = (struct output_block*)obv;
  output_record_start (ob, NULL, NULL,
		       LTO_eh_table_allowed0 +
		     (has_inner ? 1 : 0) + (may_contain_throw ? 2 : 0));
  output_sleb128 (ob, region_number);
  output_type_list (ob, type_list);
  if (!has_peer)
    output_zero (ob);
  LTO_DEBUG_UNDENT ();
}


/* Output an eh_must_not_throw region with REGION_NUMBER.  HAS_INNER
   is true if there are children of this node and HAS_PEER is true if
   there are siblings of this node.  MAY_CONTAIN_THROW is the field of
   the eh_region.  */

static void
output_eh_must_not_throw (void *obv,
			  int region_number,
			  bool has_inner, bool has_peer,
			  bool may_contain_throw)
{
  struct output_block *ob = (struct output_block*)obv;
  output_record_start (ob, NULL, NULL,
		       LTO_eh_table_must_not_throw0 +
		     (has_inner ? 1 : 0) + (may_contain_throw ? 2 : 0));
  output_sleb128 (ob, region_number);
  if (!has_peer)
    output_zero (ob);
  LTO_DEBUG_UNDENT ();
}


/* Output the existing eh_table to OB.  */

static void
output_eh_regions (struct output_block *ob, struct function *fn)
{
  if (0 && fn->eh)
    {
      output_record_start (ob, NULL, NULL, LTO_eh_table);
      output_eh_records (ob, fn,
			 output_eh_cleanup,
			 output_eh_try,
			 output_eh_catch,
			 output_eh_allowed,
			 output_eh_must_not_throw);
      LTO_DEBUG_UNDENT ();
    }
  /* The 0 either terminates the record or indicates that there are no
     eh_records at all.  */
  output_zero (ob);
}


/* Output constructor CTOR to OB.  */

static void
output_constructor (struct output_block *ob, tree ctor)
{
  tree value;
  tree purpose;
  unsigned HOST_WIDE_INT idx;

  output_record_start (ob, ctor, ctor, LTO_constructor);
  output_uleb128 (ob, VEC_length (constructor_elt, CONSTRUCTOR_ELTS (ctor)));

  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, purpose, value)
    {
      if (purpose)
	output_expr_operand (ob, purpose);
      else 
	output_zero (ob);

      if (TREE_CODE (value) == CONSTRUCTOR)
	{
	  output_constructor (ob, value);
	  LTO_DEBUG_UNDENT ();
	}
      else 
	output_expr_operand (ob, value);
    }
}

/* Output EXPR to the main stream in OB.  */

static void
output_expr_operand (struct output_block *ob, tree expr)
{
  enum tree_code code;
  enum tree_code_class class;
  unsigned int tag;

  gcc_assert (expr);

  code = TREE_CODE (expr);
  class = TREE_CODE_CLASS (code);
  tag = expr_to_tag [code];

  gcc_assert (class != tcc_type);

  switch (code)
    {
    case COMPLEX_CST:
      if (TREE_CODE (TREE_REALPART (expr)) == REAL_CST)
	{
	  output_record_start (ob, expr, expr, LTO_complex_cst1);
	  output_type_ref (ob, TREE_TYPE (TREE_REALPART (expr)));
	  output_real (ob, TREE_REALPART (expr));
	  output_real (ob, TREE_IMAGPART (expr));
	}
      else
	{
	  output_record_start (ob, expr, expr, LTO_complex_cst0);
	  output_type_ref (ob, TREE_TYPE (TREE_REALPART (expr)));
	  output_integer (ob, TREE_REALPART (expr));
	  output_integer (ob, TREE_IMAGPART (expr));
	}
      break;

    case INTEGER_CST:
      output_record_start (ob, expr, expr, tag);
      output_integer (ob, expr);
      break;

    case REAL_CST:
      output_record_start (ob, expr, expr, tag);
      output_real (ob, expr);
      break;

    case STRING_CST:
      {
	/* Most STRING_CSTs have a type when they get here.  The ones
	   in the string operands of asms do not.  Put something there
	   so that all STRING_CSTs can be handled uniformly.  */
	if (!TREE_TYPE (expr))
	  TREE_TYPE (expr) = void_type_node;

	output_record_start (ob, expr, expr, LTO_string_cst);
	output_string (ob, ob->main_stream, 
		       TREE_STRING_POINTER (expr),
		       TREE_STRING_LENGTH (expr));
      }
      break;

    case IDENTIFIER_NODE:
      {
	output_record_start (ob, expr, expr, LTO_identifier_node);
	output_string (ob, ob->main_stream, 
		       IDENTIFIER_POINTER (expr),
		       IDENTIFIER_LENGTH (expr));
      }
      break;
      

    case VECTOR_CST:
      {
	tree t = TREE_VECTOR_CST_ELTS (expr);
	int len = 1;

	while ((t = TREE_CHAIN (t)) != NULL)
	  len++;
	t = TREE_VECTOR_CST_ELTS (expr);
	if (TREE_CODE (TREE_VALUE(t)) == REAL_CST)
	  {
	    output_record_start (ob, expr, expr, LTO_vector_cst1);
	    output_uleb128 (ob, len);
	    output_type_ref (ob, TREE_TYPE (TREE_VALUE (t)));
	    output_real (ob, TREE_VALUE (t));
	    while ((t = TREE_CHAIN (t)) != NULL)
	      output_real (ob, TREE_VALUE (t));
	  }
	else
	  {
	    output_record_start (ob, expr, expr, LTO_vector_cst0);
	    output_uleb128 (ob, len);
	    output_type_ref (ob, TREE_TYPE (TREE_VALUE (t)));
	    output_integer (ob, TREE_VALUE (t));
	    while ((t = TREE_CHAIN (t)) != NULL)
	      output_integer (ob, TREE_VALUE (t));
	  }
      }
      break;

    case CASE_LABEL_EXPR:
      {
	int variant = 0;
	if (CASE_LOW (expr) != NULL_TREE)
	  variant |= 0x1;
	if (CASE_HIGH (expr) != NULL_TREE)
	  variant |= 0x2;
	output_record_start (ob, expr, NULL,
			     LTO_case_label_expr0 + variant);

	if (CASE_LOW (expr) != NULL_TREE)
	  output_expr_operand (ob, CASE_LOW (expr));
	if (CASE_HIGH (expr) != NULL_TREE)
	  output_expr_operand (ob, CASE_HIGH (expr));
	output_label_ref (ob, CASE_LABEL (expr));
      }
      break;

    case CONSTRUCTOR:
      output_constructor (ob, expr);
      break;

    case SSA_NAME:
      output_record_start (ob, expr, expr, LTO_ssa_name);
      output_uleb128 (ob, SSA_NAME_VERSION (expr));
      break;

    case CONST_DECL:
      /* Just ignore these, Mark will make them disappear.  */
      break;

    case FIELD_DECL:
      {
	unsigned int index;
	bool new;
	output_record_start (ob, NULL, NULL, tag);
	
	new = output_decl_index (ob->main_stream, ob->field_decl_hash_table,
				 &ob->next_field_decl_index, expr, &index);
	if (new)
	  VEC_safe_push (tree, heap, ob->field_decls, expr);
      }
      break;

    case FUNCTION_DECL:
      {
	unsigned int index;
	bool new;
	output_record_start (ob, NULL, NULL, tag);
	
	new = output_decl_index (ob->main_stream, ob->fn_decl_hash_table,
				 &ob->next_fn_decl_index, expr, &index);
	if (new)
	  VEC_safe_push (tree, heap, ob->fn_decls, expr);
      }
      break;

    case VAR_DECL:
      if (TREE_STATIC (expr) || DECL_EXTERNAL (expr))
	{
	  /* Static or extern VAR_DECLs.  */
	  unsigned int index;
	  bool new;
	  output_record_start (ob, NULL, NULL, LTO_var_decl1);

	  new = output_decl_index (ob->main_stream, ob->var_decl_hash_table,
				   &ob->next_var_decl_index, expr, &index);
	  if (new)
	    VEC_safe_push (tree, heap, ob->var_decls, expr);
	}
      else
	{
	  /* Local VAR_DECLs.  */
	  output_record_start (ob, NULL, NULL, LTO_var_decl0);
	  output_local_decl_ref (ob, expr, true);
	}
      break;

    case TYPE_DECL:
      {
	unsigned int index;
	bool new;
	output_record_start (ob, NULL, NULL, tag);
	
	new = output_decl_index (ob->main_stream, ob->type_decl_hash_table,
				 &ob->next_type_decl_index, expr, &index);
	if (new)
	  VEC_safe_push (tree, heap, ob->type_decls, expr);
      }
      break;

    case PARM_DECL:
      gcc_assert (!DECL_RTL_SET_P (expr));
      output_record_start (ob, NULL, NULL, tag);
      output_local_decl_ref (ob, expr, true);
      break;

    case LABEL_DECL:
      output_record_start (ob, expr, NULL, tag);
      output_label_ref (ob, expr);
      break;

    case LABEL_EXPR:
      output_record_start (ob, expr, NULL, tag);
      output_label_ref (ob, TREE_OPERAND (expr, 0));
      break;

    case COND_EXPR:
      if (TREE_OPERAND (expr, 1))
	{
	  output_record_start (ob, expr, expr, LTO_cond_expr0);
	  output_expr_operand (ob, TREE_OPERAND (expr, 0));
	  output_expr_operand (ob, TREE_OPERAND (expr, 1));
	  output_expr_operand (ob, TREE_OPERAND (expr, 2));
	}
      else 
	{
	  output_record_start (ob, expr, expr, LTO_cond_expr1);
	  output_expr_operand (ob, TREE_OPERAND (expr, 0));
	}
      break;

    case RESULT_DECL:
      output_record_start (ob, expr, expr, tag);
      break;

    case COMPONENT_REF:
      output_record_start (ob, expr, expr, tag);
      output_expr_operand (ob, TREE_OPERAND (expr, 0));
      output_expr_operand (ob, TREE_OPERAND (expr, 1));
      /* Ignore 3 because it can be recomputed.  */
      break;

    case CALL_EXPR:
      {
	unsigned int count = TREE_INT_CST_LOW (TREE_OPERAND (expr, 0));
	unsigned int i;

	/* Operand 2 is the call chain.  */
	if (TREE_OPERAND (expr, 2))
	  {
	    output_record_start (ob, expr, expr, LTO_call_expr1);
	    output_uleb128 (ob, count);
	    output_expr_operand (ob, TREE_OPERAND (expr, 2));
	  }
	else
	  {
	    output_record_start (ob, expr, expr, LTO_call_expr0);
	    output_uleb128 (ob, count);
	  }
	output_expr_operand (ob, TREE_OPERAND (expr, 1));
	for (i = 3; i < count; i++)
	  output_expr_operand (ob, TREE_OPERAND (expr, i));
      }
      break;

    case BIT_FIELD_REF:
      {
	tree op1 = TREE_OPERAND (expr, 1);
	tree op2 = TREE_OPERAND (expr, 2);
	if ((TREE_CODE (op1) == INTEGER_CST)
	    && (TREE_CODE (op2) == INTEGER_CST))
	  {
	    output_record_start (ob, expr, expr,
				 LTO_bit_field_ref1);
	    output_uleb128 (ob, TREE_INT_CST_LOW (op1));
	    output_uleb128 (ob, TREE_INT_CST_LOW (op2));
	    output_expr_operand (ob, TREE_OPERAND (expr, 0));
	  }
	else
	  {
	    output_record_start (ob, expr, expr,
				 LTO_bit_field_ref0);
	    output_expr_operand (ob, TREE_OPERAND (expr, 0));
	    output_expr_operand (ob, op1);
	    output_expr_operand (ob, op2);
	  }
      }
      break;

    case ARRAY_REF:
    case ARRAY_RANGE_REF:
      /* Ignore operands 2 and 3 for ARRAY_REF and ARRAY_RANGE REF
	 because they can be recomputed.  */
      output_record_start (ob, expr, expr, tag);
      output_expr_operand (ob, TREE_OPERAND (expr, 0));
      output_expr_operand (ob, TREE_OPERAND (expr, 1));
      break;


    case ASM_EXPR:
      {
	tree string_cst = ASM_STRING (expr);
	output_record_start (ob, expr, NULL, LTO_asm_expr);
	output_string (ob, ob->main_stream, 
		       TREE_STRING_POINTER (string_cst),
		       TREE_STRING_LENGTH (string_cst));
	if (ASM_INPUTS (expr))
	  output_expr_operand (ob, ASM_INPUTS (expr));
	else 
	  output_zero (ob);

	if (ASM_OUTPUTS (expr))
	  output_expr_operand (ob, ASM_OUTPUTS (expr));
	else 
	  output_zero (ob);

	if (ASM_CLOBBERS (expr))
	  output_expr_operand (ob, ASM_CLOBBERS (expr));
	else 
	  output_zero (ob);
      }
      break;

    case RANGE_EXPR:
      {
	output_record_start (ob, NULL, NULL, LTO_range_expr);
	/* Need the types here to reconstruct the ranges.  */
	output_type_ref (ob, TREE_OPERAND (expr, 0));
	output_integer (ob, TREE_OPERAND (expr, 0));
	output_type_ref (ob, TREE_OPERAND (expr, 1));
	output_integer (ob, TREE_OPERAND (expr, 1));
      }
      break; 

    case RESX_EXPR:
      output_record_start (ob, expr, NULL, tag);
      output_uleb128 (ob, TREE_INT_CST_LOW (TREE_OPERAND (expr, 0)));
      break;

    case RETURN_EXPR:
      {
	tree t = TREE_OPERAND (expr, 0);
	if (t == NULL)
	  {
	    /* Form return.  */
	    output_record_start (ob, expr, expr,
				 LTO_return_expr0);
	  }
	else if (TREE_CODE (t) == MODIFY_EXPR)
	  {
	    /* Form return a = b;  */
	    output_record_start (ob, expr, expr,
				 LTO_return_expr2);
	    output_expr_operand (ob, TREE_OPERAND (t, 0));
	    output_expr_operand (ob, TREE_OPERAND (t, 1));
	  }
	else
	  {
	    /* Form return a; */
	    output_record_start (ob, expr, expr,
				 LTO_return_expr1);
            /* If the type of the argument is a type that gets returned
               in memory, then the gimplifier would have changed the
               argument of the RETURN_EXPR to point at DECL_RESULT of
               the current function.  Communicate this fact to the
               reader so we avoid reading in superfluous trees.  */
            if (t == DECL_RESULT (current_function_decl))
              output_zero (ob);
            else
              output_expr_operand (ob, t);
	  }
      }
      break;

    case GIMPLE_MODIFY_STMT:
      output_record_start (ob, expr, NULL, tag);
      output_expr_operand (ob, GIMPLE_STMT_OPERAND (expr, 0));
      output_expr_operand (ob, GIMPLE_STMT_OPERAND (expr, 1));
      break;

    case SWITCH_EXPR:
      {
	tree label_vec = TREE_OPERAND (expr, 2);
	size_t len = TREE_VEC_LENGTH (label_vec);
	size_t i;
	output_record_start (ob, expr, expr, tag);
	output_uleb128 (ob, len);
	output_expr_operand (ob, TREE_OPERAND (expr, 0));
	gcc_assert (TREE_OPERAND (expr, 1) == NULL);

	for (i = 0; i < len; ++i)
	  output_expr_operand (ob, TREE_VEC_ELT (label_vec, i));
      }
      break;

    case TREE_LIST:
      {
	tree tl;
	int count = 0;

	output_record_start (ob, expr, NULL, tag);
	for (tl = expr; tl; tl = TREE_CHAIN (tl))
	  count++;

	gcc_assert (count);
	output_uleb128 (ob, count);
	for (tl = expr; tl; tl = TREE_CHAIN (tl))
	  {
	    if (TREE_VALUE (tl) != NULL_TREE)
	      output_expr_operand (ob, TREE_VALUE (tl));
	    else
	      output_zero (ob);
	    
	    if (TREE_PURPOSE (tl))
	      output_expr_operand (ob, TREE_PURPOSE (tl));
	    else
	      output_zero (ob);
	  }
      }
      break;

      /* This is the default case. All of the cases that can be done
	 completely mechanically are done here.  */
      {
	int i;
#define SET_NAME(a,b)
#define MAP_EXPR_TAG(expr, tag) case expr:
#define TREE_SINGLE_MECHANICAL_TRUE

#include "lto-tree-tags.def"
#undef MAP_EXPR_TAG
#undef TREE_SINGLE_MECHANICAL_TRUE
#undef SET_NAME
	output_record_start (ob, expr, expr, tag);
	for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (expr)); i++)
	  output_expr_operand (ob, TREE_OPERAND (expr, i));
	break;
      }

      /* This is the error case, these are type codes that will either
	 never happen or that we have not gotten around to dealing
	 with are here.  */
    case BIND_EXPR:
    case BLOCK:
    case CATCH_EXPR:
    case EH_FILTER_EXPR:
    case NAME_MEMORY_TAG:
    case OMP_CONTINUE:
    case OMP_CRITICAL:
    case OMP_FOR:
    case OMP_MASTER:
    case OMP_ORDERED:
    case OMP_PARALLEL:
    case OMP_RETURN:
    case OMP_SECTIONS:
    case OMP_SINGLE:
    case STRUCT_FIELD_TAG:
    case SYMBOL_MEMORY_TAG:
    case TARGET_MEM_REF:
    case TRY_CATCH_EXPR:
    case TRY_FINALLY_EXPR:
    default:
      /* We cannot have forms that are not explicity handled.  So when
	 this is triggered, there is some form that is not being
	 output.  */
      gcc_unreachable ();
    }

  LTO_DEBUG_UNDENT ();
}

/* Output the local var INDEX to OB.  */

static void
output_local_var (struct output_block *ob, int index)
{
  tree decl = VEC_index (tree, ob->local_decls, index);
  unsigned int variant = 0;
  bool is_var = (TREE_CODE (decl) == VAR_DECL);
  bool needs_backing_var
    = (DECL_DEBUG_EXPR_IS_FROM (decl) && DECL_DEBUG_EXPR (decl));
  
  /* This will either be a local var decl or a parm decl. */
  unsigned int tag;
  
  gcc_assert (DECL_SIZE (decl));
  variant |= DECL_ATTRIBUTES (decl)      != NULL_TREE ? 0x01 : 0;
  variant |= DECL_SIZE_UNIT (decl)       != NULL_TREE ? 0x02 : 0;
  variant |= needs_backing_var                        ? 0x04 : 0;
  variant |= DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE ? 0x08 : 0;
  
  tag = (is_var
	 ? LTO_local_var_decl_body0
	 : LTO_parm_decl_body0)
    + variant;
  
  VEC_replace (int, ob->local_decls_index, index, ob->main_stream->total_size);
#ifdef LTO_STREAM_DEBUGGING
  VEC_replace (int, ob->local_decls_index_d, index, ob->debug_decl_stream->total_size);
#endif
  output_record_start (ob, NULL, NULL, tag);
  
  /* Put out the name if there is one.  */
  if (DECL_NAME (decl))
    {
      tree name = DECL_NAME (decl);
      output_string (ob, ob->main_stream, 
		     IDENTIFIER_POINTER (name), 
		     IDENTIFIER_LENGTH (name));
    }
  else
    output_zero (ob);
  
  output_type_ref (ob, TREE_TYPE (decl));
  
  if (is_var)
    {
      LTO_DEBUG_INDENT_TOKEN ("init");
      if (DECL_INITIAL (decl))
	output_expr_operand (ob, DECL_INITIAL (decl));
      else
	output_zero (ob);
      /* Index in unexpanded_vars_list.  */
      LTO_DEBUG_INDENT_TOKEN ("unexpanded index");
      output_sleb128 (ob, VEC_index (int, ob->unexpanded_local_decls_index, index));
    }
  else
    {
      output_type_ref (ob, DECL_ARG_TYPE (decl));
      /* The chain is only necessary for parm_decls.  */
      LTO_DEBUG_TOKEN ("chain");
      if (TREE_CHAIN (decl))
	output_expr_operand (ob, TREE_CHAIN (decl));
      else
	output_zero (ob);
    }

  clear_line_info (ob);
  output_tree_flags (ob, 0, decl, true);

  LTO_DEBUG_TOKEN ("context");
  if (DECL_CONTEXT (decl))
    output_expr_operand (ob, DECL_CONTEXT (decl));
  else 
    output_zero (ob);
  
  LTO_DEBUG_TOKEN ("align");
  output_uleb128 (ob, DECL_ALIGN (decl));
  
  /* Put out the subtrees.  */
  LTO_DEBUG_TOKEN ("size");
  output_expr_operand (ob, DECL_SIZE (decl));
  if (DECL_ATTRIBUTES (decl)!= NULL_TREE)
    {
      LTO_DEBUG_TOKEN ("attributes");
      output_expr_operand (ob, DECL_ATTRIBUTES (decl));
    }
  if (DECL_SIZE_UNIT (decl) != NULL_TREE)
    output_expr_operand (ob, DECL_SIZE_UNIT (decl));
  if (needs_backing_var)
    output_expr_operand (ob, DECL_DEBUG_EXPR (decl));
  if (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE)
    output_expr_operand (ob, DECL_ABSTRACT_ORIGIN (decl));
  
  LTO_DEBUG_UNDENT();
}


/* Output the local var_decls and parm_decls to OB.  */

static void
output_local_vars (struct output_block *ob, struct function *fn)
{
  unsigned int index = 0;
  tree t;
  int i = 0;
  struct output_stream *tmp_stream = ob->main_stream;
  bitmap local_statics = BITMAP_ALLOC (NULL);

  ob->main_stream = ob->local_decl_stream;

  /* We have found MOST of the local vars by scanning the function.
     However, many local vars have other local vars inside them.
     Other local vars can be found by walking the unexpanded vars
     list.  */

  /* Need to put out the local statics first, to avoid the pointer
     games used for the regular locals.  */
  LTO_DEBUG_TOKEN ("local statics");
  for (t = fn->unexpanded_var_list; t; t = TREE_CHAIN (t))
    {
      tree lv = TREE_VALUE (t);

      if (TREE_STATIC (lv))
	{
	  /* Do not put the static in the chain more than once, even
	     if it was in the chain more than once to start.  */
	  if (!bitmap_bit_p (local_statics, DECL_UID (lv)))
	    {
	      bitmap_set_bit (local_statics, DECL_UID (lv));
	      output_expr_operand (ob, lv);
	      if (DECL_CONTEXT (lv) == fn->decl)
		{
		  output_uleb128 (ob, 1); /* Restore context.  */
		}
	      else
		{
		  output_zero (ob); /* Restore context. */
		}
	      if (DECL_INITIAL (lv))
		output_expr_operand (ob, DECL_INITIAL (lv));
	      else 
		output_zero (ob); /* DECL_INITIAL.  */
	    }
	}
      else
	{
	  int j = output_local_decl_ref (ob, lv, false);
	  /* Just for the fun of it, some of the locals are in the
	     unexpanded_var_list more than once.  */
	  if (VEC_index (int, ob->unexpanded_local_decls_index, j) == -1)
	    VEC_replace (int, ob->unexpanded_local_decls_index, j, i++);
	}
    }


  /* End of statics.  */
  output_zero (ob);
  BITMAP_FREE (local_statics);

  /* The easiest way to get all of this stuff generated is to play
     pointer games with the streams and reuse the code for putting out
     the function bodies for putting out the local decls.  It needs to
     go into a separate stream because the LTO reader will want to
     process the local variables first, rather than have to back patch
     them.  */
  LTO_DEBUG_TOKEN ("local vars");
  while (index < VEC_length (tree, ob->local_decls))
    output_local_var (ob, index++);

  ob->main_stream = tmp_stream;
}


/* Output the local var_decls index and parm_decls index to OB.  */

static void
output_local_vars_index (struct output_block *ob)
{
  unsigned int index = 0;
  unsigned int stop;

  struct output_stream *tmp_stream = ob->main_stream;
  ob->main_stream = ob->local_decl_index_stream;

  stop = VEC_length (int, ob->local_decls_index);
  for (index = 0; index < stop; index++)
    {
      output_uleb128 (ob, VEC_index (int, ob->local_decls_index, index));
#ifdef LTO_STREAM_DEBUGGING
      output_uleb128 (ob, VEC_index (int, ob->local_decls_index_d, index));
#endif
    }
  ob->main_stream = tmp_stream;
}


/* Output the names in the named labels to the named_label stream.  */

static void
output_named_labels (struct output_block *ob)
{
  unsigned int index = 0;
  clear_line_info (ob);

  while (index < VEC_length (tree, ob->named_labels))
    {
      tree decl = VEC_index (tree, ob->named_labels, index++);
      tree name = DECL_NAME (decl);
      output_string (ob, ob->named_label_stream, 
		     IDENTIFIER_POINTER (name), 
		     IDENTIFIER_LENGTH (name));
   }
}


/* Output all of the active ssa names to the ssa_names stream.  */

static void
output_ssa_names (struct output_block *ob, struct function *fn)
{
  /* Switch streams so we can use output_expr_operand to write the
     SSA_NAME_VAR.  */
  struct output_stream *tmp_stream = ob->main_stream;
  unsigned int i;
  unsigned int len = VEC_length (tree, SSANAMES (fn));

  ob->main_stream = ob->ssa_names_stream;
  output_uleb128 (ob, len);

  for (i = 1; i < len; i++)
    {
      tree ptr = VEC_index (tree, SSANAMES (fn), i);

      if (ptr == NULL_TREE || SSA_NAME_IN_FREE_LIST (ptr))
	continue;

      output_uleb128 (ob, i);
      output_expr_operand (ob, SSA_NAME_VAR (ptr));
      /* Use code 0 to force flags to be output.  */
      output_tree_flags (ob, 0, ptr, false);
    }

  output_zero (ob);
  ob->main_stream = tmp_stream;
}


/* Output the cfg.  */

static void
output_cfg (struct output_block *ob, struct function *fn)
{
  struct output_stream *tmp_stream = ob->main_stream;
  basic_block bb;

  ob->main_stream = ob->cfg_stream;

  /* Output the number of the highest basic block.  */
  LTO_DEBUG_TOKEN ("lastbb");
  output_uleb128 (ob, last_basic_block_for_function(fn));

  FOR_ALL_BB_FN (bb, fn)
    {
      edge_iterator ei;
      edge e;

      LTO_DEBUG_TOKEN ("bbindex");
      output_sleb128 (ob, bb->index);

      /* Output the successors and the edge flags.  */
      LTO_DEBUG_TOKEN ("edgecount");
      output_uleb128 (ob, EDGE_COUNT (bb->succs));
      FOR_EACH_EDGE (e, ei, bb->succs)
	{
	  LTO_DEBUG_TOKEN ("dest");
	  output_uleb128 (ob, e->dest->index);
	  LTO_DEBUG_TOKEN ("eflags");
	  output_uleb128 (ob, e->flags);
	}
    }

  LTO_DEBUG_TOKEN ("bbindex");
  output_sleb128 (ob, -1);

  bb = ENTRY_BLOCK_PTR;
  while (bb->next_bb)
    {
      LTO_DEBUG_TOKEN ("bbchain");
      output_sleb128 (ob, bb->next_bb->index);
      bb = bb->next_bb;
    }
  LTO_DEBUG_TOKEN ("bbchain");
  output_sleb128 (ob, -1);

  ob->main_stream = tmp_stream;
}


/* Output a phi function to the main stream in OB.  */

static void
output_phi (struct output_block *ob, tree expr)
{
  int len = PHI_NUM_ARGS (expr);
  int i;
  
  output_record_start (ob, expr, expr, LTO_phi_node);
  output_uleb128 (ob, SSA_NAME_VERSION (PHI_RESULT (expr)));

  for (i = 0; i < len; i++)
    {
      output_expr_operand (ob, PHI_ARG_DEF (expr, i));
      output_uleb128 (ob, PHI_ARG_EDGE (expr, i)->src->index);
    }
  LTO_DEBUG_UNDENT ();
}


/* Output a basic block BB to the main stream in OB for this FN.  */

static void
output_bb (struct output_block *ob, basic_block bb, struct function *fn)
{
  block_stmt_iterator bsi = bsi_start (bb);

  output_record_start (ob, NULL, NULL,
		       (!bsi_end_p (bsi)) || phi_nodes (bb) ? LTO_bb1 : LTO_bb0);

  /* The index of the basic block.  */
  LTO_DEBUG_TOKEN ("bbindex");
  output_uleb128 (ob, bb->index);

  if ((!bsi_end_p (bsi)) || phi_nodes (bb))
    {
      /* Output the statements.  The list of statements is terminated
	 with a zero.  */
      tree phi;

      for (bsi = bsi_start (bb);
	   !bsi_end_p (bsi); bsi_next (&bsi))
	{
	  tree stmt = bsi_stmt (bsi);
	
	  LTO_DEBUG_INDENT_TOKEN ("stmt");
	  output_expr_operand (ob, stmt);
	
	  /* We only need to set the region number of the tree that
	     could throw if the region number is different from the
	     last region number we set.  */
	  if (0 && tree_could_throw_p (stmt))
	    {
	      int region = lookup_stmt_eh_region_fn (fn, stmt);
	      if (region != last_eh_region_seen)
		{
		  output_record_start (ob, NULL, NULL,
				       LTO_set_eh0 + region ? 1 : 0);
		  if (region)
		    output_sleb128 (ob, region);
		
		  last_eh_region_seen = region;
		}
	    }
	}

      LTO_DEBUG_INDENT_TOKEN ("stmt");
      output_zero (ob);

      for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
	{
	  LTO_DEBUG_INDENT_TOKEN ("phi");
	  output_phi (ob, phi);
	}

      LTO_DEBUG_INDENT_TOKEN ("phi");
      output_zero (ob);
    }

  LTO_DEBUG_UNDENT();

#ifdef LTO_STREAM_DEBUGGING
  gcc_assert (lto_debug_context.indent == 1);
#endif
}

/* Write the references for the objects in V to section SEC in the
   assembly file.  Use REF_FN to compute the reference.  */

static void
write_references (VEC(tree,heap) *v, section *sec,
		  void (*ref_fn) (tree, lto_out_ref *))
{
  int index;
  tree t;
  lto_out_ref out_ref = {0, NULL, NULL};

  for (index = 0; VEC_iterate(tree, v, index, t); index++)
    {
      ref_fn (t, &out_ref);
      /* We always call switch_to_section as the act of creating a
	 handle we can reference may have dumped some bits into the
	 assembly.  */
      switch_to_section (sec);
      dw2_asm_output_data (8, out_ref.section, " ");
      dw2_asm_output_delta (8, out_ref.label, out_ref.base_label, " ");
    }
}

/* Create the header in the file using OB for t.  */

static void
produce_asm (struct output_block *ob, tree t, bool is_function)
{
  const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t));
  const char *section_name = concat (LTO_SECTION_NAME_PREFIX, name, NULL);
  section *section = get_section (section_name, SECTION_DEBUG, t);
  struct lto_header header;

  memset (&header, 0, sizeof (struct lto_header)); 

  /* The entire header is stream computed here.  */
  switch_to_section (section);
  
  /* Write the header which says how to decode the pieces of the
     t.  */
  header.major_version = LTO_major_version;
  header.minor_version = LTO_minor_version;
  
  header.num_field_decls = VEC_length (tree, ob->field_decls);
  header.num_fn_decls = VEC_length (tree, ob->fn_decls);
  header.num_var_decls = VEC_length (tree, ob->var_decls);
  header.num_type_decls = VEC_length (tree, ob->type_decls);
  header.num_types = VEC_length (tree, ob->types);
  if (is_function)
    {
      header.num_local_decls = VEC_length (tree, ob->local_decls);
      header.num_named_labels = ob->next_named_label_index;
      header.num_unnamed_labels = -ob->next_unnamed_label_index;
    }
  header.compressed_size = 0;
  
  if (is_function)
    {
      header.named_label_size = ob->named_label_stream->total_size;
      header.ssa_names_size = ob->ssa_names_stream->total_size;
      header.cfg_size = ob->cfg_stream->total_size;
      header.local_decls_index_size = ob->local_decl_index_stream->total_size;
      header.local_decls_size = ob->local_decl_stream->total_size;
    }
  header.main_size = ob->main_stream->total_size;
  header.string_size = ob->string_stream->total_size;
#ifdef LTO_STREAM_DEBUGGING
  if (is_function)
    {
      header.debug_decl_index_size = ob->debug_decl_index_stream->total_size;
      header.debug_decl_size = ob->debug_decl_stream->total_size;
      header.debug_label_size = ob->debug_label_stream->total_size;
      header.debug_ssa_names_size = ob->debug_ssa_names_stream->total_size;
      header.debug_cfg_size = ob->debug_cfg_stream->total_size;
    }
  header.debug_main_size = ob->debug_main_stream->total_size;
#else
  header.debug_decl_index_size = -1;
  header.debug_decl_size = -1;
  header.debug_label_size = -1;
  header.debug_ssa_names_size = -1;
  header.debug_cfg_size = -1;
  header.debug_main_size = -1;
#endif

  assemble_string ((const char *)&header, 
		   sizeof (struct lto_header));

  /* Write the global field references.  */
  write_references (ob->field_decls, section, lto_field_ref);

  /* Write the global function references.  */
  write_references (ob->fn_decls, section, lto_fn_ref);

  /* Write the global var references.  */
  write_references (ob->var_decls, section, lto_var_ref);

  /* Write the global type_decl references.  */
  write_references (ob->type_decls, section, lto_typedecl_ref);

  /* Write the global type references.  */
  write_references (ob->types, section, lto_type_ref);

  /* Put all of the gimple and the string table out the asm file as a
     block of text.  */
  if (is_function)
    {
      write_stream (ob->named_label_stream);
      write_stream (ob->ssa_names_stream);
      write_stream (ob->cfg_stream);
      write_stream (ob->local_decl_index_stream);
      write_stream (ob->local_decl_stream);
    }
  write_stream (ob->main_stream);
  write_stream (ob->string_stream);
#ifdef LTO_STREAM_DEBUGGING
  if (is_function)
    {
      write_stream (ob->debug_decl_index_stream);
      write_stream (ob->debug_decl_stream);
      write_stream (ob->debug_label_stream);
      write_stream (ob->debug_ssa_names_stream);
      write_stream (ob->debug_cfg_stream);
    }
  write_stream (ob->debug_main_stream);
#endif
}


static bool initialized = false;
static bool initialized_local = false;


/* Static initialization for both the lto reader and the lto
   writer.  */

void
lto_static_init (void)
{
  if (initialized)
    return;

  initialized = true;

  lto_flags_needed_for = sbitmap_alloc (NUM_TREE_CODES);
  sbitmap_ones (lto_flags_needed_for);
  RESET_BIT (lto_flags_needed_for, FIELD_DECL);
  RESET_BIT (lto_flags_needed_for, FUNCTION_DECL);
  RESET_BIT (lto_flags_needed_for, IDENTIFIER_NODE);
  RESET_BIT (lto_flags_needed_for, PARM_DECL);
  RESET_BIT (lto_flags_needed_for, SSA_NAME);
  RESET_BIT (lto_flags_needed_for, VAR_DECL);
  RESET_BIT (lto_flags_needed_for, TREE_LIST);
  RESET_BIT (lto_flags_needed_for, TYPE_DECL);

  lto_types_needed_for = sbitmap_alloc (NUM_TREE_CODES);

#if REDUNDANT_TYPE_SYSTEM
  /* These forms never need types.  */
  sbitmap_ones (lto_types_needed_for);
  RESET_BIT (lto_types_needed_for, ASM_EXPR);
  RESET_BIT (lto_types_needed_for, CASE_LABEL_EXPR);
  RESET_BIT (lto_types_needed_for, FIELD_DECL);
  RESET_BIT (lto_types_needed_for, FUNCTION_DECL);
  RESET_BIT (lto_types_needed_for, GIMPLE_MODIFY_STMT);
  RESET_BIT (lto_types_needed_for, IDENTIFIER_NODE);
  RESET_BIT (lto_types_needed_for, LABEL_DECL);
  RESET_BIT (lto_types_needed_for, LABEL_EXPR);
  RESET_BIT (lto_types_needed_for, MODIFY_EXPR);
  RESET_BIT (lto_types_needed_for, PARM_DECL);
  RESET_BIT (lto_types_needed_for, PHI_NODE);
  RESET_BIT (lto_types_needed_for, RESX_EXPR);
  RESET_BIT (lto_types_needed_for, SSA_NAME);
  RESET_BIT (lto_types_needed_for, VAR_DECL);
  RESET_BIT (lto_types_needed_for, TREE_LIST);
  RESET_BIT (lto_types_needed_for, TYPE_DECL);
#else
  /* These forms will need types, even when the type system is fixed.  */
  SET_BIT (lto_types_needed_for, COMPLEX_CST);
  SET_BIT (lto_types_needed_for, CONSTRUCTOR);
  SET_BIT (lto_types_needed_for, CONVERT_EXPR);
  SET_BIT (lto_types_needed_for, FIXED_CONVERT_EXPR);
  SET_BIT (lto_types_needed_for, FIXED_CST);
  SET_BIT (lto_types_needed_for, INTEGER_CST);
  SET_BIT (lto_types_needed_for, NOP_EXPR);
  SET_BIT (lto_types_needed_for, REAL_CST);
  SET_BIT (lto_types_needed_for, STRING_CST);
  SET_BIT (lto_types_needed_for, VECTOR_CST );
  SET_BIT (lto_types_needed_for, VIEW_CONVERT_EXPR);
#endif

#ifdef LTO_STREAM_DEBUGGING
#define LTO_STREAM_DEBUGGING_INIT_NAMES
#define SET_NAME(index,value) LTO_tag_names[index] = value;
#include "lto-tree-tags.def"
#undef SET_NAME
#undef LTO_STREAM_DEBUGGING_INIT_NAMES
#endif
}


/* Static initialization for the lto writer.  */

static void
lto_static_init_local (void)
{
  if (initialized_local)
    return;

  initialized_local = true;

  /* Initialize the expression to tag mapping.  */
#define MAP_EXPR_TAG(expr,tag)   expr_to_tag [expr] = tag;
#define TREE_SINGLE_MECHANICAL_TRUE
#define TREE_SINGLE_MECHANICAL_FALSE
#include "lto-tree-tags.def"

#undef MAP_EXPR_TAG
#undef TREE_SINGLE_MECHANICAL_TRUE
#undef TREE_SINGLE_MECHANICAL_FALSE

  lto_static_init ();
}


#ifdef FILE_PER_FUNCTION
/* The once per compilation unit initialization flag.  */
static int function_num;
#endif

/* Generate complete DWARF information for the function now so that we
   don't run into missing or incomplete information later.  */

static void
generate_early_dwarf_information (tree function)
{
  /* Don't bother with frame information, since we have no RTL.  */
  dwarf2out_decl (function);
}

/* Output FN.  */

static void
output_function (tree function)
{
  struct function *fn = DECL_STRUCT_FUNCTION (function);
  basic_block bb;
  struct output_block *ob = create_output_block (true);

  LTO_SET_DEBUGGING_STREAM (debug_main_stream, main_data);
  clear_line_info (ob);

  gcc_assert (!current_function_decl && !cfun);

  /* Set current_function_decl to what the dwarf2 machinery expects.  */
  current_function_decl = function;
  push_cfun (fn);

  /* Generate debugging info as early as we can.  */
  generate_early_dwarf_information (function);

  /* Make string 0 be a NULL string.  */
  output_1_stream (ob->string_stream, 0);

  last_eh_region_seen = 0;

  output_record_start (ob, NULL, NULL, LTO_function);

  /* Output any exception-handling regions.  */
  output_eh_regions (ob, fn);

  /* Output the head of the arguments list.  */
  LTO_DEBUG_INDENT_TOKEN ("decl_arguments");
  if (DECL_ARGUMENTS (function))
    output_expr_operand (ob, DECL_ARGUMENTS (function));
  else
    output_zero (ob);
    
  LTO_DEBUG_INDENT_TOKEN ("decl_context");
  if (DECL_CONTEXT (function))
    output_expr_operand (ob, DECL_CONTEXT (function));
  else
    output_zero (ob);

  /* Output the code for the function.  */
  FOR_ALL_BB_FN (bb, fn)
    output_bb (ob, bb, fn);

  /* The terminator for this function.  */
  output_zero (ob);
  LTO_DEBUG_UNDENT();

  LTO_SET_DEBUGGING_STREAM (debug_ssa_names_stream, ssa_names_data);
  output_ssa_names (ob, fn);

  LTO_SET_DEBUGGING_STREAM (debug_cfg_stream, cfg_data);
  output_cfg (ob, fn);

  LTO_SET_DEBUGGING_STREAM (debug_decl_stream, decl_data);
  output_local_vars (ob, fn);

  LTO_SET_DEBUGGING_STREAM (debug_decl_index_stream, decl_index_data);
  output_local_vars_index (ob);

  LTO_SET_DEBUGGING_STREAM (debug_label_stream, label_data);
  output_named_labels (ob);

  /* Create a file to hold the pickled output of this function.  This
     is a temp standin until we start writing sections.  */
  produce_asm (ob, function, true);

  destroy_output_block (ob, true);

  current_function_decl = NULL;

  pop_cfun ();
}


/* Output constructor for VAR.  */

static void
output_constructor_or_init (tree var)
{
  struct output_block *ob = create_output_block (false);

  LTO_SET_DEBUGGING_STREAM (debug_main_stream, main_data);
  clear_line_info (ob);

  /* Make string 0 be a NULL string.  */
  output_1_stream (ob->string_stream, 0);

  LTO_DEBUG_INDENT_TOKEN ("init");
  output_expr_operand (ob, DECL_INITIAL (var));

  /* The terminator for the constructor.  */
  output_zero (ob);

  /* Create a file to hold the pickled output of this function.  This
     is a temp standin until we start writing sections.  */
  produce_asm (ob, var, false);

  destroy_output_block (ob, false);
}


/* Main entry point from the pass manager.  */

static unsigned int
lto_output (void)
{
  struct cgraph_node *node;
  struct varpool_node *vnode;

  section *saved_section = in_section;

  lto_static_init_local ();

  /* Turn off some DWARF2 bits.  */
  dwarf2_called_from_lto_p = true;

  /* Process only the fuctions with bodies and only process the master
     ones of them.  */
  for (node = cgraph_nodes; node; node = node->next)
    if (node->analyzed && cgraph_is_master_clone (node, false))
      output_function (node->decl);

  /* Process the global static vars that have initializers or
     constructors.  */
  FOR_EACH_STATIC_INITIALIZER (vnode)
    if (DECL_CONTEXT (vnode->decl) == NULL_TREE)
      output_constructor_or_init (vnode->decl);

  /* Put back the assembly section that was there before we started
     writing lto info.  */
  if (saved_section)
    switch_to_section (saved_section);

  dwarf2_called_from_lto_p = false;

  return 0;
}

static bool
gate_lto_out (void)
{
  return (flag_generate_lto
	  /* Don't bother doing anything if the program has errors.  */
	  && !(errorcount || sorrycount));
}

struct tree_opt_pass pass_ipa_lto_out =
{
  "lto_function_out",	                /* name */
  gate_lto_out,			        /* gate */
  lto_output,		        	/* execute */
  NULL,					/* sub */
  NULL,					/* next */
  0,					/* static_pass_number */
  TV_IPA_LTO_OUT,		        /* tv_id */
  0,	                                /* properties_required */
  0,					/* properties_provided */
  0,					/* properties_destroyed */
  0,            			/* todo_flags_start */
  TODO_dump_func,                       /* todo_flags_finish */
  0					/* letter */
};


#ifdef LTO_STREAM_DEBUGGING

/* The low level output routine to print a single character to the
   debugging stream.  */

static void
debug_out_fun (struct lto_debug_context *context, char c)
{
  struct output_stream * stream 
    = (struct output_stream *)context->current_data;
  output_1_stream (stream, c);
}
/* Print the tree flags to the debugging stream.  */
   
void 
lto_debug_tree_flags (struct lto_debug_context *context, 
		      enum tree_code code, 
		      lto_flags_type flags)
{
#define CLEAROUT (BITS_PER_LTO_FLAGS_TYPE - 1)

#define START_CLASS_SWITCH()              \
  {                                       \
                                          \
    switch (TREE_CODE_CLASS (code))       \
    {

#define START_CLASS_CASE(class)    case class:
#define ADD_CLASS_DECL_FLAG(flag_name) \
  { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
#define ADD_CLASS_EXPR_FLAG(flag_name) \
  { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
#define END_CLASS_CASE(class)      break;
#define END_CLASS_SWITCH()                \
    default:                              \
      gcc_unreachable ();                 \
    }


#define START_EXPR_SWITCH()               \
    switch (code)			  \
    {
#define START_EXPR_CASE(code)    case code:
#define ADD_EXPR_FLAG(flag_name) \
  { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
#define ADD_DECL_FLAG(flag_name) \
  { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
#define ADD_VIS_FLAG(flag_name)  \
  { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
#define ADD_VIS_FLAG_SIZE(flag_name,size)					\
  { if (flags >> (BITS_PER_LTO_FLAGS_TYPE - size)) lto_debug_token (context, " " # flag_name ); flags <<= size; }
#define END_EXPR_CASE(class)      break;
#define END_EXPR_SWITCH()                 \
    default:                              \
      gcc_unreachable ();                 \
    }                                     \
  }

#include "lto-tree-flags.def"

#undef START_CLASS_SWITCH
#undef START_CLASS_CASE
#undef ADD_CLASS_DECL_FLAG
#undef ADD_CLASS_EXPR_FLAG
#undef END_CLASS_CASE
#undef END_CLASS_SWITCH
#undef START_EXPR_SWITCH
#undef START_EXPR_CASE
#undef ADD_EXPR_FLAG
#undef ADD_DECL_FLAG
#undef ADD_VIS_FLAG
#undef END_EXPR_CASE
#undef END_EXPR_SWITCH
}
#endif