diff --git a/docs/BitCodeFormat.html b/docs/BitCodeFormat.html index 70f0ec27492..7194c7a6d34 100644 --- a/docs/BitCodeFormat.html +++ b/docs/BitCodeFormat.html @@ -22,7 +22,11 @@
  • Standard Blocks
  • -
  • LLVM IR Encoding
  • +
  • LLVM IR Encoding +
      +
    1. Basics
    2. +
    +
  • Written by Chris Lattner. @@ -114,7 +118,8 @@ is used by a reader to know what is contained in the file.

    A bitstream literally consists of a stream of bits. This stream is made up of a -number of primitive values that encode a stream of integer values. These +number of primitive values that encode a stream of unsigned integer values. +These integers are are encoded in two ways: either as Fixed Width Integers or as Variable Width Integers. @@ -505,7 +510,92 @@ abbreviation.

    -

    +

    LLVM IR is encoded into a bitstream by defining blocks and records. It uses +blocks for things like constant pools, functions, symbol tables, etc. It uses +records for things like instructions, global variable descriptors, type +descriptions, etc. This document does not describe the set of abbreviations +that the writer uses, as these are fully self-described in the file, and the +reader is not allowed to build in any knowledge of this.

    + +
    + + +
    Basics +
    + + +
    LLVM IR Magic Number
    + +
    + +

    +The magic number for LLVM IR files is: +

    + +

    ['B'8, 'C'8, 0x04, 0xC4, +0xE4, 0xD4]

    + +

    When viewed as bytes, this is "BC 0xC0DE".

    + +
    + + +
    Signed VBRs
    + +
    + +

    +Variable Width Integers are an efficient way to +encode arbitrary sized unsigned values, but is an extremely inefficient way to +encode signed values (as signed values are otherwise treated as maximally large +unsigned values).

    + +

    As such, signed vbr values of a specific width are emitted as follows:

    + + + +

    With this encoding, small positive and small negative values can both be +emitted efficiently.

    + +
    + + + +
    LLVM IR Blocks
    + +
    + +

    +LLVM IR is defined with the following blocks: +

    + + + +
    + + +
    MODULE_BLOCK Contents +
    + +
    + +

    +