aboutsummaryrefslogtreecommitdiffstats
path: root/docs/BitCodeFormat.html
blob: 949de94698284f8a8ef0a177d914b1b11b1f3047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>LLVM Bitcode File Format</title>
  <link rel="stylesheet" href="llvm.css" type="text/css">
</head>
<body>
<div class="doc_title"> LLVM Bitcode File Format </div>
<ol>
  <li><a href="#abstract">Abstract</a></li>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#bitstream">Bitstream Format</a>
    <ol>
    <li><a href="#magic">Magic Numbers</a></li>
    </ol>
  </li>
  <li><a href="#llvmir">LLVM IR Encoding</a></li>
</ol>
<div class="doc_author">
  <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>.
</p>
</div>

<!-- *********************************************************************** -->
<div class="doc_section"> <a name="abstract">Abstract</a></div>
<!-- *********************************************************************** -->

<div class="doc_text">

<p>This document describes the LLVM bitstream file format and the encoding of
the LLVM IR into it.</p>

</div>

<!-- *********************************************************************** -->
<div class="doc_section"> <a name="overview">Overview</a></div>
<!-- *********************************************************************** -->

<div class="doc_text">

<p>
What is commonly known as the LLVM bitcode file format (also, sometimes
anachronistically known as bytecode) is actually two things: a <a 
href="#bitstream">bitstream container format</a>
and an <a href="#llvmir">encoding of LLVM IR</a> into the container format.</p>

<p>
The bitstream format is an abstract encoding of structured data, like very
similar to XML in some ways.  Like XML, bitstream files contain tags, and nested
structures, and you can parse the file without having to understand the tags.
Unlike XML, the bitstream format is a binary encoding, and unlike XML it
provides a mechanism for the file to self-describe "abbreviations", which are
effectively size optimizations for the content.</p>

<p>This document first describes the LLVM bitstream format, then describes the
record structure used by LLVM IR files.
</p>

</div>

<!-- *********************************************************************** -->
<div class="doc_section"> <a name="bitstream">Bitstream Format</a></div>
<!-- *********************************************************************** -->

<div class="doc_text">

<p>
The bitstream format is literally a stream of bits, with a very simple
structure.  This structure consists of the following concepts:
</p>

<ul>
<li>A magic number that identifies the stream.</li>
<li>Encoding primitives like variable bit-rate integers.</li> 
<li>Blocks, which define nested content.</li> 
<li>Data Records, which describe entities within the file.</li> 
<li>Abbreviations, which specify compression optimizations for the file.</li> 
</ul>

<p>Note that the <a 
href="CommandGuide/html/llvm-bcanalyzer.html">llvm-bcanalyzer</a> tool can be
used to dump and inspect arbitrary bitstreams, which is very useful for
understanding the encoding.</p>

</div>

<!-- ======================================================================= -->
<div class="doc_subsection"><a name="magic">Magic Numbers</a>
</div>

<div class="doc_text">

<p>LLVM </p>

</div>


<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection"> <a name="wellformed">Well-Formedness</a> </div>

<div class="doc_text">

<p>blah
</p>

</div>

<!-- *********************************************************************** -->
<div class="doc_section"> <a name="llvmir">LLVM IR Encoding</a></div>
<!-- *********************************************************************** -->

<div class="doc_text">

<p></p>

</div>


<!-- *********************************************************************** -->
<hr>
<address> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
<a href="http://validator.w3.org/check/referer"><img
 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
<a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>
Last modified: $Date$
</address>
</body>
</html>