Remove HAVE_BZLIB and HAVE_BZIP2. We always have bzip2 now.
[oota-llvm.git] / docs / BytecodeFormat.html
index 76365b4ea0df941a916f0291401aa9d14719df73..a7726c164476c6b3e308e3651efdccb2ba35bca1 100644 (file)
@@ -1,6 +1,7 @@
 <!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 Bytecode File Format</title>
   <link rel="stylesheet" href="llvm.css" type="text/css">
   <style type="text/css">
       <li><a href="#functiondefs">Function Definition</a></li>
       <li><a href="#compactiontable">Compaction Table</a></li>
       <li><a href="#instructionlist">Instruction List</a></li>
+      <li><a href="#opcodes">Instruction Opcodes</a></li>
       <li><a href="#symtab">Symbol Table</a></li>
     </ol>
   </li>
   <li><a href="#versiondiffs">Version Differences</a>
     <ol>
+      <li><a href="#vers13">Version 1.3 Differences From 1.4</a></li>
       <li><a href="#vers12">Version 1.2 Differences From 1.3</a></li>
       <li><a href="#vers11">Version 1.1 Differences From 1.2</a></li>
       <li><a href="#vers10">Version 1.0 Differences From 1.1</a></li>
@@ -397,10 +400,9 @@ slot numbers with their "type plane". That is, Values of the same type
 are written to the bytecode file in a list (sequentially). Their order in 
 that list determines their slot number. This means that slot #1 doesn't mean
 anything unless you also specify for which type you want slot #1. Types are
-handled specially and are always written to the file first (in the <a
- href="#globaltypes">Global Type Pool</a>) and in such a way that both forward 
-and backward references of the types can often be resolved with a single pass 
-through the type pool. </p>
+always written to the file first (in the <a href="#globaltypes">Global Type 
+Pool</a>) and in such a way that both forward and backward references of the 
+types can often be resolved with a single pass through the type pool. </p>
 <p>Slot numbers are also kept small by rearranging their order. Because
 of the structure of LLVM, certain values are much more likely to be used
 frequently in the body of a function. For this reason, a compaction table is
@@ -409,6 +411,10 @@ smaller.  Suppose you have a function body that uses just the types "int*" and
 "{double}" but uses them thousands of time. Its worthwhile to ensure that the 
 slot number for these types are low so they can be encoded in a single byte 
 (via vbr). This is exactly what the compaction table does.</p>
+<p>In summary then, a slot number can be though of as just a vbr encoded index 
+into a list of Type* or Value*. To keep slot numbers low, Value* are indexed by
+two slot numbers: the "type plane index" (type slot) and the "value index"
+(value slot).</p>
 </div>
 <!-- *********************************************************************** -->
 <div class="doc_section"> <a name="general">General Structure</a> </div>
@@ -574,30 +580,57 @@ bytecode file. This block is always four bytes in length and differs from the
 other blocks because there is no identifier and no block length at the start
 of the block. Essentially, this block is just the "magic number" for the file.
 </p>
+<p>There are two types of signatures for LLVM bytecode: uncompressed and
+compressed as shown in the table below. </p>
 <table>
   <tbody>
     <tr>
       <th><b>Type</b></th>
-      <th class="td_left"><b>Field Description</b></th>
+      <th class="td_left"><b>Uncompressed</b></th>
+      <th class="td_left"><b>Compressed</b></th>
     </tr>
     <tr>
       <td><a href="#char">char</a></td>
       <td class="td_left">Constant "l" (0x6C)</td>
+      <td class="td_left">Constant "l" (0x6C)</td>
     </tr>
     <tr>
       <td><a href="#char">char</a></td>
       <td class="td_left">Constant "l" (0x6C)</td>
+      <td class="td_left">Constant "l" (0x6C)</td>
     </tr>
     <tr>
       <td><a href="#char">char</a></td>
       <td class="td_left">Constant "v" (0x76)</td>
+      <td class="td_left">Constant "v" (0x76)</td>
     </tr>
     <tr>
       <td><a href="#char">char</a></td>
       <td class="td_left">Constant "m" (0x6D)</td>
+      <td class="td_left">Constant "c" (0x63)</td>
+    </tr>
+    <tr>
+      <td><a href="#char">char</a></td>
+      <td class="td_left">N/A</td>
+      <td class="td_left">'0'=null,'1'=gzip,'2'=bzip2</td>
     </tr>
   </tbody>
 </table>
+<p>In other words, the uncompressed signature is just the characters 'llvm'
+while the compressed signature is the characters 'llvc' followed by an ascii
+digit ('0', '1', or '2') that indicates the kind of compression used. A value of
+'0' indicates that null compression was used. This can happen when compression
+was requested on a platform that wasn't configured for gzip or bzip2. A value of
+'1' means that the rest of the file is compressed using the gzip algorithm and
+should be uncompressed before interpretation. A value of '2' means that the rest
+of the file is compressed using the bzip2 algorithm and should be uncompressed
+before interpretation. In all cases, the data resulting from uncompression
+should be interpreted as if it occurred immediately after the 'llvm'
+signature (i.e. the uncompressed data begins with the 
+<a href="#module">Module Block</a></p>
+<p><b>NOTE:</b> As of LLVM 1.4, all bytecode files produced by the LLVM tools
+are compressed by default. To disable compression, pass the 
+<tt>--disable-compression</tt> option to the tool, if it supports it.
 </div>
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection"><a name="module">Module Block</a> </div>
@@ -644,7 +677,7 @@ sections.</p>
     </tr>
     <tr>
       <td><a href="#block">block</a></td>
-      <td class="td_left"><a href="#symboltable">Module Symbol Table</a></td>
+      <td class="td_left"><a href="#symtab">Module Symbol Table</a></td>
     </tr>
   </tbody>
 </table>
@@ -720,7 +753,7 @@ triples</a>.
 <div class="doc_subsection"><a name="globaltypes">Global Type Pool</a> </div>
 <div class="doc_text">
 <p>The global type pool consists of type definitions. Their order of appearance
-in the file determines their slot number (0 based). Slot numbers are
+in the file determines their type slot number (0 based). Slot numbers are
 used to replace pointers in the intermediate representation. Each slot number 
 uniquely identifies one entry in a type plane (a collection of values of the
 same type).  Since all values have types and are associated with the order in 
@@ -754,7 +787,7 @@ table below.</p>
 of type, as given in the following sections.</p>
 <h3>Primitive Types</h3>
 <p>The primitive types encompass the basic integer and floating point
-types</p>
+types. They are encoded simply as their TypeID.</p>
 <table>
   <tbody>
     <tr>
@@ -802,11 +835,11 @@ following mapping:
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a></td>
-      <td class="td_left">Slot number of function's return type.</td>
+      <td class="td_left">Type slot number of function's return type.</td>
     </tr>
     <tr>
       <td><a href="#llist">llist</a>(<a href="#uint24_vbr">uint24_vbr</a>)</td>
-      <td class="td_left">Slot number of each argument's type.</td>
+      <td class="td_left">Type slot number of each argument's type.</td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a>?</td>
@@ -845,7 +878,7 @@ missing otherwise.</td>
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a></td>
-      <td class="td_left">Slot number of array's element type.</td>
+      <td class="td_left">Type slot number of array's element type.</td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a></td>
@@ -866,7 +899,7 @@ missing otherwise.</td>
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a></td>
-      <td class="td_left">Slot number of pointer's element type.</td>
+      <td class="td_left">Type slot number of pointer's element type.</td>
     </tr>
   </tbody>
 </table>
@@ -883,6 +916,27 @@ missing otherwise.</td>
     </tr>
   </tbody>
 </table>
+<h3>Packed Types</h3>
+<table>
+  <tbody>
+    <tr>
+      <th><b>Type</b></th>
+      <th class="td_left"><b>Description</b></th>
+    </tr>
+    <tr>
+      <td><a href="#uint24_vbr">uint24_vbr</a></td>
+      <td class="td_left">Type ID for Packed Types (18)</td>
+    </tr>
+    <tr>
+      <td><a href="#uint24_vbr">uint24_vbr</a></td>
+      <td class="td_left">Slot number of packed vector's element type.</td>
+    </tr>
+    <tr>
+      <td><a href="#uint32_vbr">uint32_vbr</a></td>
+      <td class="td_left">The number of elements in the packed vector.</td>
+    </tr>
+  </tbody>
+</table>
 </div>
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection"><a name="globalinfo">Module Global Info</a>
@@ -905,12 +959,12 @@ all functions. The format is shown in the table below:</p>
     <tr>
       <td><a href="#zlist">zlist</a>(<a href="#globalvar">globalvar</a>)</td>
       <td class="td_left">A zero terminated list of global var
-definitions occuring in the module.</td>
+definitions occurring in the module.</td>
     </tr>
     <tr>
-      <td><a href="#zlist">zlist</a>(<a href="#uint24_vbr">uint24_vbr</a>)</td>
-      <td class="td_left">A zero terminated list of function types
-occuring in the module.</td>
+      <td><a href="#zlist">zlist</a>(<a href="#funcfield">funcfield</a>)</td>
+      <td class="td_left">A zero terminated list of function definitions
+occurring in the module.</td>
     </tr>
     <tr>
       <td style="vertical-align: top;"><a href="#llist">llist</a>(<a
@@ -932,6 +986,7 @@ platform independent module).<br>
   </tbody>
 </table>
 </div>
+
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection"><a name="globalvar">Global Variable Field</a>
 </div>
@@ -964,7 +1019,7 @@ follows. </td>
     </tr>
     <tr>
       <td><a href="#bit">bit(5-31)</a></td>
-      <td class="td_left">Slot number of type for the global variable.</td>
+      <td class="td_left">Type slot number of type for the global variable.</td>
     </tr>
   </tbody>
 </table>
@@ -979,12 +1034,48 @@ the global variable field, if it has one.</p>
     <tr>
       <td>(<a href="#zlist">zlist</a>(<a href="#uint32_vbr">uint32_vbr</a>))?
       </td>
-      <td class="td_left">An optional zero-terminated list of slot
+      <td class="td_left">An optional zero-terminated list of value slot
 numbers of the global variable's constant initializer.</td>
     </tr>
   </tbody>
 </table>
 </div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection"><a name="funcfield">Function Field</a>
+</div>
+<div class="doc_text">
+<p>Functions are written using an <a href="#uint32_vbr">uint32_vbr</a>
+that encodes information about the function and a set of flags.</p>
+
+<p>The table below provides the bit layout of the <a
+href="#uint32_vbr">uint32_vbr</a> that describes the function.</p>
+
+<table>
+  <tbody>
+    <tr>
+      <th><b>Type</b></th>
+      <th class="td_left"><b>Description</b></th>
+    </tr>
+    <tr>
+      <td><a href="#bit">bit(0-3)</a></td>
+      <td class="td_left">Reserved for future use.  Currently set to 0001.</td>
+    </tr>
+    <tr>
+      <td><a href="#bit">bit(4)</a></td>
+      <td class="td_left">If this bit is set to 1, the indicated function is
+      external, and there is no <a href="#functiondefs">Function Definiton
+      Block</a> in the bytecode file for the function.</td>
+    </tr>
+    <tr>
+      <td><a href="#bit">bit(5-)</a></td>
+      <td class="td_left">Type slot number of type for the function.</td>
+    </tr>
+  </tbody>
+</table>
+
+</div>
+
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection"><a name="constantpool">Constant Pool</a> </div>
 <div class="doc_text">
@@ -1029,7 +1120,7 @@ uniquely from other constant planes that follow. </td>
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a>+</td>
-      <td class="td_left">Slot number of the constant string's type.
+      <td class="td_left">Type slot number of the constant string's type.
 Note that the constant string's type implicitly defines the length of
 the string. </td>
     </tr>
@@ -1064,7 +1155,7 @@ for the details. </p>
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection"><a name="constant">Constant Field</a></div>
 <div class="doc_text">
-<p>Constants come in many shapes and flavors. The sections that followe
+<p>Constants come in many shapes and flavors. The sections that follow
 define the format for each of them. All constants start with a <a
  href="#uint32_vbr">uint32_vbr</a> encoded integer that provides the
 number of operands for the constant. For primitive, structure, and
@@ -1082,14 +1173,19 @@ corresponding value. </li>
   <li><b>Floating Point</b>. Both the float and double types are
 written literally in binary format.</li>
   <li><b>Arrays</b>. Arrays are written simply as a list of <a
- href="#uint32_vbr">uint32_vbr</a> encoded slot numbers to the constant
+ href="#uint32_vbr">uint32_vbr</a> encoded value slot numbers to the constant
 element values.</li>
   <li><b>Structures</b>. Structures are written simply as a list of <a
- href="#uint32_vbr">uint32_vbr</a> encoded slot numbers to the constant
+ href="#uint32_vbr">uint32_vbr</a> encoded value slot numbers to the constant
 field values of the structure.</li>
 </ul>
-<p>When the number of operands to the constant is non-zero, we have a
-constant expression and its field format is provided in the table below.</p>
+
+<p>When the number of operands to the constant is one, we have an 'undef' value
+of the specified type.</p>
+
+<p>When the number of operands to the constant is greater than one, we have a
+constant expression and its field format is provided in the table below, and the
+number is equal to the number of operands+1.</p>
 <table>
   <tbody>
     <tr>
@@ -1103,12 +1199,12 @@ expression.</td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a></td>
-      <td class="td_left">The slot number of the constant value for an
+      <td class="td_left">The value slot number of the constant value for an
 operand.<sup>1</sup></td>
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a></td>
-      <td class="td_left">The slot number for the type of the constant
+      <td class="td_left">The type slot number for the type of the constant
 value for an operand.<sup>1</sup></td>
     </tr>
   </tbody>
@@ -1159,7 +1255,7 @@ list</a> for the function.</td>
     </tr>
     <tr>
       <td><a href="#block">block</a></td>
-      <td class="td_left">The function's <a href="#symboltable">symbol
+      <td class="td_left">The function's <a href="#symtab">symbol
 table</a> containing only those symbols pertinent to the function
 (mostly block labels).</td>
     </tr>
@@ -1180,7 +1276,7 @@ save bytecode space. If not, then a regular constant pool is written.</li>
 <div class="doc_text">
 <p>Compaction tables are part of a function definition. They are merely
 a device for reducing the size of bytecode files. The size of a
-bytecode file is dependent on the <em>value</em> of the slot numbers
+bytecode file is dependent on the <em>values</em> of the slot numbers
 used because larger values use more bytes in the variable bit rate
 encoding scheme. Furthermore, the compressed instruction format
 reserves only six bits for the type of the instruction. In large
@@ -1203,7 +1299,7 @@ both. Compaction tables have the format shown in the table below.</p>
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a>+</td>
-      <td class="td_left">The slot number in the global type plane of
+      <td class="td_left">The type slot number in the global types of
 the type that will be referenced in the function with the index of this
 entry in the compaction table.</td>
     </tr>
@@ -1216,9 +1312,9 @@ details.</td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a>+</td>
-      <td class="td_left">The slot number in the globals of the value
+      <td class="td_left">The value slot number in the global values
 that will be referenced in the function with the index of this entry in
-the compaction table</td>
+the compaction table.</td>
     </tr>
   </tbody>
 </table>
@@ -1236,8 +1332,7 @@ encoding uses a <a href="#uint32_vbr">uint32_vbr</a> for each of the
 length and type, in that order.</p>
 </div>
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsection"><a name="instructionlist">Instruction List</a>
-</div>
+<div class="doc_subsection"><a name="instructionlist">Instruction List</a></div>
 <div class="doc_text">
 <p>The instructions in a function are written as a simple list. Basic
 blocks are inferred by the terminating instruction types. The format of
@@ -1269,11 +1364,11 @@ of formats. See <a href="#instruction">Instructions</a> for details.</td>
 depending on the number of operands to the instruction. Each
 instruction begins with a <a href="#uint32_vbr">uint32_vbr</a> that
 encodes the type of the instruction as well as other things. The tables
-that follow describe the format of this first word of each instruction.</p>
+that follow describe the format of this first part of each instruction.</p>
 <p><b>Instruction Format 0</b></p>
 <p>This format is used for a few instructions that can't easily be
-optimized because they have large numbers of operands (e.g. PHI Node or
-getelementptr). Each of the opcode, type, and operand fields is as
+shortened because they have large numbers of operands (e.g. PHI Node or
+getelementptr). Each of the opcode, type, and operand fields is found in
 successive fields.</p>
 <table>
   <tbody>
@@ -1290,8 +1385,8 @@ format.</td>
     </tr>
     <tr>
       <td><a href="#uint24_vbr">uint24_vbr</a></td>
-      <td class="td_left">Provides the slot number of the result type
-of the instruction</td>
+      <td class="td_left">Provides the type slot number of the result type of
+        the instruction.</td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a></td>
@@ -1299,8 +1394,8 @@ of the instruction</td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a>+</td>
-      <td class="td_left">The slot number of the value(s) for the
-operand(s). <sup>1</sup></td>
+      <td class="td_left">The slot number of the value(s) for the operand(s).
+        <sup>1</sup></td>
     </tr>
   </tbody>
 </table>
@@ -1324,27 +1419,27 @@ single <a href="#uint32_vbr">uint32_vbr</a> as follows:</p>
     <tr>
       <td>0-1</td>
       <td>constant "1"</td>
-      <td class="td_left">These two bits must be the value 1 which
-identifies this as an instruction of format 1.</td>
+      <td class="td_left">These two bits must be the value 1 which identifies 
+        this as an instruction of format 1.</td>
     </tr>
     <tr>
       <td>2-7</td>
-      <td><a href="#opcodes">opcode</a></td>
-      <td class="td_left">Specifies the opcode of the instruction. Note
-that the maximum opcode value is 63.</td>
+      <td><a href="#opcode">opcode</a></td>
+      <td class="td_left">Specifies the opcode of the instruction. Note that 
+        the maximum opcode value is 63.</td>
     </tr>
     <tr>
       <td>8-19</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the type for
-this instruction. Maximum slot number is 2<sup>12</sup>-1=4095.</td>
+      <td class="td_left">Specifies the slot number of the type for this 
+        instruction. Maximum slot number is 2<sup>12</sup>-1=4095.</td>
     </tr>
     <tr>
       <td>20-31</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the value for
-the first operand. Maximum slot number is 2<sup>12</sup>-1=4095. Note
-that the value 2<sup>12</sup>-1 denotes zero operands.</td>
+      <td class="td_left">Specifies the slot number of the value for the 
+        first operand. Maximum slot number is 2<sup>12</sup>-1=4095. Note that 
+        the value 2<sup>12</sup>-1 denotes zero operands.</td>
     </tr>
   </tbody>
 </table>
@@ -1361,32 +1456,32 @@ that the value 2<sup>12</sup>-1 denotes zero operands.</td>
     <tr>
       <td>0-1</td>
       <td>constant "2"</td>
-      <td class="td_left">These two bits must be the value 2 which
-identifies this as an instruction of format 2.</td>
+      <td class="td_left">These two bits must be the value 2 which identifies 
+        this as an instruction of format 2.</td>
     </tr>
     <tr>
       <td>2-7</td>
       <td><a href="#opcodes">opcode</a></td>
-      <td class="td_left">Specifies the opcode of the instruction. Note
-that the maximum opcode value is 63.</td>
+      <td class="td_left">Specifies the opcode of the instruction. Note that 
+        the maximum opcode value is 63.</td>
     </tr>
     <tr>
       <td>8-15</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the type for
-this instruction. Maximum slot number is 2<sup>8</sup>-1=255.</td>
+      <td class="td_left">Specifies the slot number of the type for this 
+        instruction. Maximum slot number is 2<sup>8</sup>-1=255.</td>
     </tr>
     <tr>
       <td>16-23</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the value for
-the first operand. Maximum slot number is 2<sup>8</sup>-1=255.</td>
+      <td class="td_left">Specifies the slot number of the value for the first 
+        operand. Maximum slot number is 2<sup>8</sup>-1=255.</td>
     </tr>
     <tr>
       <td>24-31</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the value for
-the second operand. Maximum slot number is 2<sup>8</sup>-1=255.</td>
+      <td class="td_left">Specifies the slot number of the value for the second 
+        operand. Maximum slot number is 2<sup>8</sup>-1=255.</td>
     </tr>
   </tbody>
 </table>
@@ -1403,51 +1498,121 @@ single <a href="#uint32_vbr">uint32_vbr</a> as follows:</p>
     <tr>
       <td>0-1</td>
       <td>constant "3"</td>
-      <td class="td_left">These two bits must be the value 3 which
-identifies this as an instruction of format 3.</td>
+      <td class="td_left">These two bits must be the value 3 which identifies 
+        this as an instruction of format 3.</td>
     </tr>
     <tr>
       <td>2-7</td>
       <td><a href="#opcodes">opcode</a></td>
-      <td class="td_left">Specifies the opcode of the instruction. Note
-that the maximum opcode value is 63.</td>
+      <td class="td_left">Specifies the opcode of the instruction. Note that 
+        the maximum opcode value is 63.</td>
     </tr>
     <tr>
       <td>8-13</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the type for
-this instruction. Maximum slot number is 2<sup>6</sup>-1=63.</td>
+      <td class="td_left">Specifies the slot number of the type for this 
+        instruction. Maximum slot number is 2<sup>6</sup>-1=63.</td>
     </tr>
     <tr>
       <td>14-19</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the value for
-the first operand. Maximum slot number is 2<sup>6</sup>-1=63.</td>
+      <td class="td_left">Specifies the slot number of the value for the first 
+        operand. Maximum slot number is 2<sup>6</sup>-1=63.</td>
     </tr>
     <tr>
       <td>20-25</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the value for
-the second operand. Maximum slot number is 2<sup>6</sup>-1=63.</td>
+      <td class="td_left">Specifies the slot number of the value for the second
+        operand. Maximum slot number is 2<sup>6</sup>-1=63.</td>
     </tr>
     <tr>
       <td>26-31</td>
       <td><a href="#unsigned">unsigned</a></td>
-      <td class="td_left">Specifies the slot number of the value for
-the third operand. Maximum slot number is 2<sup>6</sup>-1=63.</td>
+      <td class="td_left">Specifies the slot number of the value for the third
+        operand. Maximum slot number is 2<sup>6</sup>-1=63.</td>
     </tr>
   </tbody>
 </table>
 </div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsection"><a name="opcodes">Instruction Opcodes</a></div>
+<div class="doc_text">
+  <p>Instructions encode an opcode that identifies the kind of instruction.
+  Opcodes are an enumerated integer value. The specific values used depend on
+  the version of LLVM you're using. The opcode values are defined in the
+  <a href="http://llvm.cs.uiuc.edu/cvsweb/cvsweb.cgi/llvm/include/llvm/Instruction.def">
+  <tt>include/llvm/Instruction.def</tt></a> file. You should check there for the
+  most recent definitions. The table below provides the opcodes defined as of
+  the writing of this document. The table associates each opcode mnemonic with
+  its enumeration value and the bytecode and LLVM version numbers in which the
+  opcode was introduced.</p>
+  <table>
+    <tbody>
+      <tr>
+        <th>Opcode</th>
+        <th>Number</th>
+        <th>Bytecode Version</th>
+        <th>LLVM Version</th>
+      </tr>
+      <tr><td colspan="4"><b>Terminator Instructions</b></td></tr>
+      <tr><td>Ret</td><td>1</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Br</td><td>2</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Switch</td><td>3</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Invoke</td><td>4</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Unwind</td><td>5</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Unreachable</td><td>6</td><td>1</td><td>1.4</td></tr>
+      <tr><td colspan="4"><b>Binary Operators</b></td></tr>
+      <tr><td>Add</td><td>7</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Sub</td><td>8</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Mul</td><td>9</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Div</td><td>10</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Rem</td><td>11</td><td>1</td><td>1.0</td></tr>
+      <tr><td colspan="4"><b>Logical Operators</b></td></tr>
+      <tr><td>And</td><td>12</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Or</td><td>13</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Xor</td><td>14</td><td>1</td><td>1.0</td></tr>
+      <tr><td colspan="4"><b>Binary Comparison Operators</b></td></tr>
+      <tr><td>SetEQ</td><td>15</td><td>1</td><td>1.0</td></tr>
+      <tr><td>SetNE</td><td>16</td><td>1</td><td>1.0</td></tr>
+      <tr><td>SetLE</td><td>17</td><td>1</td><td>1.0</td></tr>
+      <tr><td>SetGE</td><td>18</td><td>1</td><td>1.0</td></tr>
+      <tr><td>SetLT</td><td>19</td><td>1</td><td>1.0</td></tr>
+      <tr><td>SetGT</td><td>20</td><td>1</td><td>1.0</td></tr>
+      <tr><td colspan="4"><b>Memory Operators</b></td></tr>
+      <tr><td>Malloc</td><td>21</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Free</td><td>22</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Alloca</td><td>23</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Load</td><td>24</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Store</td><td>25</td><td>1</td><td>1.0</td></tr>
+      <tr><td>GetElementPtr</td><td>26</td><td>1</td><td>1.0</td></tr>
+      <tr><td colspan="4"><b>Other Operators</b></td></tr>
+      <tr><td>PHI</td><td>27</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Cast</td><td>28</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Call</td><td>29</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Shl</td><td>30</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Shr</td><td>31</td><td>1</td><td>1.0</td></tr>
+      <tr><td>VANext</td><td>32</td><td>1</td><td>1.0</td></tr>
+      <tr><td>VAArg</td><td>33</td><td>1</td><td>1.0</td></tr>
+      <tr><td>Select</td><td>34</td><td>2</td><td>1.2</td></tr>
+      <tr><td>UserOp1</td><td>35</td><td>1</td><td>1.0</td></tr>
+      <tr><td>UserOp2</td><td>36</td><td>1</td><td>1.0</td></tr>
+    </tbody>
+  </table>
+</div>
+
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection"><a name="symtab">Symbol Table</a> </div>
 <div class="doc_text">
-<p>A symbol table can be put out in conjunction with a module or a function.
-A symbol table is a list of type planes. Each type plane starts with the number
-of entries in the plane and the type plane's slot number (so the type
-can be looked up in the global type pool). For each entry in a type
-plane, the slot number of the value and the name associated with that
-value are written. The format is given in the table below. </p>
+<p>A symbol table can be put out in conjunction with a module or a function. A
+symbol table has a list of name/type associations followed by a list of
+name/value associations. The name/value associations are organized into "type
+planes" so that all values of a common type are listed together.  Each type 
+plane starts with the number of entries in the plane and the type slot number
+for all the values in that plane (so the type can be looked up in the global 
+type pool). For each entry in a type plane, the slot number of the value and 
+the name associated with that value are written. The format is given in the 
+table below. </p>
 <table>
   <tbody>
     <tr>
@@ -1460,18 +1625,47 @@ value are written. The format is given in the table below. </p>
       <td class="td_left">Symbol Table Identifier (0x04)</td>
     </tr>
     <tr>
-      <td><a href="#uint32_vbr">uint32_vbr</a></td>
-      <td class="td_left">Number of entries in type plane</td>
+      <td><a href="#llist">llist</a>(<a href="#symtab_entry">type_entry</a>)</td>
+      <td class="td_left">A length list of symbol table entries for
+        <tt>Type</tt>s
+      </td>
+    </tr>
+    <tr>
+      <td><a href="#zlist">llist</a>(<a href="#symtab_plane">symtab_plane</a>)</td>
+      <td class="td_left">A length list of "type planes" of symbol table
+        entries for <tt>Value</tt>s</td>
+    </tr>
+  </tbody>
+</table>
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection"> <a name="type_entry">Symbol Table Type
+Entry</a>
+</div>
+<div class="doc_text">
+<p>A symbol table type entry associates a name with a type. The name is provided
+simply as an array of chars. The type is provided as a type slot number (index)
+into the global type pool. The format is given in the following table:</p>
+<table>
+  <tbody>
+    <tr>
+      <th><b>Type</b></th>
+      <th class="td_left"><b>Field Description</b></th>
+    </tr>
+    <tr>
+      <td><a href="#uint32_vbr">uint24_vbr</a></td>
+      <td class="td_left">Type slot number of the type being given a
+        name relative to the global type pool.
+      </td>
     </tr>
     <tr>
-      <td><a href="#symtab_entry">symtab_entry</a>*</td>
-      <td class="td_left">Provides the slot number of the type and its
-name.</td>
+      <td><a href="#uint32_vbr">uint32_vbr</a></td>
+      <td class="td_left">Length of the character array that follows.</td>
     </tr>
     <tr>
-      <td><a href="#symtab_plane">symtab_plane</a>*</td>
-      <td class="td_left">A type plane containing value slot number and
-name for all values of the same type.</td>
+      <td><a href="#char">char</a>+</td>
+      <td class="td_left">The characters of the name.</td>
     </tr>
   </tbody>
 </table>
@@ -1495,22 +1689,23 @@ values of a common type. The encoding is given in the following table:</p>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a></td>
-      <td class="td_left">Slot number of type for this plane.</td>
+      <td class="td_left">Type slot number of type for all values in this plane..</td>
     </tr>
     <tr>
-      <td><a href="#symtab_entry">symtab_entry</a>+</td>
-      <td class="td_left">The symbol table entries for this plane.</td>
+      <td><a href="#value_entry">value_entry</a>+</td>
+      <td class="td_left">The symbol table entries for to associate values with
+        names.</td>
     </tr>
   </tbody>
 </table>
 </div>
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsubsection"> <a name="symtab_entry">Symbol Table
+<div class="doc_subsubsection"><a name="value_entry">Symbol Table Value
 Entry</a>
 </div>
 <div class="doc_text">
-<p>A symbol table entry provides the assocation between a type or
-value's slot number and the name given to that type or value. The
+<p>A symbol table value entry provides the assocation between a value and the
+name given to the value. The value is referenced by its slot number. The
 format is given in the following table:</p>
 <table>
   <tbody>
@@ -1520,8 +1715,8 @@ format is given in the following table:</p>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint24_vbr</a></td>
-      <td class="td_left">Slot number of the type or value being given
-a name. </td>
+      <td class="td_left">Value slot number of the value being given a name.
+      </td>
     </tr>
     <tr>
       <td><a href="#uint32_vbr">uint32_vbr</a></td>
@@ -1534,6 +1729,7 @@ a name. </td>
   </tbody>
 </table>
 </div>
+
 <!-- *********************************************************************** -->
 <div class="doc_section"> <a name="versiondiffs">Version Differences</a>
 </div>
@@ -1547,10 +1743,64 @@ section here
 describes the differences between that version and the one that <i>follows</i>.
 </p>
 </div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsection"><a name="vers13">Version 1.3 Differences From 
+    1.4</a></div>
+<!-- _______________________________________________________________________ -->
+
+<div class="doc_subsubsection">Unreachable Instruction</div>
+<div class="doc_text">
+  <p>The LLVM <a href="LangRef.html#i_unreachable">Unreachable</a> instruction
+  was added in version 1.4 of LLVM.  This caused all instruction numbers after
+  it to shift down by one.</p>
+</div>
+
+<div class="doc_subsubsection">Function Flags</div>
+<div class="doc_text">
+  <p>LLVM bytecode versions prior to 1.4 did not include the 5 bit offset 
+     in <a href="#funcfield">the function list</a> in the <a
+     href="#globalinfo">Module Global Info</a> block.</p>
+</div>
+
+<div class="doc_subsubsection">Function Flags</div>
+<div class="doc_text">
+  <p>LLVM bytecode versions prior to 1.4 did not include the 'undef' constant
+     value, which affects the encoding of <a href="#constant">Constant
+     Fields</a>.</p>
+</div>
+
+<!--
+<div class="doc_subsubsection">Aligned Data</div>
+<div class="doc_text">
+  <p>In version 1.3, certain data items were aligned to 32-bit boundaries. In
+  version 1.4, alignment of data was done away with completely. The need for
+  alignment has gone away and the only thing it adds is bytecode file size
+  overhead. In most cases this overhead was small. However, in functions with
+  large numbers of format 0 instructions (GEPs and PHIs with lots of parameters)
+  or regular instructions with large valued operands (e.g. because there's just
+  a lot of instructions in the function) the overhead can be extreme. In one
+  test case, the overhead was 44,000 bytes (34% of the total file size).
+  Consequently in release 1.4, the decision was made to eliminate alignment
+  altogether.</p>
+  <p>In version 1.3 format, the following bytecode constructs were aligned (i.e.
+  they were followed by one to three bytes of padding):</p>
+  <ul>
+    <li>All blocks.</li>
+    <li>Instructions using the long format (format 0).</li>
+    <li>All call instructions that called a var args function.</li>
+    <li>The target triple (a string field at the end of the module block).</li>
+    <li>The version field (immediately following the signature).</li>
+  </ul>
+  <p>None of these constructs are aligned in version 1.4</p>
+</div>
+-->
+
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsection"><a name="vers12">Version 1.2 Differences
 From 1.3</a></div>
 <!-- _______________________________________________________________________ -->
+
 <div class="doc_subsubsection">Type Derives From Value</div>
 <div class="doc_text">
 <p>In version 1.2, the Type class in the LLVM IR derives from the Value
@@ -1650,7 +1900,5 @@ From 1.1</a></div>
 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
 Last modified: $Date$
 </address>
-<!-- vim: sw=2
--->
 </body>
 </html>