llvm.org GIT mirror llvm / a727d55
minor cleanups. Add provisions for a new standard BLOCKINFO_BLOCK block type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36748 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
4 changed file(s) with 41 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
2929 BlockSizeWidth = 32 // BlockSize up to 2^32 32-bit words = 32GB per block.
3030 };
3131
32 // The standard code namespace always has a way to exit a block, enter a
32 // The standard abbrev namespace always has a way to exit a block, enter a
3333 // nested block, define abbrevs, and define an unabbreviated record.
34 enum FixedCodes {
34 enum FixedAbbrevIDs {
3535 END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode.
3636 ENTER_SUBBLOCK = 1,
3737
4747 UNABBREV_RECORD = 3,
4848
4949 // This is not a code, this is a marker for the first abbrev assignment.
50 FIRST_ABBREV = 4
50 FIRST_APPLICATION_ABBREV = 4
5151 };
52
53 /// StandardBlockIDs - All bitcode files can optionally include a BLOCKINFO
54 /// block, which contains metadata about other blocks in the file.
55 enum StandardBlockIDs {
56 /// BLOCKINFO_BLOCK is used to define metadata about blocks, for example,
57 /// standard abbrevs that should be available to all blocks of a specified
58 /// ID.
59 BLOCKINFO_BLOCK_ID = 0,
60
61 // Block IDs 1-7 are reserved for future expansion.
62 FIRST_APPLICATION_BLOCKID = 8
63 };
64
65 /// BlockInfoCodes - The blockinfo block contains metadata about user-defined
66 /// blocks.
67 enum BlockInfoCodes {
68 BLOCKINFO_CODE_SETBID = 1, // SETBID: [blockid#]
69 BLOCKINFO_CODE_ABBREV = 2 // ABBREV: [standard abbrev encoding]
70 // BLOCKNAME: give string name to block, if desired.
71 };
72
5273 } // End bitc namespace
5374
5475 /// BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
6283 unsigned Enc : 3; // The encoding to use.
6384 public:
6485 enum Encoding {
65 FixedWidth = 1, // A fixed with field, Val specifies number of bits.
86 FixedWidth = 1, // A fixed with field, Val specifies number of bits.
6687 VBR = 2 // A VBR field where Val specifies the width of each chunk.
6788 };
6889
86107 }
87108 };
88109
110 /// BitCodeAbbrev - This class represents an abbreviation record. An
111 /// abbreviation allows a complex record that has redundancy to be stored in a
112 /// specialized format instead of the fully-general, fully-vbr, format.
89113 class BitCodeAbbrev {
90114 SmallVector OperandList;
91115 unsigned char RefCount; // Number of things using this.
282282 return Code;
283283 }
284284
285 unsigned AbbrevNo = AbbrevID-bitc::FIRST_ABBREV;
285 unsigned AbbrevNo = AbbrevID-bitc::FIRST_APPLICATION_ABBREV;
286286 assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
287287 BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];
288288
193193 void EmitRecord(unsigned Code, SmallVectorImpl &Vals,
194194 unsigned Abbrev = 0) {
195195 if (Abbrev) {
196 unsigned AbbrevNo = Abbrev-bitc::FIRST_ABBREV;
196 unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
197197 assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
198198 BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];
199199
246246 void EmitRecord(unsigned Code, SmallVectorImpl &Vals,
247247 unsigned Abbrev = 0) {
248248 if (Abbrev) {
249 unsigned AbbrevNo = Abbrev-bitc::FIRST_ABBREV;
249 unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
250250 assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
251251 BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];
252252
317317 }
318318
319319 CurAbbrevs.push_back(Abbv);
320 return CurAbbrevs.size()-1+bitc::FIRST_ABBREV;
320 return CurAbbrevs.size()-1+bitc::FIRST_APPLICATION_ABBREV;
321321 }
322322 };
323323
2424 // The only top-level block type defined is for a module.
2525 enum BlockIDs {
2626 // Blocks
27 MODULE_BLOCK_ID = 0,
27 MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID,
2828
29 // Module sub-block id's
30 PARAMATTR_BLOCK_ID = 1,
31 TYPE_BLOCK_ID = 2,
32 CONSTANTS_BLOCK_ID = 3,
33 FUNCTION_BLOCK_ID = 4,
34 TYPE_SYMTAB_BLOCK_ID = 5,
35 VALUE_SYMTAB_BLOCK_ID = 6
29 // Module sub-block id's.
30 PARAMATTR_BLOCK_ID,
31 TYPE_BLOCK_ID,
32 CONSTANTS_BLOCK_ID,
33 FUNCTION_BLOCK_ID,
34 TYPE_SYMTAB_BLOCK_ID,
35 VALUE_SYMTAB_BLOCK_ID
3636 };
3737
3838
6767
6868 /// TYPE blocks have codes for each type primitive they use.
6969 enum TypeCodes {
70 TYPE_CODE_NUMENTRY = 1, // TYPE_CODE_NUMENTRY: [numentries]
70 TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries]
7171
7272 // Type Codes
7373 TYPE_CODE_VOID = 2, // VOID