blob: 396904a3d6d1e93f734aafe0036d6c96c7dce15c [file] [log] [blame]
Chris Lattner3a1716d2007-05-12 05:37:42 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
Reid Spencer2c1ce4f2007-01-20 23:21:08 +00003<html>
4<head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>LLVM Bitcode File Format</title>
7 <link rel="stylesheet" href="llvm.css" type="text/css">
Reid Spencer2c1ce4f2007-01-20 23:21:08 +00008</head>
9<body>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000010<h1> LLVM Bitcode File Format</h1>
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000011<ol>
12 <li><a href="#abstract">Abstract</a></li>
Chris Lattnere9ef4572007-05-12 03:23:40 +000013 <li><a href="#overview">Overview</a></li>
14 <li><a href="#bitstream">Bitstream Format</a>
15 <ol>
16 <li><a href="#magic">Magic Numbers</a></li>
Chris Lattner3a1716d2007-05-12 05:37:42 +000017 <li><a href="#primitives">Primitives</a></li>
18 <li><a href="#abbrevid">Abbreviation IDs</a></li>
19 <li><a href="#blocks">Blocks</a></li>
20 <li><a href="#datarecord">Data Records</a></li>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +000021 <li><a href="#abbreviations">Abbreviations</a></li>
Chris Lattner7300af52007-05-13 00:59:52 +000022 <li><a href="#stdblocks">Standard Blocks</a></li>
Chris Lattnere9ef4572007-05-12 03:23:40 +000023 </ol>
24 </li>
Chris Lattner6fa6a322008-07-09 05:14:23 +000025 <li><a href="#wrapper">Bitcode Wrapper Format</a>
26 </li>
Chris Lattner69b3e402007-05-13 01:39:44 +000027 <li><a href="#llvmir">LLVM IR Encoding</a>
28 <ol>
29 <li><a href="#basics">Basics</a></li>
Chris Lattner5c303e82009-10-29 04:25:46 +000030 <li><a href="#MODULE_BLOCK">MODULE_BLOCK Contents</a></li>
31 <li><a href="#PARAMATTR_BLOCK">PARAMATTR_BLOCK Contents</a></li>
32 <li><a href="#TYPE_BLOCK">TYPE_BLOCK Contents</a></li>
33 <li><a href="#CONSTANTS_BLOCK">CONSTANTS_BLOCK Contents</a></li>
34 <li><a href="#FUNCTION_BLOCK">FUNCTION_BLOCK Contents</a></li>
35 <li><a href="#TYPE_SYMTAB_BLOCK">TYPE_SYMTAB_BLOCK Contents</a></li>
36 <li><a href="#VALUE_SYMTAB_BLOCK">VALUE_SYMTAB_BLOCK Contents</a></li>
37 <li><a href="#METADATA_BLOCK">METADATA_BLOCK Contents</a></li>
38 <li><a href="#METADATA_ATTACHMENT">METADATA_ATTACHMENT Contents</a></li>
Chris Lattner69b3e402007-05-13 01:39:44 +000039 </ol>
40 </li>
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000041</ol>
42<div class="doc_author">
Chris Lattner299f4242010-05-21 22:20:54 +000043 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>,
44 <a href="http://www.reverberate.org">Joshua Haberman</a>,
45 and <a href="mailto:housel@acm.org">Peter S. Housel</a>.
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000046</p>
47</div>
Chris Lattnere9ef4572007-05-12 03:23:40 +000048
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000049<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000050<h2><a name="abstract">Abstract</a></h2>
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000051<!-- *********************************************************************** -->
Chris Lattnere9ef4572007-05-12 03:23:40 +000052
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000053<div class="doc_text">
Chris Lattnere9ef4572007-05-12 03:23:40 +000054
55<p>This document describes the LLVM bitstream file format and the encoding of
56the LLVM IR into it.</p>
57
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000058</div>
Chris Lattnere9ef4572007-05-12 03:23:40 +000059
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000060<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000061<h2><a name="overview">Overview</a></h2>
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000062<!-- *********************************************************************** -->
Chris Lattnere9ef4572007-05-12 03:23:40 +000063
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000064<div class="doc_text">
Chris Lattnere9ef4572007-05-12 03:23:40 +000065
66<p>
67What is commonly known as the LLVM bitcode file format (also, sometimes
68anachronistically known as bytecode) is actually two things: a <a
69href="#bitstream">bitstream container format</a>
70and an <a href="#llvmir">encoding of LLVM IR</a> into the container format.</p>
71
72<p>
Reid Spencer58d05472007-05-12 08:01:52 +000073The bitstream format is an abstract encoding of structured data, very
Chris Lattnere9ef4572007-05-12 03:23:40 +000074similar to XML in some ways. Like XML, bitstream files contain tags, and nested
75structures, and you can parse the file without having to understand the tags.
76Unlike XML, the bitstream format is a binary encoding, and unlike XML it
77provides a mechanism for the file to self-describe "abbreviations", which are
78effectively size optimizations for the content.</p>
79
Chris Lattner6fa6a322008-07-09 05:14:23 +000080<p>LLVM IR files may be optionally embedded into a <a
81href="#wrapper">wrapper</a> structure that makes it easy to embed extra data
82along with LLVM IR files.</p>
83
84<p>This document first describes the LLVM bitstream format, describes the
85wrapper format, then describes the record structure used by LLVM IR files.
Chris Lattnere9ef4572007-05-12 03:23:40 +000086</p>
87
Reid Spencer2c1ce4f2007-01-20 23:21:08 +000088</div>
Chris Lattnere9ef4572007-05-12 03:23:40 +000089
90<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000091<h2><a name="bitstream">Bitstream Format</a></h2>
Chris Lattnere9ef4572007-05-12 03:23:40 +000092<!-- *********************************************************************** -->
93
94<div class="doc_text">
95
96<p>
97The bitstream format is literally a stream of bits, with a very simple
98structure. This structure consists of the following concepts:
99</p>
100
101<ul>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000102<li>A "<a href="#magic">magic number</a>" that identifies the contents of
103 the stream.</li>
104<li>Encoding <a href="#primitives">primitives</a> like variable bit-rate
105 integers.</li>
106<li><a href="#blocks">Blocks</a>, which define nested content.</li>
107<li><a href="#datarecord">Data Records</a>, which describe entities within the
108 file.</li>
Chris Lattnere9ef4572007-05-12 03:23:40 +0000109<li>Abbreviations, which specify compression optimizations for the file.</li>
110</ul>
111
112<p>Note that the <a
113href="CommandGuide/html/llvm-bcanalyzer.html">llvm-bcanalyzer</a> tool can be
114used to dump and inspect arbitrary bitstreams, which is very useful for
115understanding the encoding.</p>
116
117</div>
118
119<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000120<h3>
121 <a name="magic">Magic Numbers</a>
122</h3>
Chris Lattnere9ef4572007-05-12 03:23:40 +0000123
124<div class="doc_text">
125
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000126<p>The first two bytes of a bitcode file are 'BC' (0x42, 0x43).
127The second two bytes are an application-specific magic number. Generic
128bitcode tools can look at only the first two bytes to verify the file is
129bitcode, while application-specific programs will want to look at all four.</p>
Chris Lattnere9ef4572007-05-12 03:23:40 +0000130
131</div>
132
Chris Lattner3a1716d2007-05-12 05:37:42 +0000133<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000134<h3>
135 <a name="primitives">Primitives</a>
136</h3>
Chris Lattnere9ef4572007-05-12 03:23:40 +0000137
138<div class="doc_text">
139
Chris Lattner3a1716d2007-05-12 05:37:42 +0000140<p>
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000141A bitstream literally consists of a stream of bits, which are read in order
142starting with the least significant bit of each byte. The stream is made up of a
Chris Lattner69b3e402007-05-13 01:39:44 +0000143number of primitive values that encode a stream of unsigned integer values.
Chris Lattnerf958dd22010-01-20 17:53:51 +0000144These integers are encoded in two ways: either as <a href="#fixedwidth">Fixed
Chris Lattner3a1716d2007-05-12 05:37:42 +0000145Width Integers</a> or as <a href="#variablewidth">Variable Width
146Integers</a>.
Chris Lattnere9ef4572007-05-12 03:23:40 +0000147</p>
148
149</div>
150
Chris Lattner3a1716d2007-05-12 05:37:42 +0000151<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000152<h4>
153 <a name="fixedwidth">Fixed Width Integers</a>
154</h4>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000155
156<div class="doc_text">
157
158<p>Fixed-width integer values have their low bits emitted directly to the file.
159 For example, a 3-bit integer value encodes 1 as 001. Fixed width integers
160 are used when there are a well-known number of options for a field. For
161 example, boolean values are usually encoded with a 1-bit wide integer.
162</p>
163
164</div>
165
166<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000167<h4>
168 <a name="variablewidth">Variable Width Integers</a>
169</h4>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000170
171<div class="doc_text">
172
173<p>Variable-width integer (VBR) values encode values of arbitrary size,
174optimizing for the case where the values are small. Given a 4-bit VBR field,
175any 3-bit value (0 through 7) is encoded directly, with the high bit set to
176zero. Values larger than N-1 bits emit their bits in a series of N-1 bit
177chunks, where all but the last set the high bit.</p>
178
179<p>For example, the value 27 (0x1B) is encoded as 1011 0011 when emitted as a
180vbr4 value. The first set of four bits indicates the value 3 (011) with a
181continuation piece (indicated by a high bit of 1). The next word indicates a
182value of 24 (011 << 3) with no continuation. The sum (3+24) yields the value
18327.
184</p>
185
186</div>
187
188<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000189<h4><a name="char6">6-bit characters</a></h4>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000190
191<div class="doc_text">
192
193<p>6-bit characters encode common characters into a fixed 6-bit field. They
Chris Lattnerf1d64e92007-05-12 07:50:14 +0000194represent the following characters with the following 6-bit values:</p>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000195
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000196<div class="doc_code">
197<pre>
198'a' .. 'z' &mdash; 0 .. 25
199'A' .. 'Z' &mdash; 26 .. 51
200'0' .. '9' &mdash; 52 .. 61
201 '.' &mdash; 62
202 '_' &mdash; 63
203</pre>
204</div>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000205
206<p>This encoding is only suitable for encoding characters and strings that
207consist only of the above characters. It is completely incapable of encoding
208characters not in the set.</p>
209
210</div>
211
212<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000213<h4><a name="wordalign">Word Alignment</a></h4>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000214
215<div class="doc_text">
216
217<p>Occasionally, it is useful to emit zero bits until the bitstream is a
218multiple of 32 bits. This ensures that the bit position in the stream can be
219represented as a multiple of 32-bit words.</p>
220
221</div>
222
223
224<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000225<h3>
226 <a name="abbrevid">Abbreviation IDs</a>
227</h3>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000228
229<div class="doc_text">
230
231<p>
232A bitstream is a sequential series of <a href="#blocks">Blocks</a> and
233<a href="#datarecord">Data Records</a>. Both of these start with an
234abbreviation ID encoded as a fixed-bitwidth field. The width is specified by
235the current block, as described below. The value of the abbreviation ID
236specifies either a builtin ID (which have special meanings, defined below) or
Chris Lattner5c303e82009-10-29 04:25:46 +0000237one of the abbreviation IDs defined for the current block by the stream itself.
Chris Lattner3a1716d2007-05-12 05:37:42 +0000238</p>
239
240<p>
241The set of builtin abbrev IDs is:
242</p>
243
244<ul>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000245<li><tt>0 - <a href="#END_BLOCK">END_BLOCK</a></tt> &mdash; This abbrev ID marks
246 the end of the current block.</li>
247<li><tt>1 - <a href="#ENTER_SUBBLOCK">ENTER_SUBBLOCK</a></tt> &mdash; This
248 abbrev ID marks the beginning of a new block.</li>
249<li><tt>2 - <a href="#DEFINE_ABBREV">DEFINE_ABBREV</a></tt> &mdash; This defines
250 a new abbreviation.</li>
251<li><tt>3 - <a href="#UNABBREV_RECORD">UNABBREV_RECORD</a></tt> &mdash; This ID
252 specifies the definition of an unabbreviated record.</li>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000253</ul>
254
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000255<p>Abbreviation IDs 4 and above are defined by the stream itself, and specify
256an <a href="#abbrev_records">abbreviated record encoding</a>.</p>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000257
258</div>
259
260<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000261<h3>
262 <a name="blocks">Blocks</a>
263</h3>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000264
265<div class="doc_text">
266
267<p>
268Blocks in a bitstream denote nested regions of the stream, and are identified by
269a content-specific id number (for example, LLVM IR uses an ID of 12 to represent
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000270function bodies). Block IDs 0-7 are reserved for <a href="#stdblocks">standard blocks</a>
271whose meaning is defined by Bitcode; block IDs 8 and greater are
Benjamin Kramer8040cd32009-10-12 14:46:08 +0000272application specific. Nested blocks capture the hierarchical structure of the data
Chris Lattner3a1716d2007-05-12 05:37:42 +0000273encoded in it, and various properties are associated with blocks as the file is
274parsed. Block definitions allow the reader to efficiently skip blocks
275in constant time if the reader wants a summary of blocks, or if it wants to
Chris Lattner5c303e82009-10-29 04:25:46 +0000276efficiently skip data it does not understand. The LLVM IR reader uses this
Chris Lattner3a1716d2007-05-12 05:37:42 +0000277mechanism to skip function bodies, lazily reading them on demand.
278</p>
279
280<p>
281When reading and encoding the stream, several properties are maintained for the
282block. In particular, each block maintains:
283</p>
284
285<ol>
Chris Lattner5c303e82009-10-29 04:25:46 +0000286<li>A current abbrev id width. This value starts at 2 at the beginning of
287 the stream, and is set every time a
Chris Lattner3a1716d2007-05-12 05:37:42 +0000288 block record is entered. The block entry specifies the abbrev id width for
289 the body of the block.</li>
290
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000291<li>A set of abbreviations. Abbreviations may be defined within a block, in
292 which case they are only defined in that block (neither subblocks nor
293 enclosing blocks see the abbreviation). Abbreviations can also be defined
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000294 inside a <tt><a href="#BLOCKINFO">BLOCKINFO</a></tt> block, in which case
295 they are defined in all blocks that match the ID that the BLOCKINFO block is
296 describing.
Chris Lattner3a1716d2007-05-12 05:37:42 +0000297</li>
298</ol>
299
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000300<p>
301As sub blocks are entered, these properties are saved and the new sub-block has
302its own set of abbreviations, and its own abbrev id width. When a sub-block is
303popped, the saved values are restored.
304</p>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000305
306</div>
307
308<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000309<h4><a name="ENTER_SUBBLOCK">ENTER_SUBBLOCK Encoding</a></h4>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000310
311<div class="doc_text">
312
313<p><tt>[ENTER_SUBBLOCK, blockid<sub>vbr8</sub>, newabbrevlen<sub>vbr4</sub>,
314 &lt;align32bits&gt;, blocklen<sub>32</sub>]</tt></p>
315
316<p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000317The <tt>ENTER_SUBBLOCK</tt> abbreviation ID specifies the start of a new block
318record. The <tt>blockid</tt> value is encoded as an 8-bit VBR identifier, and
319indicates the type of block being entered, which can be
320a <a href="#stdblocks">standard block</a> or an application-specific block.
321The <tt>newabbrevlen</tt> value is a 4-bit VBR, which specifies the abbrev id
322width for the sub-block. The <tt>blocklen</tt> value is a 32-bit aligned value
323that specifies the size of the subblock in 32-bit words. This value allows the
324reader to skip over the entire block in one jump.
Chris Lattner3a1716d2007-05-12 05:37:42 +0000325</p>
326
327</div>
328
329<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000330<h4><a name="END_BLOCK">END_BLOCK Encoding</a></h4>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000331
332<div class="doc_text">
333
334<p><tt>[END_BLOCK, &lt;align32bits&gt;]</tt></p>
335
336<p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000337The <tt>END_BLOCK</tt> abbreviation ID specifies the end of the current block
338record. Its end is aligned to 32-bits to ensure that the size of the block is
339an even multiple of 32-bits.
340</p>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000341
342</div>
343
344
345
346<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000347<h3>
348 <a name="datarecord">Data Records</a>
349</h3>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000350
351<div class="doc_text">
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000352<p>
Chris Lattner5c303e82009-10-29 04:25:46 +0000353Data records consist of a record code and a number of (up to) 64-bit
354integer values. The interpretation of the code and values is
355application specific and may vary between different block types.
356Records can be encoded either using an unabbrev record, or with an
357abbreviation. In the LLVM IR format, for example, there is a record
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000358which encodes the target triple of a module. The code is
Chris Lattner5c303e82009-10-29 04:25:46 +0000359<tt>MODULE_CODE_TRIPLE</tt>, and the values of the record are the
360ASCII codes for the characters in the string.
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000361</p>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000362
363</div>
364
365<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000366<h4><a name="UNABBREV_RECORD">UNABBREV_RECORD Encoding</a></h4>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000367
368<div class="doc_text">
369
370<p><tt>[UNABBREV_RECORD, code<sub>vbr6</sub>, numops<sub>vbr6</sub>,
371 op0<sub>vbr6</sub>, op1<sub>vbr6</sub>, ...]</tt></p>
372
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000373<p>
374An <tt>UNABBREV_RECORD</tt> provides a default fallback encoding, which is both
375completely general and extremely inefficient. It can describe an arbitrary
Chris Lattner5c303e82009-10-29 04:25:46 +0000376record by emitting the code and operands as VBRs.
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000377</p>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000378
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000379<p>
380For example, emitting an LLVM IR target triple as an unabbreviated record
381requires emitting the <tt>UNABBREV_RECORD</tt> abbrevid, a vbr6 for the
382<tt>MODULE_CODE_TRIPLE</tt> code, a vbr6 for the length of the string, which is
383equal to the number of operands, and a vbr6 for each character. Because there
384are no letters with values less than 32, each letter would need to be emitted as
385at least a two-part VBR, which means that each letter would require at least 12
386bits. This is not an efficient encoding, but it is fully general.
387</p>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000388
389</div>
390
391<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000392<h4><a name="abbrev_records">Abbreviated Record Encoding</a></h4>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000393
394<div class="doc_text">
395
396<p><tt>[&lt;abbrevid&gt;, fields...]</tt></p>
397
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000398<p>
399An abbreviated record is a abbreviation id followed by a set of fields that are
400encoded according to the <a href="#abbreviations">abbreviation definition</a>.
401This allows records to be encoded significantly more densely than records
402encoded with the <tt><a href="#UNABBREV_RECORD">UNABBREV_RECORD</a></tt> type,
403and allows the abbreviation types to be specified in the stream itself, which
404allows the files to be completely self describing. The actual encoding of
405abbreviations is defined below.
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000406</p>
407
Chris Lattner5c303e82009-10-29 04:25:46 +0000408<p>The record code, which is the first field of an abbreviated record,
409may be encoded in the abbreviation definition (as a literal
410operand) or supplied in the abbreviated record (as a Fixed or VBR
411operand value).</p>
412
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000413</div>
414
415<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000416<h3>
417 <a name="abbreviations">Abbreviations</a>
418</h3>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000419
420<div class="doc_text">
421<p>
422Abbreviations are an important form of compression for bitstreams. The idea is
423to specify a dense encoding for a class of records once, then use that encoding
424to emit many records. It takes space to emit the encoding into the file, but
425the space is recouped (hopefully plus some) when the records that use it are
426emitted.
427</p>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000428
429<p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000430Abbreviations can be determined dynamically per client, per file. Because the
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000431abbreviations are stored in the bitstream itself, different streams of the same
Chris Lattner5c303e82009-10-29 04:25:46 +0000432format can contain different sets of abbreviations according to the needs
433of the specific stream.
434As a concrete example, LLVM IR files usually emit an abbreviation
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000435for binary operators. If a specific LLVM module contained no or few binary
436operators, the abbreviation does not need to be emitted.
Chris Lattner3a1716d2007-05-12 05:37:42 +0000437</p>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000438</div>
439
440<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000441<h4><a name="DEFINE_ABBREV">DEFINE_ABBREV Encoding</a></h4>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000442
443<div class="doc_text">
444
445<p><tt>[DEFINE_ABBREV, numabbrevops<sub>vbr5</sub>, abbrevop0, abbrevop1,
446 ...]</tt></p>
447
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000448<p>
449A <tt>DEFINE_ABBREV</tt> record adds an abbreviation to the list of currently
450defined abbreviations in the scope of this block. This definition only exists
451inside this immediate block &mdash; it is not visible in subblocks or enclosing
452blocks. Abbreviations are implicitly assigned IDs sequentially starting from 4
453(the first application-defined abbreviation ID). Any abbreviations defined in a
Chris Lattner5c303e82009-10-29 04:25:46 +0000454<tt>BLOCKINFO</tt> record for the particular block type
455receive IDs first, in order, followed by any
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000456abbreviations defined within the block itself. Abbreviated data records
457reference this ID to indicate what abbreviation they are invoking.
458</p>
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000459
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000460<p>
461An abbreviation definition consists of the <tt>DEFINE_ABBREV</tt> abbrevid
462followed by a VBR that specifies the number of abbrev operands, then the abbrev
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000463operands themselves. Abbreviation operands come in three forms. They all start
464with a single bit that indicates whether the abbrev operand is a literal operand
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000465(when the bit is 1) or an encoding operand (when the bit is 0).
466</p>
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000467
468<ol>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000469<li>Literal operands &mdash; <tt>[1<sub>1</sub>, litvalue<sub>vbr8</sub>]</tt>
470&mdash; Literal operands specify that the value in the result is always a single
471specific value. This specific value is emitted as a vbr8 after the bit
472indicating that it is a literal operand.</li>
473<li>Encoding info without data &mdash; <tt>[0<sub>1</sub>,
474 encoding<sub>3</sub>]</tt> &mdash; Operand encodings that do not have extra
475 data are just emitted as their code.
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000476</li>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000477<li>Encoding info with data &mdash; <tt>[0<sub>1</sub>, encoding<sub>3</sub>,
478value<sub>vbr5</sub>]</tt> &mdash; Operand encodings that do have extra data are
Chris Lattner7300af52007-05-13 00:59:52 +0000479emitted as their code, followed by the extra data.
Chris Lattnerdaeb63c2007-05-12 07:49:15 +0000480</li>
481</ol>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000482
Chris Lattner7300af52007-05-13 00:59:52 +0000483<p>The possible operand encodings are:</p>
484
Chris Lattner5c303e82009-10-29 04:25:46 +0000485<ul>
486<li>Fixed (code 1): The field should be emitted as
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000487 a <a href="#fixedwidth">fixed-width value</a>, whose width is specified by
488 the operand's extra data.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000489<li>VBR (code 2): The field should be emitted as
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000490 a <a href="#variablewidth">variable-width value</a>, whose width is
491 specified by the operand's extra data.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000492<li>Array (code 3): This field is an array of values. The array operand
493 has no extra data, but expects another operand to follow it, indicating
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000494 the element type of the array. When reading an array in an abbreviated
495 record, the first integer is a vbr6 that indicates the array length,
496 followed by the encoded elements of the array. An array may only occur as
497 the last operand of an abbreviation (except for the one final operand that
498 gives the array's type).</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000499<li>Char6 (code 4): This field should be emitted as
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000500 a <a href="#char6">char6-encoded value</a>. This operand type takes no
Chris Lattner5c303e82009-10-29 04:25:46 +0000501 extra data. Char6 encoding is normally used as an array element type.
502 </li>
503<li>Blob (code 5): This field is emitted as a vbr6, followed by padding to a
Chris Lattnerdcd006b2009-04-06 21:50:39 +0000504 32-bit boundary (for alignment) and an array of 8-bit objects. The array of
505 bytes is further followed by tail padding to ensure that its total length is
506 a multiple of 4 bytes. This makes it very efficient for the reader to
507 decode the data without having to make a copy of it: it can use a pointer to
508 the data in the mapped in file and poke directly at it. A blob may only
509 occur as the last operand of an abbreviation.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000510</ul>
Chris Lattner7300af52007-05-13 00:59:52 +0000511
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000512<p>
513For example, target triples in LLVM modules are encoded as a record of the
Chris Lattner7300af52007-05-13 00:59:52 +0000514form <tt>[TRIPLE, 'a', 'b', 'c', 'd']</tt>. Consider if the bitstream emitted
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000515the following abbrev entry:
516</p>
Chris Lattner7300af52007-05-13 00:59:52 +0000517
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000518<div class="doc_code">
519<pre>
520[0, Fixed, 4]
521[0, Array]
522[0, Char6]
523</pre>
524</div>
Chris Lattner7300af52007-05-13 00:59:52 +0000525
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000526<p>
527When emitting a record with this abbreviation, the above entry would be emitted
528as:
529</p>
Chris Lattner7300af52007-05-13 00:59:52 +0000530
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000531<div class="doc_code">
Bill Wendling903bcc42009-04-04 22:36:02 +0000532<p>
533<tt>[4<sub>abbrevwidth</sub>, 2<sub>4</sub>, 4<sub>vbr6</sub>, 0<sub>6</sub>,
5341<sub>6</sub>, 2<sub>6</sub>, 3<sub>6</sub>]</tt>
535</p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000536</div>
Chris Lattner7300af52007-05-13 00:59:52 +0000537
538<p>These values are:</p>
539
540<ol>
541<li>The first value, 4, is the abbreviation ID for this abbreviation.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000542<li>The second value, 2, is the record code for <tt>TRIPLE</tt> records within LLVM IR file <tt>MODULE_BLOCK</tt> blocks.</li>
Chris Lattner7300af52007-05-13 00:59:52 +0000543<li>The third value, 4, is the length of the array.</li>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000544<li>The rest of the values are the char6 encoded values
545 for <tt>"abcd"</tt>.</li>
Chris Lattner7300af52007-05-13 00:59:52 +0000546</ol>
547
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000548<p>
549With this abbreviation, the triple is emitted with only 37 bits (assuming a
Chris Lattner7300af52007-05-13 00:59:52 +0000550abbrev id width of 3). Without the abbreviation, significantly more space would
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000551be required to emit the target triple. Also, because the <tt>TRIPLE</tt> value
552is not emitted as a literal in the abbreviation, the abbreviation can also be
553used for any other string value.
Chris Lattner7300af52007-05-13 00:59:52 +0000554</p>
555
Chris Lattner3a1716d2007-05-12 05:37:42 +0000556</div>
557
Chris Lattner7300af52007-05-13 00:59:52 +0000558<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000559<h3>
560 <a name="stdblocks">Standard Blocks</a>
561</h3>
Chris Lattner7300af52007-05-13 00:59:52 +0000562
563<div class="doc_text">
564
565<p>
566In addition to the basic block structure and record encodings, the bitstream
Chris Lattner5c303e82009-10-29 04:25:46 +0000567also defines specific built-in block types. These block types specify how the
Chris Lattner7300af52007-05-13 00:59:52 +0000568stream is to be decoded or other metadata. In the future, new standard blocks
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000569may be added. Block IDs 0-7 are reserved for standard blocks.
Chris Lattner7300af52007-05-13 00:59:52 +0000570</p>
571
572</div>
573
574<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000575<h4><a name="BLOCKINFO">#0 - BLOCKINFO Block</a></h4>
Chris Lattner7300af52007-05-13 00:59:52 +0000576
577<div class="doc_text">
578
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000579<p>
580The <tt>BLOCKINFO</tt> block allows the description of metadata for other
581blocks. The currently specified records are:
582</p>
583
584<div class="doc_code">
585<pre>
586[SETBID (#1), blockid]
587[DEFINE_ABBREV, ...]
Chris Lattnerf9a3ec82009-04-26 22:21:57 +0000588[BLOCKNAME, ...name...]
589[SETRECORDNAME, RecordID, ...name...]
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000590</pre>
591</div>
Chris Lattner7300af52007-05-13 00:59:52 +0000592
593<p>
Chris Lattner5c303e82009-10-29 04:25:46 +0000594The <tt>SETBID</tt> record (code 1) indicates which block ID is being
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000595described. <tt>SETBID</tt> records can occur multiple times throughout the
596block to change which block ID is being described. There must be
597a <tt>SETBID</tt> record prior to any other records.
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000598</p>
599
600<p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000601Standard <tt>DEFINE_ABBREV</tt> records can occur inside <tt>BLOCKINFO</tt>
602blocks, but unlike their occurrence in normal blocks, the abbreviation is
603defined for blocks matching the block ID we are describing, <i>not</i> the
604<tt>BLOCKINFO</tt> block itself. The abbreviations defined
605in <tt>BLOCKINFO</tt> blocks receive abbreviation IDs as described
606in <tt><a href="#DEFINE_ABBREV">DEFINE_ABBREV</a></tt>.
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000607</p>
608
Chris Lattner5c303e82009-10-29 04:25:46 +0000609<p>The <tt>BLOCKNAME</tt> record (code 2) can optionally occur in this block. The elements of
610the record are the bytes of the string name of the block. llvm-bcanalyzer can use
Chris Lattnerf9a3ec82009-04-26 22:21:57 +0000611this to dump out bitcode files symbolically.</p>
612
Chris Lattner5c303e82009-10-29 04:25:46 +0000613<p>The <tt>SETRECORDNAME</tt> record (code 3) can also optionally occur in this block. The
614first operand value is a record ID number, and the rest of the elements of the record are
615the bytes for the string name of the record. llvm-bcanalyzer can use
Chris Lattnerf9a3ec82009-04-26 22:21:57 +0000616this to dump out bitcode files symbolically.</p>
617
Chris Lattnerf19b8e42007-10-08 18:42:45 +0000618<p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000619Note that although the data in <tt>BLOCKINFO</tt> blocks is described as
620"metadata," the abbreviations they contain are essential for parsing records
621from the corresponding blocks. It is not safe to skip them.
Chris Lattner7300af52007-05-13 00:59:52 +0000622</p>
623
624</div>
Chris Lattner3a1716d2007-05-12 05:37:42 +0000625
Chris Lattnere9ef4572007-05-12 03:23:40 +0000626<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000627<h2><a name="wrapper">Bitcode Wrapper Format</a></h2>
Chris Lattner6fa6a322008-07-09 05:14:23 +0000628<!-- *********************************************************************** -->
629
630<div class="doc_text">
631
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000632<p>
633Bitcode files for LLVM IR may optionally be wrapped in a simple wrapper
Chris Lattner6fa6a322008-07-09 05:14:23 +0000634structure. This structure contains a simple header that indicates the offset
635and size of the embedded BC file. This allows additional information to be
636stored alongside the BC file. The structure of this file header is:
637</p>
638
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000639<div class="doc_code">
Bill Wendling903bcc42009-04-04 22:36:02 +0000640<p>
641<tt>[Magic<sub>32</sub>, Version<sub>32</sub>, Offset<sub>32</sub>,
642Size<sub>32</sub>, CPUType<sub>32</sub>]</tt>
643</p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000644</div>
Chris Lattner6fa6a322008-07-09 05:14:23 +0000645
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000646<p>
647Each of the fields are 32-bit fields stored in little endian form (as with
Chris Lattner6fa6a322008-07-09 05:14:23 +0000648the rest of the bitcode file fields). The Magic number is always
649<tt>0x0B17C0DE</tt> and the version is currently always <tt>0</tt>. The Offset
650field is the offset in bytes to the start of the bitcode stream in the file, and
Chris Lattner5c303e82009-10-29 04:25:46 +0000651the Size field is the size in bytes of the stream. CPUType is a target-specific
Chris Lattner6fa6a322008-07-09 05:14:23 +0000652value that can be used to encode the CPU of the target.
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000653</p>
Chris Lattner6fa6a322008-07-09 05:14:23 +0000654
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000655</div>
Chris Lattner6fa6a322008-07-09 05:14:23 +0000656
657<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000658<h2><a name="llvmir">LLVM IR Encoding</a></h2>
Chris Lattnere9ef4572007-05-12 03:23:40 +0000659<!-- *********************************************************************** -->
660
661<div class="doc_text">
662
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000663<p>
664LLVM IR is encoded into a bitstream by defining blocks and records. It uses
Chris Lattner69b3e402007-05-13 01:39:44 +0000665blocks for things like constant pools, functions, symbol tables, etc. It uses
666records for things like instructions, global variable descriptors, type
667descriptions, etc. This document does not describe the set of abbreviations
668that the writer uses, as these are fully self-described in the file, and the
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000669reader is not allowed to build in any knowledge of this.
670</p>
Chris Lattner69b3e402007-05-13 01:39:44 +0000671
672</div>
673
674<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000675<h3>
676 <a name="basics">Basics</a>
677</h3>
Chris Lattner69b3e402007-05-13 01:39:44 +0000678
679<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000680<h4><a name="ir_magic">LLVM IR Magic Number</a></h4>
Chris Lattner69b3e402007-05-13 01:39:44 +0000681
682<div class="doc_text">
683
684<p>
685The magic number for LLVM IR files is:
686</p>
687
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000688<div class="doc_code">
Bill Wendling903bcc42009-04-04 22:36:02 +0000689<p>
690<tt>[0x0<sub>4</sub>, 0xC<sub>4</sub>, 0xE<sub>4</sub>, 0xD<sub>4</sub>]</tt>
691</p>
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000692</div>
Chris Lattner69b3e402007-05-13 01:39:44 +0000693
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000694<p>
695When combined with the bitcode magic number and viewed as bytes, this is
696<tt>"BC&nbsp;0xC0DE"</tt>.
697</p>
Chris Lattner69b3e402007-05-13 01:39:44 +0000698
699</div>
700
701<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000702<h4><a name="ir_signed_vbr">Signed VBRs</a></h4>
Chris Lattner69b3e402007-05-13 01:39:44 +0000703
704<div class="doc_text">
705
706<p>
Chris Lattner5c303e82009-10-29 04:25:46 +0000707<a href="#variablewidth">Variable Width Integer</a> encoding is an efficient way to
708encode arbitrary sized unsigned values, but is an extremely inefficient for
709encoding signed values, as signed values are otherwise treated as maximally large
710unsigned values.
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000711</p>
Chris Lattner69b3e402007-05-13 01:39:44 +0000712
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000713<p>
Chris Lattner5c303e82009-10-29 04:25:46 +0000714As such, signed VBR values of a specific width are emitted as follows:
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000715</p>
Chris Lattner69b3e402007-05-13 01:39:44 +0000716
717<ul>
Chris Lattner5c303e82009-10-29 04:25:46 +0000718<li>Positive values are emitted as VBRs of the specified width, but with their
Chris Lattner69b3e402007-05-13 01:39:44 +0000719 value shifted left by one.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000720<li>Negative values are emitted as VBRs of the specified width, but the negated
Chris Lattner69b3e402007-05-13 01:39:44 +0000721 value is shifted left by one, and the low bit is set.</li>
722</ul>
723
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000724<p>
Chris Lattner5c303e82009-10-29 04:25:46 +0000725With this encoding, small positive and small negative values can both
726be emitted efficiently. Signed VBR encoding is used in
727<tt>CST_CODE_INTEGER</tt> and <tt>CST_CODE_WIDE_INTEGER</tt> records
728within <tt>CONSTANTS_BLOCK</tt> blocks.
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000729</p>
Chris Lattner69b3e402007-05-13 01:39:44 +0000730
731</div>
732
733
734<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000735<h4><a name="ir_blocks">LLVM IR Blocks</a></h4>
Chris Lattner69b3e402007-05-13 01:39:44 +0000736
737<div class="doc_text">
738
739<p>
740LLVM IR is defined with the following blocks:
741</p>
742
743<ul>
Chris Lattner5c303e82009-10-29 04:25:46 +0000744<li>8 &mdash; <a href="#MODULE_BLOCK"><tt>MODULE_BLOCK</tt></a> &mdash; This is the top-level block that
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000745 contains the entire module, and describes a variety of per-module
746 information.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000747<li>9 &mdash; <a href="#PARAMATTR_BLOCK"><tt>PARAMATTR_BLOCK</tt></a> &mdash; This enumerates the parameter
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000748 attributes.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000749<li>10 &mdash; <a href="#TYPE_BLOCK"><tt>TYPE_BLOCK</tt></a> &mdash; This describes all of the types in
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000750 the module.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000751<li>11 &mdash; <a href="#CONSTANTS_BLOCK"><tt>CONSTANTS_BLOCK</tt></a> &mdash; This describes constants for a
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000752 module or function.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000753<li>12 &mdash; <a href="#FUNCTION_BLOCK"><tt>FUNCTION_BLOCK</tt></a> &mdash; This describes a function
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000754 body.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000755<li>13 &mdash; <a href="#TYPE_SYMTAB_BLOCK"><tt>TYPE_SYMTAB_BLOCK</tt></a> &mdash; This describes the type symbol
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000756 table.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000757<li>14 &mdash; <a href="#VALUE_SYMTAB_BLOCK"><tt>VALUE_SYMTAB_BLOCK</tt></a> &mdash; This describes a value symbol
Bill Wendlingbb7425f2009-04-04 22:27:03 +0000758 table.</li>
Chris Lattner5c303e82009-10-29 04:25:46 +0000759<li>15 &mdash; <a href="#METADATA_BLOCK"><tt>METADATA_BLOCK</tt></a> &mdash; This describes metadata items.</li>
760<li>16 &mdash; <a href="#METADATA_ATTACHMENT"><tt>METADATA_ATTACHMENT</tt></a> &mdash; This contains records associating metadata with function instruction values.</li>
Chris Lattner69b3e402007-05-13 01:39:44 +0000761</ul>
762
763</div>
764
765<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000766<h3>
767 <a name="MODULE_BLOCK">MODULE_BLOCK Contents</a>
768</h3>
Chris Lattner69b3e402007-05-13 01:39:44 +0000769
770<div class="doc_text">
771
Chris Lattner5c303e82009-10-29 04:25:46 +0000772<p>The <tt>MODULE_BLOCK</tt> block (id 8) is the top-level block for LLVM
773bitcode files, and each bitcode file must contain exactly one. In
774addition to records (described below) containing information
775about the module, a <tt>MODULE_BLOCK</tt> block may contain the
776following sub-blocks:
777</p>
778
779<ul>
780<li><a href="#BLOCKINFO"><tt>BLOCKINFO</tt></a></li>
781<li><a href="#PARAMATTR_BLOCK"><tt>PARAMATTR_BLOCK</tt></a></li>
782<li><a href="#TYPE_BLOCK"><tt>TYPE_BLOCK</tt></a></li>
783<li><a href="#TYPE_SYMTAB_BLOCK"><tt>TYPE_SYMTAB_BLOCK</tt></a></li>
784<li><a href="#VALUE_SYMTAB_BLOCK"><tt>VALUE_SYMTAB_BLOCK</tt></a></li>
785<li><a href="#CONSTANTS_BLOCK"><tt>CONSTANTS_BLOCK</tt></a></li>
786<li><a href="#FUNCTION_BLOCK"><tt>FUNCTION_BLOCK</tt></a></li>
787<li><a href="#METADATA_BLOCK"><tt>METADATA_BLOCK</tt></a></li>
788</ul>
789
790</div>
791
792<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000793<h4><a name="MODULE_CODE_VERSION">MODULE_CODE_VERSION Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000794
795<div class="doc_text">
796
797<p><tt>[VERSION, version#]</tt></p>
798
799<p>The <tt>VERSION</tt> record (code 1) contains a single value
800indicating the format version. Only version 0 is supported at this
801time.</p>
802</div>
803
804<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000805<h4><a name="MODULE_CODE_TRIPLE">MODULE_CODE_TRIPLE Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000806
807<div class="doc_text">
808<p><tt>[TRIPLE, ...string...]</tt></p>
809
810<p>The <tt>TRIPLE</tt> record (code 2) contains a variable number of
811values representing the bytes of the <tt>target triple</tt>
812specification string.</p>
813</div>
814
815<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000816<h4><a name="MODULE_CODE_DATALAYOUT">MODULE_CODE_DATALAYOUT Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000817
818<div class="doc_text">
819<p><tt>[DATALAYOUT, ...string...]</tt></p>
820
821<p>The <tt>DATALAYOUT</tt> record (code 3) contains a variable number of
822values representing the bytes of the <tt>target datalayout</tt>
823specification string.</p>
824</div>
825
826<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000827<h4><a name="MODULE_CODE_ASM">MODULE_CODE_ASM Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000828
829<div class="doc_text">
830<p><tt>[ASM, ...string...]</tt></p>
831
832<p>The <tt>ASM</tt> record (code 4) contains a variable number of
833values representing the bytes of <tt>module asm</tt> strings, with
834individual assembly blocks separated by newline (ASCII 10) characters.</p>
835</div>
836
837<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000838<h4><a name="MODULE_CODE_SECTIONNAME">MODULE_CODE_SECTIONNAME Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000839
840<div class="doc_text">
841<p><tt>[SECTIONNAME, ...string...]</tt></p>
842
843<p>The <tt>SECTIONNAME</tt> record (code 5) contains a variable number
844of values representing the bytes of a single section name
845string. There should be one <tt>SECTIONNAME</tt> record for each
846section name referenced (e.g., in global variable or function
847<tt>section</tt> attributes) within the module. These records can be
848referenced by the 1-based index in the <i>section</i> fields of
849<tt>GLOBALVAR</tt> or <tt>FUNCTION</tt> records.</p>
850</div>
851
852<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000853<h4><a name="MODULE_CODE_DEPLIB">MODULE_CODE_DEPLIB Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000854
855<div class="doc_text">
856<p><tt>[DEPLIB, ...string...]</tt></p>
857
858<p>The <tt>DEPLIB</tt> record (code 6) contains a variable number of
859values representing the bytes of a single dependent library name
860string, one of the libraries mentioned in a <tt>deplibs</tt>
861declaration. There should be one <tt>DEPLIB</tt> record for each
862library name referenced.</p>
863</div>
864
865<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000866<h4><a name="MODULE_CODE_GLOBALVAR">MODULE_CODE_GLOBALVAR Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000867
868<div class="doc_text">
869<p><tt>[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal]</tt></p>
870
871<p>The <tt>GLOBALVAR</tt> record (code 7) marks the declaration or
872definition of a global variable. The operand fields are:</p>
873
874<ul>
875<li><i>pointer type</i>: The type index of the pointer type used to point to
876this global variable</li>
877
878<li><i>isconst</i>: Non-zero if the variable is treated as constant within
879the module, or zero if it is not</li>
880
881<li><i>initid</i>: If non-zero, the value index of the initializer for this
882variable, plus 1.</li>
883
884<li><a name="linkage"><i>linkage</i></a>: An encoding of the linkage
885type for this variable:
886 <ul>
887 <li><tt>external</tt>: code 0</li>
888 <li><tt>weak</tt>: code 1</li>
889 <li><tt>appending</tt>: code 2</li>
890 <li><tt>internal</tt>: code 3</li>
891 <li><tt>linkonce</tt>: code 4</li>
892 <li><tt>dllimport</tt>: code 5</li>
893 <li><tt>dllexport</tt>: code 6</li>
894 <li><tt>extern_weak</tt>: code 7</li>
895 <li><tt>common</tt>: code 8</li>
896 <li><tt>private</tt>: code 9</li>
897 <li><tt>weak_odr</tt>: code 10</li>
898 <li><tt>linkonce_odr</tt>: code 11</li>
899 <li><tt>available_externally</tt>: code 12</li>
900 <li><tt>linker_private</tt>: code 13</li>
901 </ul>
902</li>
903
904<li><i>alignment</i>: The logarithm base 2 of the variable's requested
905alignment, plus 1</li>
906
907<li><i>section</i>: If non-zero, the 1-based section index in the
908table of <a href="#MODULE_CODE_SECTIONNAME">MODULE_CODE_SECTIONNAME</a>
909entries.</li>
910
911<li><a name="visibility"><i>visibility</i></a>: If present, an
912encoding of the visibility of this variable:
913 <ul>
914 <li><tt>default</tt>: code 0</li>
915 <li><tt>hidden</tt>: code 1</li>
916 <li><tt>protected</tt>: code 2</li>
917 </ul>
918</li>
919
920<li><i>threadlocal</i>: If present and non-zero, indicates that the variable
921is <tt>thread_local</tt></li>
922
Rafael Espindolabea46262011-01-08 16:42:36 +0000923<li><i>unnamed_addr</i>: If present and non-zero, indicates that the variable
Bill Wendling90464132011-04-08 21:43:08 +0000924has <tt>unnamed_addr</tt></li>
Rafael Espindolabea46262011-01-08 16:42:36 +0000925
Chris Lattner5c303e82009-10-29 04:25:46 +0000926</ul>
927</div>
928
929<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000930<h4><a name="MODULE_CODE_FUNCTION">MODULE_CODE_FUNCTION Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000931
932<div class="doc_text">
933
934<p><tt>[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc]</tt></p>
935
936<p>The <tt>FUNCTION</tt> record (code 8) marks the declaration or
937definition of a function. The operand fields are:</p>
938
939<ul>
940<li><i>type</i>: The type index of the function type describing this function</li>
941
942<li><i>callingconv</i>: The calling convention number:
943 <ul>
944 <li><tt>ccc</tt>: code 0</li>
945 <li><tt>fastcc</tt>: code 8</li>
946 <li><tt>coldcc</tt>: code 9</li>
947 <li><tt>x86_stdcallcc</tt>: code 64</li>
948 <li><tt>x86_fastcallcc</tt>: code 65</li>
949 <li><tt>arm_apcscc</tt>: code 66</li>
950 <li><tt>arm_aapcscc</tt>: code 67</li>
951 <li><tt>arm_aapcs_vfpcc</tt>: code 68</li>
952 </ul>
953</li>
954
955<li><i>isproto</i>: Non-zero if this entry represents a declaration
956rather than a definition</li>
957
958<li><i>linkage</i>: An encoding of the <a href="#linkage">linkage type</a>
959for this function</li>
960
961<li><i>paramattr</i>: If nonzero, the 1-based parameter attribute index
962into the table of <a href="#PARAMATTR_CODE_ENTRY">PARAMATTR_CODE_ENTRY</a>
963entries.</li>
964
965<li><i>alignment</i>: The logarithm base 2 of the function's requested
966alignment, plus 1</li>
967
968<li><i>section</i>: If non-zero, the 1-based section index in the
969table of <a href="#MODULE_CODE_SECTIONNAME">MODULE_CODE_SECTIONNAME</a>
970entries.</li>
971
972<li><i>visibility</i>: An encoding of the <a href="#visibility">visibility</a>
973 of this function</li>
974
975<li><i>gc</i>: If present and nonzero, the 1-based garbage collector
976index in the table of
977<a href="#MODULE_CODE_GCNAME">MODULE_CODE_GCNAME</a> entries.</li>
Rafael Espindolabea46262011-01-08 16:42:36 +0000978
979<li><i>unnamed_addr</i>: If present and non-zero, indicates that the function
NAKAMURA Takumi4d6deb02011-04-09 09:51:57 +0000980has <tt>unnamed_addr</tt></li>
Rafael Espindolabea46262011-01-08 16:42:36 +0000981
Chris Lattner5c303e82009-10-29 04:25:46 +0000982</ul>
983</div>
984
985<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000986<h4><a name="MODULE_CODE_ALIAS">MODULE_CODE_ALIAS Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +0000987
988<div class="doc_text">
989
990<p><tt>[ALIAS, alias type, aliasee val#, linkage, visibility]</tt></p>
991
992<p>The <tt>ALIAS</tt> record (code 9) marks the definition of an
993alias. The operand fields are</p>
994
995<ul>
996<li><i>alias type</i>: The type index of the alias</li>
997
998<li><i>aliasee val#</i>: The value index of the aliased value</li>
999
1000<li><i>linkage</i>: An encoding of the <a href="#linkage">linkage type</a>
1001for this alias</li>
1002
1003<li><i>visibility</i>: If present, an encoding of the
1004<a href="#visibility">visibility</a> of the alias</li>
1005
1006</ul>
1007</div>
1008
1009<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001010<h4><a name="MODULE_CODE_PURGEVALS">MODULE_CODE_PURGEVALS Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +00001011
1012<div class="doc_text">
1013<p><tt>[PURGEVALS, numvals]</tt></p>
1014
1015<p>The <tt>PURGEVALS</tt> record (code 10) resets the module-level
1016value list to the size given by the single operand value. Module-level
1017value list items are added by <tt>GLOBALVAR</tt>, <tt>FUNCTION</tt>,
1018and <tt>ALIAS</tt> records. After a <tt>PURGEVALS</tt> record is seen,
1019new value indices will start from the given <i>numvals</i> value.</p>
1020</div>
1021
1022<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001023<h4><a name="MODULE_CODE_GCNAME">MODULE_CODE_GCNAME Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +00001024
1025<div class="doc_text">
1026<p><tt>[GCNAME, ...string...]</tt></p>
1027
1028<p>The <tt>GCNAME</tt> record (code 11) contains a variable number of
1029values representing the bytes of a single garbage collector name
1030string. There should be one <tt>GCNAME</tt> record for each garbage
1031collector name referenced in function <tt>gc</tt> attributes within
1032the module. These records can be referenced by 1-based index in the <i>gc</i>
1033fields of <tt>FUNCTION</tt> records.</p>
1034</div>
1035
1036<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001037<h3>
1038 <a name="PARAMATTR_BLOCK">PARAMATTR_BLOCK Contents</a>
1039</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001040
1041<div class="doc_text">
1042
Chris Lattner299f4242010-05-21 22:20:54 +00001043<p>The <tt>PARAMATTR_BLOCK</tt> block (id 9) contains a table of
1044entries describing the attributes of function parameters. These
1045entries are referenced by 1-based index in the <i>paramattr</i> field
1046of module block <a name="MODULE_CODE_FUNCTION"><tt>FUNCTION</tt></a>
1047records, or within the <i>attr</i> field of function block <a
1048href="#FUNC_CODE_INST_INVOKE"><tt>INST_INVOKE</tt></a> and <a
1049href="#FUNC_CODE_INST_CALL"><tt>INST_CALL</tt></a> records.</p>
1050
1051<p>Entries within <tt>PARAMATTR_BLOCK</tt> are constructed to ensure
1052that each is unique (i.e., no two indicies represent equivalent
1053attribute lists). </p>
Chris Lattner5c303e82009-10-29 04:25:46 +00001054
1055</div>
1056
1057
1058<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001059<h4><a name="PARAMATTR_CODE_ENTRY">PARAMATTR_CODE_ENTRY Record</a></h4>
Chris Lattner5c303e82009-10-29 04:25:46 +00001060
1061<div class="doc_text">
1062
1063<p><tt>[ENTRY, paramidx0, attr0, paramidx1, attr1...]</tt></p>
1064
Chris Lattner299f4242010-05-21 22:20:54 +00001065<p>The <tt>ENTRY</tt> record (code 1) contains an even number of
1066values describing a unique set of function parameter attributes. Each
1067<i>paramidx</i> value indicates which set of attributes is
1068represented, with 0 representing the return value attributes,
10690xFFFFFFFF representing function attributes, and other values
1070representing 1-based function parameters. Each <i>attr</i> value is a
1071bitmap with the following interpretation:
Chris Lattner5c303e82009-10-29 04:25:46 +00001072</p>
Chris Lattner299f4242010-05-21 22:20:54 +00001073
1074<ul>
1075<li>bit 0: <tt>zeroext</tt></li>
1076<li>bit 1: <tt>signext</tt></li>
1077<li>bit 2: <tt>noreturn</tt></li>
1078<li>bit 3: <tt>inreg</tt></li>
1079<li>bit 4: <tt>sret</tt></li>
1080<li>bit 5: <tt>nounwind</tt></li>
1081<li>bit 6: <tt>noalias</tt></li>
1082<li>bit 7: <tt>byval</tt></li>
1083<li>bit 8: <tt>nest</tt></li>
1084<li>bit 9: <tt>readnone</tt></li>
1085<li>bit 10: <tt>readonly</tt></li>
1086<li>bit 11: <tt>noinline</tt></li>
1087<li>bit 12: <tt>alwaysinline</tt></li>
1088<li>bit 13: <tt>optsize</tt></li>
1089<li>bit 14: <tt>ssp</tt></li>
1090<li>bit 15: <tt>sspreq</tt></li>
1091<li>bits 16&ndash;31: <tt>align <var>n</var></tt></li>
1092<li>bit 32: <tt>nocapture</tt></li>
1093<li>bit 33: <tt>noredzone</tt></li>
1094<li>bit 34: <tt>noimplicitfloat</tt></li>
1095<li>bit 35: <tt>naked</tt></li>
1096<li>bit 36: <tt>inlinehint</tt></li>
1097<li>bits 37&ndash;39: <tt>alignstack <var>n</var></tt>, represented as
1098the logarithm base 2 of the requested alignment, plus 1</li>
1099</ul>
Chris Lattner5c303e82009-10-29 04:25:46 +00001100</div>
1101
1102<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001103<h3>
1104 <a name="TYPE_BLOCK">TYPE_BLOCK Contents</a>
1105</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001106
1107<div class="doc_text">
1108
Chris Lattner299f4242010-05-21 22:20:54 +00001109<p>The <tt>TYPE_BLOCK</tt> block (id 10) contains records which
1110constitute a table of type operator entries used to represent types
1111referenced within an LLVM module. Each record (with the exception of
1112<a href="#TYPE_CODE_NUMENTRY"><tt>NUMENTRY</tt></a>) generates a
1113single type table entry, which may be referenced by 0-based index from
1114instructions, constants, metadata, type symbol table entries, or other
1115type operator records.
Chris Lattner5c303e82009-10-29 04:25:46 +00001116</p>
1117
Chris Lattner299f4242010-05-21 22:20:54 +00001118<p>Entries within <tt>TYPE_BLOCK</tt> are constructed to ensure that
1119each entry is unique (i.e., no two indicies represent structurally
1120equivalent types). </p>
1121
Chris Lattner5c303e82009-10-29 04:25:46 +00001122</div>
1123
Chris Lattner299f4242010-05-21 22:20:54 +00001124<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001125<h4><a name="TYPE_CODE_NUMENTRY">TYPE_CODE_NUMENTRY Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001126
1127<div class="doc_text">
1128
1129<p><tt>[NUMENTRY, numentries]</tt></p>
1130
1131<p>The <tt>NUMENTRY</tt> record (code 1) contains a single value which
1132indicates the total number of type code entries in the type table of
1133the module. If present, <tt>NUMENTRY</tt> should be the first record
1134in the block.
1135</p>
1136</div>
1137
1138<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001139<h4><a name="TYPE_CODE_VOID">TYPE_CODE_VOID Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001140
1141<div class="doc_text">
1142
1143<p><tt>[VOID]</tt></p>
1144
1145<p>The <tt>VOID</tt> record (code 2) adds a <tt>void</tt> type to the
1146type table.
1147</p>
1148</div>
1149
1150<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001151<h4><a name="TYPE_CODE_FLOAT">TYPE_CODE_FLOAT Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001152
1153<div class="doc_text">
1154
1155<p><tt>[FLOAT]</tt></p>
1156
1157<p>The <tt>FLOAT</tt> record (code 3) adds a <tt>float</tt> (32-bit
1158floating point) type to the type table.
1159</p>
1160</div>
1161
1162<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001163<h4><a name="TYPE_CODE_DOUBLE">TYPE_CODE_DOUBLE Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001164
1165<div class="doc_text">
1166
1167<p><tt>[DOUBLE]</tt></p>
1168
1169<p>The <tt>DOUBLE</tt> record (code 4) adds a <tt>double</tt> (64-bit
1170floating point) type to the type table.
1171</p>
1172</div>
1173
1174<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001175<h4><a name="TYPE_CODE_LABEL">TYPE_CODE_LABEL Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001176
1177<div class="doc_text">
1178
1179<p><tt>[LABEL]</tt></p>
1180
1181<p>The <tt>LABEL</tt> record (code 5) adds a <tt>label</tt> type to
1182the type table.
1183</p>
1184</div>
1185
1186<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001187<h4><a name="TYPE_CODE_OPAQUE">TYPE_CODE_OPAQUE Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001188
1189<div class="doc_text">
1190
1191<p><tt>[OPAQUE]</tt></p>
1192
1193<p>The <tt>OPAQUE</tt> record (code 6) adds an <tt>opaque</tt> type to
1194the type table. Note that distinct <tt>opaque</tt> types are not
1195unified.
1196</p>
1197</div>
1198
1199<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001200<h4><a name="TYPE_CODE_INTEGER">TYPE_CODE_INTEGER Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001201
1202<div class="doc_text">
1203
1204<p><tt>[INTEGER, width]</tt></p>
1205
1206<p>The <tt>INTEGER</tt> record (code 7) adds an integer type to the
1207type table. The single <i>width</i> field indicates the width of the
1208integer type.
1209</p>
1210</div>
1211
1212<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001213<h4><a name="TYPE_CODE_POINTER">TYPE_CODE_POINTER Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001214
1215<div class="doc_text">
1216
1217<p><tt>[POINTER, pointee type, address space]</tt></p>
1218
1219<p>The <tt>POINTER</tt> record (code 8) adds a pointer type to the
1220type table. The operand fields are</p>
1221
1222<ul>
1223<li><i>pointee type</i>: The type index of the pointed-to type</li>
1224
1225<li><i>address space</i>: If supplied, the target-specific numbered
1226address space where the pointed-to object resides. Otherwise, the
1227default address space is zero.
1228</li>
1229</ul>
1230</div>
1231
1232<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001233<h4><a name="TYPE_CODE_FUNCTION">TYPE_CODE_FUNCTION Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001234
1235<div class="doc_text">
1236
1237<p><tt>[FUNCTION, vararg, ignored, retty, ...paramty... ]</tt></p>
1238
1239<p>The <tt>FUNCTION</tt> record (code 9) adds a function type to the
1240type table. The operand fields are</p>
1241
1242<ul>
1243<li><i>vararg</i>: Non-zero if the type represents a varargs function</li>
1244
1245<li><i>ignored</i>: This value field is present for backward
1246compatibility only, and is ignored</li>
1247
1248<li><i>retty</i>: The type index of the function's return type</li>
1249
1250<li><i>paramty</i>: Zero or more type indices representing the
1251parameter types of the function</li>
1252</ul>
1253
1254</div>
1255
1256<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001257<h4><a name="TYPE_CODE_STRUCT">TYPE_CODE_STRUCT Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001258
1259<div class="doc_text">
1260
1261<p><tt>[STRUCT, ispacked, ...eltty...]</tt></p>
1262
1263<p>The <tt>STRUCT </tt> record (code 10) adds a struct type to the
1264type table. The operand fields are</p>
1265
1266<ul>
1267<li><i>ispacked</i>: Non-zero if the type represents a packed structure</li>
1268
1269<li><i>eltty</i>: Zero or more type indices representing the element
1270types of the structure</li>
1271</ul>
1272</div>
1273
1274<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001275<h4><a name="TYPE_CODE_ARRAY">TYPE_CODE_ARRAY Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001276
1277<div class="doc_text">
1278
1279<p><tt>[ARRAY, numelts, eltty]</tt></p>
1280
1281<p>The <tt>ARRAY</tt> record (code 11) adds an array type to the type
1282table. The operand fields are</p>
1283
1284<ul>
1285<li><i>numelts</i>: The number of elements in arrays of this type</li>
1286
1287<li><i>eltty</i>: The type index of the array element type</li>
1288</ul>
1289</div>
1290
1291<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001292<h4><a name="TYPE_CODE_VECTOR">TYPE_CODE_VECTOR Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001293
1294<div class="doc_text">
1295
1296<p><tt>[VECTOR, numelts, eltty]</tt></p>
1297
1298<p>The <tt>VECTOR</tt> record (code 12) adds a vector type to the type
1299table. The operand fields are</p>
1300
1301<ul>
1302<li><i>numelts</i>: The number of elements in vectors of this type</li>
1303
1304<li><i>eltty</i>: The type index of the vector element type</li>
1305</ul>
1306</div>
1307
1308<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001309<h4><a name="TYPE_CODE_X86_FP80">TYPE_CODE_X86_FP80 Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001310
1311<div class="doc_text">
1312
1313<p><tt>[X86_FP80]</tt></p>
1314
1315<p>The <tt>X86_FP80</tt> record (code 13) adds an <tt>x86_fp80</tt> (80-bit
1316floating point) type to the type table.
1317</p>
1318</div>
1319
1320<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001321<h4><a name="TYPE_CODE_FP128">TYPE_CODE_FP128 Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001322
1323<div class="doc_text">
1324
1325<p><tt>[FP128]</tt></p>
1326
1327<p>The <tt>FP128</tt> record (code 14) adds an <tt>fp128</tt> (128-bit
1328floating point) type to the type table.
1329</p>
1330</div>
1331
1332<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001333<h4><a name="TYPE_CODE_PPC_FP128">TYPE_CODE_PPC_FP128 Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001334
1335<div class="doc_text">
1336
1337<p><tt>[PPC_FP128]</tt></p>
1338
1339<p>The <tt>PPC_FP128</tt> record (code 15) adds a <tt>ppc_fp128</tt>
1340(128-bit floating point) type to the type table.
1341</p>
1342</div>
1343
1344<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001345<h4><a name="TYPE_CODE_METADATA">TYPE_CODE_METADATA Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001346
1347<div class="doc_text">
1348
1349<p><tt>[METADATA]</tt></p>
1350
1351<p>The <tt>METADATA</tt> record (code 16) adds a <tt>metadata</tt>
1352type to the type table.
1353</p>
1354</div>
1355
Chris Lattner5c303e82009-10-29 04:25:46 +00001356<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001357<h3>
1358 <a name="CONSTANTS_BLOCK">CONSTANTS_BLOCK Contents</a>
1359</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001360
1361<div class="doc_text">
1362
1363<p>The <tt>CONSTANTS_BLOCK</tt> block (id 11) ...
1364</p>
1365
1366</div>
1367
1368
1369<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001370<h3>
1371 <a name="FUNCTION_BLOCK">FUNCTION_BLOCK Contents</a>
1372</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001373
1374<div class="doc_text">
1375
1376<p>The <tt>FUNCTION_BLOCK</tt> block (id 12) ...
1377</p>
1378
1379<p>In addition to the record types described below, a
1380<tt>FUNCTION_BLOCK</tt> block may contain the following sub-blocks:
1381</p>
1382
1383<ul>
1384<li><a href="#CONSTANTS_BLOCK"><tt>CONSTANTS_BLOCK</tt></a></li>
1385<li><a href="#VALUE_SYMTAB_BLOCK"><tt>VALUE_SYMTAB_BLOCK</tt></a></li>
1386<li><a href="#METADATA_ATTACHMENT"><tt>METADATA_ATTACHMENT</tt></a></li>
1387</ul>
1388
1389</div>
1390
1391
1392<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001393<h3>
1394 <a name="TYPE_SYMTAB_BLOCK">TYPE_SYMTAB_BLOCK Contents</a>
1395</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001396
1397<div class="doc_text">
1398
Chris Lattner299f4242010-05-21 22:20:54 +00001399<p>The <tt>TYPE_SYMTAB_BLOCK</tt> block (id 13) contains entries which
1400map between module-level named types and their corresponding type
1401indices.
Chris Lattner5c303e82009-10-29 04:25:46 +00001402</p>
1403
1404</div>
1405
Chris Lattner299f4242010-05-21 22:20:54 +00001406<!-- _______________________________________________________________________ -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001407<h4><a name="TST_CODE_ENTRY">TST_CODE_ENTRY Record</a></h4>
Chris Lattner299f4242010-05-21 22:20:54 +00001408
1409<div class="doc_text">
1410
1411<p><tt>[ENTRY, typeid, ...string...]</tt></p>
1412
1413<p>The <tt>ENTRY</tt> record (code 1) contains a variable number of
1414values, with the first giving the type index of the designated type,
1415and the remaining values giving the character codes of the type
1416name. Each entry corresponds to a single named type.
1417</p>
1418</div>
1419
Chris Lattner5c303e82009-10-29 04:25:46 +00001420
1421<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001422<h3>
1423 <a name="VALUE_SYMTAB_BLOCK">VALUE_SYMTAB_BLOCK Contents</a>
1424</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001425
1426<div class="doc_text">
1427
1428<p>The <tt>VALUE_SYMTAB_BLOCK</tt> block (id 14) ...
1429</p>
1430
1431</div>
1432
1433
1434<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001435<h3>
1436 <a name="METADATA_BLOCK">METADATA_BLOCK Contents</a>
1437</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001438
1439<div class="doc_text">
1440
1441<p>The <tt>METADATA_BLOCK</tt> block (id 15) ...
1442</p>
1443
1444</div>
1445
1446
1447<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +00001448<h3>
1449 <a name="METADATA_ATTACHMENT">METADATA_ATTACHMENT Contents</a>
1450</h3>
Chris Lattner5c303e82009-10-29 04:25:46 +00001451
1452<div class="doc_text">
1453
1454<p>The <tt>METADATA_ATTACHMENT</tt> block (id 16) ...
Chris Lattner69b3e402007-05-13 01:39:44 +00001455</p>
Chris Lattnere9ef4572007-05-12 03:23:40 +00001456
1457</div>
1458
1459
Reid Spencer2c1ce4f2007-01-20 23:21:08 +00001460<!-- *********************************************************************** -->
1461<hr>
1462<address> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +00001463 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Reid Spencer2c1ce4f2007-01-20 23:21:08 +00001464<a href="http://validator.w3.org/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +00001465 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Chris Lattnere9ef4572007-05-12 03:23:40 +00001466 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
NAKAMURA Takumib9a33632011-04-09 02:13:37 +00001467<a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br>
Reid Spencer2c1ce4f2007-01-20 23:21:08 +00001468Last modified: $Date$
1469</address>
1470</body>
1471</html>