1e28d50a8SBill Wendling.. role:: raw-html(raw)
2e28d50a8SBill Wendling   :format: html
3e28d50a8SBill Wendling
4e28d50a8SBill Wendling========================
5e28d50a8SBill WendlingLLVM Bitcode File Format
6e28d50a8SBill Wendling========================
7e28d50a8SBill Wendling
8e28d50a8SBill Wendling.. contents::
9e28d50a8SBill Wendling   :local:
10e28d50a8SBill Wendling
11e28d50a8SBill WendlingAbstract
12e28d50a8SBill Wendling========
13e28d50a8SBill Wendling
14e28d50a8SBill WendlingThis document describes the LLVM bitstream file format and the encoding of the
15e28d50a8SBill WendlingLLVM IR into it.
16e28d50a8SBill Wendling
17e28d50a8SBill WendlingOverview
18e28d50a8SBill Wendling========
19e28d50a8SBill Wendling
20e28d50a8SBill WendlingWhat is commonly known as the LLVM bitcode file format (also, sometimes
21e28d50a8SBill Wendlinganachronistically known as bytecode) is actually two things: a `bitstream
22e28d50a8SBill Wendlingcontainer format`_ and an `encoding of LLVM IR`_ into the container format.
23e28d50a8SBill Wendling
24e28d50a8SBill WendlingThe bitstream format is an abstract encoding of structured data, very similar to
25e28d50a8SBill WendlingXML in some ways.  Like XML, bitstream files contain tags, and nested
26e28d50a8SBill Wendlingstructures, and you can parse the file without having to understand the tags.
27e28d50a8SBill WendlingUnlike XML, the bitstream format is a binary encoding, and unlike XML it
28e28d50a8SBill Wendlingprovides a mechanism for the file to self-describe "abbreviations", which are
29e28d50a8SBill Wendlingeffectively size optimizations for the content.
30e28d50a8SBill Wendling
3110039c02SPeter CollingbourneLLVM IR files may be optionally embedded into a `wrapper`_ structure, or in a
3210039c02SPeter Collingbourne`native object file`_. Both of these mechanisms make it easy to embed extra
3310039c02SPeter Collingbournedata along with LLVM IR files.
34e28d50a8SBill Wendling
35e28d50a8SBill WendlingThis document first describes the LLVM bitstream format, describes the wrapper
36e28d50a8SBill Wendlingformat, then describes the record structure used by LLVM IR files.
37e28d50a8SBill Wendling
38e28d50a8SBill Wendling.. _bitstream container format:
39e28d50a8SBill Wendling
40e28d50a8SBill WendlingBitstream Format
41e28d50a8SBill Wendling================
42e28d50a8SBill Wendling
43e28d50a8SBill WendlingThe bitstream format is literally a stream of bits, with a very simple
44e28d50a8SBill Wendlingstructure.  This structure consists of the following concepts:
45e28d50a8SBill Wendling
46e28d50a8SBill Wendling* A "`magic number`_" that identifies the contents of the stream.
47e28d50a8SBill Wendling
48e28d50a8SBill Wendling* Encoding `primitives`_ like variable bit-rate integers.
49e28d50a8SBill Wendling
50e28d50a8SBill Wendling* `Blocks`_, which define nested content.
51e28d50a8SBill Wendling
52e28d50a8SBill Wendling* `Data Records`_, which describe entities within the file.
53e28d50a8SBill Wendling
54e28d50a8SBill Wendling* Abbreviations, which specify compression optimizations for the file.
55e28d50a8SBill Wendling
56159fac49SJoe AbbeyNote that the :doc:`llvm-bcanalyzer <CommandGuide/llvm-bcanalyzer>` tool can be
57159fac49SJoe Abbeyused to dump and inspect arbitrary bitstreams, which is very useful for
58159fac49SJoe Abbeyunderstanding the encoding.
59e28d50a8SBill Wendling
60e28d50a8SBill Wendling.. _magic number:
61e28d50a8SBill Wendling
62e28d50a8SBill WendlingMagic Numbers
63e28d50a8SBill Wendling-------------
64e28d50a8SBill Wendling
6517dfa193SBrian GesiakThe first four bytes of a bitstream are used as an application-specific magic
6617dfa193SBrian Gesiaknumber.  Generic bitcode tools may look at the first four bytes to determine
6717dfa193SBrian Gesiakwhether the stream is a known stream type.  However, these tools should *not*
6817dfa193SBrian Gesiakdetermine whether a bitstream is valid based on its magic number alone.  New
6917dfa193SBrian Gesiakapplication-specific bitstream formats are being developed all the time; tools
7017dfa193SBrian Gesiakshould not reject them just because they have a hitherto unseen magic number.
71e28d50a8SBill Wendling
72e28d50a8SBill Wendling.. _primitives:
73e28d50a8SBill Wendling
74e28d50a8SBill WendlingPrimitives
75e28d50a8SBill Wendling----------
76e28d50a8SBill Wendling
77e28d50a8SBill WendlingA bitstream literally consists of a stream of bits, which are read in order
78e28d50a8SBill Wendlingstarting with the least significant bit of each byte.  The stream is made up of
79e28d50a8SBill Wendlinga number of primitive values that encode a stream of unsigned integer values.
80e28d50a8SBill WendlingThese integers are encoded in two ways: either as `Fixed Width Integers`_ or as
81e28d50a8SBill Wendling`Variable Width Integers`_.
82e28d50a8SBill Wendling
83e28d50a8SBill Wendling.. _Fixed Width Integers:
84e28d50a8SBill Wendling.. _fixed-width value:
85e28d50a8SBill Wendling
86e28d50a8SBill WendlingFixed Width Integers
87e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^
88e28d50a8SBill Wendling
89e28d50a8SBill WendlingFixed-width integer values have their low bits emitted directly to the file.
90e28d50a8SBill WendlingFor example, a 3-bit integer value encodes 1 as 001.  Fixed width integers are
91e28d50a8SBill Wendlingused when there are a well-known number of options for a field.  For example,
92e28d50a8SBill Wendlingboolean values are usually encoded with a 1-bit wide integer.
93e28d50a8SBill Wendling
94e28d50a8SBill Wendling.. _Variable Width Integers:
95e28d50a8SBill Wendling.. _Variable Width Integer:
96e28d50a8SBill Wendling.. _variable-width value:
97e28d50a8SBill Wendling
98e28d50a8SBill WendlingVariable Width Integers
99e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^
100e28d50a8SBill Wendling
101e28d50a8SBill WendlingVariable-width integer (VBR) values encode values of arbitrary size, optimizing
102e28d50a8SBill Wendlingfor the case where the values are small.  Given a 4-bit VBR field, any 3-bit
103e28d50a8SBill Wendlingvalue (0 through 7) is encoded directly, with the high bit set to zero.  Values
104e28d50a8SBill Wendlinglarger than N-1 bits emit their bits in a series of N-1 bit chunks, where all
105e28d50a8SBill Wendlingbut the last set the high bit.
106e28d50a8SBill Wendling
107178da37bSVolodymyr SapsaiFor example, the value 30 (0x1E) is encoded as 62 (0b0011'1110) when emitted as
108178da37bSVolodymyr Sapsaia vbr4 value.  The first set of four bits starting from the least significant
109178da37bSVolodymyr Sapsaiindicates the value 6 (110) with a continuation piece (indicated by a high bit
110178da37bSVolodymyr Sapsaiof 1).  The next set of four bits indicates a value of 24 (011 << 3) with no
111178da37bSVolodymyr Sapsaicontinuation.  The sum (6+24) yields the value 30.
112e28d50a8SBill Wendling
113e28d50a8SBill Wendling.. _char6-encoded value:
114e28d50a8SBill Wendling
115e28d50a8SBill Wendling6-bit characters
116e28d50a8SBill Wendling^^^^^^^^^^^^^^^^
117e28d50a8SBill Wendling
118e28d50a8SBill Wendling6-bit characters encode common characters into a fixed 6-bit field.  They
119e28d50a8SBill Wendlingrepresent the following characters with the following 6-bit values:
120e28d50a8SBill Wendling
121e28d50a8SBill Wendling::
122e28d50a8SBill Wendling
123e28d50a8SBill Wendling  'a' .. 'z' ---  0 .. 25
124e28d50a8SBill Wendling  'A' .. 'Z' --- 26 .. 51
125e28d50a8SBill Wendling  '0' .. '9' --- 52 .. 61
126e28d50a8SBill Wendling         '.' --- 62
127e28d50a8SBill Wendling         '_' --- 63
128e28d50a8SBill Wendling
129e28d50a8SBill WendlingThis encoding is only suitable for encoding characters and strings that consist
130e28d50a8SBill Wendlingonly of the above characters.  It is completely incapable of encoding characters
131e28d50a8SBill Wendlingnot in the set.
132e28d50a8SBill Wendling
133e28d50a8SBill WendlingWord Alignment
134e28d50a8SBill Wendling^^^^^^^^^^^^^^
135e28d50a8SBill Wendling
136e28d50a8SBill WendlingOccasionally, it is useful to emit zero bits until the bitstream is a multiple
137e28d50a8SBill Wendlingof 32 bits.  This ensures that the bit position in the stream can be represented
138e28d50a8SBill Wendlingas a multiple of 32-bit words.
139e28d50a8SBill Wendling
140e28d50a8SBill WendlingAbbreviation IDs
141e28d50a8SBill Wendling----------------
142e28d50a8SBill Wendling
143e28d50a8SBill WendlingA bitstream is a sequential series of `Blocks`_ and `Data Records`_.  Both of
144e28d50a8SBill Wendlingthese start with an abbreviation ID encoded as a fixed-bitwidth field.  The
145e28d50a8SBill Wendlingwidth is specified by the current block, as described below.  The value of the
146e28d50a8SBill Wendlingabbreviation ID specifies either a builtin ID (which have special meanings,
147e28d50a8SBill Wendlingdefined below) or one of the abbreviation IDs defined for the current block by
148e28d50a8SBill Wendlingthe stream itself.
149e28d50a8SBill Wendling
150e28d50a8SBill WendlingThe set of builtin abbrev IDs is:
151e28d50a8SBill Wendling
152e28d50a8SBill Wendling* 0 - `END_BLOCK`_ --- This abbrev ID marks the end of the current block.
153e28d50a8SBill Wendling
154e28d50a8SBill Wendling* 1 - `ENTER_SUBBLOCK`_ --- This abbrev ID marks the beginning of a new
155e28d50a8SBill Wendling  block.
156e28d50a8SBill Wendling
157e28d50a8SBill Wendling* 2 - `DEFINE_ABBREV`_ --- This defines a new abbreviation.
158e28d50a8SBill Wendling
159e28d50a8SBill Wendling* 3 - `UNABBREV_RECORD`_ --- This ID specifies the definition of an
160e28d50a8SBill Wendling  unabbreviated record.
161e28d50a8SBill Wendling
162e28d50a8SBill WendlingAbbreviation IDs 4 and above are defined by the stream itself, and specify an
163e28d50a8SBill Wendling`abbreviated record encoding`_.
164e28d50a8SBill Wendling
165e28d50a8SBill Wendling.. _Blocks:
166e28d50a8SBill Wendling
167e28d50a8SBill WendlingBlocks
168e28d50a8SBill Wendling------
169e28d50a8SBill Wendling
170e28d50a8SBill WendlingBlocks in a bitstream denote nested regions of the stream, and are identified by
171e28d50a8SBill Wendlinga content-specific id number (for example, LLVM IR uses an ID of 12 to represent
172e28d50a8SBill Wendlingfunction bodies).  Block IDs 0-7 are reserved for `standard blocks`_ whose
173e28d50a8SBill Wendlingmeaning is defined by Bitcode; block IDs 8 and greater are application
174e28d50a8SBill Wendlingspecific. Nested blocks capture the hierarchical structure of the data encoded
175e28d50a8SBill Wendlingin it, and various properties are associated with blocks as the file is parsed.
176e28d50a8SBill WendlingBlock definitions allow the reader to efficiently skip blocks in constant time
177e28d50a8SBill Wendlingif the reader wants a summary of blocks, or if it wants to efficiently skip data
178e28d50a8SBill Wendlingit does not understand.  The LLVM IR reader uses this mechanism to skip function
179e28d50a8SBill Wendlingbodies, lazily reading them on demand.
180e28d50a8SBill Wendling
181e28d50a8SBill WendlingWhen reading and encoding the stream, several properties are maintained for the
182e28d50a8SBill Wendlingblock.  In particular, each block maintains:
183e28d50a8SBill Wendling
184e28d50a8SBill Wendling#. A current abbrev id width.  This value starts at 2 at the beginning of the
185e28d50a8SBill Wendling   stream, and is set every time a block record is entered.  The block entry
186e28d50a8SBill Wendling   specifies the abbrev id width for the body of the block.
187e28d50a8SBill Wendling
188e28d50a8SBill Wendling#. A set of abbreviations.  Abbreviations may be defined within a block, in
189e28d50a8SBill Wendling   which case they are only defined in that block (neither subblocks nor
190e28d50a8SBill Wendling   enclosing blocks see the abbreviation).  Abbreviations can also be defined
191e28d50a8SBill Wendling   inside a `BLOCKINFO`_ block, in which case they are defined in all blocks
192e28d50a8SBill Wendling   that match the ID that the ``BLOCKINFO`` block is describing.
193e28d50a8SBill Wendling
194e28d50a8SBill WendlingAs sub blocks are entered, these properties are saved and the new sub-block has
195e28d50a8SBill Wendlingits own set of abbreviations, and its own abbrev id width.  When a sub-block is
196e28d50a8SBill Wendlingpopped, the saved values are restored.
197e28d50a8SBill Wendling
198e28d50a8SBill Wendling.. _ENTER_SUBBLOCK:
199e28d50a8SBill Wendling
200e28d50a8SBill WendlingENTER_SUBBLOCK Encoding
201e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^
202e28d50a8SBill Wendling
203e28d50a8SBill Wendling:raw-html:`<tt>`
204e28d50a8SBill Wendling[ENTER_SUBBLOCK, blockid\ :sub:`vbr8`, newabbrevlen\ :sub:`vbr4`, <align32bits>, blocklen_32]
205e28d50a8SBill Wendling:raw-html:`</tt>`
206e28d50a8SBill Wendling
207e28d50a8SBill WendlingThe ``ENTER_SUBBLOCK`` abbreviation ID specifies the start of a new block
208e28d50a8SBill Wendlingrecord.  The ``blockid`` value is encoded as an 8-bit VBR identifier, and
209e28d50a8SBill Wendlingindicates the type of block being entered, which can be a `standard block`_ or
210e28d50a8SBill Wendlingan application-specific block.  The ``newabbrevlen`` value is a 4-bit VBR, which
211e28d50a8SBill Wendlingspecifies the abbrev id width for the sub-block.  The ``blocklen`` value is a
212e28d50a8SBill Wendling32-bit aligned value that specifies the size of the subblock in 32-bit
213e28d50a8SBill Wendlingwords. This value allows the reader to skip over the entire block in one jump.
214e28d50a8SBill Wendling
215e28d50a8SBill Wendling.. _END_BLOCK:
216e28d50a8SBill Wendling
217e28d50a8SBill WendlingEND_BLOCK Encoding
218e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^
219e28d50a8SBill Wendling
220e28d50a8SBill Wendling``[END_BLOCK, <align32bits>]``
221e28d50a8SBill Wendling
222e28d50a8SBill WendlingThe ``END_BLOCK`` abbreviation ID specifies the end of the current block record.
223e28d50a8SBill WendlingIts end is aligned to 32-bits to ensure that the size of the block is an even
224e28d50a8SBill Wendlingmultiple of 32-bits.
225e28d50a8SBill Wendling
226e28d50a8SBill Wendling.. _Data Records:
227e28d50a8SBill Wendling
228e28d50a8SBill WendlingData Records
229e28d50a8SBill Wendling------------
230e28d50a8SBill Wendling
231e28d50a8SBill WendlingData records consist of a record code and a number of (up to) 64-bit integer
232e28d50a8SBill Wendlingvalues.  The interpretation of the code and values is application specific and
233e28d50a8SBill Wendlingmay vary between different block types.  Records can be encoded either using an
234e28d50a8SBill Wendlingunabbrev record, or with an abbreviation.  In the LLVM IR format, for example,
235e28d50a8SBill Wendlingthere is a record which encodes the target triple of a module.  The code is
236e28d50a8SBill Wendling``MODULE_CODE_TRIPLE``, and the values of the record are the ASCII codes for the
237e28d50a8SBill Wendlingcharacters in the string.
238e28d50a8SBill Wendling
239e28d50a8SBill Wendling.. _UNABBREV_RECORD:
240e28d50a8SBill Wendling
241e28d50a8SBill WendlingUNABBREV_RECORD Encoding
242e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^
243e28d50a8SBill Wendling
244e28d50a8SBill Wendling:raw-html:`<tt>`
245e28d50a8SBill Wendling[UNABBREV_RECORD, code\ :sub:`vbr6`, numops\ :sub:`vbr6`, op0\ :sub:`vbr6`, op1\ :sub:`vbr6`, ...]
246e28d50a8SBill Wendling:raw-html:`</tt>`
247e28d50a8SBill Wendling
248e28d50a8SBill WendlingAn ``UNABBREV_RECORD`` provides a default fallback encoding, which is both
249e28d50a8SBill Wendlingcompletely general and extremely inefficient.  It can describe an arbitrary
250e28d50a8SBill Wendlingrecord by emitting the code and operands as VBRs.
251e28d50a8SBill Wendling
252e28d50a8SBill WendlingFor example, emitting an LLVM IR target triple as an unabbreviated record
253e28d50a8SBill Wendlingrequires emitting the ``UNABBREV_RECORD`` abbrevid, a vbr6 for the
254e28d50a8SBill Wendling``MODULE_CODE_TRIPLE`` code, a vbr6 for the length of the string, which is equal
255e28d50a8SBill Wendlingto the number of operands, and a vbr6 for each character.  Because there are no
256e28d50a8SBill Wendlingletters with values less than 32, each letter would need to be emitted as at
257e28d50a8SBill Wendlingleast a two-part VBR, which means that each letter would require at least 12
258e28d50a8SBill Wendlingbits.  This is not an efficient encoding, but it is fully general.
259e28d50a8SBill Wendling
260e28d50a8SBill Wendling.. _abbreviated record encoding:
261e28d50a8SBill Wendling
262e28d50a8SBill WendlingAbbreviated Record Encoding
263e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^^
264e28d50a8SBill Wendling
265e28d50a8SBill Wendling``[<abbrevid>, fields...]``
266e28d50a8SBill Wendling
267e8fa9014SKazu HirataAn abbreviated record is an abbreviation id followed by a set of fields that are
268e28d50a8SBill Wendlingencoded according to the `abbreviation definition`_.  This allows records to be
269e28d50a8SBill Wendlingencoded significantly more densely than records encoded with the
270e28d50a8SBill Wendling`UNABBREV_RECORD`_ type, and allows the abbreviation types to be specified in
271e28d50a8SBill Wendlingthe stream itself, which allows the files to be completely self describing.  The
272e28d50a8SBill Wendlingactual encoding of abbreviations is defined below.
273e28d50a8SBill Wendling
274e28d50a8SBill WendlingThe record code, which is the first field of an abbreviated record, may be
275e28d50a8SBill Wendlingencoded in the abbreviation definition (as a literal operand) or supplied in the
276e28d50a8SBill Wendlingabbreviated record (as a Fixed or VBR operand value).
277e28d50a8SBill Wendling
278e28d50a8SBill Wendling.. _abbreviation definition:
279e28d50a8SBill Wendling
280e28d50a8SBill WendlingAbbreviations
281e28d50a8SBill Wendling-------------
282e28d50a8SBill Wendling
283e28d50a8SBill WendlingAbbreviations are an important form of compression for bitstreams.  The idea is
284e28d50a8SBill Wendlingto specify a dense encoding for a class of records once, then use that encoding
285e28d50a8SBill Wendlingto emit many records.  It takes space to emit the encoding into the file, but
286e28d50a8SBill Wendlingthe space is recouped (hopefully plus some) when the records that use it are
287e28d50a8SBill Wendlingemitted.
288e28d50a8SBill Wendling
289e28d50a8SBill WendlingAbbreviations can be determined dynamically per client, per file. Because the
290e28d50a8SBill Wendlingabbreviations are stored in the bitstream itself, different streams of the same
291e28d50a8SBill Wendlingformat can contain different sets of abbreviations according to the needs of the
292e28d50a8SBill Wendlingspecific stream.  As a concrete example, LLVM IR files usually emit an
293e28d50a8SBill Wendlingabbreviation for binary operators.  If a specific LLVM module contained no or
294e28d50a8SBill Wendlingfew binary operators, the abbreviation does not need to be emitted.
295e28d50a8SBill Wendling
296e28d50a8SBill Wendling.. _DEFINE_ABBREV:
297e28d50a8SBill Wendling
298e28d50a8SBill WendlingDEFINE_ABBREV Encoding
299e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^
300e28d50a8SBill Wendling
301e28d50a8SBill Wendling:raw-html:`<tt>`
302e28d50a8SBill Wendling[DEFINE_ABBREV, numabbrevops\ :sub:`vbr5`, abbrevop0, abbrevop1, ...]
303e28d50a8SBill Wendling:raw-html:`</tt>`
304e28d50a8SBill Wendling
305e28d50a8SBill WendlingA ``DEFINE_ABBREV`` record adds an abbreviation to the list of currently defined
306e28d50a8SBill Wendlingabbreviations in the scope of this block.  This definition only exists inside
307e28d50a8SBill Wendlingthis immediate block --- it is not visible in subblocks or enclosing blocks.
308e28d50a8SBill WendlingAbbreviations are implicitly assigned IDs sequentially starting from 4 (the
309e28d50a8SBill Wendlingfirst application-defined abbreviation ID).  Any abbreviations defined in a
310e28d50a8SBill Wendling``BLOCKINFO`` record for the particular block type receive IDs first, in order,
311e28d50a8SBill Wendlingfollowed by any abbreviations defined within the block itself.  Abbreviated data
312e28d50a8SBill Wendlingrecords reference this ID to indicate what abbreviation they are invoking.
313e28d50a8SBill Wendling
314e28d50a8SBill WendlingAn abbreviation definition consists of the ``DEFINE_ABBREV`` abbrevid followed
315e28d50a8SBill Wendlingby a VBR that specifies the number of abbrev operands, then the abbrev operands
316e28d50a8SBill Wendlingthemselves.  Abbreviation operands come in three forms.  They all start with a
317e28d50a8SBill Wendlingsingle bit that indicates whether the abbrev operand is a literal operand (when
318e28d50a8SBill Wendlingthe bit is 1) or an encoding operand (when the bit is 0).
319e28d50a8SBill Wendling
320e28d50a8SBill Wendling#. Literal operands --- :raw-html:`<tt>` [1\ :sub:`1`, litvalue\
321e28d50a8SBill Wendling   :sub:`vbr8`] :raw-html:`</tt>` --- Literal operands specify that the value in
322e28d50a8SBill Wendling   the result is always a single specific value.  This specific value is emitted
323e28d50a8SBill Wendling   as a vbr8 after the bit indicating that it is a literal operand.
324e28d50a8SBill Wendling
325e28d50a8SBill Wendling#. Encoding info without data --- :raw-html:`<tt>` [0\ :sub:`1`, encoding\
326e28d50a8SBill Wendling   :sub:`3`] :raw-html:`</tt>` --- Operand encodings that do not have extra data
327e28d50a8SBill Wendling   are just emitted as their code.
328e28d50a8SBill Wendling
329e28d50a8SBill Wendling#. Encoding info with data --- :raw-html:`<tt>` [0\ :sub:`1`, encoding\
330e28d50a8SBill Wendling   :sub:`3`, value\ :sub:`vbr5`] :raw-html:`</tt>` --- Operand encodings that do
331e28d50a8SBill Wendling   have extra data are emitted as their code, followed by the extra data.
332e28d50a8SBill Wendling
333e28d50a8SBill WendlingThe possible operand encodings are:
334e28d50a8SBill Wendling
335e28d50a8SBill Wendling* Fixed (code 1): The field should be emitted as a `fixed-width value`_, whose
336e28d50a8SBill Wendling  width is specified by the operand's extra data.
337e28d50a8SBill Wendling
338e28d50a8SBill Wendling* VBR (code 2): The field should be emitted as a `variable-width value`_, whose
339e28d50a8SBill Wendling  width is specified by the operand's extra data.
340e28d50a8SBill Wendling
341e28d50a8SBill Wendling* Array (code 3): This field is an array of values.  The array operand has no
342e28d50a8SBill Wendling  extra data, but expects another operand to follow it, indicating the element
343e28d50a8SBill Wendling  type of the array.  When reading an array in an abbreviated record, the first
344e28d50a8SBill Wendling  integer is a vbr6 that indicates the array length, followed by the encoded
345e28d50a8SBill Wendling  elements of the array.  An array may only occur as the last operand of an
346e28d50a8SBill Wendling  abbreviation (except for the one final operand that gives the array's
347e28d50a8SBill Wendling  type).
348e28d50a8SBill Wendling
349e28d50a8SBill Wendling* Char6 (code 4): This field should be emitted as a `char6-encoded value`_.
350e28d50a8SBill Wendling  This operand type takes no extra data. Char6 encoding is normally used as an
351e28d50a8SBill Wendling  array element type.
352e28d50a8SBill Wendling
353e28d50a8SBill Wendling* Blob (code 5): This field is emitted as a vbr6, followed by padding to a
354e28d50a8SBill Wendling  32-bit boundary (for alignment) and an array of 8-bit objects.  The array of
355e28d50a8SBill Wendling  bytes is further followed by tail padding to ensure that its total length is a
356e28d50a8SBill Wendling  multiple of 4 bytes.  This makes it very efficient for the reader to decode
357e28d50a8SBill Wendling  the data without having to make a copy of it: it can use a pointer to the data
358e28d50a8SBill Wendling  in the mapped in file and poke directly at it.  A blob may only occur as the
359e28d50a8SBill Wendling  last operand of an abbreviation.
360e28d50a8SBill Wendling
361e28d50a8SBill WendlingFor example, target triples in LLVM modules are encoded as a record of the form
362e28d50a8SBill Wendling``[TRIPLE, 'a', 'b', 'c', 'd']``.  Consider if the bitstream emitted the
363e28d50a8SBill Wendlingfollowing abbrev entry:
364e28d50a8SBill Wendling
365e28d50a8SBill Wendling::
366e28d50a8SBill Wendling
367e28d50a8SBill Wendling  [0, Fixed, 4]
368e28d50a8SBill Wendling  [0, Array]
369e28d50a8SBill Wendling  [0, Char6]
370e28d50a8SBill Wendling
371e28d50a8SBill WendlingWhen emitting a record with this abbreviation, the above entry would be emitted
372e28d50a8SBill Wendlingas:
373e28d50a8SBill Wendling
374e28d50a8SBill Wendling:raw-html:`<tt><blockquote>`
375e28d50a8SBill Wendling[4\ :sub:`abbrevwidth`, 2\ :sub:`4`, 4\ :sub:`vbr6`, 0\ :sub:`6`, 1\ :sub:`6`, 2\ :sub:`6`, 3\ :sub:`6`]
376e28d50a8SBill Wendling:raw-html:`</blockquote></tt>`
377e28d50a8SBill Wendling
378e28d50a8SBill WendlingThese values are:
379e28d50a8SBill Wendling
380e28d50a8SBill Wendling#. The first value, 4, is the abbreviation ID for this abbreviation.
381e28d50a8SBill Wendling
382e28d50a8SBill Wendling#. The second value, 2, is the record code for ``TRIPLE`` records within LLVM IR
383e28d50a8SBill Wendling   file ``MODULE_BLOCK`` blocks.
384e28d50a8SBill Wendling
385e28d50a8SBill Wendling#. The third value, 4, is the length of the array.
386e28d50a8SBill Wendling
387e28d50a8SBill Wendling#. The rest of the values are the char6 encoded values for ``"abcd"``.
388e28d50a8SBill Wendling
389e28d50a8SBill WendlingWith this abbreviation, the triple is emitted with only 37 bits (assuming a
390e28d50a8SBill Wendlingabbrev id width of 3).  Without the abbreviation, significantly more space would
391e28d50a8SBill Wendlingbe required to emit the target triple.  Also, because the ``TRIPLE`` value is
392e28d50a8SBill Wendlingnot emitted as a literal in the abbreviation, the abbreviation can also be used
393e28d50a8SBill Wendlingfor any other string value.
394e28d50a8SBill Wendling
395e28d50a8SBill Wendling.. _standard blocks:
396e28d50a8SBill Wendling.. _standard block:
397e28d50a8SBill Wendling
398e28d50a8SBill WendlingStandard Blocks
399e28d50a8SBill Wendling---------------
400e28d50a8SBill Wendling
401e28d50a8SBill WendlingIn addition to the basic block structure and record encodings, the bitstream
402e28d50a8SBill Wendlingalso defines specific built-in block types.  These block types specify how the
403e28d50a8SBill Wendlingstream is to be decoded or other metadata.  In the future, new standard blocks
404e28d50a8SBill Wendlingmay be added.  Block IDs 0-7 are reserved for standard blocks.
405e28d50a8SBill Wendling
406e28d50a8SBill Wendling.. _BLOCKINFO:
407e28d50a8SBill Wendling
408e28d50a8SBill Wendling#0 - BLOCKINFO Block
409e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^
410e28d50a8SBill Wendling
411e28d50a8SBill WendlingThe ``BLOCKINFO`` block allows the description of metadata for other blocks.
412e28d50a8SBill WendlingThe currently specified records are:
413e28d50a8SBill Wendling
414e28d50a8SBill Wendling::
415e28d50a8SBill Wendling
416e28d50a8SBill Wendling  [SETBID (#1), blockid]
417e28d50a8SBill Wendling  [DEFINE_ABBREV, ...]
418e28d50a8SBill Wendling  [BLOCKNAME, ...name...]
419e28d50a8SBill Wendling  [SETRECORDNAME, RecordID, ...name...]
420e28d50a8SBill Wendling
421e28d50a8SBill WendlingThe ``SETBID`` record (code 1) indicates which block ID is being described.
422e28d50a8SBill Wendling``SETBID`` records can occur multiple times throughout the block to change which
423e28d50a8SBill Wendlingblock ID is being described.  There must be a ``SETBID`` record prior to any
424e28d50a8SBill Wendlingother records.
425e28d50a8SBill Wendling
426e28d50a8SBill WendlingStandard ``DEFINE_ABBREV`` records can occur inside ``BLOCKINFO`` blocks, but
427e28d50a8SBill Wendlingunlike their occurrence in normal blocks, the abbreviation is defined for blocks
428e28d50a8SBill Wendlingmatching the block ID we are describing, *not* the ``BLOCKINFO`` block
429e28d50a8SBill Wendlingitself.  The abbreviations defined in ``BLOCKINFO`` blocks receive abbreviation
430e28d50a8SBill WendlingIDs as described in `DEFINE_ABBREV`_.
431e28d50a8SBill Wendling
432e28d50a8SBill WendlingThe ``BLOCKNAME`` record (code 2) can optionally occur in this block.  The
433e28d50a8SBill Wendlingelements of the record are the bytes of the string name of the block.
434e28d50a8SBill Wendlingllvm-bcanalyzer can use this to dump out bitcode files symbolically.
435e28d50a8SBill Wendling
436e28d50a8SBill WendlingThe ``SETRECORDNAME`` record (code 3) can also optionally occur in this block.
437e28d50a8SBill WendlingThe first operand value is a record ID number, and the rest of the elements of
438e28d50a8SBill Wendlingthe record are the bytes for the string name of the record.  llvm-bcanalyzer can
439e28d50a8SBill Wendlinguse this to dump out bitcode files symbolically.
440e28d50a8SBill Wendling
441e28d50a8SBill WendlingNote that although the data in ``BLOCKINFO`` blocks is described as "metadata,"
442e28d50a8SBill Wendlingthe abbreviations they contain are essential for parsing records from the
443e28d50a8SBill Wendlingcorresponding blocks.  It is not safe to skip them.
444e28d50a8SBill Wendling
445e28d50a8SBill Wendling.. _wrapper:
446e28d50a8SBill Wendling
447e28d50a8SBill WendlingBitcode Wrapper Format
448e28d50a8SBill Wendling======================
449e28d50a8SBill Wendling
450e28d50a8SBill WendlingBitcode files for LLVM IR may optionally be wrapped in a simple wrapper
451e28d50a8SBill Wendlingstructure.  This structure contains a simple header that indicates the offset
452e28d50a8SBill Wendlingand size of the embedded BC file.  This allows additional information to be
453e28d50a8SBill Wendlingstored alongside the BC file.  The structure of this file header is:
454e28d50a8SBill Wendling
455e28d50a8SBill Wendling:raw-html:`<tt><blockquote>`
456e28d50a8SBill Wendling[Magic\ :sub:`32`, Version\ :sub:`32`, Offset\ :sub:`32`, Size\ :sub:`32`, CPUType\ :sub:`32`]
457e28d50a8SBill Wendling:raw-html:`</blockquote></tt>`
458e28d50a8SBill Wendling
459e28d50a8SBill WendlingEach of the fields are 32-bit fields stored in little endian form (as with the
460e28d50a8SBill Wendlingrest of the bitcode file fields).  The Magic number is always ``0x0B17C0DE`` and
461e28d50a8SBill Wendlingthe version is currently always ``0``.  The Offset field is the offset in bytes
462e28d50a8SBill Wendlingto the start of the bitcode stream in the file, and the Size field is the size
463e28d50a8SBill Wendlingin bytes of the stream. CPUType is a target-specific value that can be used to
464e28d50a8SBill Wendlingencode the CPU of the target.
465e28d50a8SBill Wendling
46610039c02SPeter Collingbourne.. _native object file:
46710039c02SPeter Collingbourne
46810039c02SPeter CollingbourneNative Object File Wrapper Format
46910039c02SPeter Collingbourne=================================
47010039c02SPeter Collingbourne
47110039c02SPeter CollingbourneBitcode files for LLVM IR may also be wrapped in a native object file
472f2fe0141SSteven Wu(i.e. ELF, COFF, Mach-O).  The bitcode must be stored in a section of the object
473f2fe0141SSteven Wufile named ``__LLVM,__bitcode`` for MachO and ``.llvmbc`` for the other object
474f2fe0141SSteven Wuformats.  This wrapper format is useful for accommodating LTO in compilation
475f2fe0141SSteven Wupipelines where intermediate objects must be native object files which contain
476f2fe0141SSteven Wumetadata in other sections.
47710039c02SPeter Collingbourne
478*4b1e3d19STom StellardNot all tools support this format.  For example, lld and the gold plugin will
479*4b1e3d19STom Stellardignore these sections when linking object files.
48010039c02SPeter Collingbourne
481e28d50a8SBill Wendling.. _encoding of LLVM IR:
482e28d50a8SBill Wendling
483e28d50a8SBill WendlingLLVM IR Encoding
484e28d50a8SBill Wendling================
485e28d50a8SBill Wendling
486e28d50a8SBill WendlingLLVM IR is encoded into a bitstream by defining blocks and records.  It uses
487e28d50a8SBill Wendlingblocks for things like constant pools, functions, symbol tables, etc.  It uses
488e28d50a8SBill Wendlingrecords for things like instructions, global variable descriptors, type
489e28d50a8SBill Wendlingdescriptions, etc.  This document does not describe the set of abbreviations
490e28d50a8SBill Wendlingthat the writer uses, as these are fully self-described in the file, and the
491e28d50a8SBill Wendlingreader is not allowed to build in any knowledge of this.
492e28d50a8SBill Wendling
493e28d50a8SBill WendlingBasics
494e28d50a8SBill Wendling------
495e28d50a8SBill Wendling
496e28d50a8SBill WendlingLLVM IR Magic Number
497e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^
498e28d50a8SBill Wendling
499e28d50a8SBill WendlingThe magic number for LLVM IR files is:
500e28d50a8SBill Wendling
501e28d50a8SBill Wendling:raw-html:`<tt><blockquote>`
50217dfa193SBrian Gesiak['B'\ :sub:`8`, 'C'\ :sub:`8`, 0x0\ :sub:`4`, 0xC\ :sub:`4`, 0xE\ :sub:`4`, 0xD\ :sub:`4`]
503e28d50a8SBill Wendling:raw-html:`</blockquote></tt>`
504e28d50a8SBill Wendling
50577c6c85eSJan Wen Voung.. _Signed VBRs:
50677c6c85eSJan Wen Voung
507e28d50a8SBill WendlingSigned VBRs
508e28d50a8SBill Wendling^^^^^^^^^^^
509e28d50a8SBill Wendling
510e28d50a8SBill Wendling`Variable Width Integer`_ encoding is an efficient way to encode arbitrary sized
511e28d50a8SBill Wendlingunsigned values, but is an extremely inefficient for encoding signed values, as
512e28d50a8SBill Wendlingsigned values are otherwise treated as maximally large unsigned values.
513e28d50a8SBill Wendling
514e28d50a8SBill WendlingAs such, signed VBR values of a specific width are emitted as follows:
515e28d50a8SBill Wendling
516e28d50a8SBill Wendling* Positive values are emitted as VBRs of the specified width, but with their
517e28d50a8SBill Wendling  value shifted left by one.
518e28d50a8SBill Wendling
519e28d50a8SBill Wendling* Negative values are emitted as VBRs of the specified width, but the negated
520e28d50a8SBill Wendling  value is shifted left by one, and the low bit is set.
521e28d50a8SBill Wendling
522e28d50a8SBill WendlingWith this encoding, small positive and small negative values can both be emitted
523e28d50a8SBill Wendlingefficiently. Signed VBR encoding is used in ``CST_CODE_INTEGER`` and
524e28d50a8SBill Wendling``CST_CODE_WIDE_INTEGER`` records within ``CONSTANTS_BLOCK`` blocks.
52577c6c85eSJan Wen VoungIt is also used for phi instruction operands in `MODULE_CODE_VERSION`_ 1.
526e28d50a8SBill Wendling
527e28d50a8SBill WendlingLLVM IR Blocks
528e28d50a8SBill Wendling^^^^^^^^^^^^^^
529e28d50a8SBill Wendling
530e28d50a8SBill WendlingLLVM IR is defined with the following blocks:
531e28d50a8SBill Wendling
532e28d50a8SBill Wendling* 8 --- `MODULE_BLOCK`_ --- This is the top-level block that contains the entire
533e28d50a8SBill Wendling  module, and describes a variety of per-module information.
534e28d50a8SBill Wendling
535e28d50a8SBill Wendling* 9 --- `PARAMATTR_BLOCK`_ --- This enumerates the parameter attributes.
536e28d50a8SBill Wendling
537472a1419SMehdi Amini* 10 --- `PARAMATTR_GROUP_BLOCK`_ --- This describes the attribute group table.
538e28d50a8SBill Wendling
539e28d50a8SBill Wendling* 11 --- `CONSTANTS_BLOCK`_ --- This describes constants for a module or
540e28d50a8SBill Wendling  function.
541e28d50a8SBill Wendling
542e28d50a8SBill Wendling* 12 --- `FUNCTION_BLOCK`_ --- This describes a function body.
543e28d50a8SBill Wendling
544e28d50a8SBill Wendling* 14 --- `VALUE_SYMTAB_BLOCK`_ --- This describes a value symbol table.
545e28d50a8SBill Wendling
546e28d50a8SBill Wendling* 15 --- `METADATA_BLOCK`_ --- This describes metadata items.
547e28d50a8SBill Wendling
548e28d50a8SBill Wendling* 16 --- `METADATA_ATTACHMENT`_ --- This contains records associating metadata
549e28d50a8SBill Wendling  with function instruction values.
550e28d50a8SBill Wendling
551472a1419SMehdi Amini* 17 --- `TYPE_BLOCK`_ --- This describes all of the types in the module.
552472a1419SMehdi Amini
553a0f371a1SPeter Collingbourne* 23 --- `STRTAB_BLOCK`_ --- The bitcode file's string table.
554a0f371a1SPeter Collingbourne
555e28d50a8SBill Wendling.. _MODULE_BLOCK:
556e28d50a8SBill Wendling
557e28d50a8SBill WendlingMODULE_BLOCK Contents
558e28d50a8SBill Wendling---------------------
559e28d50a8SBill Wendling
560e28d50a8SBill WendlingThe ``MODULE_BLOCK`` block (id 8) is the top-level block for LLVM bitcode files,
56176b74236Sminglotus-6and each module in a bitcode file must contain exactly one. A bitcode file with
56276b74236Sminglotus-6multi-module bitcode is valid. In addition to records (described below)
56376b74236Sminglotus-6containing information about the module, a ``MODULE_BLOCK`` block may contain
56476b74236Sminglotus-6the following sub-blocks:
565e28d50a8SBill Wendling
566e28d50a8SBill Wendling* `BLOCKINFO`_
567e28d50a8SBill Wendling* `PARAMATTR_BLOCK`_
568472a1419SMehdi Amini* `PARAMATTR_GROUP_BLOCK`_
569e28d50a8SBill Wendling* `TYPE_BLOCK`_
570e28d50a8SBill Wendling* `VALUE_SYMTAB_BLOCK`_
571e28d50a8SBill Wendling* `CONSTANTS_BLOCK`_
572e28d50a8SBill Wendling* `FUNCTION_BLOCK`_
573e28d50a8SBill Wendling* `METADATA_BLOCK`_
574e28d50a8SBill Wendling
57577c6c85eSJan Wen Voung.. _MODULE_CODE_VERSION:
57677c6c85eSJan Wen Voung
577e28d50a8SBill WendlingMODULE_CODE_VERSION Record
578e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^
579e28d50a8SBill Wendling
580e28d50a8SBill Wendling``[VERSION, version#]``
581e28d50a8SBill Wendling
582e28d50a8SBill WendlingThe ``VERSION`` record (code 1) contains a single value indicating the format
583a0f371a1SPeter Collingbourneversion. Versions 0, 1 and 2 are supported at this time. The difference between
58477c6c85eSJan Wen Voungversion 0 and 1 is in the encoding of instruction operands in
58577c6c85eSJan Wen Voungeach `FUNCTION_BLOCK`_.
58677c6c85eSJan Wen Voung
58777c6c85eSJan Wen VoungIn version 0, each value defined by an instruction is assigned an ID
58877c6c85eSJan Wen Voungunique to the function. Function-level value IDs are assigned starting from
58977c6c85eSJan Wen Voung``NumModuleValues`` since they share the same namespace as module-level
59077c6c85eSJan Wen Voungvalues. The value enumerator resets after each function. When a value is
59177c6c85eSJan Wen Voungan operand of an instruction, the value ID is used to represent the operand.
59277c6c85eSJan Wen VoungFor large functions or large modules, these operand values can be large.
59377c6c85eSJan Wen Voung
59477c6c85eSJan Wen VoungThe encoding in version 1 attempts to avoid large operand values
59577c6c85eSJan Wen Voungin common cases. Instead of using the value ID directly, operands are
59677c6c85eSJan Wen Voungencoded as relative to the current instruction. Thus, if an operand
59777c6c85eSJan Wen Voungis the value defined by the previous instruction, the operand
59877c6c85eSJan Wen Voungwill be encoded as 1.
59977c6c85eSJan Wen Voung
60077c6c85eSJan Wen VoungFor example, instead of
60177c6c85eSJan Wen Voung
602a0c1f408SAaron Ballman.. code-block:: none
60377c6c85eSJan Wen Voung
60477c6c85eSJan Wen Voung  #n = load #n-1
60577c6c85eSJan Wen Voung  #n+1 = icmp eq #n, #const0
60677c6c85eSJan Wen Voung  br #n+1, label #(bb1), label #(bb2)
60777c6c85eSJan Wen Voung
60877c6c85eSJan Wen Voungversion 1 will encode the instructions as
60977c6c85eSJan Wen Voung
610a0c1f408SAaron Ballman.. code-block:: none
61177c6c85eSJan Wen Voung
61277c6c85eSJan Wen Voung  #n = load #1
61377c6c85eSJan Wen Voung  #n+1 = icmp eq #1, (#n+1)-#const0
61477c6c85eSJan Wen Voung  br #1, label #(bb1), label #(bb2)
61577c6c85eSJan Wen Voung
61677c6c85eSJan Wen VoungNote in the example that operands which are constants also use
61777c6c85eSJan Wen Voungthe relative encoding, while operands like basic block labels
61877c6c85eSJan Wen Voungdo not use the relative encoding.
61977c6c85eSJan Wen Voung
62077c6c85eSJan Wen VoungForward references will result in a negative value.
62177c6c85eSJan Wen VoungThis can be inefficient, as operands are normally encoded
62277c6c85eSJan Wen Voungas unsigned VBRs. However, forward references are rare, except in the
62377c6c85eSJan Wen Voungcase of phi instructions. For phi instructions, operands are encoded as
62477c6c85eSJan Wen Voung`Signed VBRs`_ to deal with forward references.
62577c6c85eSJan Wen Voung
626a0f371a1SPeter CollingbourneIn version 2, the meaning of module records ``FUNCTION``, ``GLOBALVAR``,
627a0f371a1SPeter Collingbourne``ALIAS``, ``IFUNC`` and ``COMDAT`` change such that the first two operands
628a0f371a1SPeter Collingbournespecify an offset and size of a string in a string table (see `STRTAB_BLOCK
629a0f371a1SPeter CollingbourneContents`_), the function name is removed from the ``FNENTRY`` record in the
630a0f371a1SPeter Collingbournevalue symbol table, and the top-level ``VALUE_SYMTAB_BLOCK`` may only contain
631a0f371a1SPeter Collingbourne``FNENTRY`` records.
632e28d50a8SBill Wendling
633e28d50a8SBill WendlingMODULE_CODE_TRIPLE Record
634e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^
635e28d50a8SBill Wendling
636e28d50a8SBill Wendling``[TRIPLE, ...string...]``
637e28d50a8SBill Wendling
638e28d50a8SBill WendlingThe ``TRIPLE`` record (code 2) contains a variable number of values representing
639e28d50a8SBill Wendlingthe bytes of the ``target triple`` specification string.
640e28d50a8SBill Wendling
641e28d50a8SBill WendlingMODULE_CODE_DATALAYOUT Record
642e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
643e28d50a8SBill Wendling
644e28d50a8SBill Wendling``[DATALAYOUT, ...string...]``
645e28d50a8SBill Wendling
646e28d50a8SBill WendlingThe ``DATALAYOUT`` record (code 3) contains a variable number of values
647e28d50a8SBill Wendlingrepresenting the bytes of the ``target datalayout`` specification string.
648e28d50a8SBill Wendling
649e28d50a8SBill WendlingMODULE_CODE_ASM Record
650e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^
651e28d50a8SBill Wendling
652e28d50a8SBill Wendling``[ASM, ...string...]``
653e28d50a8SBill Wendling
654e28d50a8SBill WendlingThe ``ASM`` record (code 4) contains a variable number of values representing
655e28d50a8SBill Wendlingthe bytes of ``module asm`` strings, with individual assembly blocks separated
656e28d50a8SBill Wendlingby newline (ASCII 10) characters.
657e28d50a8SBill Wendling
658e28d50a8SBill Wendling.. _MODULE_CODE_SECTIONNAME:
659e28d50a8SBill Wendling
660e28d50a8SBill WendlingMODULE_CODE_SECTIONNAME Record
661e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
662e28d50a8SBill Wendling
663e28d50a8SBill Wendling``[SECTIONNAME, ...string...]``
664e28d50a8SBill Wendling
665e28d50a8SBill WendlingThe ``SECTIONNAME`` record (code 5) contains a variable number of values
666e28d50a8SBill Wendlingrepresenting the bytes of a single section name string. There should be one
667e28d50a8SBill Wendling``SECTIONNAME`` record for each section name referenced (e.g., in global
668e28d50a8SBill Wendlingvariable or function ``section`` attributes) within the module. These records
669e28d50a8SBill Wendlingcan be referenced by the 1-based index in the *section* fields of ``GLOBALVAR``
670e28d50a8SBill Wendlingor ``FUNCTION`` records.
671e28d50a8SBill Wendling
672e28d50a8SBill WendlingMODULE_CODE_DEPLIB Record
673e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^
674e28d50a8SBill Wendling
675e28d50a8SBill Wendling``[DEPLIB, ...string...]``
676e28d50a8SBill Wendling
677e28d50a8SBill WendlingThe ``DEPLIB`` record (code 6) contains a variable number of values representing
678e28d50a8SBill Wendlingthe bytes of a single dependent library name string, one of the libraries
679e28d50a8SBill Wendlingmentioned in a ``deplibs`` declaration.  There should be one ``DEPLIB`` record
680e28d50a8SBill Wendlingfor each library name referenced.
681e28d50a8SBill Wendling
682e28d50a8SBill WendlingMODULE_CODE_GLOBALVAR Record
683e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^^^
684e28d50a8SBill Wendling
685c70d28bfSSean Fertile``[GLOBALVAR, strtab offset, strtab size, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, externally_initialized, dllstorageclass, comdat, attributes, preemptionspecifier]``
686e28d50a8SBill Wendling
687e28d50a8SBill WendlingThe ``GLOBALVAR`` record (code 7) marks the declaration or definition of a
688e28d50a8SBill Wendlingglobal variable. The operand fields are:
689e28d50a8SBill Wendling
690a0f371a1SPeter Collingbourne* *strtab offset*, *strtab size*: Specifies the name of the global variable.
691a0f371a1SPeter Collingbourne  See `STRTAB_BLOCK Contents`_.
692a0f371a1SPeter Collingbourne
693e28d50a8SBill Wendling* *pointer type*: The type index of the pointer type used to point to this
694e28d50a8SBill Wendling  global variable
695e28d50a8SBill Wendling
696e28d50a8SBill Wendling* *isconst*: Non-zero if the variable is treated as constant within the module,
697e28d50a8SBill Wendling  or zero if it is not
698e28d50a8SBill Wendling
699e28d50a8SBill Wendling* *initid*: If non-zero, the value index of the initializer for this variable,
700e28d50a8SBill Wendling  plus 1.
701e28d50a8SBill Wendling
702e28d50a8SBill Wendling.. _linkage type:
703e28d50a8SBill Wendling
704e28d50a8SBill Wendling* *linkage*: An encoding of the linkage type for this variable:
70562b5b73eSPeter Collingbourne
706e28d50a8SBill Wendling  * ``external``: code 0
707e28d50a8SBill Wendling  * ``weak``: code 1
708e28d50a8SBill Wendling  * ``appending``: code 2
709e28d50a8SBill Wendling  * ``internal``: code 3
710e28d50a8SBill Wendling  * ``linkonce``: code 4
711e28d50a8SBill Wendling  * ``dllimport``: code 5
712e28d50a8SBill Wendling  * ``dllexport``: code 6
713e28d50a8SBill Wendling  * ``extern_weak``: code 7
714e28d50a8SBill Wendling  * ``common``: code 8
715e28d50a8SBill Wendling  * ``private``: code 9
716e28d50a8SBill Wendling  * ``weak_odr``: code 10
717e28d50a8SBill Wendling  * ``linkonce_odr``: code 11
718e28d50a8SBill Wendling  * ``available_externally``: code 12
7192fb5bc33SRafael Espindola  * deprecated : code 13
7202fb5bc33SRafael Espindola  * deprecated : code 14
721e28d50a8SBill Wendling
722e28d50a8SBill Wendling* alignment*: The logarithm base 2 of the variable's requested alignment, plus 1
723e28d50a8SBill Wendling
724e28d50a8SBill Wendling* *section*: If non-zero, the 1-based section index in the table of
725e28d50a8SBill Wendling  `MODULE_CODE_SECTIONNAME`_ entries.
726e28d50a8SBill Wendling
727e28d50a8SBill Wendling.. _visibility:
728e28d50a8SBill Wendling
729e28d50a8SBill Wendling* *visibility*: If present, an encoding of the visibility of this variable:
73062b5b73eSPeter Collingbourne
731e28d50a8SBill Wendling  * ``default``: code 0
732e28d50a8SBill Wendling  * ``hidden``: code 1
733e28d50a8SBill Wendling  * ``protected``: code 2
734e28d50a8SBill Wendling
73562b5b73eSPeter Collingbourne.. _bcthreadlocal:
73662b5b73eSPeter Collingbourne
737e28d50a8SBill Wendling* *threadlocal*: If present, an encoding of the thread local storage mode of the
738e28d50a8SBill Wendling  variable:
73962b5b73eSPeter Collingbourne
740e28d50a8SBill Wendling  * ``not thread local``: code 0
741e28d50a8SBill Wendling  * ``thread local; default TLS model``: code 1
742e28d50a8SBill Wendling  * ``localdynamic``: code 2
743e28d50a8SBill Wendling  * ``initialexec``: code 3
744e28d50a8SBill Wendling  * ``localexec``: code 4
745e28d50a8SBill Wendling
74696efdd61SPeter Collingbourne.. _bcunnamedaddr:
74796efdd61SPeter Collingbourne
74896efdd61SPeter Collingbourne* *unnamed_addr*: If present, an encoding of the ``unnamed_addr`` attribute of this
74996efdd61SPeter Collingbourne  variable:
75096efdd61SPeter Collingbourne
75196efdd61SPeter Collingbourne  * not ``unnamed_addr``: code 0
75296efdd61SPeter Collingbourne  * ``unnamed_addr``: code 1
75396efdd61SPeter Collingbourne  * ``local_unnamed_addr``: code 2
754e28d50a8SBill Wendling
755042b7ffdSPeter Collingbourne.. _bcdllstorageclass:
7567157bb76SNico Rieck
7577157bb76SNico Rieck* *dllstorageclass*: If present, an encoding of the DLL storage class of this variable:
7587157bb76SNico Rieck
7597157bb76SNico Rieck  * ``default``: code 0
7607157bb76SNico Rieck  * ``dllimport``: code 1
7617157bb76SNico Rieck  * ``dllexport``: code 2
7627157bb76SNico Rieck
76362b5b73eSPeter Collingbourne* *comdat*: An encoding of the COMDAT of this function
76462b5b73eSPeter Collingbourne
765c70d28bfSSean Fertile* *attributes*: If nonzero, the 1-based index into the table of AttributeLists.
766c70d28bfSSean Fertile
767c70d28bfSSean Fertile.. _bcpreemptionspecifier:
768c70d28bfSSean Fertile
769c70d28bfSSean Fertile* *preemptionspecifier*: If present, an encoding of the runtime preemption specifier of this variable:
770c70d28bfSSean Fertile
771c70d28bfSSean Fertile  * ``dso_preemptable``: code 0
772c70d28bfSSean Fertile  * ``dso_local``: code 1
773c70d28bfSSean Fertile
774e28d50a8SBill Wendling.. _FUNCTION:
775e28d50a8SBill Wendling
776e28d50a8SBill WendlingMODULE_CODE_FUNCTION Record
777e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^^
778e28d50a8SBill Wendling
779c70d28bfSSean Fertile``[FUNCTION, strtab offset, strtab size, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prologuedata, dllstorageclass, comdat, prefixdata, personalityfn, preemptionspecifier]``
780e28d50a8SBill Wendling
781e28d50a8SBill WendlingThe ``FUNCTION`` record (code 8) marks the declaration or definition of a
782e28d50a8SBill Wendlingfunction. The operand fields are:
783e28d50a8SBill Wendling
784a0f371a1SPeter Collingbourne* *strtab offset*, *strtab size*: Specifies the name of the function.
785a0f371a1SPeter Collingbourne  See `STRTAB_BLOCK Contents`_.
786a0f371a1SPeter Collingbourne
787e28d50a8SBill Wendling* *type*: The type index of the function type describing this function
788e28d50a8SBill Wendling
789e28d50a8SBill Wendling* *callingconv*: The calling convention number:
790e28d50a8SBill Wendling  * ``ccc``: code 0
791e28d50a8SBill Wendling  * ``fastcc``: code 8
792e28d50a8SBill Wendling  * ``coldcc``: code 9
793976d94b8SJuergen Ributzka  * ``webkit_jscc``: code 12
794976d94b8SJuergen Ributzka  * ``anyregcc``: code 13
795e6250130SJuergen Ributzka  * ``preserve_mostcc``: code 14
796e6250130SJuergen Ributzka  * ``preserve_allcc``: code 15
797f8bdd88cSManman Ren  * ``swiftcc`` : code 16
79819c7bbe3SManman Ren  * ``cxx_fast_tlscc``: code 17
799f9b67b81SReid Kleckner  * ``tailcc`` : code 18
80082a0e808STim Northover  * ``cfguard_checkcc`` : code 19
80182a0e808STim Northover  * ``swifttailcc`` : code 20
802e28d50a8SBill Wendling  * ``x86_stdcallcc``: code 64
803e28d50a8SBill Wendling  * ``x86_fastcallcc``: code 65
804e28d50a8SBill Wendling  * ``arm_apcscc``: code 66
805e28d50a8SBill Wendling  * ``arm_aapcscc``: code 67
806e28d50a8SBill Wendling  * ``arm_aapcs_vfpcc``: code 68
807e28d50a8SBill Wendling
808e28d50a8SBill Wendling* isproto*: Non-zero if this entry represents a declaration rather than a
809e28d50a8SBill Wendling  definition
810e28d50a8SBill Wendling
811e28d50a8SBill Wendling* *linkage*: An encoding of the `linkage type`_ for this function
812e28d50a8SBill Wendling
813e28d50a8SBill Wendling* *paramattr*: If nonzero, the 1-based parameter attribute index into the table
814e28d50a8SBill Wendling  of `PARAMATTR_CODE_ENTRY`_ entries.
815e28d50a8SBill Wendling
816e28d50a8SBill Wendling* *alignment*: The logarithm base 2 of the function's requested alignment, plus
817e28d50a8SBill Wendling  1
818e28d50a8SBill Wendling
819e28d50a8SBill Wendling* *section*: If non-zero, the 1-based section index in the table of
820e28d50a8SBill Wendling  `MODULE_CODE_SECTIONNAME`_ entries.
821e28d50a8SBill Wendling
822e28d50a8SBill Wendling* *visibility*: An encoding of the `visibility`_ of this function
823e28d50a8SBill Wendling
824e28d50a8SBill Wendling* *gc*: If present and nonzero, the 1-based garbage collector index in the table
825e28d50a8SBill Wendling  of `MODULE_CODE_GCNAME`_ entries.
826e28d50a8SBill Wendling
82796efdd61SPeter Collingbourne* *unnamed_addr*: If present, an encoding of the
82896efdd61SPeter Collingbourne  :ref:`unnamed_addr<bcunnamedaddr>` attribute of this function
829e28d50a8SBill Wendling
83051d2de7bSPeter Collingbourne* *prologuedata*: If non-zero, the value index of the prologue data for this function,
8313fa50f9bSPeter Collingbourne  plus 1.
8323fa50f9bSPeter Collingbourne
833042b7ffdSPeter Collingbourne* *dllstorageclass*: An encoding of the
834042b7ffdSPeter Collingbourne  :ref:`dllstorageclass<bcdllstorageclass>` of this function
8357157bb76SNico Rieck
83651d2de7bSPeter Collingbourne* *comdat*: An encoding of the COMDAT of this function
83751d2de7bSPeter Collingbourne
83851d2de7bSPeter Collingbourne* *prefixdata*: If non-zero, the value index of the prefix data for this function,
83951d2de7bSPeter Collingbourne  plus 1.
84051d2de7bSPeter Collingbourne
8417fddeccbSDavid Majnemer* *personalityfn*: If non-zero, the value index of the personality function for this function,
8427fddeccbSDavid Majnemer  plus 1.
84351d2de7bSPeter Collingbourne
844c70d28bfSSean Fertile* *preemptionspecifier*: If present, an encoding of the :ref:`runtime preemption specifier<bcpreemptionspecifier>`  of this function.
845c70d28bfSSean Fertile
846e28d50a8SBill WendlingMODULE_CODE_ALIAS Record
847e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^
848e28d50a8SBill Wendling
849c70d28bfSSean Fertile``[ALIAS, strtab offset, strtab size, alias type, aliasee val#, linkage, visibility, dllstorageclass, threadlocal, unnamed_addr, preemptionspecifier]``
850e28d50a8SBill Wendling
851e28d50a8SBill WendlingThe ``ALIAS`` record (code 9) marks the definition of an alias. The operand
852e28d50a8SBill Wendlingfields are
853e28d50a8SBill Wendling
854a0f371a1SPeter Collingbourne* *strtab offset*, *strtab size*: Specifies the name of the alias.
855a0f371a1SPeter Collingbourne  See `STRTAB_BLOCK Contents`_.
856a0f371a1SPeter Collingbourne
857e28d50a8SBill Wendling* *alias type*: The type index of the alias
858e28d50a8SBill Wendling
859e28d50a8SBill Wendling* *aliasee val#*: The value index of the aliased value
860e28d50a8SBill Wendling
861e28d50a8SBill Wendling* *linkage*: An encoding of the `linkage type`_ for this alias
862e28d50a8SBill Wendling
863e28d50a8SBill Wendling* *visibility*: If present, an encoding of the `visibility`_ of the alias
864e28d50a8SBill Wendling
865042b7ffdSPeter Collingbourne* *dllstorageclass*: If present, an encoding of the
866042b7ffdSPeter Collingbourne  :ref:`dllstorageclass<bcdllstorageclass>` of the alias
8677157bb76SNico Rieck
86862b5b73eSPeter Collingbourne* *threadlocal*: If present, an encoding of the
86962b5b73eSPeter Collingbourne  :ref:`thread local property<bcthreadlocal>` of the alias
87062b5b73eSPeter Collingbourne
87196efdd61SPeter Collingbourne* *unnamed_addr*: If present, an encoding of the
87296efdd61SPeter Collingbourne  :ref:`unnamed_addr<bcunnamedaddr>` attribute of this alias
87362b5b73eSPeter Collingbourne
874c70d28bfSSean Fertile* *preemptionspecifier*: If present, an encoding of the :ref:`runtime preemption specifier<bcpreemptionspecifier>`  of this alias.
875c70d28bfSSean Fertile
876e28d50a8SBill Wendling.. _MODULE_CODE_GCNAME:
877e28d50a8SBill Wendling
878e28d50a8SBill WendlingMODULE_CODE_GCNAME Record
879e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^
880e28d50a8SBill Wendling
881e28d50a8SBill Wendling``[GCNAME, ...string...]``
882e28d50a8SBill Wendling
883e28d50a8SBill WendlingThe ``GCNAME`` record (code 11) contains a variable number of values
884e28d50a8SBill Wendlingrepresenting the bytes of a single garbage collector name string. There should
885e28d50a8SBill Wendlingbe one ``GCNAME`` record for each garbage collector name referenced in function
886e28d50a8SBill Wendling``gc`` attributes within the module. These records can be referenced by 1-based
887e28d50a8SBill Wendlingindex in the *gc* fields of ``FUNCTION`` records.
888e28d50a8SBill Wendling
889e28d50a8SBill Wendling.. _PARAMATTR_BLOCK:
890e28d50a8SBill Wendling
891e28d50a8SBill WendlingPARAMATTR_BLOCK Contents
892e28d50a8SBill Wendling------------------------
893e28d50a8SBill Wendling
894e28d50a8SBill WendlingThe ``PARAMATTR_BLOCK`` block (id 9) contains a table of entries describing the
895e28d50a8SBill Wendlingattributes of function parameters. These entries are referenced by 1-based index
896e28d50a8SBill Wendlingin the *paramattr* field of module block `FUNCTION`_ records, or within the
897e28d50a8SBill Wendling*attr* field of function block ``INST_INVOKE`` and ``INST_CALL`` records.
898e28d50a8SBill Wendling
899e28d50a8SBill WendlingEntries within ``PARAMATTR_BLOCK`` are constructed to ensure that each is unique
900e9ffb45bSBruce Mitchener(i.e., no two indices represent equivalent attribute lists).
901e28d50a8SBill Wendling
902e28d50a8SBill Wendling.. _PARAMATTR_CODE_ENTRY:
903e28d50a8SBill Wendling
904e28d50a8SBill WendlingPARAMATTR_CODE_ENTRY Record
905e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^^
906e28d50a8SBill Wendling
907472a1419SMehdi Amini``[ENTRY, attrgrp0, attrgrp1, ...]``
908472a1419SMehdi Amini
909472a1419SMehdi AminiThe ``ENTRY`` record (code 2) contains a variable number of values describing a
910472a1419SMehdi Aminiunique set of function parameter attributes. Each *attrgrp* value is used as a
911760c0c9eSHiroshi Inouekey with which to look up an entry in the attribute group table described
912472a1419SMehdi Aminiin the ``PARAMATTR_GROUP_BLOCK`` block.
913472a1419SMehdi Amini
914472a1419SMehdi Amini.. _PARAMATTR_CODE_ENTRY_OLD:
915472a1419SMehdi Amini
916472a1419SMehdi AminiPARAMATTR_CODE_ENTRY_OLD Record
917472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
918472a1419SMehdi Amini
919472a1419SMehdi Amini.. note::
920472a1419SMehdi Amini  This is a legacy encoding for attributes, produced by LLVM versions 3.2 and
921472a1419SMehdi Amini  earlier. It is guaranteed to be understood by the current LLVM version, as
922472a1419SMehdi Amini  specified in the :ref:`IR backwards compatibility` policy.
923472a1419SMehdi Amini
924e28d50a8SBill Wendling``[ENTRY, paramidx0, attr0, paramidx1, attr1...]``
925e28d50a8SBill Wendling
926e28d50a8SBill WendlingThe ``ENTRY`` record (code 1) contains an even number of values describing a
927e28d50a8SBill Wendlingunique set of function parameter attributes. Each *paramidx* value indicates
928e28d50a8SBill Wendlingwhich set of attributes is represented, with 0 representing the return value
929e28d50a8SBill Wendlingattributes, 0xFFFFFFFF representing function attributes, and other values
930e28d50a8SBill Wendlingrepresenting 1-based function parameters. Each *attr* value is a bitmap with the
931e28d50a8SBill Wendlingfollowing interpretation:
932e28d50a8SBill Wendling
933e28d50a8SBill Wendling* bit 0: ``zeroext``
934e28d50a8SBill Wendling* bit 1: ``signext``
935e28d50a8SBill Wendling* bit 2: ``noreturn``
936e28d50a8SBill Wendling* bit 3: ``inreg``
937e28d50a8SBill Wendling* bit 4: ``sret``
938e28d50a8SBill Wendling* bit 5: ``nounwind``
939e28d50a8SBill Wendling* bit 6: ``noalias``
940e28d50a8SBill Wendling* bit 7: ``byval``
941e28d50a8SBill Wendling* bit 8: ``nest``
942e28d50a8SBill Wendling* bit 9: ``readnone``
943e28d50a8SBill Wendling* bit 10: ``readonly``
944e28d50a8SBill Wendling* bit 11: ``noinline``
945e28d50a8SBill Wendling* bit 12: ``alwaysinline``
946e28d50a8SBill Wendling* bit 13: ``optsize``
947e28d50a8SBill Wendling* bit 14: ``ssp``
948e28d50a8SBill Wendling* bit 15: ``sspreq``
949e28d50a8SBill Wendling* bits 16-31: ``align n``
950e28d50a8SBill Wendling* bit 32: ``nocapture``
951e28d50a8SBill Wendling* bit 33: ``noredzone``
952e28d50a8SBill Wendling* bit 34: ``noimplicitfloat``
953e28d50a8SBill Wendling* bit 35: ``naked``
954e28d50a8SBill Wendling* bit 36: ``inlinehint``
955e28d50a8SBill Wendling* bits 37-39: ``alignstack n``, represented as the logarithm
956e28d50a8SBill Wendling  base 2 of the requested alignment, plus 1
957e28d50a8SBill Wendling
958472a1419SMehdi Amini.. _PARAMATTR_GROUP_BLOCK:
959472a1419SMehdi Amini
960472a1419SMehdi AminiPARAMATTR_GROUP_BLOCK Contents
961472a1419SMehdi Amini------------------------------
962472a1419SMehdi Amini
963472a1419SMehdi AminiThe ``PARAMATTR_GROUP_BLOCK`` block (id 10) contains a table of entries
964472a1419SMehdi Aminidescribing the attribute groups present in the module. These entries can be
965472a1419SMehdi Aminireferenced within ``PARAMATTR_CODE_ENTRY`` entries.
966472a1419SMehdi Amini
967472a1419SMehdi Amini.. _PARAMATTR_GRP_CODE_ENTRY:
968472a1419SMehdi Amini
969472a1419SMehdi AminiPARAMATTR_GRP_CODE_ENTRY Record
970472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
971472a1419SMehdi Amini
972472a1419SMehdi Amini``[ENTRY, grpid, paramidx, attr0, attr1, ...]``
973472a1419SMehdi Amini
974472a1419SMehdi AminiThe ``ENTRY`` record (code 3) contains *grpid* and *paramidx* values, followed
975472a1419SMehdi Aminiby a variable number of values describing a unique group of attributes. The
976472a1419SMehdi Amini*grpid* value is a unique key for the attribute group, which can be referenced
977472a1419SMehdi Aminiwithin ``PARAMATTR_CODE_ENTRY`` entries. The *paramidx* value indicates which
978472a1419SMehdi Aminiset of attributes is represented, with 0 representing the return value
979472a1419SMehdi Aminiattributes, 0xFFFFFFFF representing function attributes, and other values
980472a1419SMehdi Aminirepresenting 1-based function parameters.
981472a1419SMehdi Amini
982472a1419SMehdi AminiEach *attr* is itself represented as a variable number of values:
983472a1419SMehdi Amini
984472a1419SMehdi Amini``kind, key [, ...], [value [, ...]]``
985472a1419SMehdi Amini
986472a1419SMehdi AminiEach attribute is either a well-known LLVM attribute (possibly with an integer
987472a1419SMehdi Aminivalue associated with it), or an arbitrary string (possibly with an arbitrary
988472a1419SMehdi Aministring value associated with it). The *kind* value is an integer code
989472a1419SMehdi Aminidistinguishing between these possibilities:
990472a1419SMehdi Amini
991472a1419SMehdi Amini* code 0: well-known attribute
992472a1419SMehdi Amini* code 1: well-known attribute with an integer value
993472a1419SMehdi Amini* code 3: string attribute
994472a1419SMehdi Amini* code 4: string attribute with a string value
995472a1419SMehdi Amini
996472a1419SMehdi AminiFor well-known attributes (code 0 or 1), the *key* value is an integer code
997472a1419SMehdi Aminiidentifying the attribute. For attributes with an integer argument (code 1),
998472a1419SMehdi Aminithe *value* value indicates the argument.
999472a1419SMehdi Amini
1000472a1419SMehdi AminiFor string attributes (code 3 or 4), the *key* value is actually a variable
1001472a1419SMehdi Amininumber of values representing the bytes of a null-terminated string. For
1002472a1419SMehdi Aminiattributes with a string argument (code 4), the *value* value is similarly a
1003472a1419SMehdi Aminivariable number of values representing the bytes of a null-terminated string.
1004472a1419SMehdi Amini
1005472a1419SMehdi AminiThe integer codes are mapped to well-known attributes as follows.
1006472a1419SMehdi Amini
1007472a1419SMehdi Amini* code 1: ``align(<n>)``
1008472a1419SMehdi Amini* code 2: ``alwaysinline``
1009472a1419SMehdi Amini* code 3: ``byval``
1010472a1419SMehdi Amini* code 4: ``inlinehint``
1011472a1419SMehdi Amini* code 5: ``inreg``
1012472a1419SMehdi Amini* code 6: ``minsize``
1013472a1419SMehdi Amini* code 7: ``naked``
1014472a1419SMehdi Amini* code 8: ``nest``
1015472a1419SMehdi Amini* code 9: ``noalias``
1016472a1419SMehdi Amini* code 10: ``nobuiltin``
1017472a1419SMehdi Amini* code 11: ``nocapture``
101839248779SFangrui Song* code 12: ``nodeduplicate``
1019472a1419SMehdi Amini* code 13: ``noimplicitfloat``
1020472a1419SMehdi Amini* code 14: ``noinline``
1021472a1419SMehdi Amini* code 15: ``nonlazybind``
1022472a1419SMehdi Amini* code 16: ``noredzone``
1023472a1419SMehdi Amini* code 17: ``noreturn``
1024472a1419SMehdi Amini* code 18: ``nounwind``
1025472a1419SMehdi Amini* code 19: ``optsize``
1026472a1419SMehdi Amini* code 20: ``readnone``
1027472a1419SMehdi Amini* code 21: ``readonly``
1028472a1419SMehdi Amini* code 22: ``returned``
1029472a1419SMehdi Amini* code 23: ``returns_twice``
1030472a1419SMehdi Amini* code 24: ``signext``
1031472a1419SMehdi Amini* code 25: ``alignstack(<n>)``
1032472a1419SMehdi Amini* code 26: ``ssp``
1033472a1419SMehdi Amini* code 27: ``sspreq``
1034472a1419SMehdi Amini* code 28: ``sspstrong``
1035472a1419SMehdi Amini* code 29: ``sret``
1036472a1419SMehdi Amini* code 30: ``sanitize_address``
1037472a1419SMehdi Amini* code 31: ``sanitize_thread``
1038472a1419SMehdi Amini* code 32: ``sanitize_memory``
1039472a1419SMehdi Amini* code 33: ``uwtable``
1040472a1419SMehdi Amini* code 34: ``zeroext``
1041472a1419SMehdi Amini* code 35: ``builtin``
1042472a1419SMehdi Amini* code 36: ``cold``
1043472a1419SMehdi Amini* code 37: ``optnone``
1044472a1419SMehdi Amini* code 38: ``inalloca``
1045472a1419SMehdi Amini* code 39: ``nonnull``
1046472a1419SMehdi Amini* code 40: ``jumptable``
1047472a1419SMehdi Amini* code 41: ``dereferenceable(<n>)``
1048472a1419SMehdi Amini* code 42: ``dereferenceable_or_null(<n>)``
1049472a1419SMehdi Amini* code 43: ``convergent``
1050472a1419SMehdi Amini* code 44: ``safestack``
1051472a1419SMehdi Amini* code 45: ``argmemonly``
1052472a1419SMehdi Amini* code 46: ``swiftself``
1053472a1419SMehdi Amini* code 47: ``swifterror``
1054472a1419SMehdi Amini* code 48: ``norecurse``
1055472a1419SMehdi Amini* code 49: ``inaccessiblememonly``
1056472a1419SMehdi Amini* code 50: ``inaccessiblememonly_or_argmemonly``
1057472a1419SMehdi Amini* code 51: ``allocsize(<EltSizeParam>[, <NumEltsParam>])``
1058472a1419SMehdi Amini* code 52: ``writeonly``
1059cdf1abc3SEvgeniy Stepanov* code 53: ``speculatable``
1060cdf1abc3SEvgeniy Stepanov* code 54: ``strictfp``
1061c667c1f4SEvgeniy Stepanov* code 55: ``sanitize_hwaddress``
1062fdd72fd5SOren Ben Simhon* code 56: ``nocf_check``
10633181941bSMatt Morehouse* code 57: ``optforfuzzing``
1064d17f61eaSVlad Tsyrklevich* code 58: ``shadowcallstack``
10659aa9855aSGui Andrade* code 59: ``speculative_load_hardening``
10669aa9855aSGui Andrade* code 60: ``immarg``
10679aa9855aSGui Andrade* code 61: ``willreturn``
10689aa9855aSGui Andrade* code 62: ``nofree``
10699aa9855aSGui Andrade* code 63: ``nosync``
1070c5e7f562SEvgeniy Stepanov* code 64: ``sanitize_memtag``
10719aa9855aSGui Andrade* code 65: ``preallocated``
10729aa9855aSGui Andrade* code 66: ``no_merge``
10739aa9855aSGui Andrade* code 67: ``null_pointer_is_valid``
107489f1ad88SGui Andrade* code 68: ``noundef``
10754abaf0ecSNick Desaulniers* code 69: ``byref``
10764abaf0ecSNick Desaulniers* code 70: ``mustprogress``
107748f5a392SBradley Smith* code 74: ``vscale_range(<Min>[, <Max>])``
107828033302SMarco Elver* code 75: ``swiftasync``
107928033302SMarco Elver* code 76: ``nosanitize_coverage``
1080b0391dfcSAlexander Potapenko* code 77: ``elementtype``
1081b0391dfcSAlexander Potapenko* code 78: ``disable_sanitizer_instrumentation``
108217ce89faSTong Zhang* code 79: ``nosanitize_bounds``
1083472a1419SMehdi Amini
1084472a1419SMehdi Amini.. note::
1085472a1419SMehdi Amini  The ``allocsize`` attribute has a special encoding for its arguments. Its two
1086472a1419SMehdi Amini  arguments, which are 32-bit integers, are packed into one 64-bit integer value
1087472a1419SMehdi Amini  (i.e. ``(EltSizeParam << 32) | NumEltsParam``), with ``NumEltsParam`` taking on
1088472a1419SMehdi Amini  the sentinel value -1 if it is not specified.
1089472a1419SMehdi Amini
109048f5a392SBradley Smith.. note::
109148f5a392SBradley Smith  The ``vscale_range`` attribute has a special encoding for its arguments. Its two
109248f5a392SBradley Smith  arguments, which are 32-bit integers, are packed into one 64-bit integer value
109348f5a392SBradley Smith  (i.e. ``(Min << 32) | Max``), with ``Max`` taking on the value of ``Min`` if
109448f5a392SBradley Smith  it is not specified.
109548f5a392SBradley Smith
1096e28d50a8SBill Wendling.. _TYPE_BLOCK:
1097e28d50a8SBill Wendling
1098e28d50a8SBill WendlingTYPE_BLOCK Contents
1099e28d50a8SBill Wendling-------------------
1100e28d50a8SBill Wendling
1101472a1419SMehdi AminiThe ``TYPE_BLOCK`` block (id 17) contains records which constitute a table of
1102e28d50a8SBill Wendlingtype operator entries used to represent types referenced within an LLVM
1103e28d50a8SBill Wendlingmodule. Each record (with the exception of `NUMENTRY`_) generates a single type
1104e28d50a8SBill Wendlingtable entry, which may be referenced by 0-based index from instructions,
1105e28d50a8SBill Wendlingconstants, metadata, type symbol table entries, or other type operator records.
1106e28d50a8SBill Wendling
1107e28d50a8SBill WendlingEntries within ``TYPE_BLOCK`` are constructed to ensure that each entry is
1108e9ffb45bSBruce Mitchenerunique (i.e., no two indices represent structurally equivalent types).
1109e28d50a8SBill Wendling
1110e28d50a8SBill Wendling.. _TYPE_CODE_NUMENTRY:
1111e28d50a8SBill Wendling.. _NUMENTRY:
1112e28d50a8SBill Wendling
1113e28d50a8SBill WendlingTYPE_CODE_NUMENTRY Record
1114e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^
1115e28d50a8SBill Wendling
1116e28d50a8SBill Wendling``[NUMENTRY, numentries]``
1117e28d50a8SBill Wendling
1118e28d50a8SBill WendlingThe ``NUMENTRY`` record (code 1) contains a single value which indicates the
1119e28d50a8SBill Wendlingtotal number of type code entries in the type table of the module. If present,
1120e28d50a8SBill Wendling``NUMENTRY`` should be the first record in the block.
1121e28d50a8SBill Wendling
1122e28d50a8SBill WendlingTYPE_CODE_VOID Record
1123e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^
1124e28d50a8SBill Wendling
1125e28d50a8SBill Wendling``[VOID]``
1126e28d50a8SBill Wendling
1127e28d50a8SBill WendlingThe ``VOID`` record (code 2) adds a ``void`` type to the type table.
1128e28d50a8SBill Wendling
1129e28d50a8SBill WendlingTYPE_CODE_HALF Record
1130e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^
1131e28d50a8SBill Wendling
1132e28d50a8SBill Wendling``[HALF]``
1133e28d50a8SBill Wendling
1134e28d50a8SBill WendlingThe ``HALF`` record (code 10) adds a ``half`` (16-bit floating point) type to
1135e28d50a8SBill Wendlingthe type table.
1136e28d50a8SBill Wendling
11378c24f331STies StuijTYPE_CODE_BFLOAT Record
1138628f008bSJinsong Ji^^^^^^^^^^^^^^^^^^^^^^^
11398c24f331STies Stuij
11408c24f331STies Stuij``[BFLOAT]``
11418c24f331STies Stuij
11428c24f331STies StuijThe ``BFLOAT`` record (code 23) adds a ``bfloat`` (16-bit brain floating point)
11438c24f331STies Stuijtype to the type table.
11448c24f331STies Stuij
1145e28d50a8SBill WendlingTYPE_CODE_FLOAT Record
1146e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^
1147e28d50a8SBill Wendling
1148e28d50a8SBill Wendling``[FLOAT]``
1149e28d50a8SBill Wendling
1150e28d50a8SBill WendlingThe ``FLOAT`` record (code 3) adds a ``float`` (32-bit floating point) type to
1151e28d50a8SBill Wendlingthe type table.
1152e28d50a8SBill Wendling
1153e28d50a8SBill WendlingTYPE_CODE_DOUBLE Record
1154e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^
1155e28d50a8SBill Wendling
1156e28d50a8SBill Wendling``[DOUBLE]``
1157e28d50a8SBill Wendling
1158e28d50a8SBill WendlingThe ``DOUBLE`` record (code 4) adds a ``double`` (64-bit floating point) type to
1159e28d50a8SBill Wendlingthe type table.
1160e28d50a8SBill Wendling
1161e28d50a8SBill WendlingTYPE_CODE_LABEL Record
1162e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^
1163e28d50a8SBill Wendling
1164e28d50a8SBill Wendling``[LABEL]``
1165e28d50a8SBill Wendling
1166e28d50a8SBill WendlingThe ``LABEL`` record (code 5) adds a ``label`` type to the type table.
1167e28d50a8SBill Wendling
1168e28d50a8SBill WendlingTYPE_CODE_OPAQUE Record
1169e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^
1170e28d50a8SBill Wendling
1171e28d50a8SBill Wendling``[OPAQUE]``
1172e28d50a8SBill Wendling
1173472a1419SMehdi AminiThe ``OPAQUE`` record (code 6) adds an ``opaque`` type to the type table, with
1174472a1419SMehdi Aminia name defined by a previously encountered ``STRUCT_NAME`` record. Note that
1175472a1419SMehdi Aminidistinct ``opaque`` types are not unified.
1176e28d50a8SBill Wendling
1177e28d50a8SBill WendlingTYPE_CODE_INTEGER Record
1178e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^
1179e28d50a8SBill Wendling
1180e28d50a8SBill Wendling``[INTEGER, width]``
1181e28d50a8SBill Wendling
1182e28d50a8SBill WendlingThe ``INTEGER`` record (code 7) adds an integer type to the type table. The
1183e28d50a8SBill Wendlingsingle *width* field indicates the width of the integer type.
1184e28d50a8SBill Wendling
1185e28d50a8SBill WendlingTYPE_CODE_POINTER Record
1186e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^
1187e28d50a8SBill Wendling
1188e28d50a8SBill Wendling``[POINTER, pointee type, address space]``
1189e28d50a8SBill Wendling
1190e28d50a8SBill WendlingThe ``POINTER`` record (code 8) adds a pointer type to the type table. The
1191e28d50a8SBill Wendlingoperand fields are
1192e28d50a8SBill Wendling
1193e28d50a8SBill Wendling* *pointee type*: The type index of the pointed-to type
1194e28d50a8SBill Wendling
1195e28d50a8SBill Wendling* *address space*: If supplied, the target-specific numbered address space where
1196e28d50a8SBill Wendling  the pointed-to object resides. Otherwise, the default address space is zero.
1197e28d50a8SBill Wendling
1198472a1419SMehdi AminiTYPE_CODE_FUNCTION_OLD Record
1199472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1200e28d50a8SBill Wendling
1201472a1419SMehdi Amini.. note::
1202472a1419SMehdi Amini  This is a legacy encoding for functions, produced by LLVM versions 3.0 and
1203472a1419SMehdi Amini  earlier. It is guaranteed to be understood by the current LLVM version, as
1204472a1419SMehdi Amini  specified in the :ref:`IR backwards compatibility` policy.
1205e28d50a8SBill Wendling
1206472a1419SMehdi Amini``[FUNCTION_OLD, vararg, ignored, retty, ...paramty... ]``
1207472a1419SMehdi Amini
1208472a1419SMehdi AminiThe ``FUNCTION_OLD`` record (code 9) adds a function type to the type table.
1209472a1419SMehdi AminiThe operand fields are
1210e28d50a8SBill Wendling
1211e28d50a8SBill Wendling* *vararg*: Non-zero if the type represents a varargs function
1212e28d50a8SBill Wendling
1213e28d50a8SBill Wendling* *ignored*: This value field is present for backward compatibility only, and is
1214e28d50a8SBill Wendling  ignored
1215e28d50a8SBill Wendling
1216e28d50a8SBill Wendling* *retty*: The type index of the function's return type
1217e28d50a8SBill Wendling
1218e28d50a8SBill Wendling* *paramty*: Zero or more type indices representing the parameter types of the
1219e28d50a8SBill Wendling  function
1220e28d50a8SBill Wendling
1221e28d50a8SBill WendlingTYPE_CODE_ARRAY Record
1222e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^
1223e28d50a8SBill Wendling
1224e28d50a8SBill Wendling``[ARRAY, numelts, eltty]``
1225e28d50a8SBill Wendling
1226e28d50a8SBill WendlingThe ``ARRAY`` record (code 11) adds an array type to the type table.  The
1227e28d50a8SBill Wendlingoperand fields are
1228e28d50a8SBill Wendling
1229e28d50a8SBill Wendling* *numelts*: The number of elements in arrays of this type
1230e28d50a8SBill Wendling
1231e28d50a8SBill Wendling* *eltty*: The type index of the array element type
1232e28d50a8SBill Wendling
1233e28d50a8SBill WendlingTYPE_CODE_VECTOR Record
1234e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^
1235e28d50a8SBill Wendling
1236e28d50a8SBill Wendling``[VECTOR, numelts, eltty]``
1237e28d50a8SBill Wendling
1238e28d50a8SBill WendlingThe ``VECTOR`` record (code 12) adds a vector type to the type table.  The
1239e28d50a8SBill Wendlingoperand fields are
1240e28d50a8SBill Wendling
1241e28d50a8SBill Wendling* *numelts*: The number of elements in vectors of this type
1242e28d50a8SBill Wendling
1243e28d50a8SBill Wendling* *eltty*: The type index of the vector element type
1244e28d50a8SBill Wendling
1245e28d50a8SBill WendlingTYPE_CODE_X86_FP80 Record
1246e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^
1247e28d50a8SBill Wendling
1248e28d50a8SBill Wendling``[X86_FP80]``
1249e28d50a8SBill Wendling
1250e28d50a8SBill WendlingThe ``X86_FP80`` record (code 13) adds an ``x86_fp80`` (80-bit floating point)
1251e28d50a8SBill Wendlingtype to the type table.
1252e28d50a8SBill Wendling
1253e28d50a8SBill WendlingTYPE_CODE_FP128 Record
1254e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^
1255e28d50a8SBill Wendling
1256e28d50a8SBill Wendling``[FP128]``
1257e28d50a8SBill Wendling
1258e28d50a8SBill WendlingThe ``FP128`` record (code 14) adds an ``fp128`` (128-bit floating point) type
1259e28d50a8SBill Wendlingto the type table.
1260e28d50a8SBill Wendling
1261e28d50a8SBill WendlingTYPE_CODE_PPC_FP128 Record
1262e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^^
1263e28d50a8SBill Wendling
1264e28d50a8SBill Wendling``[PPC_FP128]``
1265e28d50a8SBill Wendling
1266e28d50a8SBill WendlingThe ``PPC_FP128`` record (code 15) adds a ``ppc_fp128`` (128-bit floating point)
1267e28d50a8SBill Wendlingtype to the type table.
1268e28d50a8SBill Wendling
1269e28d50a8SBill WendlingTYPE_CODE_METADATA Record
1270e28d50a8SBill Wendling^^^^^^^^^^^^^^^^^^^^^^^^^
1271e28d50a8SBill Wendling
1272e28d50a8SBill Wendling``[METADATA]``
1273e28d50a8SBill Wendling
1274e28d50a8SBill WendlingThe ``METADATA`` record (code 16) adds a ``metadata`` type to the type table.
1275e28d50a8SBill Wendling
1276472a1419SMehdi AminiTYPE_CODE_X86_MMX Record
1277472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^
1278472a1419SMehdi Amini
1279472a1419SMehdi Amini``[X86_MMX]``
1280472a1419SMehdi Amini
1281472a1419SMehdi AminiThe ``X86_MMX`` record (code 17) adds an ``x86_mmx`` type to the type table.
1282472a1419SMehdi Amini
1283472a1419SMehdi AminiTYPE_CODE_STRUCT_ANON Record
1284472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1285472a1419SMehdi Amini
1286472a1419SMehdi Amini``[STRUCT_ANON, ispacked, ...eltty...]``
1287472a1419SMehdi Amini
1288472a1419SMehdi AminiThe ``STRUCT_ANON`` record (code 18) adds a literal struct type to the type
1289472a1419SMehdi Aminitable. The operand fields are
1290472a1419SMehdi Amini
1291472a1419SMehdi Amini* *ispacked*: Non-zero if the type represents a packed structure
1292472a1419SMehdi Amini
1293472a1419SMehdi Amini* *eltty*: Zero or more type indices representing the element types of the
1294472a1419SMehdi Amini  structure
1295472a1419SMehdi Amini
1296472a1419SMehdi AminiTYPE_CODE_STRUCT_NAME Record
1297472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1298472a1419SMehdi Amini
1299472a1419SMehdi Amini``[STRUCT_NAME, ...string...]``
1300472a1419SMehdi Amini
1301472a1419SMehdi AminiThe ``STRUCT_NAME`` record (code 19) contains a variable number of values
1302472a1419SMehdi Aminirepresenting the bytes of a struct name. The next ``OPAQUE`` or
1303472a1419SMehdi Amini``STRUCT_NAMED`` record will use this name.
1304472a1419SMehdi Amini
1305472a1419SMehdi AminiTYPE_CODE_STRUCT_NAMED Record
1306472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1307472a1419SMehdi Amini
1308472a1419SMehdi Amini``[STRUCT_NAMED, ispacked, ...eltty...]``
1309472a1419SMehdi Amini
1310472a1419SMehdi AminiThe ``STRUCT_NAMED`` record (code 20) adds an identified struct type to the
1311472a1419SMehdi Aminitype table, with a name defined by a previously encountered ``STRUCT_NAME``
1312472a1419SMehdi Aminirecord. The operand fields are
1313472a1419SMehdi Amini
1314472a1419SMehdi Amini* *ispacked*: Non-zero if the type represents a packed structure
1315472a1419SMehdi Amini
1316472a1419SMehdi Amini* *eltty*: Zero or more type indices representing the element types of the
1317472a1419SMehdi Amini  structure
1318472a1419SMehdi Amini
1319472a1419SMehdi AminiTYPE_CODE_FUNCTION Record
1320472a1419SMehdi Amini^^^^^^^^^^^^^^^^^^^^^^^^^
1321472a1419SMehdi Amini
1322472a1419SMehdi Amini``[FUNCTION, vararg, retty, ...paramty... ]``
1323472a1419SMehdi Amini
1324472a1419SMehdi AminiThe ``FUNCTION`` record (code 21) adds a function type to the type table. The
1325472a1419SMehdi Aminioperand fields are
1326472a1419SMehdi Amini
1327472a1419SMehdi Amini* *vararg*: Non-zero if the type represents a varargs function
1328472a1419SMehdi Amini
1329472a1419SMehdi Amini* *retty*: The type index of the function's return type
1330472a1419SMehdi Amini
1331472a1419SMehdi Amini* *paramty*: Zero or more type indices representing the parameter types of the
1332472a1419SMehdi Amini  function
1333472a1419SMehdi Amini
1334519cf6e8SLuo, YuankeTYPE_CODE_X86_AMX Record
1335519cf6e8SLuo, Yuanke^^^^^^^^^^^^^^^^^^^^^^^^
1336519cf6e8SLuo, Yuanke
1337519cf6e8SLuo, Yuanke``[X86_AMX]``
1338519cf6e8SLuo, Yuanke
1339519cf6e8SLuo, YuankeThe ``X86_AMX`` record (code 24) adds an ``x86_amx`` type to the type table.
1340519cf6e8SLuo, Yuanke
1341e28d50a8SBill Wendling.. _CONSTANTS_BLOCK:
1342e28d50a8SBill Wendling
1343e28d50a8SBill WendlingCONSTANTS_BLOCK Contents
1344e28d50a8SBill Wendling------------------------
1345e28d50a8SBill Wendling
1346e28d50a8SBill WendlingThe ``CONSTANTS_BLOCK`` block (id 11) ...
1347e28d50a8SBill Wendling
1348e28d50a8SBill Wendling.. _FUNCTION_BLOCK:
1349e28d50a8SBill Wendling
1350e28d50a8SBill WendlingFUNCTION_BLOCK Contents
1351e28d50a8SBill Wendling-----------------------
1352e28d50a8SBill Wendling
1353e28d50a8SBill WendlingThe ``FUNCTION_BLOCK`` block (id 12) ...
1354e28d50a8SBill Wendling
1355e28d50a8SBill WendlingIn addition to the record types described below, a ``FUNCTION_BLOCK`` block may
1356e28d50a8SBill Wendlingcontain the following sub-blocks:
1357e28d50a8SBill Wendling
1358e28d50a8SBill Wendling* `CONSTANTS_BLOCK`_
1359e28d50a8SBill Wendling* `VALUE_SYMTAB_BLOCK`_
1360e28d50a8SBill Wendling* `METADATA_ATTACHMENT`_
1361e28d50a8SBill Wendling
1362e28d50a8SBill Wendling.. _VALUE_SYMTAB_BLOCK:
1363e28d50a8SBill Wendling
1364e28d50a8SBill WendlingVALUE_SYMTAB_BLOCK Contents
1365e28d50a8SBill Wendling---------------------------
1366e28d50a8SBill Wendling
1367e28d50a8SBill WendlingThe ``VALUE_SYMTAB_BLOCK`` block (id 14) ...
1368e28d50a8SBill Wendling
1369e28d50a8SBill Wendling.. _METADATA_BLOCK:
1370e28d50a8SBill Wendling
1371e28d50a8SBill WendlingMETADATA_BLOCK Contents
1372e28d50a8SBill Wendling-----------------------
1373e28d50a8SBill Wendling
1374e28d50a8SBill WendlingThe ``METADATA_BLOCK`` block (id 15) ...
1375e28d50a8SBill Wendling
1376e28d50a8SBill Wendling.. _METADATA_ATTACHMENT:
1377e28d50a8SBill Wendling
1378e28d50a8SBill WendlingMETADATA_ATTACHMENT Contents
1379e28d50a8SBill Wendling----------------------------
1380e28d50a8SBill Wendling
1381e28d50a8SBill WendlingThe ``METADATA_ATTACHMENT`` block (id 16) ...
1382a0f371a1SPeter Collingbourne
1383a0f371a1SPeter Collingbourne.. _STRTAB_BLOCK:
1384a0f371a1SPeter Collingbourne
1385a0f371a1SPeter CollingbourneSTRTAB_BLOCK Contents
1386a0f371a1SPeter Collingbourne---------------------
1387a0f371a1SPeter Collingbourne
1388a0f371a1SPeter CollingbourneThe ``STRTAB`` block (id 23) contains a single record (``STRTAB_BLOB``, id 1)
1389a0f371a1SPeter Collingbournewith a single blob operand containing the bitcode file's string table.
1390a0f371a1SPeter Collingbourne
1391a0f371a1SPeter CollingbourneStrings in the string table are not null terminated. A record's *strtab
1392a0f371a1SPeter Collingbourneoffset* and *strtab size* operands specify the byte offset and size of a
1393a0f371a1SPeter Collingbournestring within the string table.
1394a0f371a1SPeter Collingbourne
1395a0f371a1SPeter CollingbourneThe string table is used by all preceding blocks in the bitcode file that are
1396a0f371a1SPeter Collingbournenot succeeded by another intervening ``STRTAB`` block. Normally a bitcode
1397a0f371a1SPeter Collingbournefile will have a single string table, but it may have more than one if it
1398a0f371a1SPeter Collingbournewas created by binary concatenation of multiple bitcode files.
1399