xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm/Bitstream/BitCodeEnums.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1*81ad6265SDimitry Andric //===- BitCodeEnums.h - Core enums for the bitstream format -----*- C++ -*-===//
2*81ad6265SDimitry Andric //
3*81ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*81ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*81ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*81ad6265SDimitry Andric //
7*81ad6265SDimitry Andric //===----------------------------------------------------------------------===//
8*81ad6265SDimitry Andric //
9*81ad6265SDimitry Andric // This header defines "core" bitstream enum values.
10*81ad6265SDimitry Andric // It has been separated from the other header that defines bitstream enum
11*81ad6265SDimitry Andric // values, BitCodes.h, to allow tools to track changes to the various
12*81ad6265SDimitry Andric // bitstream and bitcode enums without needing to fully or partially build
13*81ad6265SDimitry Andric // LLVM itself.
14*81ad6265SDimitry Andric //
15*81ad6265SDimitry Andric // The enum values defined in this file should be considered permanent.  If
16*81ad6265SDimitry Andric // new features are added, they should have values added at the end of the
17*81ad6265SDimitry Andric // respective lists.
18*81ad6265SDimitry Andric //
19*81ad6265SDimitry Andric //===----------------------------------------------------------------------===//
20*81ad6265SDimitry Andric 
21*81ad6265SDimitry Andric #ifndef LLVM_BITSTREAM_BITCODEENUMS_H
22*81ad6265SDimitry Andric #define LLVM_BITSTREAM_BITCODEENUMS_H
23*81ad6265SDimitry Andric 
24*81ad6265SDimitry Andric namespace llvm {
25*81ad6265SDimitry Andric /// Offsets of the 32-bit fields of bitstream wrapper header.
26*81ad6265SDimitry Andric enum BitstreamWrapperHeader : unsigned {
27*81ad6265SDimitry Andric   BWH_MagicField = 0 * 4,
28*81ad6265SDimitry Andric   BWH_VersionField = 1 * 4,
29*81ad6265SDimitry Andric   BWH_OffsetField = 2 * 4,
30*81ad6265SDimitry Andric   BWH_SizeField = 3 * 4,
31*81ad6265SDimitry Andric   BWH_CPUTypeField = 4 * 4,
32*81ad6265SDimitry Andric   BWH_HeaderSize = 5 * 4
33*81ad6265SDimitry Andric };
34*81ad6265SDimitry Andric 
35*81ad6265SDimitry Andric namespace bitc {
36*81ad6265SDimitry Andric enum StandardWidths {
37*81ad6265SDimitry Andric   BlockIDWidth = 8,   // We use VBR-8 for block IDs.
38*81ad6265SDimitry Andric   CodeLenWidth = 4,   // Codelen are VBR-4.
39*81ad6265SDimitry Andric   BlockSizeWidth = 32 // BlockSize up to 2^32 32-bit words = 16GB per block.
40*81ad6265SDimitry Andric };
41*81ad6265SDimitry Andric 
42*81ad6265SDimitry Andric // The standard abbrev namespace always has a way to exit a block, enter a
43*81ad6265SDimitry Andric // nested block, define abbrevs, and define an unabbreviated record.
44*81ad6265SDimitry Andric enum FixedAbbrevIDs {
45*81ad6265SDimitry Andric   END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode.
46*81ad6265SDimitry Andric   ENTER_SUBBLOCK = 1,
47*81ad6265SDimitry Andric 
48*81ad6265SDimitry Andric   /// DEFINE_ABBREV - Defines an abbrev for the current block.  It consists
49*81ad6265SDimitry Andric   /// of a vbr5 for # operand infos.  Each operand info is emitted with a
50*81ad6265SDimitry Andric   /// single bit to indicate if it is a literal encoding.  If so, the value is
51*81ad6265SDimitry Andric   /// emitted with a vbr8.  If not, the encoding is emitted as 3 bits followed
52*81ad6265SDimitry Andric   /// by the info value as a vbr5 if needed.
53*81ad6265SDimitry Andric   DEFINE_ABBREV = 2,
54*81ad6265SDimitry Andric 
55*81ad6265SDimitry Andric   // UNABBREV_RECORDs are emitted with a vbr6 for the record code, followed by
56*81ad6265SDimitry Andric   // a vbr6 for the # operands, followed by vbr6's for each operand.
57*81ad6265SDimitry Andric   UNABBREV_RECORD = 3,
58*81ad6265SDimitry Andric 
59*81ad6265SDimitry Andric   // This is not a code, this is a marker for the first abbrev assignment.
60*81ad6265SDimitry Andric   FIRST_APPLICATION_ABBREV = 4
61*81ad6265SDimitry Andric };
62*81ad6265SDimitry Andric 
63*81ad6265SDimitry Andric /// StandardBlockIDs - All bitcode files can optionally include a BLOCKINFO
64*81ad6265SDimitry Andric /// block, which contains metadata about other blocks in the file.
65*81ad6265SDimitry Andric enum StandardBlockIDs {
66*81ad6265SDimitry Andric   /// BLOCKINFO_BLOCK is used to define metadata about blocks, for example,
67*81ad6265SDimitry Andric   /// standard abbrevs that should be available to all blocks of a specified
68*81ad6265SDimitry Andric   /// ID.
69*81ad6265SDimitry Andric   BLOCKINFO_BLOCK_ID = 0,
70*81ad6265SDimitry Andric 
71*81ad6265SDimitry Andric   // Block IDs 1-7 are reserved for future expansion.
72*81ad6265SDimitry Andric   FIRST_APPLICATION_BLOCKID = 8
73*81ad6265SDimitry Andric };
74*81ad6265SDimitry Andric 
75*81ad6265SDimitry Andric /// BlockInfoCodes - The blockinfo block contains metadata about user-defined
76*81ad6265SDimitry Andric /// blocks.
77*81ad6265SDimitry Andric enum BlockInfoCodes {
78*81ad6265SDimitry Andric   // DEFINE_ABBREV has magic semantics here, applying to the current SETBID'd
79*81ad6265SDimitry Andric   // block, instead of the BlockInfo block.
80*81ad6265SDimitry Andric 
81*81ad6265SDimitry Andric   BLOCKINFO_CODE_SETBID = 1,       // SETBID: [blockid#]
82*81ad6265SDimitry Andric   BLOCKINFO_CODE_BLOCKNAME = 2,    // BLOCKNAME: [name]
83*81ad6265SDimitry Andric   BLOCKINFO_CODE_SETRECORDNAME = 3 // BLOCKINFO_CODE_SETRECORDNAME:
84*81ad6265SDimitry Andric                                    //                             [id, name]
85*81ad6265SDimitry Andric };
86*81ad6265SDimitry Andric 
87*81ad6265SDimitry Andric } // namespace bitc
88*81ad6265SDimitry Andric } // namespace llvm
89*81ad6265SDimitry Andric 
90*81ad6265SDimitry Andric #endif
91